Skip to content

Commit

Permalink
Made audio samplerate-independent
Browse files Browse the repository at this point in the history
  • Loading branch information
ferris committed May 18, 2013
1 parent f6d2455 commit 7c6541a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Chip8/Apu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ void Apu::renderCallbackRouter(float *leftBuffer, float *rightBuffer, int numSam
void Apu::renderCallback(float *leftBuffer, float *rightBuffer, int numSamples)
{
mutex->Lock();

auto beepPhaseDelta = .04 * (44100.0 / (double)audioDriver->GetSampleRate());

for (int i = 0; i < numSamples; i++)
{
leftBuffer[i] = rightBuffer[i] = beeping ? (sin(beepPhase) > 0.0 ? 1.0f : -1.0f) : 0.0f;
beepPhase += .04;
}

mutex->Unlock();
}

0 comments on commit 7c6541a

Please sign in to comment.