diff --git a/.gitignore b/.gitignore index e67c16583afd87138200a3485ab246431ae4a004..b541578dbf35154124ef860878df3557d3f1d7ce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,2 @@ -examples/example1 -examples/example2 -examples/example3 -examples/example4 ttdaw diff --git a/examples/Makefile b/examples/Makefile deleted file mode 100644 index 5f77125f474c16f85959d989da814cbe7c2daf96..0000000000000000000000000000000000000000 --- a/examples/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -tests: - $(CC) -Wall example1.c ../minisdl_audio.c -lm -ldl -lpthread -o example1 - $(CC) -Wall example2.c ../minisdl_audio.c -lm -ldl -lpthread -o example2 - $(CC) -Wall example4.c -lasound -lm -o example4 - diff --git a/examples/example1.c b/experiments/soundfont_basic.c rename from examples/example1.c rename to experiments/soundfont_basic.c diff --git a/examples/example2.c b/experiments/soundfont_from_file.c rename from examples/example2.c rename to experiments/soundfont_from_file.c diff --git a/examples/example4.c b/experiments/alsa_midi_controller.c rename from examples/example4.c rename to experiments/alsa_midi_controller.c index 1dc9ebe4ac56437b34807fb7a210d81b8591a062..3181c298495072a0fa1eb4343a0a5fa9da9217ea 100644 --- a/examples/example4.c +++ b/experiments/alsa_midi_controller.c @@ -9,7 +9,6 @@ #define MAX_MIDI_PORTS 1 static snd_seq_t *seq_handle; static snd_seq_addr_t *ports; -static int rate = 44100; static int stop = 0; static void sighandler(int sig ATTRIBUTE_UNUSED) { @@ -18,8 +17,6 @@ } int main(void) { fprintf(stdout, "Example: Reading MIDI input\n"); - - snd_seq_t *seq_handle; if (snd_seq_open(&seq_handle, "default", SND_SEQ_OPEN_DUPLEX, 0) < 0) { fprintf(stderr, "Error opening ALSA sequencer.\n"); diff --git a/experiments/.gitignore b/experiments/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..aceb7f8941bf2c31acb10045ca1f2631265f42fd --- /dev/null +++ b/experiments/.gitignore @@ -0,0 +1,5 @@ +alsa_midi_controller +soundfont_basic +soundfont_from_file +watch_file_changes + diff --git a/experiments/Makefile b/experiments/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..ad822f567c671ecf7197e3f0a46699e2803c0460 --- /dev/null +++ b/experiments/Makefile @@ -0,0 +1,22 @@ +CC := cc +CFLAGS := -Wall +LDFLAGS := -lm -ldl -lpthread -lasound + +all: \ + soundfont_basic \ + soundfont_from_file \ + alsa_midi_controller \ + watch_file_changes + +soundfont_basic: soundfont_basic.c + $(CC) $(CFLAGS) soundfont_basic.c ../minisdl_audio.c $(LDFLAGS) -o soundfont_basic + +soundfont_from_file: soundfont_from_file.c + $(CC) $(CFLAGS) soundfont_from_file.c ../minisdl_audio.c $(LDFLAGS) -o soundfont_from_file + +alsa_midi_controller: alsa_midi_controller.c + $(CC) $(CFLAGS) alsa_midi_controller.c $(LDFLAGS) -o alsa_midi_controller + +watch_file_changes: watch_file_changes.c + $(CC) $(CFLAGS) watch_file_changes.c $(LDFLAGS) -o watch_file_changes + diff --git a/experiments/watch_file_changes.c b/experiments/watch_file_changes.c new file mode 100644 index 0000000000000000000000000000000000000000..04fd3b2686976f0232c3b539b080331c2f2914f0 --- /dev/null +++ b/experiments/watch_file_changes.c @@ -0,0 +1,30 @@ +#include +#include +#include +#include + +int main(void) { + struct stat file_stat; + time_t last_mod_time; + const char* file = "watch_file_changes.txt"; + + stat(file, &file_stat); + last_mod_time = file_stat.st_mtime; + + while (1) { + sleep(1); + stat(file, &file_stat); + if (file_stat.st_mtime != last_mod_time) { + last_mod_time = file_stat.st_mtime; + + struct tm* time_info = localtime(&last_mod_time); + char formatted_time[9]; + strftime(formatted_time, sizeof(formatted_time), "%H:%M:%S", time_info); + + printf("File %s changed at %s\n", file, formatted_time); + } + } + printf("hi\n"); + return 0; +} + diff --git a/experiments/watch_file_changes.txt b/experiments/watch_file_changes.txt new file mode 100644 index 0000000000000000000000000000000000000000..9de6d55a5322c8d25c590d6a24f4f7646948eacc --- /dev/null +++ b/experiments/watch_file_changes.txt @@ -0,0 +1,3 @@ +test1 +test2 +