diff options
-rw-r--r-- | os2eindopdracht/.gitignore | 2 | ||||
-rw-r--r-- | os2eindopdracht/Arguments.cpp | 12 | ||||
-rw-r--r-- | os2eindopdracht/makefile | 16 | ||||
-rw-r--r-- | os2eindopdracht/usage.txt | 8 |
4 files changed, 33 insertions, 5 deletions
diff --git a/os2eindopdracht/.gitignore b/os2eindopdracht/.gitignore index 181de15..9ec7b74 100644 --- a/os2eindopdracht/.gitignore +++ b/os2eindopdracht/.gitignore @@ -1,5 +1,5 @@ *.o -main +ate *.png *.pcm *.wav diff --git a/os2eindopdracht/Arguments.cpp b/os2eindopdracht/Arguments.cpp index a390eab..860ecf9 100644 --- a/os2eindopdracht/Arguments.cpp +++ b/os2eindopdracht/Arguments.cpp @@ -3,6 +3,9 @@ #include "Arguments.h" +extern char _binary_usage_txt_start; +extern char _binary_usage_txt_end; + using std::string; static void coefficients_bass(int intensity, double *b0, double *b1, double *b2, double *a1, double *a2); @@ -10,7 +13,7 @@ static void coefficients_treble(int intensity, double *b0, double *b1, double *b Arguments::Arguments(int argc, char** argv) { while(1) { - switch(getopt(argc, argv, "p:b:t:")) { + switch(getopt(argc, argv, "p:b:t:h")) { case 'p': { this->max_threads = atoi(optarg); continue; @@ -23,6 +26,13 @@ Arguments::Arguments(int argc, char** argv) { this->gain_treble = atoi(optarg); continue; } + case 'h': { + char* s = &_binary_usage_txt_start; + int len = &_binary_usage_txt_end - &_binary_usage_txt_start + 1; + printf("%.*s", len, s); + exit(0); + continue; + } case -1: break; } if (optind + 2 > argc) { diff --git a/os2eindopdracht/makefile b/os2eindopdracht/makefile index eb86336..87185b4 100644 --- a/os2eindopdracht/makefile +++ b/os2eindopdracht/makefile @@ -3,16 +3,22 @@ LD = g++ RM = rm -f CFLAGS = -std=c++20 LFLAGS = -TARGET = main +TARGET = ate SRCS := $(wildcard *.cpp) OBJS := $(patsubst %.cpp,%.o, $(SRCS)) +OBJS += usage.o all: $(TARGET) %.o: %.cpp $(C++) -c $(CFLAGS) $< -o $@ +%.o: %.txt + objcopy --input binary --output elf64-x86-64 $< $@ + +Arguments.o: usage.h + $(TARGET): $(OBJS) $(LD) $^ $(LFLAGS) -o $@ @@ -25,13 +31,17 @@ compile_commands: original.pcm: original.flac ./any2s16lepcm $< $@ -edit.pcm: original.pcm ./main - ./main $< $@ -b-4 -t-18 +edit.pcm: original.pcm $(TARGET) + ./$(TARGET) $< $@ -b-4 -t-18 edit.wav: edit.pcm ./s16lepcm2any $< $@ +original.wav: original.pcm + ./s16lepcm2any $< $@ + edit.png: edit.wav +original.png: original.wav %.png: %.wav sox $< -n spectrogram -o $@ diff --git a/os2eindopdracht/usage.txt b/os2eindopdracht/usage.txt new file mode 100644 index 0000000..dfe2904 --- /dev/null +++ b/os2eindopdracht/usage.txt @@ -0,0 +1,8 @@ +usage: ./ate [-h] [-b bass] [-t treble] [-p threads] + +options: + -h show this help + -b set bass gain to `bass` (in decibels) + -t set treble gain to `treble` (in decibels) + -p set maximum allowed worker threads to `threads` (default=4) + |