MCPcopy Create free account
hub / github.com/AppleWin/AppleWin / UpdateSpkr

Function UpdateSpkr

source/Speaker.cpp:354–375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

352}
353
354static void UpdateSpkr()
355{
356 if(!g_bFullSpeed || SoundCore_GetTimerState())
357 {
358 ULONG nCycleDiff = (ULONG) (g_nCumulativeCycles - g_nSpkrLastCycle);
359
360 UpdateRemainderBuffer(&nCycleDiff);
361
362 ULONG nNumSamples = (ULONG) ((double)nCycleDiff / g_fClksPerSpkrSample);
363
364 ULONG nCyclesRemaining = (ULONG) ((double)nCycleDiff - (double)nNumSamples * g_fClksPerSpkrSample);
365
366 while ((nNumSamples--) && (g_nBufferIdx < SPKR_SAMPLE_RATE - 1))
367 {
368 QueueOneFrame(g_pSpeakerBuffer, g_nBufferIdx, (short)g_nSpeakerData);
369 }
370
371 ReinitRemainderBuffer(nCyclesRemaining); // Partially fill 1Mhz sample buffer
372 }
373
374 g_nSpkrLastCycle = g_nCumulativeCycles;
375}
376
377//=============================================================================
378

Callers 3

SpkrToggleFunction · 0.85
SpkrUpdateFunction · 0.85
SpkrUpdate_TimerFunction · 0.85

Calls 4

SoundCore_GetTimerStateFunction · 0.85
UpdateRemainderBufferFunction · 0.85
QueueOneFrameFunction · 0.85
ReinitRemainderBufferFunction · 0.85

Tested by

no test coverage detected