From fa40862b318a68b65d9e00861c204820c6bbb4f2 Mon Sep 17 00:00:00 2001 From: twobit Date: Mon, 6 Aug 2012 03:05:52 +0200 Subject: [PATCH] stand alone synth server --- synth/.gitignore | 1 + synth/Makefile | 2 ++ synth/main.c | 31 +++++++++++++++++++++++++++++++ synth/synth.c | 1 + synth/synth.h | 1 + 5 files changed, 36 insertions(+) create mode 100644 synth/.gitignore create mode 100644 synth/Makefile create mode 100644 synth/main.c create mode 120000 synth/synth.c create mode 120000 synth/synth.h diff --git a/synth/.gitignore b/synth/.gitignore new file mode 100644 index 0000000..6569f67 --- /dev/null +++ b/synth/.gitignore @@ -0,0 +1 @@ +synth diff --git a/synth/Makefile b/synth/Makefile new file mode 100644 index 0000000..903f57e --- /dev/null +++ b/synth/Makefile @@ -0,0 +1,2 @@ +all: + gcc -std=gnu99 main.c synth.c -O2 -lSDL -o synth diff --git a/synth/main.c b/synth/main.c new file mode 100644 index 0000000..2e0c27c --- /dev/null +++ b/synth/main.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include + +#include "synth.h" + + +static void fill_buffer(void* userdata, Uint8* stream, int len) { + for(int i = 0; i < len / 2; i++) ((uint16_t*)stream)[i] = synth_mix() * 100; +} + +SDL_AudioSpec spec = { 8000000 / (3 * 64), AUDIO_U16SYS, 1, 0, 1024, }; + +int main(int argc ,char** argv) { + + synth_init(); + + spec.callback = &fill_buffer; + if(SDL_OpenAudio(&spec, &spec) < 0) { + fprintf(stderr, "ERROR"); + exit(1); + } + printf("freq = %d\n", spec.freq); + + SDL_PauseAudio(0); + + getchar(); + + return 0; +} diff --git a/synth/synth.c b/synth/synth.c new file mode 120000 index 0000000..482a33e --- /dev/null +++ b/synth/synth.c @@ -0,0 +1 @@ +../firmware/synth.c \ No newline at end of file diff --git a/synth/synth.h b/synth/synth.h new file mode 120000 index 0000000..c1ea587 --- /dev/null +++ b/synth/synth.h @@ -0,0 +1 @@ +../firmware/synth.h \ No newline at end of file