starting work on apu

This commit is contained in:
2025-02-02 12:35:53 -07:00
parent e0fc6123fc
commit 243e13b19e
3 changed files with 21 additions and 6 deletions

View File

@ -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;
}
}