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

Method GenerateAllSoundData

source/MockingboardCardManager.cpp:308–388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306}
307
308UINT MockingboardCardManager::GenerateAllSoundData(void)
309{
310 UINT nNumSamples = 0;
311
312 for (UINT slot = SLOT0; slot < NUM_SLOTS; slot++)
313 {
314 if (!IsMockingboard(slot))
315 continue;
316
317 MockingboardCard& MB = dynamic_cast<MockingboardCard&>(GetCardMgr().GetRef(slot));
318
319 MB.SetNumSamplesError(m_numSamplesError);
320 nNumSamples = MB.MB_Update();
321 m_numSamplesError = MB.GetNumSamplesError();
322 }
323
324 //
325
326 DWORD dwCurrentPlayCursor, dwCurrentWriteCursor;
327 HRESULT hr = m_mockingboardVoice.lpDSBvoice->GetCurrentPosition(&dwCurrentPlayCursor, &dwCurrentWriteCursor);
328 if (FAILED(hr))
329 return 0;
330
331 if (m_byteOffset == (uint32_t)-1)
332 {
333 // First time in this func
334
335 m_byteOffset = dwCurrentWriteCursor;
336 }
337 else
338 {
339 // Check that our offset isn't between Play & Write positions
340
341 if (dwCurrentWriteCursor > dwCurrentPlayCursor)
342 {
343 // |-----PxxxxxW-----|
344 if ((m_byteOffset > dwCurrentPlayCursor) && (m_byteOffset < dwCurrentWriteCursor))
345 {
346#ifdef DBG_MB_UPDATE
347 double fTicksSecs = (double)GetTickCount() / 1000.0;
348 LogOutput("%010.3f: [MBUpdt] PC=%08X, WC=%08X, Diff=%08X, Off=%08X, NS=%08X xxx\n", fTicksSecs, dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor - dwCurrentPlayCursor, dwByteOffset, nNumSamples);
349#endif
350 m_byteOffset = dwCurrentWriteCursor;
351 m_numSamplesError = 0;
352 }
353 }
354 else
355 {
356 // |xxW----------Pxxx|
357 if ((m_byteOffset > dwCurrentPlayCursor) || (m_byteOffset < dwCurrentWriteCursor))
358 {
359#ifdef DBG_MB_UPDATE
360 double fTicksSecs = (double)GetTickCount() / 1000.0;
361 LogOutput("%010.3f: [MBUpdt] PC=%08X, WC=%08X, Diff=%08X, Off=%08X, NS=%08X XXX\n", fTicksSecs, dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor - dwCurrentPlayCursor, dwByteOffset, nNumSamples);
362#endif
363 m_byteOffset = dwCurrentWriteCursor;
364 m_numSamplesError = 0;
365 }

Callers

nothing calls this directly

Calls 6

LogOutputFunction · 0.85
SoundCore_GetErrorIncFunction · 0.85
SetNumSamplesErrorMethod · 0.80
MB_UpdateMethod · 0.80
GetNumSamplesErrorMethod · 0.80
GetCurrentPositionMethod · 0.80

Tested by

no test coverage detected