From 01a545fde6dc446fe626382f8bba50b9b7c1a35b Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Sat, 10 Nov 2018 17:00:15 +0200 Subject: [PATCH] dropped the compiled-in sound sample, loading from the filesystem --- Makefile | 2 +- src/ausamples.s | 6 ------ src/main.c | 21 ++++++++++++++++++--- 3 files changed, 19 insertions(+), 10 deletions(-) delete mode 100644 src/ausamples.s diff --git a/Makefile b/Makefile index 1015733..118d4f0 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ $(bin): $(obj) $(CC) $(CFLAGS) -o $@ -c $< %.d: %.c - @echo "gen dep $< -> $@" && $(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@ + @echo "gen dep $< -> $@"; $(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@ .PHONY: clean .PHONY: cleandep diff --git a/src/ausamples.s b/src/ausamples.s deleted file mode 100644 index e74c9e7..0000000 --- a/src/ausamples.s +++ /dev/null @@ -1,6 +0,0 @@ - .data - .global _snd_click - .global _snd_click_size -_snd_click: - .incbin "click-s8_mono.pcm" -_snd_click_size: .long . - _snd_click diff --git a/src/main.c b/src/main.c index 1e32b61..c7630e5 100644 --- a/src/main.c +++ b/src/main.c @@ -5,12 +5,27 @@ static int au_callback(void *buffer, int size, void *cls); -/* defined in ausamples.s */ -extern signed char snd_click[]; -extern int snd_click_size; +static signed char *snd_click; +static int snd_click_size; int main(int argc, char **argv) { + FILE *fp; + + if(!(fp = fopen("click.pcm", "rb"))) { + fprintf(stderr, "failed to open click.pcm\n"); + return 1; + } + fseek(fp, 0, SEEK_END); + snd_click_size = ftell(fp); + rewind(fp); + if(!(snd_click = malloc(snd_click_size))) { + fprintf(stderr, "failed to allocate sound sample\n"); + return 1; + } + fread(snd_click, 1, snd_click_size, fp); + fclose(fp); + audio_init(); audio_set_callback(au_callback, 0); -- 1.7.10.4