diff options
| -rw-r--r-- | .gitignore | 4 | ||||
| -rw-r--r-- | examples/Makefile | 5 | ||||
| -rw-r--r-- | experiments/.gitignore | 5 | ||||
| -rw-r--r-- | experiments/Makefile | 22 | ||||
| -rw-r--r-- | experiments/alsa_midi_controller.c (renamed from examples/example4.c) | 3 | ||||
| -rw-r--r-- | experiments/soundfont_basic.c (renamed from examples/example1.c) | 0 | ||||
| -rw-r--r-- | experiments/soundfont_from_file.c (renamed from examples/example2.c) | 0 | ||||
| -rw-r--r-- | experiments/watch_file_changes.c | 30 | ||||
| -rw-r--r-- | experiments/watch_file_changes.txt | 3 |
9 files changed, 60 insertions, 12 deletions
@@ -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 5f77125..0000000 --- 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/experiments/.gitignore b/experiments/.gitignore new file mode 100644 index 0000000..aceb7f8 --- /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 0000000..ad822f5 --- /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/examples/example4.c b/experiments/alsa_midi_controller.c index 1dc9ebe..3181c29 100644 --- a/examples/example4.c +++ b/experiments/alsa_midi_controller.c @@ -9,7 +9,6 @@ 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) { @@ -19,8 +18,6 @@ static void sighandler(int sig ATTRIBUTE_UNUSED) { 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"); exit(1); diff --git a/examples/example1.c b/experiments/soundfont_basic.c index 91800ad..91800ad 100644 --- a/examples/example1.c +++ b/experiments/soundfont_basic.c diff --git a/examples/example2.c b/experiments/soundfont_from_file.c index 8518744..8518744 100644 --- a/examples/example2.c +++ b/experiments/soundfont_from_file.c diff --git a/experiments/watch_file_changes.c b/experiments/watch_file_changes.c new file mode 100644 index 0000000..04fd3b2 --- /dev/null +++ b/experiments/watch_file_changes.c @@ -0,0 +1,30 @@ +#include <stdio.h> +#include <unistd.h> +#include <sys/stat.h> +#include <time.h> + +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 0000000..9de6d55 --- /dev/null +++ b/experiments/watch_file_changes.txt @@ -0,0 +1,3 @@ +test1 +test2 + |
