pentabug/synth/main.c

32 lines
567 B
C
Raw Normal View History

2012-08-06 03:05:52 +02:00
#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) {
2012-08-06 03:47:48 +02:00
for(int i = 0; i < len / 2; i++) ((uint16_t*)stream)[i] = synth_mix() * 50;
2012-08-06 03:05:52 +02:00
}
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;
}