stand alone synth server
This commit is contained in:
parent
e007b86e92
commit
fa40862b31
1
synth/.gitignore
vendored
Normal file
1
synth/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
synth
|
2
synth/Makefile
Normal file
2
synth/Makefile
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
all:
|
||||||
|
gcc -std=gnu99 main.c synth.c -O2 -lSDL -o synth
|
31
synth/main.c
Normal file
31
synth/main.c
Normal 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
1
synth/synth.c
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../firmware/synth.c
|
1
synth/synth.h
Symbolic link
1
synth/synth.h
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../firmware/synth.h
|
Loading…
Reference in New Issue
Block a user