starting work on apu
This commit is contained in:
19
lib/audio.c
19
lib/audio.c
@ -77,13 +77,13 @@ void audio_init(){
|
||||
PaStream *stream;
|
||||
PaError err;
|
||||
|
||||
ctx.sq1_amp = 0;
|
||||
ctx.sq1_duty = 0;
|
||||
ctx.sq1_freq = 0;
|
||||
ctx.sq1_amp = 0.2;
|
||||
ctx.sq1_duty = 0.5;
|
||||
ctx.sq1_freq = 200;
|
||||
|
||||
ctx.sq2_amp = 0;
|
||||
ctx.sq2_duty = 0;
|
||||
ctx.sq2_freq = 0;
|
||||
ctx.sq2_duty = 0.5;
|
||||
ctx.sq2_freq = 400;
|
||||
|
||||
for(int i = 0; i < TABLE_SIZE; i++) {
|
||||
sine[i] = (float) sin(((double)i/(double)TABLE_SIZE) * M_PI * 2.);
|
||||
@ -116,4 +116,13 @@ void audio_init(){
|
||||
error:
|
||||
Pa_Terminate();
|
||||
fprintf(stderr, "portaudio stream error\n\tError Number: %d\n\tError Message: %s\n", err, Pa_GetErrorText(err));
|
||||
}
|
||||
|
||||
static int change = 1;
|
||||
|
||||
void audio_tick(){
|
||||
ctx.sq1_freq += change;
|
||||
if(ctx.sq1_freq >= 600 || ctx.sq1_freq <= 200) {
|
||||
change = -change;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user