Compare commits
6 Commits
0b5db1314f
...
29ca3ebabd
Author | SHA1 | Date | |
---|---|---|---|
29ca3ebabd | |||
ee0d4cc27a | |||
17d8545e0a | |||
31c10caf80 | |||
b5367ea57e | |||
adfb5b249b |
5
Makefile
5
Makefile
@ -3,6 +3,8 @@ all:
|
|||||||
DOMAIN ?= karchnu.fr
|
DOMAIN ?= karchnu.fr
|
||||||
get-certificate-info:
|
get-certificate-info:
|
||||||
openssl s_client -connect $(DOMAIN):443
|
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:
|
show-connected-ipv4:
|
||||||
@# Don't forget the double $$ since we are in a Makefile.
|
@# Don't forget the double $$ since we are in a Makefile.
|
||||||
@ -18,3 +20,6 @@ which-bin-uses-this-port:
|
|||||||
MAIL_DOMAIN ?= mail.karchnu.fr
|
MAIL_DOMAIN ?= mail.karchnu.fr
|
||||||
verify-mail-certificate:
|
verify-mail-certificate:
|
||||||
echo | openssl s_client -starttls smtp -showcerts -connect $(MAIL_DOMAIN):587 -servername $(MAIL_DOMAIN) | openssl x509 -noout -dates
|
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,51 +1,63 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# TODO: good codebase, need parameters and make a more generic tool
|
set -x
|
||||||
|
|
||||||
APKPKT=apk-tools-static-2.10.1-r0.apk
|
# 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.
|
||||||
|
|
||||||
mirror=http://uk.alpinelinux.org/alpine/
|
#APKPKT=apk-tools-static-2.10.1-r0.apk
|
||||||
MAINREP=/media/fast/al
|
|
||||||
CHROOT=$MAINREP/chroot
|
#mirror=http://uk.alpinelinux.org/alpine/
|
||||||
|
mirror=http://dl-cdn.alpinelinux.org/alpine
|
||||||
|
MAIN_DIR=/tmp/root
|
||||||
|
CHROOT=$MAIN_DIR/chroot
|
||||||
PACKAGES="vim zsh"
|
PACKAGES="vim zsh"
|
||||||
POSTPACKAGES="alpine-sdk git openssh openssl openssl-dev crystal"
|
#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
|
||||||
|
#}
|
||||||
|
|
||||||
chroot_install(){
|
chroot_install(){
|
||||||
mkdir -p $CHROOT
|
cd ${MAIN_DIR}/
|
||||||
cd ${MAINREP}/
|
|
||||||
|
|
||||||
if [ -f ${APKPKT} ]; then
|
#${MAIN_DIR}/sbin/apk.static -X ${mirror}/latest-stable/main -U --allow-untrusted --root ${CHROOT} --initdb add alpine-base $PACKAGES
|
||||||
echo "apk already downloaded"
|
apk --arch $(arch) -X ${mirror}/latest-stable/main/ -U --allow-untrusted --root ${CHROOT} --initdb add alpine-base
|
||||||
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 /etc/resolv.conf $CHROOT/etc/
|
||||||
cp -r ~/.zsh* ~/.vim* ${CHROOT}/root
|
#cp -r ~/.zsh* ~/.vim* ${CHROOT}/root
|
||||||
echo export PS1=\"\(chroot\) \$PS1\" >> ${CHROOT}/root/.zshrc
|
#echo export PS1=\"\(chroot\) \$PS1\" >> ${CHROOT}/root/.zshrc
|
||||||
|
|
||||||
cat << END > $CHROOT/etc/apk/repositories
|
cat << END > $CHROOT/etc/apk/repositories
|
||||||
http://uk.alpinelinux.org/alpine/latest-stable/main
|
http://uk.alpinelinux.org/alpine/latest-stable/main
|
||||||
http://uk.alpinelinux.org/alpine/latest-stable/community
|
http://uk.alpinelinux.org/alpine/latest-stable/community
|
||||||
http://uk.alpinelinux.org/alpine/edge/main
|
|
||||||
http://uk.alpinelinux.org/alpine/edge/community
|
|
||||||
END
|
END
|
||||||
}
|
}
|
||||||
|
|
||||||
chroot_mount(){
|
chroot_mount(){
|
||||||
mount -t proc /proc ${CHROOT}/proc/
|
for a in proc sys dev; do mount -o bind /$a ${CHROOT}/$a; done
|
||||||
mount -o bind /sys ${CHROOT}/sys/
|
|
||||||
mount -o bind /dev ${CHROOT}/dev/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
chroot_env(){
|
chroot_env(){
|
||||||
chroot ${CHROOT} /bin/zsh -l
|
chroot ${CHROOT} /bin/sh
|
||||||
|
#chroot ${CHROOT} /bin/zsh -l
|
||||||
}
|
}
|
||||||
|
|
||||||
chroot_post(){
|
chroot_post(){
|
||||||
${MAINREP}/sbin/apk.static --root ${CHROOT} add $POSTPACKAGES
|
#${MAIN_DIR}/sbin/apk.static --root ${CHROOT} add $POSTPACKAGES
|
||||||
# chroot ${CHROOT} /bin/zsh -l "apk update && apk upgrade && apk add $POSTPACKAGES"
|
# chroot ${CHROOT} /bin/zsh -l "apk update && apk upgrade && apk add $POSTPACKAGES"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,6 +71,8 @@ ask(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chroot_mkdir
|
||||||
|
#ask chroot_apk_static
|
||||||
ask chroot_install
|
ask chroot_install
|
||||||
ask chroot_mount
|
ask chroot_mount
|
||||||
ask chroot_post
|
ask chroot_post
|
||||||
|
33
c/Makefile
Normal file
33
c/Makefile
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#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)
|
4
c/Makefile.distort
Normal file
4
c/Makefile.distort
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
all: compilation
|
||||||
|
|
||||||
|
compilation:
|
||||||
|
clang -o distortion $$(pkg-config --libs --cflags sndfile) -lm distort.c
|
131
c/distort.c
131
c/distort.c
@ -6,18 +6,22 @@
|
|||||||
|
|
||||||
#define BUFFER_LEN 1024
|
#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 main(int argc, char **argv) {
|
||||||
int distortionLevel;
|
int distortionLevel;
|
||||||
SNDFILE *infile, *outfile;
|
SNDFILE *infile, *outfile;
|
||||||
SF_INFO sfinfo;
|
SF_INFO sfinfo;
|
||||||
double buffer[BUFFER_LEN];
|
|
||||||
|
|
||||||
// Check for distortion level argument
|
// Check for distortion level argument
|
||||||
if (argc < 2) {
|
if (argc < 3) {
|
||||||
printf("Usage: %s distortion_level\n", argv[0]);
|
printf("Usage: %s distortion-type distortion_level\n", argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
distortionLevel = atoi(argv[1]);
|
distortionLevel = atoi(argv[2]);
|
||||||
|
|
||||||
// Open standard input as input file
|
// Open standard input as input file
|
||||||
if (!(infile = sf_open_fd(0, SFM_READ, &sfinfo, 0))) {
|
if (!(infile = sf_open_fd(0, SFM_READ, &sfinfo, 0))) {
|
||||||
@ -31,16 +35,34 @@ int main(int argc, char **argv) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read and process data
|
if (memcmp(argv[1], "overdrive", strlen("overdrive")) == 0) {
|
||||||
while (sf_read_double(infile, buffer, BUFFER_LEN) > 0) {
|
fprintf(stderr, "overdrive\n");
|
||||||
for (int i=0; i<BUFFER_LEN; i++) {
|
applyOverdriveDistortion(infile, outfile);
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
|
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
|
||||||
|
// 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);
|
||||||
|
// }
|
||||||
|
|
||||||
// Close files
|
// Close files
|
||||||
sf_close(infile);
|
sf_close(infile);
|
||||||
@ -48,3 +70,86 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
return 0;
|
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
Normal file
29
mk/alpine.mk
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
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