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