From: <man...@us...> - 2013-09-06 21:44:18
|
Revision: 2649 http://sourceforge.net/p/modplug/code/2649 Author: manxorist Date: 2013-09-06 21:44:06 +0000 (Fri, 06 Sep 2013) Log Message: ----------- [Ref] Move supported sample rates to TrackerSettings. [Ref] sounddev: Add const to CanSampleRate() . Modified Paths: -------------- trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h trunk/OpenMPT/sounddev/SoundDevice.h trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp trunk/OpenMPT/sounddev/SoundDeviceASIO.h trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp trunk/OpenMPT/sounddev/SoundDevicePortAudio.h Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-09-06 18:19:26 UTC (rev 2648) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-09-06 21:44:06 UTC (rev 2649) @@ -26,7 +26,6 @@ #include <fstream> -extern UINT nMixingRates[NUMMIXRATE]; extern LPCSTR gszChnCfgNames[3]; @@ -210,10 +209,10 @@ SetDlgItemInt(IDC_EDIT5, loopCount, FALSE); m_SpinLoopCount.SetRange(1, int16_max); - - for (size_t i = 0; i < CountOf(nMixingRates); i++) + const std::vector<uint32> samplerates = TrackerSettings::Instance().GetSampleRates(); + for(size_t i = 0; i < samplerates.size(); i++) { - UINT n = nMixingRates[i]; + UINT n = samplerates[i]; wsprintf(s, "%d Hz", n); m_CbnSampleRate.SetItemData(m_CbnSampleRate.AddString(s), n); if (n == WaveFormat.Format.nSamplesPerSec) m_CbnSampleRate.SetCurSel(i); Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-09-06 18:19:26 UTC (rev 2648) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-09-06 21:44:06 UTC (rev 2649) @@ -78,27 +78,6 @@ END_MESSAGE_MAP() -UINT nMixingRates[NUMMIXRATE] = -{ - 16000, - 19800, - 20000, - 22050, - 24000, - 32000, - 33075, - 37800, - 40000, - 44100, - 48000, - 64000, - 88200, - 96000, - 176400, - 192000, -}; - - void COptionsSoundcard::DoDataExchange(CDataExchange* pDX) //-------------------------------------------------------- { @@ -402,11 +381,7 @@ m_CbnMixingFreq.ResetContent(); std::vector<bool> supportedRates; - std::vector<uint32> samplerates; - for(size_t i = 0; i < CountOf(nMixingRates); i++) - { - samplerates.push_back(nMixingRates[i]); - } + const std::vector<uint32> samplerates = TrackerSettings::Instance().GetSampleRates(); bool knowRates = false; { @@ -441,14 +416,14 @@ supportedRates.assign(samplerates.size(), true); } int n = 1; - for(size_t i = 0; i < CountOf(nMixingRates); i++) + for(size_t i = 0; i < samplerates.size(); i++) { if(supportedRates[i]) { - wsprintf(s, "%u Hz", nMixingRates[i]); + wsprintf(s, "%i Hz", samplerates[i]); int pos = m_CbnMixingFreq.AddString(s); - m_CbnMixingFreq.SetItemData(pos, nMixingRates[i]); - if(m_dwRate == nMixingRates[i]) n = pos; + m_CbnMixingFreq.SetItemData(pos, samplerates[i]); + if(m_dwRate == samplerates[i]) n = pos; } } m_CbnMixingFreq.SetCurSel(n); Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-09-06 18:19:26 UTC (rev 2648) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-09-06 21:44:06 UTC (rev 2649) @@ -959,6 +959,31 @@ } +std::vector<uint32> TrackerSettings::GetSampleRates() +//--------------------------------------------------- +{ + static const uint32 samplerates [] = { + 192000, + 176400, + 96000, + 88200, + 64000, + 48000, + 44100, + 40000, + 37800, + 33075, + 32000, + 24000, + 22050, + 20000, + 19800, + 16000 + }; + return std::vector<uint32>(samplerates, samplerates + CountOf(samplerates)); +} + + //////////////////////////////////////////////////////////////////////////////// // Chords Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2013-09-06 18:19:26 UTC (rev 2648) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2013-09-06 21:44:06 UTC (rev 2649) @@ -269,6 +269,8 @@ void SetDefaultDirectory(const LPCTSTR szFilenameFrom, Directory dir, bool bStripFilename = false); LPCTSTR GetDefaultDirectory(Directory dir) const; + std::vector<uint32> GetSampleRates(); + static MPTChords &GetChords() { return Instance().Chords; } // Get settings object singleton Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2013-09-06 18:19:26 UTC (rev 2648) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2013-09-06 21:44:06 UTC (rev 2649) @@ -168,7 +168,7 @@ virtual int64 GetStreamPositionSamples() const { return 0; } virtual UINT GetCurrentSampleRate(UINT nDevice) { UNREFERENCED_PARAMETER(nDevice); return 0; } // Return which samplerates are actually supported by the device. Currently only implemented properly for ASIO. - virtual bool CanSampleRate(UINT nDevice, std::vector<uint32> &samplerates, std::vector<bool> &result) { UNREFERENCED_PARAMETER(nDevice); result.assign(samplerates.size(), true); return true; } ; + virtual bool CanSampleRate(UINT nDevice, const std::vector<uint32> &samplerates, std::vector<bool> &result) { UNREFERENCED_PARAMETER(nDevice); result.assign(samplerates.size(), true); return true; } ; }; Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2013-09-06 18:19:26 UTC (rev 2648) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2013-09-06 21:44:06 UTC (rev 2649) @@ -702,8 +702,8 @@ } -bool CASIODevice::CanSampleRate(UINT nDevice, std::vector<uint32> &samplerates, std::vector<bool> &result) -//------------------------------------------------------------------------------------------------------- +bool CASIODevice::CanSampleRate(UINT nDevice, const std::vector<uint32> &samplerates, std::vector<bool> &result) +//-------------------------------------------------------------------------------------------------------------- { const bool wasOpen = (m_pAsioDrv != NULL); if(!wasOpen) Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2013-09-06 18:19:26 UTC (rev 2648) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2013-09-06 21:44:06 UTC (rev 2649) @@ -68,7 +68,7 @@ UINT GetNumBuffers() { return 2; } float GetCurrentRealLatencyMS() { return m_nAsioBufferLen * 2 * 1000.0f / m_Settings.Samplerate; } - bool CanSampleRate(UINT nDevice, std::vector<uint32> &samplerates, std::vector<bool> &result); + bool CanSampleRate(UINT nDevice, const std::vector<uint32> &samplerates, std::vector<bool> &result); UINT GetCurrentSampleRate(UINT nDevice); public: Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2013-09-06 18:19:26 UTC (rev 2648) +++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2013-09-06 21:44:06 UTC (rev 2649) @@ -159,8 +159,8 @@ } -bool CPortaudioDevice::CanSampleRate(UINT nDevice, std::vector<uint32> &samplerates, std::vector<bool> &result) -//------------------------------------------------------------------------------------------------------------ +bool CPortaudioDevice::CanSampleRate(UINT nDevice, const std::vector<uint32> &samplerates, std::vector<bool> &result) +//------------------------------------------------------------------------------------------------------------------- { result.clear(); for(UINT n=0; n<samplerates.size(); n++) Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevicePortAudio.h 2013-09-06 18:19:26 UTC (rev 2648) +++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.h 2013-09-06 21:44:06 UTC (rev 2649) @@ -55,7 +55,7 @@ float GetCurrentRealLatencyMS(); bool HasGetStreamPosition() const { return false; } int64 GetStreamPositionSamples() const; - bool CanSampleRate(UINT nDevice, std::vector<uint32> &samplerates, std::vector<bool> &result); + bool CanSampleRate(UINT nDevice, const std::vector<uint32> &samplerates, std::vector<bool> &result); int StreamCallback( const void *input, void *output, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |