Compare commits
No commits in common. "29ca3ebabd98a25a15ac8a2fd5bb25ce0bd53c6f" and "0b5db1314f1a2c3908619a43a61d35b5270eda9b" have entirely different histories.
29ca3ebabd
...
0b5db1314f
5
Makefile
5
Makefile
@ -3,8 +3,6 @@ all:
|
||||
DOMAIN ?= karchnu.fr
|
||||
get-certificate-info:
|
||||
openssl s_client -connect $(DOMAIN):443
|
||||
verify-web-certificate-dates:
|
||||
echo | openssl s_client -connect $(DOMAIN):443 2>/dev/null | openssl x509 -noout -dates
|
||||
|
||||
show-connected-ipv4:
|
||||
@# Don't forget the double $$ since we are in a Makefile.
|
||||
@ -20,6 +18,3 @@ which-bin-uses-this-port:
|
||||
MAIL_DOMAIN ?= mail.karchnu.fr
|
||||
verify-mail-certificate:
|
||||
echo | openssl s_client -starttls smtp -showcerts -connect $(MAIL_DOMAIN):587 -servername $(MAIL_DOMAIN) | openssl x509 -noout -dates
|
||||
|
||||
verify-mail-imap-certificate:
|
||||
echo | openssl s_client -showcerts -connect $(MAIL_DOMAIN):993 -servername $(MAIL_DOMAIN) | openssl x509 -noout -dates
|
||||
|
@ -1,63 +1,51 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -x
|
||||
# TODO: good codebase, need parameters and make a more generic tool
|
||||
|
||||
# WARNING: this codebase is now updated in the "alpine.mk" makefile.
|
||||
# A makefile is a better option than a plain shell script, it enables
|
||||
# an automatic selection of the action to perform (by just selecting
|
||||
# the "rule" to make), without dedicated code.
|
||||
APKPKT=apk-tools-static-2.10.1-r0.apk
|
||||
|
||||
#APKPKT=apk-tools-static-2.10.1-r0.apk
|
||||
|
||||
#mirror=http://uk.alpinelinux.org/alpine/
|
||||
mirror=http://dl-cdn.alpinelinux.org/alpine
|
||||
MAIN_DIR=/tmp/root
|
||||
CHROOT=$MAIN_DIR/chroot
|
||||
mirror=http://uk.alpinelinux.org/alpine/
|
||||
MAINREP=/media/fast/al
|
||||
CHROOT=$MAINREP/chroot
|
||||
PACKAGES="vim zsh"
|
||||
#POSTPACKAGES="alpine-sdk git openssh openssl openssl-dev crystal"
|
||||
POSTPACKAGES=""
|
||||
|
||||
chroot_mkdir(){
|
||||
mkdir -p $CHROOT || true
|
||||
}
|
||||
|
||||
#chroot_apk_static(){
|
||||
# cd ${MAIN_DIR}/
|
||||
#
|
||||
# if [ -f ${APKPKT} ]; then
|
||||
# echo "apk already downloaded"
|
||||
# else
|
||||
# wget ${mirror}/latest-stable/main/`uname -p`/${APKPKT}
|
||||
# tar -xzf ${APKPKT}
|
||||
# fi
|
||||
#}
|
||||
POSTPACKAGES="alpine-sdk git openssh openssl openssl-dev crystal"
|
||||
|
||||
chroot_install(){
|
||||
cd ${MAIN_DIR}/
|
||||
mkdir -p $CHROOT
|
||||
cd ${MAINREP}/
|
||||
|
||||
#${MAIN_DIR}/sbin/apk.static -X ${mirror}/latest-stable/main -U --allow-untrusted --root ${CHROOT} --initdb add alpine-base $PACKAGES
|
||||
apk --arch $(arch) -X ${mirror}/latest-stable/main/ -U --allow-untrusted --root ${CHROOT} --initdb add alpine-base
|
||||
if [ -f ${APKPKT} ]; then
|
||||
echo "apk already downloaded"
|
||||
else
|
||||
wget ${mirror}/latest-stable/main/`uname -p`/${APKPKT}
|
||||
tar -xzf ${APKPKT}
|
||||
fi
|
||||
|
||||
${MAINREP}/sbin/apk.static -X ${mirror}/latest-stable/main -U --allow-untrusted --root ${CHROOT} --initdb add alpine-base $PACKAGES
|
||||
cp /etc/resolv.conf $CHROOT/etc/
|
||||
#cp -r ~/.zsh* ~/.vim* ${CHROOT}/root
|
||||
#echo export PS1=\"\(chroot\) \$PS1\" >> ${CHROOT}/root/.zshrc
|
||||
cp -r ~/.zsh* ~/.vim* ${CHROOT}/root
|
||||
echo export PS1=\"\(chroot\) \$PS1\" >> ${CHROOT}/root/.zshrc
|
||||
|
||||
cat << END > $CHROOT/etc/apk/repositories
|
||||
http://uk.alpinelinux.org/alpine/latest-stable/main
|
||||
http://uk.alpinelinux.org/alpine/latest-stable/community
|
||||
http://uk.alpinelinux.org/alpine/edge/main
|
||||
http://uk.alpinelinux.org/alpine/edge/community
|
||||
END
|
||||
}
|
||||
|
||||
chroot_mount(){
|
||||
for a in proc sys dev; do mount -o bind /$a ${CHROOT}/$a; done
|
||||
mount -t proc /proc ${CHROOT}/proc/
|
||||
mount -o bind /sys ${CHROOT}/sys/
|
||||
mount -o bind /dev ${CHROOT}/dev/
|
||||
}
|
||||
|
||||
chroot_env(){
|
||||
chroot ${CHROOT} /bin/sh
|
||||
#chroot ${CHROOT} /bin/zsh -l
|
||||
chroot ${CHROOT} /bin/zsh -l
|
||||
}
|
||||
|
||||
chroot_post(){
|
||||
#${MAIN_DIR}/sbin/apk.static --root ${CHROOT} add $POSTPACKAGES
|
||||
${MAINREP}/sbin/apk.static --root ${CHROOT} add $POSTPACKAGES
|
||||
# chroot ${CHROOT} /bin/zsh -l "apk update && apk upgrade && apk add $POSTPACKAGES"
|
||||
}
|
||||
|
||||
@ -71,8 +59,6 @@ ask(){
|
||||
fi
|
||||
}
|
||||
|
||||
chroot_mkdir
|
||||
#ask chroot_apk_static
|
||||
ask chroot_install
|
||||
ask chroot_mount
|
||||
ask chroot_post
|
||||
|
33
c/Makefile
33
c/Makefile
@ -1,33 +0,0 @@
|
||||
#SOURCE= vlc
|
||||
#CFLAGS=$(shell pkg-config --libs vlc)
|
||||
#
|
||||
#all: compilationvlc
|
||||
#
|
||||
#compilationvlc:
|
||||
# $(CC) $(SOURCE).c -o $(SOURCE) $(CFLAGS)
|
||||
|
||||
CC=clang
|
||||
CFLAGS=-c -Wall -g
|
||||
LDFLAGS=
|
||||
CFILES=$(wildcard *.c) # CFILES => recompiles everything on a C file change
|
||||
EXEC=$(basename $(wildcard *.c))
|
||||
#SOURCES=$(wildcard *.c)
|
||||
TESTS=$(addsuffix .test, $(EXEC))
|
||||
|
||||
all: $(SOURCES) $(EXEC)
|
||||
|
||||
$(EXEC): $(CFILES)
|
||||
$(CC) $(LDFLAGS) $@.c -o $@
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) $< -o $@
|
||||
|
||||
clean:
|
||||
@-rm $(EXEC)
|
||||
|
||||
# to test a binary "prog" : make prog.test
|
||||
|
||||
$(TESTS):
|
||||
valgrind --leak-check=full -v --track-origins=yes ./$(basename $@)
|
||||
|
||||
test: all $(TESTS)
|
@ -1,4 +0,0 @@
|
||||
all: compilation
|
||||
|
||||
compilation:
|
||||
clang -o distortion $$(pkg-config --libs --cflags sndfile) -lm distort.c
|
131
c/distort.c
131
c/distort.c
@ -6,22 +6,18 @@
|
||||
|
||||
#define BUFFER_LEN 1024
|
||||
|
||||
void applyOverdriveDistortion (SNDFILE *inputFile, SNDFILE *outputFile);
|
||||
void applyFuzzDistortion (SNDFILE *inputFile, SNDFILE *outputFile);
|
||||
void applyDistortion (SNDFILE *inputFile, SNDFILE *outputFile);
|
||||
void applyBoostDistortion (SNDFILE *inputFile, SNDFILE *outputFile, float gain);
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int distortionLevel;
|
||||
SNDFILE *infile, *outfile;
|
||||
SF_INFO sfinfo;
|
||||
double buffer[BUFFER_LEN];
|
||||
|
||||
// Check for distortion level argument
|
||||
if (argc < 3) {
|
||||
printf("Usage: %s distortion-type distortion_level\n", argv[0]);
|
||||
if (argc < 2) {
|
||||
printf("Usage: %s distortion_level\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
distortionLevel = atoi(argv[2]);
|
||||
distortionLevel = atoi(argv[1]);
|
||||
|
||||
// Open standard input as input file
|
||||
if (!(infile = sf_open_fd(0, SFM_READ, &sfinfo, 0))) {
|
||||
@ -35,34 +31,16 @@ int main(int argc, char **argv) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (memcmp(argv[1], "overdrive", strlen("overdrive")) == 0) {
|
||||
fprintf(stderr, "overdrive\n");
|
||||
applyOverdriveDistortion(infile, outfile);
|
||||
}
|
||||
if (memcmp(argv[1], "fuzz", strlen("fuzz")) == 0) {
|
||||
fprintf(stderr, "fuzz\n");
|
||||
applyFuzzDistortion(infile, outfile);
|
||||
}
|
||||
if (memcmp(argv[1], "distortion", strlen("distortion")) == 0) {
|
||||
fprintf(stderr, "distortion\n");
|
||||
applyDistortion(infile, outfile);
|
||||
}
|
||||
if (memcmp(argv[1], "boost", strlen("boost")) == 0) {
|
||||
fprintf(stderr, "boost\n");
|
||||
applyBoostDistortion(infile, outfile, distortionLevel);
|
||||
}
|
||||
// Read and process data
|
||||
while (sf_read_double(infile, buffer, BUFFER_LEN) > 0) {
|
||||
for (int i=0; i<BUFFER_LEN; i++) {
|
||||
// Add distortion to the sample
|
||||
buffer[i] = buffer[i] * (1.0 + (distortionLevel/100.0) * sin(2.0 * M_PI * buffer[i]));
|
||||
}
|
||||
|
||||
// // Read and process data
|
||||
// double buffer[BUFFER_LEN];
|
||||
// while (sf_read_double(infile, buffer, BUFFER_LEN) > 0) {
|
||||
// for (int i=0; i<BUFFER_LEN; i++) {
|
||||
// // Add distortion to the sample
|
||||
// buffer[i] = buffer[i] * (1.0 + (distortionLevel/100.0) * sin(2.0 * M_PI * buffer[i]));
|
||||
// }
|
||||
//
|
||||
// // Write the processed sample to the output file
|
||||
// sf_write_double(outfile, buffer, BUFFER_LEN);
|
||||
// }
|
||||
// Write the processed sample to the output file
|
||||
sf_write_double(outfile, buffer, BUFFER_LEN);
|
||||
}
|
||||
|
||||
// Close files
|
||||
sf_close(infile);
|
||||
@ -70,86 +48,3 @@ int main(int argc, char **argv) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO: use these functions
|
||||
|
||||
// function to apply overdrive distortion to an audio signal using sndfile API
|
||||
void applyOverdriveDistortion(SNDFILE *inputFile, SNDFILE *outputFile)
|
||||
{
|
||||
// read in the data from the input file
|
||||
int bufferSize = 1024;
|
||||
float *inputBuffer = malloc(bufferSize * sizeof(float));
|
||||
int framesRead;
|
||||
while ((framesRead = sf_readf_float(inputFile, inputBuffer, bufferSize))) {
|
||||
// apply overdrive distortion
|
||||
for (int i = 0; i < framesRead; i++) {
|
||||
float x = inputBuffer[i];
|
||||
float y = (1 + x) * (1 + x) / (1 + 2 * x + x * x);
|
||||
inputBuffer[i] = y;
|
||||
}
|
||||
// write processed data to output file
|
||||
sf_writef_float(outputFile, inputBuffer, framesRead);
|
||||
}
|
||||
free(inputBuffer);
|
||||
}
|
||||
|
||||
// function to apply fuzz distortion to an audio signal using sndfile API
|
||||
void applyFuzzDistortion(SNDFILE *inputFile, SNDFILE *outputFile)
|
||||
{
|
||||
// read in the data from the input file
|
||||
int bufferSize = 1024;
|
||||
float *inputBuffer = malloc(bufferSize * sizeof(float));
|
||||
int framesRead;
|
||||
while ((framesRead = sf_readf_float(inputFile, inputBuffer, bufferSize))) {
|
||||
// apply fuzz distortion
|
||||
for (int i = 0; i < framesRead; i++) {
|
||||
float x = inputBuffer[i];
|
||||
float y = x / (1 + fabs(x));
|
||||
inputBuffer[i] = y;
|
||||
}
|
||||
// write processed data to output file
|
||||
sf_writef_float(outputFile, inputBuffer, framesRead);
|
||||
}
|
||||
free(inputBuffer);
|
||||
}
|
||||
|
||||
// function to apply distortion to an audio signal using sndfile API
|
||||
void applyDistortion(SNDFILE *inputFile, SNDFILE *outputFile)
|
||||
{
|
||||
// read in the data from the input file
|
||||
int bufferSize = 1024;
|
||||
float *inputBuffer = malloc(bufferSize * sizeof(float));
|
||||
int framesRead;
|
||||
while ((framesRead = sf_readf_float(inputFile, inputBuffer, bufferSize))) {
|
||||
// apply distortion
|
||||
for (int i = 0; i < framesRead; i++) {
|
||||
float x = inputBuffer[i];
|
||||
float y = x / (1 + fabs(x));
|
||||
y = y * 0.5 + 0.5;
|
||||
inputBuffer[i] = y;
|
||||
}
|
||||
// write processed data to output file
|
||||
sf_writef_float(outputFile, inputBuffer, framesRead);
|
||||
}
|
||||
free(inputBuffer);
|
||||
}
|
||||
|
||||
// function to apply boost to an audio signal using sndfile API
|
||||
void applyBoostDistortion(SNDFILE *inputFile, SNDFILE *outputFile, float gain)
|
||||
{
|
||||
// read in the data from the input file
|
||||
int bufferSize = 1024;
|
||||
float *inputBuffer = malloc(bufferSize * sizeof(float));
|
||||
int framesRead;
|
||||
while ((framesRead = sf_readf_float(inputFile, inputBuffer, bufferSize))) {
|
||||
// apply boost
|
||||
for (int i = 0; i < framesRead; i++) {
|
||||
float x = inputBuffer[i];
|
||||
float y = x * gain;
|
||||
inputBuffer[i] = y;
|
||||
}
|
||||
// write processed data to output file
|
||||
sf_writef_float(outputFile, inputBuffer, framesRead);
|
||||
}
|
||||
free(inputBuffer);
|
||||
}
|
||||
|
29
mk/alpine.mk
29
mk/alpine.mk
@ -1,29 +0,0 @@
|
||||
CHROOT ?= /tmp/root
|
||||
ARCH ?= x86_64
|
||||
VERSION ?= v3.20
|
||||
MIRROR ?= http://uk.alpinelinux.org/alpine/
|
||||
URL_REPOS ?= $(MIRROR)$(VERSION)
|
||||
|
||||
enter:
|
||||
chroot $(CHROOT) /bin/sh
|
||||
|
||||
install:
|
||||
@echo "creating a new alpine $(VERSION) chroot"
|
||||
mkdir -p $(CHROOT)
|
||||
apk --arch $(ARCH) -X $(URL_REPOS)/main/ -U --allow-untrusted --root $(CHROOT) --initdb add alpine-base
|
||||
cp /etc/resolv.conf $(CHROOT)/etc/
|
||||
echo "$(URL_REPOS)/main" > $(CHROOT)/etc/apk/repositories
|
||||
echo "$(URL_REPOS)/community" >> $(CHROOT)/etc/apk/repositories
|
||||
|
||||
mount:
|
||||
for a in proc sys dev; do mount -o bind /$$a $(CHROOT)/$$a; done
|
||||
|
||||
unmount:
|
||||
-umount $(CHROOT)/proc
|
||||
-umount $(CHROOT)/sys
|
||||
-umount $(CHROOT)/dev
|
||||
|
||||
delete: unmount
|
||||
rm -r $(CHROOT)
|
||||
|
||||
new: install mount enter
|
Loading…
Reference in New Issue
Block a user