stand alone synth server

This commit is contained in:
twobit 2012-08-06 03:05:52 +02:00
parent e007b86e92
commit fa40862b31
5 changed files with 36 additions and 0 deletions

1
synth/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
synth

2
synth/Makefile Normal file
View File

@ -0,0 +1,2 @@
all:
gcc -std=gnu99 main.c synth.c -O2 -lSDL -o synth

31
synth/main.c Normal file
View File

@ -0,0 +1,31 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <SDL/SDL.h>
#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;
}

1
synth/synth.c Symbolic link
View File

@ -0,0 +1 @@
../firmware/synth.c

1
synth/synth.h Symbolic link
View File

@ -0,0 +1 @@
../firmware/synth.h