diff --git a/source/Mockingboard.h b/source/Mockingboard.h index ac6a26e9..b0d65c73 100644 --- a/source/Mockingboard.h +++ b/source/Mockingboard.h @@ -71,6 +71,9 @@ public: static std::string GetSnapshotCardNameMegaAudio(void); static std::string GetSnapshotCardNameSDMusic(void); + static const unsigned short NUM_MB_CHANNELS = 2; + static const DWORD SAMPLE_RATE = 44100; // Use a base freq so that DirectX (or sound h/w) doesn't have to up/down-sample + private: enum MockingboardUnitState_e { AY_NOP0, AY_NOP1, AY_INACTIVE, AY_READ, AY_NOP4, AY_NOP5, AY_WRITE, AY_LATCH }; @@ -151,8 +154,6 @@ private: UINT64 m_lastCumulativeCycle; - static const DWORD SAMPLE_RATE = 44100; // Use a base freq so that DirectX (or sound h/w) doesn't have to up/down-sample - short* m_ppAYVoiceBuffer[NUM_VOICES]; UINT64 m_inActiveCycleCount; diff --git a/source/MockingboardCardManager.cpp b/source/MockingboardCardManager.cpp index ea8466b6..1c99015f 100644 --- a/source/MockingboardCardManager.cpp +++ b/source/MockingboardCardManager.cpp @@ -33,7 +33,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "Core.h" #include "CardManager.h" #include "CPU.h" -#include "Mockingboard.h" #include "MockingboardDefs.h" #include "Riff.h" @@ -284,9 +283,7 @@ bool MockingboardCardManager::Init(void) if (!g_bDSAvailable) return false; - const DWORD SAMPLE_RATE = 44100; // Use a base freq so that DirectX (or sound h/w) doesn't have to up/down-sample - - HRESULT hr = DSGetSoundBuffer(&m_mockingboardVoice, DSBCAPS_CTRLVOLUME, SOUNDBUFFER_SIZE, SAMPLE_RATE, NUM_MB_CHANNELS, "MB"); + HRESULT hr = DSGetSoundBuffer(&m_mockingboardVoice, DSBCAPS_CTRLVOLUME, SOUNDBUFFER_SIZE, MockingboardCard::SAMPLE_RATE, MockingboardCard::NUM_MB_CHANNELS, "MB"); LogFileOutput("MBCardMgr: DSGetSoundBuffer(), hr=0x%08X\n", hr); if (FAILED(hr)) { @@ -441,8 +438,8 @@ void MockingboardCardManager::MixAllAndCopyToRingBuffer(UINT nNumSamples) else if (nDataR > WAVE_DATA_MAX) nDataR = WAVE_DATA_MAX; - m_mixBuffer[i * NUM_MB_CHANNELS + 0] = (short)nDataL; // L - m_mixBuffer[i * NUM_MB_CHANNELS + 1] = (short)nDataR; // R + m_mixBuffer[i * MockingboardCard::NUM_MB_CHANNELS + 0] = (short)nDataL; // L + m_mixBuffer[i * MockingboardCard::NUM_MB_CHANNELS + 1] = (short)nDataR; // R } // @@ -451,7 +448,7 @@ void MockingboardCardManager::MixAllAndCopyToRingBuffer(UINT nNumSamples) SHORT* pDSLockedBuffer0, * pDSLockedBuffer1; HRESULT hr = DSGetLock(m_mockingboardVoice.lpDSBvoice, - m_byteOffset, (DWORD)nNumSamples * sizeof(short) * NUM_MB_CHANNELS, + m_byteOffset, (DWORD)nNumSamples * sizeof(short) * MockingboardCard::NUM_MB_CHANNELS, &pDSLockedBuffer0, &dwDSLockedBufferSize0, &pDSLockedBuffer1, &dwDSLockedBufferSize1); if (FAILED(hr)) @@ -465,7 +462,7 @@ void MockingboardCardManager::MixAllAndCopyToRingBuffer(UINT nNumSamples) hr = m_mockingboardVoice.lpDSBvoice->Unlock((void*)pDSLockedBuffer0, dwDSLockedBufferSize0, (void*)pDSLockedBuffer1, dwDSLockedBufferSize1); - m_byteOffset = (m_byteOffset + (DWORD)nNumSamples * sizeof(short) * NUM_MB_CHANNELS) % SOUNDBUFFER_SIZE; + m_byteOffset = (m_byteOffset + (DWORD)nNumSamples * sizeof(short) * MockingboardCard::NUM_MB_CHANNELS) % SOUNDBUFFER_SIZE; if (m_outputToRiff) RiffPutSamples(&m_mixBuffer[0], nNumSamples); diff --git a/source/MockingboardCardManager.h b/source/MockingboardCardManager.h index e76abd97..36f4777c 100644 --- a/source/MockingboardCardManager.h +++ b/source/MockingboardCardManager.h @@ -2,6 +2,7 @@ #include "Core.h" #include "SoundCore.h" +#include "Mockingboard.h" class MockingboardCardManager { @@ -54,8 +55,7 @@ private: void MixAllAndCopyToRingBuffer(UINT nNumSamples); bool IsMockingboardExtraCardType(UINT slot); - static const unsigned short NUM_MB_CHANNELS = 2; - static const DWORD SOUNDBUFFER_SIZE = MAX_SAMPLES * sizeof(short) * NUM_MB_CHANNELS; + static const DWORD SOUNDBUFFER_SIZE = MAX_SAMPLES * sizeof(short) * MockingboardCard::NUM_MB_CHANNELS; static const SHORT WAVE_DATA_MIN = (SHORT)0x8000; static const SHORT WAVE_DATA_MAX = (SHORT)0x7FFF; diff --git a/source/Windows/AppleWin.cpp b/source/Windows/AppleWin.cpp index c228e599..a1ec1818 100644 --- a/source/Windows/AppleWin.cpp +++ b/source/Windows/AppleWin.cpp @@ -632,7 +632,7 @@ static void OneTimeInitialization(HINSTANCE passinstance) } else if (!g_cmdLine.wavFileMockingboard.empty()) { - if (RiffInitWriteFile(g_cmdLine.wavFileMockingboard.c_str(), 44100, 2)) + if (RiffInitWriteFile(g_cmdLine.wavFileMockingboard.c_str(), MockingboardCard::SAMPLE_RATE, MockingboardCard::NUM_MB_CHANNELS)) GetCardMgr().GetMockingboardCardMgr().OutputToRiff(); }