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

Method MixAllAndCopyToRingBuffer

source/MockingboardCardManager.cpp:390–467  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

388}
389
390void MockingboardCardManager::MixAllAndCopyToRingBuffer(UINT nNumSamples)
391{
392// const double fAttenuation = g_bPhasorEnable ? 2.0 / 3.0 : 1.0;
393 const double fAttenuation = true ? 2.0 / 3.0 : 1.0;
394
395 short** slotAYVoiceBuffers[NUM_SLOTS] = {0};
396
397 for (UINT slot = SLOT0; slot < NUM_SLOTS; slot++)
398 {
399 if (IsMockingboard(slot))
400 slotAYVoiceBuffers[slot] = dynamic_cast<MockingboardCard&>(GetCardMgr().GetRef(slot)).GetVoiceBuffers();
401 }
402
403 for (UINT i = 0; i < nNumSamples; i++)
404 {
405 // Mockingboard stereo (all voices on an AY8910 wire-or'ed together)
406 // L = Address.b7=0, R = Address.b7=1
407 int nDataL = 0, nDataR = 0;
408
409 for (UINT slot = SLOT0; slot < NUM_SLOTS; slot++)
410 {
411 if (!slotAYVoiceBuffers[slot])
412 continue;
413
414 for (UINT j = 0; j < NUM_VOICES_PER_AY8913; j++)
415 {
416 short** ppAYVoiceBuffer = slotAYVoiceBuffers[slot];
417
418 // Regular MB-C AY's
419 nDataL += (int)((double)ppAYVoiceBuffer[0 * NUM_VOICES_PER_AY8913 + j][i] * fAttenuation);
420 nDataR += (int)((double)ppAYVoiceBuffer[2 * NUM_VOICES_PER_AY8913 + j][i] * fAttenuation);
421
422 // Extra Phasor AY's
423 nDataL += (int)((double)ppAYVoiceBuffer[1 * NUM_VOICES_PER_AY8913 + j][i] * fAttenuation);
424 nDataR += (int)((double)ppAYVoiceBuffer[3 * NUM_VOICES_PER_AY8913 + j][i] * fAttenuation);
425 }
426 }
427
428 // Cap the superpositioned output
429 if (nDataL < WAVE_DATA_MIN)
430 nDataL = WAVE_DATA_MIN;
431 else if (nDataL > WAVE_DATA_MAX)
432 nDataL = WAVE_DATA_MAX;
433
434 if (nDataR < WAVE_DATA_MIN)
435 nDataR = WAVE_DATA_MIN;
436 else if (nDataR > WAVE_DATA_MAX)
437 nDataR = WAVE_DATA_MAX;
438
439 m_mixBuffer[i * MockingboardCard::NUM_MB_CHANNELS + 0] = (short)nDataL; // L
440 m_mixBuffer[i * MockingboardCard::NUM_MB_CHANNELS + 1] = (short)nDataR; // R
441 }
442
443 //
444
445 DWORD dwDSLockedBufferSize0, dwDSLockedBufferSize1;
446 SHORT* pDSLockedBuffer0, * pDSLockedBuffer1;
447

Callers

nothing calls this directly

Calls 4

DSGetLockFunction · 0.85
RiffPutSamplesFunction · 0.85
GetVoiceBuffersMethod · 0.80
UnlockMethod · 0.80

Tested by

no test coverage detected