From: <man...@us...> - 2013-11-24 19:28:21
|
Revision: 3305 http://sourceforge.net/p/modplug/code/3305 Author: manxorist Date: 2013-11-24 19:28:11 +0000 (Sun, 24 Nov 2013) Log Message: ----------- [Imp] sounddev: Remember device settings per device. Old settings are propagated to all found devices on the first start of the new version. [Fix] sounddev: The sound device itself is now remembered by an identifier string instead of a (api,id) pair to avoid catching the wrong device when the number or order of sound cards changes. [Mod] sounddev: Default to floating point output for new installations. [Imp] Cleanup the list of samplerates that OpenMPT presents to the user: Remove some totally uncommon ones and add the lower range of common ones instead. The user can still select the old uncommon ones by editing [Sound Settings]SampleRates. This even allows for samplerates that were previously unavailable. If the previously selected samplerate is not contained in the new default list of samplerates, it gets automatically added to the setting on the first start of the new version. [Mod] OpenMPT: Version is now 1.22.07.04 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/Mpdlgs.h trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/resource.h trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/sounddev/SoundDevice.h Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2013-11-24 16:02:25 UTC (rev 3304) +++ trunk/OpenMPT/common/versionNumber.h 2013-11-24 19:28:11 UTC (rev 3305) @@ -17,7 +17,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 22 #define VER_MINOR 07 -#define VER_MINORMINOR 03 +#define VER_MINORMINOR 04 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-24 16:02:25 UTC (rev 3304) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-24 19:28:11 UTC (rev 3305) @@ -804,7 +804,7 @@ } gpSoundDevice->SetMessageReceiver(this); gpSoundDevice->SetSource(this); - if(!gpSoundDevice->Open(TrackerSettings::Instance().GetSoundDeviceSettings())) + if(!gpSoundDevice->Open(TrackerSettings::Instance().GetSoundDeviceSettings(deviceID))) { Reporting::Error("Unable to open sound device: Could not open sound device."); return false; @@ -815,7 +815,9 @@ Reporting::Error("Unable to open sound device: Unknown sample format."); return false; } - TrackerSettings::Instance().m_SampleFormat = actualSampleFormat; + SoundDeviceSettings deviceSettings = TrackerSettings::Instance().GetSoundDeviceSettings(deviceID); + deviceSettings.sampleFormat = actualSampleFormat; + TrackerSettings::Instance().SetSoundDeviceSettings(deviceID, deviceSettings); return true; } @@ -1192,7 +1194,7 @@ if(!gpSoundDevice->Start()) return false; if(!m_NotifyTimer) { - m_NotifyTimer = SetTimer(TIMERID_NOTIFY, TrackerSettings::Instance().m_UpdateIntervalMS, NULL); + m_NotifyTimer = SetTimer(TIMERID_NOTIFY, std::max<int>(1, Util::Round<int>(gpSoundDevice->GetBufferAttributes().UpdateInterval * 1000.0)), NULL); } return true; } @@ -1595,7 +1597,7 @@ //------------------------------------------------------------------------------------------------ { const bool isPlaying = IsPlaying(); - if((TrackerSettings::Instance().GetSoundDeviceID() != deviceID) || (TrackerSettings::Instance().GetSoundDeviceSettings() != deviceSettings)) + if((TrackerSettings::Instance().GetSoundDeviceID() != deviceID) || (TrackerSettings::Instance().GetSoundDeviceSettings(deviceID) != deviceSettings)) { CModDoc *pActiveMod = NULL; if (isPlaying) @@ -1604,7 +1606,10 @@ PauseMod(); } TrackerSettings::Instance().SetSoundDeviceID(deviceID); - TrackerSettings::Instance().SetSoundDeviceSettings(deviceSettings); + TrackerSettings::Instance().SetSoundDeviceSettings(deviceID, deviceSettings); + + TrackerSettings::Instance().MixerOutputChannels = deviceSettings.Channels; + TrackerSettings::Instance().MixerSamplerate = deviceSettings.Samplerate; { CriticalSection cs; if (pActiveMod) UpdateAudioParameters(pActiveMod->GetrSoundFile(), FALSE); @@ -1772,7 +1777,7 @@ CPropertySheet dlg("OpenMPT Setup", this, m_nLastOptionsPage); COptionsGeneral general; - COptionsSoundcard sounddlg(TrackerSettings::Instance().GetSoundDeviceSettings(), TrackerSettings::Instance().GetSoundDeviceID()); + COptionsSoundcard sounddlg(TrackerSettings::Instance().GetSoundDeviceID()); COptionsKeyboard keyboard; COptionsColors colors; COptionsPlayer playerdlg; Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-11-24 16:02:25 UTC (rev 3304) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-11-24 19:28:11 UTC (rev 3305) @@ -103,21 +103,27 @@ } -COptionsSoundcard::COptionsSoundcard(const SoundDeviceSettings &settings, SoundDeviceID sd) -//----------------------------------------------------------------------------------------- +COptionsSoundcard::COptionsSoundcard(SoundDeviceID dev) +//----------------------------------------------------- : CPropertyPage(IDD_OPTIONS_SOUNDCARD) - , m_Settings(settings) + , m_CurrentDeviceInfo(theApp.GetSoundDevicesManager()->FindDeviceInfo(dev)) + , m_CurrentDeviceCaps(theApp.GetSoundDevicesManager()->GetDeviceCaps(dev, TrackerSettings::Instance().GetSampleRates(), CMainFrame::GetMainFrame(), CMainFrame::GetMainFrame()->gpSoundDevice, true)) + , m_Settings(TrackerSettings::Instance().GetSoundDeviceSettings(dev)) { m_PreAmpNoteShowed = false; - SetDevice(sd); } -void COptionsSoundcard::SetDevice(SoundDeviceID dev) -//-------------------------------------------------- +void COptionsSoundcard::SetDevice(SoundDeviceID dev, bool forceReload) +//-------------------------------------------------------------------- { + bool deviceChanged = (dev != m_CurrentDeviceInfo.id); m_CurrentDeviceInfo = theApp.GetSoundDevicesManager()->FindDeviceInfo(dev); m_CurrentDeviceCaps = theApp.GetSoundDevicesManager()->GetDeviceCaps(dev, TrackerSettings::Instance().GetSampleRates(), CMainFrame::GetMainFrame(), CMainFrame::GetMainFrame()->gpSoundDevice, true); + if(deviceChanged || forceReload) + { + m_Settings = TrackerSettings::Instance().GetSoundDeviceSettings(dev); + } } @@ -144,31 +150,12 @@ } -void COptionsSoundcard::UpdateEverything() -//---------------------------------------- +void COptionsSoundcard::UpdateLatency() +//------------------------------------- { - - CHAR s[128]; - - CheckDlgButton(IDC_CHECK2, (TrackerSettings::Instance().MixerFlags & SNDMIX_SOFTPANNING) ? MF_CHECKED : MF_UNCHECKED); - CheckDlgButton(IDC_CHECK4, m_Settings.ExclusiveMode ? MF_CHECKED : MF_UNCHECKED); - CheckDlgButton(IDC_CHECK5, m_Settings.BoostThreadPriority ? MF_CHECKED : MF_UNCHECKED); - - // Sampling Rate - UpdateSampleRates(); - - // Max Mixing Channels - { - m_CbnPolyphony.ResetContent(); - for (UINT n = 0; n < CountOf(nCPUMix); n++) - { - wsprintf(s, "%d (%s)", nCPUMix[n], szCPUNames[n]); - m_CbnPolyphony.AddString(s); - if (TrackerSettings::Instance().MixerMaxChannels == nCPUMix[n]) m_CbnPolyphony.SetCurSel(n); - } - } // latency { + CHAR s[128]; m_CbnLatencyMS.ResetContent(); wsprintf(s, "%d ms", m_Settings.LatencyMS); m_CbnLatencyMS.SetWindowText(s); @@ -190,8 +177,15 @@ m_CbnLatencyMS.AddString("200 ms"); m_CbnLatencyMS.AddString("250 ms"); } +} + + +void COptionsSoundcard::UpdateUpdateInterval() +//-------------------------------------------- +{ // update interval { + CHAR s[128]; m_CbnUpdateIntervalMS.ResetContent(); wsprintf(s, "%d ms", m_Settings.UpdateIntervalMS); m_CbnUpdateIntervalMS.SetWindowText(s); @@ -204,6 +198,27 @@ m_CbnUpdateIntervalMS.AddString("25 ms"); m_CbnUpdateIntervalMS.AddString("50 ms"); } +} + + +void COptionsSoundcard::UpdateEverything() +//---------------------------------------- +{ + + CHAR s[128]; + + CheckDlgButton(IDC_CHECK2, (TrackerSettings::Instance().MixerFlags & SNDMIX_SOFTPANNING) ? MF_CHECKED : MF_UNCHECKED); + + // Max Mixing Channels + { + m_CbnPolyphony.ResetContent(); + for (UINT n = 0; n < CountOf(nCPUMix); n++) + { + wsprintf(s, "%d (%s)", nCPUMix[n], szCPUNames[n]); + m_CbnPolyphony.AddString(s); + if (TrackerSettings::Instance().MixerMaxChannels == nCPUMix[n]) m_CbnPolyphony.SetCurSel(n); + } + } // Stereo Separation { m_SliderStereoSep.SetRange(0, 4); @@ -294,20 +309,28 @@ iItem++; } } - UpdateControls(); } + UpdateDevice(); + +} + + +void COptionsSoundcard::UpdateDevice() +//------------------------------------ +{ + UpdateControls(); + UpdateLatency(); + UpdateUpdateInterval(); + UpdateSampleRates(); UpdateChannels(); UpdateSampleFormat(); - } void COptionsSoundcard::UpdateChannels() //-------------------------------------- { - CHAR s[128]; - UINT n = 0; m_CbnChannels.ResetContent(); UINT maxChannels = 0; if(m_CurrentDeviceCaps.channelNames.size() > 0) @@ -317,21 +340,23 @@ { maxChannels = 4; } + int sel = 0; for(UINT channels = maxChannels; channels >= 1; channels /= 2) { - wsprintf(s, "%s", gszChnCfgNames[(channels+2)/2-1]); - UINT ndx = m_CbnChannels.AddString(s); + int ndx = m_CbnChannels.AddString(gszChnCfgNames[(channels+2)/2-1]); m_CbnChannels.SetItemData(ndx, channels); if(channels == m_Settings.Channels) { - n = ndx; + sel = ndx; } } - m_CbnChannels.SetCurSel(n); + m_CbnChannels.SetCurSel(sel); + + GetDlgItem(IDC_STATIC_BASECHANNEL)->EnableWindow(m_CurrentDeviceCaps.CanChannelMapping ? TRUE : FALSE); + m_CbnBaseChannel.EnableWindow(m_CurrentDeviceCaps.CanChannelMapping ? TRUE : FALSE); + m_CbnBaseChannel.ResetContent(); if(m_CurrentDeviceCaps.CanChannelMapping) { - m_CbnBaseChannel.ResetContent(); - m_CbnBaseChannel.EnableWindow(TRUE); int sel = 0; for(std::size_t channel = 0; channel < m_CurrentDeviceCaps.channelNames.size(); ++channel) { @@ -343,10 +368,6 @@ } } m_CbnBaseChannel.SetCurSel(sel); - } else - { - m_CbnBaseChannel.ResetContent(); - m_CbnBaseChannel.EnableWindow(FALSE); } m_BtnDriverPanel.ShowWindow(m_CurrentDeviceCaps.CanDriverPanel ? SW_SHOW : SW_HIDE); } @@ -357,10 +378,6 @@ { UINT n = 0; m_CbnSampleFormat.ResetContent(); - if(m_CurrentDeviceInfo.id.GetType() == SNDDEV_ASIO) - { - m_Settings.sampleFormat = TrackerSettings::Instance().m_SampleFormat; - } m_CbnSampleFormat.EnableWindow(m_CurrentDeviceCaps.CanSampleFormat ? TRUE : FALSE); for(UINT bits = 40; bits >= 8; bits -= 8) { @@ -456,10 +473,7 @@ if(n >= 0) { SetDevice(SoundDeviceID::FromIdRaw(m_CbnDevice.GetItemData(n))); - UpdateControls(); - UpdateSampleRates(); - UpdateChannels(); - UpdateSampleFormat(); + UpdateDevice(); OnSettingsChanged(); } } @@ -516,6 +530,8 @@ { GetDlgItem(IDC_CHECK4)->SetWindowText("Use device exclusively"); } + CheckDlgButton(IDC_CHECK4, m_Settings.ExclusiveMode ? MF_CHECKED : MF_UNCHECKED); + CheckDlgButton(IDC_CHECK5, m_Settings.BoostThreadPriority ? MF_CHECKED : MF_UNCHECKED); } @@ -563,14 +579,6 @@ CMainFrame::GetMainFrame()->SetupPlayer(); } } - // Sound Device - { - int n = m_CbnDevice.GetCurSel(); - if(n >= 0) - { - SetDevice(SoundDeviceID::FromIdRaw(m_CbnDevice.GetItemData(n))); - } - } const SoundDeviceID dev = m_CurrentDeviceInfo.id; // Latency { @@ -600,9 +608,8 @@ } } CMainFrame::GetMainFrame()->SetupSoundCard(m_Settings, m_CurrentDeviceInfo.id); - SetDevice(m_CurrentDeviceInfo.id); // Poll changed ASIO channel names - UpdateSampleFormat(); - UpdateChannels(); + SetDevice(m_CurrentDeviceInfo.id, true); // Poll changed ASIO sample format and channel names + UpdateDevice(); UpdateStatistics(); CPropertyPage::OnOK(); } Modified: trunk/OpenMPT/mptrack/Mpdlgs.h =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.h 2013-11-24 16:02:25 UTC (rev 3304) +++ trunk/OpenMPT/mptrack/Mpdlgs.h 2013-11-24 19:28:11 UTC (rev 3305) @@ -24,20 +24,23 @@ CComboBox m_CbnBaseChannel; CEdit m_EditStatistics; CButton m_BtnDriverPanel; - SoundDeviceSettings m_Settings; bool m_PreAmpNoteShowed; - void SetDevice(SoundDeviceID dev); + void SetDevice(SoundDeviceID dev, bool forceReload=false); SoundDeviceInfo m_CurrentDeviceInfo; SoundDeviceCaps m_CurrentDeviceCaps; + SoundDeviceSettings m_Settings; public: - COptionsSoundcard(const SoundDeviceSettings &settings, SoundDeviceID sd); + COptionsSoundcard(SoundDeviceID sd); void UpdateStatistics(); private: void UpdateEverything(); + void UpdateDevice(); + void UpdateLatency(); + void UpdateUpdateInterval(); void UpdateSampleRates(); void UpdateChannels(); void UpdateSampleFormat(); Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-11-24 16:02:25 UTC (rev 3304) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-11-24 19:28:11 UTC (rev 3305) @@ -838,6 +838,16 @@ // Load sound APIs m_pSoundDevicesManager = new SoundDevicesManager(); + if(TrackerSettings::Instance().m_SoundDeviceSettingsUseOldDefaults) + { + // get the old default device + TrackerSettings::Instance().m_SoundDeviceIdentifier = m_pSoundDevicesManager->FindDeviceInfo(TrackerSettings::Instance().m_SoundDeviceID_DEPRECATED).GetIdentifier(); + // apply old global sound device settings to each found device + for(std::vector<SoundDeviceInfo>::const_iterator it = m_pSoundDevicesManager->begin(); it != m_pSoundDevicesManager->end(); ++it) + { + TrackerSettings::Instance().SetSoundDeviceSettings(it->id, TrackerSettings::Instance().GetSoundDeviceSettingsDefaults()); + } + } // Load DLS Banks if (!cmdInfo.m_bNoDls) LoadDefaultDLSBanks(); Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-11-24 16:02:25 UTC (rev 3304) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-11-24 19:28:11 UTC (rev 3305) @@ -23,6 +23,7 @@ #include "../common/misc_util.h" #include "PatternClipboard.h" +#include <algorithm> #define OLD_SOUNDSETUP_REVERSESTEREO 0x20 #define OLD_SOUNDSETUP_SECONDARY 0x40 @@ -151,16 +152,10 @@ , DefaultPlugVolumeHandling(conf, "Misc", "DefaultPlugVolumeHandling", PLUGIN_VOLUMEHANDLING_IGNORE) , autoApplySmoothFT2Ramping(conf, "Misc", "SmoothFT2Ramping", false) // Sound Settings + , m_SoundSampleRates(conf, "Sound Settings", "SampleRates", GetDefaultSampleRates()) , m_MorePortaudio(conf, "Sound Settings", "MorePortaudio", false) - , m_nWaveDevice(conf, "Sound Settings", "WaveDevice", SoundDeviceID()) - , m_BufferLength_DEPRECATED(conf, "Sound Settings", "BufferLength", 50) - , m_LatencyMS(conf, "Sound Settings", "Latency", SoundDeviceSettings().LatencyMS) - , m_UpdateIntervalMS(conf, "Sound Settings", "UpdateInterval", SoundDeviceSettings().UpdateIntervalMS) - , m_SampleFormat(conf, "Sound Settings", "BitsPerSample", SoundDeviceSettings().sampleFormat) - , m_SoundDeviceExclusiveMode(conf, "Sound Settings", "ExclusiveMode", SoundDeviceSettings().ExclusiveMode) - , m_SoundDeviceBoostThreadPriority(conf, "Sound Settings", "BoostThreadPriority", SoundDeviceSettings().BoostThreadPriority) - , m_SoundDeviceUseHardwareTiming(conf, "Sound Settings", "UseHardwareTiming", SoundDeviceSettings().UseHardwareTiming) - , m_SoundDeviceChannelMapping(conf, "Sound Settings", "ChannelMapping", SoundDeviceSettings().ChannelMapping) + , m_SoundDeviceSettingsUseOldDefaults(false) + , m_SoundDeviceIdentifier(conf, "Sound Settings", "Device", std::wstring()) , MixerMaxChannels(conf, "Sound Settings", "MixChannels", MixerSettings().m_nMaxMixChannels) , MixerDSPMask(conf, "Sound Settings", "Quality", MixerSettings().DSPMask) , MixerFlags(conf, "Sound Settings", "SoundSetup", MixerSettings().MixerFlags) @@ -337,27 +332,68 @@ } // Sound Settings - if(storedVersion < MAKE_VERSION_NUMERIC(1,22,07,03)) + if(storedVersion < MAKE_VERSION_NUMERIC(1,22,07,04)) { - m_SoundDeviceChannelMapping = SoundChannelMapping::BaseChannel(MixerOutputChannels, conf.Read<int>("Sound Settings", "ASIOBaseChannel", 0)); + std::vector<uint32> sampleRates = m_SoundSampleRates; + if(std::count(sampleRates.begin(), sampleRates.end(), MixerSamplerate) == 0) + { + sampleRates.push_back(MixerSamplerate); + std::sort(sampleRates.begin(), sampleRates.end()); + std::reverse(sampleRates.begin(), sampleRates.end()); + m_SoundSampleRates = sampleRates; + } } - if(storedVersion < MAKE_VERSION_NUMERIC(1,21,01,26)) + if(storedVersion < MAKE_VERSION_NUMERIC(1,22,07,04)) { - if(m_BufferLength_DEPRECATED != 0) + m_SoundDeviceID_DEPRECATED = conf.Read<SoundDeviceID>("Sound Settings", "WaveDevice", SoundDeviceID()); + Setting<uint32> m_BufferLength_DEPRECATED(conf, "Sound Settings", "BufferLength", 50); + Setting<uint32> m_LatencyMS(conf, "Sound Settings", "Latency", SoundDeviceSettings().LatencyMS); + Setting<uint32> m_UpdateIntervalMS(conf, "Sound Settings", "UpdateInterval", SoundDeviceSettings().UpdateIntervalMS); + Setting<SampleFormat> m_SampleFormat(conf, "Sound Settings", "BitsPerSample", SoundDeviceSettings().sampleFormat); + Setting<bool> m_SoundDeviceExclusiveMode(conf, "Sound Settings", "ExclusiveMode", SoundDeviceSettings().ExclusiveMode); + Setting<bool> m_SoundDeviceBoostThreadPriority(conf, "Sound Settings", "BoostThreadPriority", SoundDeviceSettings().BoostThreadPriority); + Setting<bool> m_SoundDeviceUseHardwareTiming(conf, "Sound Settings", "UseHardwareTiming", SoundDeviceSettings().UseHardwareTiming); + Setting<SoundChannelMapping> m_SoundDeviceChannelMapping(conf, "Sound Settings", "ChannelMapping", SoundDeviceSettings().ChannelMapping); + if(storedVersion < MAKE_VERSION_NUMERIC(1,21,01,26)) { - if(m_BufferLength_DEPRECATED < 1) m_BufferLength_DEPRECATED = 1; // 1ms - if(m_BufferLength_DEPRECATED > 1000) m_BufferLength_DEPRECATED = 1000; // 1sec - if(GetSoundDeviceID().GetType() == SNDDEV_ASIO) + if(m_BufferLength_DEPRECATED != 0) { - m_LatencyMS = m_BufferLength_DEPRECATED; - m_UpdateIntervalMS = m_BufferLength_DEPRECATED / 8; - } else - { - m_LatencyMS = m_BufferLength_DEPRECATED * 3; - m_UpdateIntervalMS = m_BufferLength_DEPRECATED / 8; + if(m_BufferLength_DEPRECATED < 1) m_BufferLength_DEPRECATED = 1; // 1ms + if(m_BufferLength_DEPRECATED > 1000) m_BufferLength_DEPRECATED = 1000; // 1sec + if(GetSoundDeviceID().GetType() == SNDDEV_ASIO) + { + m_LatencyMS = m_BufferLength_DEPRECATED; + m_UpdateIntervalMS = m_BufferLength_DEPRECATED / 8; + } else + { + m_LatencyMS = m_BufferLength_DEPRECATED * 3; + m_UpdateIntervalMS = m_BufferLength_DEPRECATED / 8; + } } + conf.Remove(m_BufferLength_DEPRECATED.GetPath()); } - conf.Remove(m_BufferLength_DEPRECATED.GetPath()); + if(storedVersion < MAKE_VERSION_NUMERIC(1,22,01,03)) + { + m_SoundDeviceExclusiveMode = ((MixerFlags & OLD_SOUNDSETUP_SECONDARY) == 0); + } + if(storedVersion < MAKE_VERSION_NUMERIC(1,22,01,03)) + { + m_SoundDeviceBoostThreadPriority = ((MixerFlags & OLD_SOUNDSETUP_NOBOOSTTHREADPRIORITY) == 0); + } + if(storedVersion < MAKE_VERSION_NUMERIC(1,22,07,03)) + { + m_SoundDeviceChannelMapping = SoundChannelMapping::BaseChannel(MixerOutputChannels, conf.Read<int>("Sound Settings", "ASIOBaseChannel", 0)); + } + m_SoundDeviceSettingsDefaults.LatencyMS = m_LatencyMS; + m_SoundDeviceSettingsDefaults.UpdateIntervalMS = m_UpdateIntervalMS; + m_SoundDeviceSettingsDefaults.Samplerate = MixerSamplerate; + m_SoundDeviceSettingsDefaults.Channels = (uint8)MixerOutputChannels; + m_SoundDeviceSettingsDefaults.sampleFormat = m_SampleFormat; + m_SoundDeviceSettingsDefaults.ExclusiveMode = m_SoundDeviceExclusiveMode; + m_SoundDeviceSettingsDefaults.BoostThreadPriority = m_SoundDeviceBoostThreadPriority; + m_SoundDeviceSettingsDefaults.UseHardwareTiming = m_SoundDeviceUseHardwareTiming; + m_SoundDeviceSettingsDefaults.ChannelMapping = m_SoundDeviceChannelMapping; + m_SoundDeviceSettingsUseOldDefaults = true; } if(storedVersion < MAKE_VERSION_NUMERIC(1,21,01,26)) { @@ -365,12 +401,10 @@ } if(storedVersion < MAKE_VERSION_NUMERIC(1,22,01,03)) { - m_SoundDeviceExclusiveMode = ((MixerFlags & OLD_SOUNDSETUP_SECONDARY) == 0); MixerFlags &= ~OLD_SOUNDSETUP_SECONDARY; } if(storedVersion < MAKE_VERSION_NUMERIC(1,22,01,03)) { - m_SoundDeviceBoostThreadPriority = ((MixerFlags & OLD_SOUNDSETUP_NOBOOSTTHREADPRIORITY) == 0); MixerFlags &= ~OLD_SOUNDSETUP_NOBOOSTTHREADPRIORITY; } if(storedVersion < MAKE_VERSION_NUMERIC(1,20,00,22)) @@ -456,33 +490,119 @@ } -SoundDeviceSettings TrackerSettings::GetSoundDeviceSettings() const -//----------------------------------------------------------------- +struct StoredSoundDeviceSettings { - SoundDeviceSettings settings; + +private: + + SettingsContainer &conf; + const SoundDeviceInfo deviceInfo; + +public: + + Setting<uint32> LatencyUS; + Setting<uint32> UpdateIntervalUS; + Setting<uint32> Samplerate; + Setting<uint8> Channels; + Setting<SampleFormat> sampleFormat; + Setting<bool> ExclusiveMode; + Setting<bool> BoostThreadPriority; + Setting<bool> UseHardwareTiming; + Setting<SoundChannelMapping> ChannelMapping; + +public: + + StoredSoundDeviceSettings(SettingsContainer &conf, const SoundDeviceInfo & deviceInfo, const SoundDeviceSettings &defaults = SoundDeviceSettings()) + : conf(conf) + , deviceInfo(deviceInfo) + , LatencyUS(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"Latency", defaults.LatencyMS * 1000) + , UpdateIntervalUS(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"UpdateInterval", defaults.UpdateIntervalMS * 1000) + , Samplerate(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"SampleRate", defaults.Samplerate) + , Channels(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"Channels", defaults.Channels) + , sampleFormat(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"SampleFormat", defaults.sampleFormat) + , ExclusiveMode(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"ExclusiveMode", defaults.ExclusiveMode) + , BoostThreadPriority(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"BoostThreadPriority", defaults.BoostThreadPriority) + , UseHardwareTiming(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"UseHardwareTiming", defaults.UseHardwareTiming) + , ChannelMapping(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"ChannelMapping", defaults.ChannelMapping) + { + // store informational data (not read back, jsut to allow the user to mock with the raw ini file) + conf.Write(L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"ID", deviceInfo.id); + conf.Write(L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"InternalID", deviceInfo.internalID); + conf.Write(L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"API", deviceInfo.apiName); + conf.Write(L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"Name", deviceInfo.name); + } + + StoredSoundDeviceSettings & operator = (const SoundDeviceSettings &settings) + { + LatencyUS = settings.LatencyMS * 1000; + UpdateIntervalUS = settings.UpdateIntervalMS * 1000; + Samplerate = settings.Samplerate; + Channels = settings.Channels; + sampleFormat = settings.sampleFormat; + ExclusiveMode = settings.ExclusiveMode; + BoostThreadPriority = settings.BoostThreadPriority; + UseHardwareTiming = settings.UseHardwareTiming; + ChannelMapping = settings.ChannelMapping; + return *this; + } + + operator SoundDeviceSettings () const + { + SoundDeviceSettings settings; + settings.LatencyMS = LatencyUS / 1000; + settings.UpdateIntervalMS = UpdateIntervalUS / 1000; + settings.Samplerate = Samplerate; + settings.Channels = Channels; + settings.sampleFormat = sampleFormat; + settings.ExclusiveMode = ExclusiveMode; + settings.BoostThreadPriority = BoostThreadPriority; + settings.UseHardwareTiming = UseHardwareTiming; + settings.ChannelMapping = ChannelMapping; + return settings; + } + +}; + +SoundDeviceSettings TrackerSettings::GetSoundDeviceSettingsDefaults() const +//------------------------------------------------------------------------- +{ + return m_SoundDeviceSettingsDefaults; +} + +SoundDeviceID TrackerSettings::GetSoundDeviceID() const +//----------------------------------------------------- +{ + return theApp.GetSoundDevicesManager()->FindDeviceInfo(m_SoundDeviceIdentifier).id; +} + +void TrackerSettings::SetSoundDeviceID(const SoundDeviceID &id) +//------------------------------------------------------------- +{ + m_SoundDeviceIdentifier = theApp.GetSoundDevicesManager()->FindDeviceInfo(id).GetIdentifier(); +} + +SoundDeviceSettings TrackerSettings::GetSoundDeviceSettings(const SoundDeviceID &device) const +//-------------------------------------------------------------------------------------------- +{ + const SoundDeviceInfo deviceInfo = theApp.GetSoundDevicesManager()->FindDeviceInfo(device); + if(!deviceInfo.IsValid()) + { + return GetSoundDeviceSettingsDefaults(); + } + SoundDeviceSettings settings = StoredSoundDeviceSettings(conf, deviceInfo); settings.hWnd = CMainFrame::GetMainFrame()->m_hWnd; - settings.LatencyMS = m_LatencyMS; - settings.UpdateIntervalMS = m_UpdateIntervalMS; - settings.Samplerate = MixerSamplerate; - settings.Channels = (uint8)MixerOutputChannels; - settings.sampleFormat = m_SampleFormat; - settings.ExclusiveMode = m_SoundDeviceExclusiveMode; - settings.BoostThreadPriority = m_SoundDeviceBoostThreadPriority; - settings.ChannelMapping = m_SoundDeviceChannelMapping; return settings; } -void TrackerSettings::SetSoundDeviceSettings(const SoundDeviceSettings &settings) -//------------------------------------------------------------------------------- +void TrackerSettings::SetSoundDeviceSettings(const SoundDeviceID &device, const SoundDeviceSettings &settings) +//------------------------------------------------------------------------------------------------------------ { - m_LatencyMS = settings.LatencyMS; - m_UpdateIntervalMS = settings.UpdateIntervalMS; - MixerSamplerate = settings.Samplerate; - MixerOutputChannels = settings.Channels; - m_SampleFormat = settings.sampleFormat; - m_SoundDeviceExclusiveMode = settings.ExclusiveMode; - m_SoundDeviceBoostThreadPriority = settings.BoostThreadPriority; - m_SoundDeviceChannelMapping = settings.ChannelMapping; + const SoundDeviceInfo deviceInfo = theApp.GetSoundDevicesManager()->FindDeviceInfo(device); + if(!deviceInfo.IsValid()) + { + return; + } + StoredSoundDeviceSettings(conf, deviceInfo) = settings; } @@ -689,26 +809,29 @@ } -std::vector<uint32> TrackerSettings::GetSampleRates() -//--------------------------------------------------- +std::vector<uint32> TrackerSettings::GetSampleRates() const +//--------------------------------------------------------- { + return m_SoundSampleRates; +} + + +std::vector<uint32> TrackerSettings::GetDefaultSampleRates() +//---------------------------------------------------------- +{ static const uint32 samplerates [] = { 192000, 176400, 96000, 88200, - 64000, 48000, 44100, - 40000, - 37800, - 33075, 32000, 24000, 22050, - 20000, - 19800, - 16000 + 16000, + 11025, + 8000 }; return std::vector<uint32>(samplerates, samplerates + CountOf(samplerates)); } Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2013-11-24 16:02:25 UTC (rev 3304) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2013-11-24 19:28:11 UTC (rev 3305) @@ -198,6 +198,9 @@ return static_cast<PLUGVOLUMEHANDLING>(val.as<int32>()); } +template<> inline SettingValue ToSettingValue(const std::vector<uint32> &val) { return mpt::String::Combine(val); } +template<> inline std::vector<uint32> FromSettingValue(const SettingValue &val) { return mpt::String::Split<uint32>(val); } + template<> inline SettingValue ToSettingValue(const SoundDeviceID &val) { return SettingValue(int32(val.GetIdRaw())); } template<> inline SoundDeviceID FromSettingValue(const SettingValue &val) { return SoundDeviceID::FromIdRaw(val.as<int32>()); } @@ -269,21 +272,20 @@ // Sound Settings + Setting<std::vector<uint32> > m_SoundSampleRates; Setting<bool> m_MorePortaudio; - Setting<SoundDeviceID> m_nWaveDevice; - SoundDeviceID GetSoundDeviceID() const { return m_nWaveDevice; } - void SetSoundDeviceID(const SoundDeviceID &id) { m_nWaveDevice = id; } - Setting<uint32> m_BufferLength_DEPRECATED; - Setting<uint32> m_LatencyMS; - Setting<uint32> m_UpdateIntervalMS; - Setting<SampleFormat> m_SampleFormat; - Setting<bool> m_SoundDeviceExclusiveMode; - Setting<bool> m_SoundDeviceBoostThreadPriority; - Setting<bool> m_SoundDeviceUseHardwareTiming; - Setting<SoundChannelMapping> m_SoundDeviceChannelMapping; - SoundDeviceSettings GetSoundDeviceSettings() const; - void SetSoundDeviceSettings(const SoundDeviceSettings &settings); + bool m_SoundDeviceSettingsUseOldDefaults; + SoundDeviceID m_SoundDeviceID_DEPRECATED; + SoundDeviceSettings m_SoundDeviceSettingsDefaults; + SoundDeviceSettings GetSoundDeviceSettingsDefaults() const; + + Setting<std::wstring> m_SoundDeviceIdentifier; + SoundDeviceID GetSoundDeviceID() const; + void SetSoundDeviceID(const SoundDeviceID &id); + SoundDeviceSettings GetSoundDeviceSettings(const SoundDeviceID &device) const; + void SetSoundDeviceSettings(const SoundDeviceID &device, const SoundDeviceSettings &settings); + Setting<uint32> MixerMaxChannels; Setting<uint32> MixerDSPMask; Setting<uint32> MixerFlags; @@ -370,7 +372,7 @@ static void GetDefaultColourScheme(COLORREF (&colours)[MAX_MODCOLORS]); - std::vector<uint32> GetSampleRates(); + std::vector<uint32> GetSampleRates() const; static MPTChords &GetChords() { return Instance().Chords; } @@ -379,6 +381,8 @@ protected: + static std::vector<uint32> GetDefaultSampleRates(); + void FixupEQ(EQPreset *pEqSettings); void LoadChords(MPTChords &chords); Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2013-11-24 16:02:25 UTC (rev 3304) +++ trunk/OpenMPT/mptrack/mptrack.rc 2013-11-24 19:28:11 UTC (rev 3305) @@ -1310,7 +1310,7 @@ COMBOBOX IDC_COMBO3,72,84,66,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_COMBO5,144,84,42,80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_COMBO6,192,84,66,80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Base channel:",IDC_STATIC,12,102,54,12,SS_CENTERIMAGE + LTEXT "Base channel:",IDC_STATIC_BASECHANNEL,12,102,54,12,SS_CENTERIMAGE COMBOBOX IDC_COMBO9,72,102,114,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Driver Panel",IDC_BUTTON2,192,102,66,12 GROUPBOX "",IDC_STATIC,6,126,258,90 Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2013-11-24 16:02:25 UTC (rev 3304) +++ trunk/OpenMPT/mptrack/resource.h 2013-11-24 19:28:11 UTC (rev 3305) @@ -934,6 +934,7 @@ #define IDC_STATIC_BUFFERLENGTH 2457 #define IDC_STATIC_UPDATEINTERVAL 2458 #define IDC_COMBO_UPDATEINTERVAL 2459 +#define IDC_STATIC_BASECHANNEL 2461 #define ID_FILE_NEWMOD 32771 #define ID_FILE_NEWXM 32772 #define ID_FILE_NEWS3M 32773 @@ -1213,7 +1214,7 @@ #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 541 #define _APS_NEXT_COMMAND_VALUE 44611 -#define _APS_NEXT_CONTROL_VALUE 2461 +#define _APS_NEXT_CONTROL_VALUE 2462 #define _APS_NEXT_SYMED_VALUE 901 #endif #endif Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-11-24 16:02:25 UTC (rev 3304) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-11-24 19:28:11 UTC (rev 3305) @@ -878,6 +878,28 @@ } +SoundDeviceInfo SoundDevicesManager::FindDeviceInfo(const std::wstring &identifier) const +//--------------------------------------------------------------------------------------- +{ + if(m_SoundDevices.empty()) + { + return SoundDeviceInfo(); + } + if(identifier.empty()) + { + return m_SoundDevices[0]; + } + for(std::vector<SoundDeviceInfo>::const_iterator it = begin(); it != end(); ++it) + { + if(it->GetIdentifier() == identifier) + { + return *it; + } + } + return SoundDeviceInfo(); +} + + bool SoundDevicesManager::OpenDriverSettings(SoundDeviceID id, ISoundMessageReceiver *messageReceiver, ISoundDevice *currentSoundDevice) //-------------------------------------------------------------------------------------------------------------------------------------- { Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2013-11-24 16:02:25 UTC (rev 3304) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2013-11-24 19:28:11 UTC (rev 3305) @@ -257,7 +257,7 @@ , UpdateIntervalMS(5) , Samplerate(48000) , Channels(2) - , sampleFormat(SampleFormatInt16) + , sampleFormat(SampleFormatFloat32) , ExclusiveMode(false) , BoostThreadPriority(true) , UseHardwareTiming(false) @@ -469,6 +469,30 @@ { return id.IsValid(); } + std::wstring GetIdentifier() const + { + if(!IsValid()) + { + return std::wstring(); + } + std::wstring result = apiName; + result += L"_"; + if(!internalID.empty()) + { + result += internalID; // safe to not contain special characters + } else if(!name.empty()) + { + // UTF8-encode the name and convert the utf8 to hex. + // This ensures that no special characters are contained in the configuration key. + std::string utf8String = mpt::To(mpt::CharsetUTF8, name); + std::wstring hexString = Util::BinToHex(std::vector<char>(utf8String.begin(), utf8String.end())); + result += hexString; + } else + { + result += mpt::ToWString(id.GetIndex()); + } + return result; + } }; @@ -493,6 +517,7 @@ const std::vector<SoundDeviceInfo> & GetDeviceInfos() const { return m_SoundDevices; } SoundDeviceInfo FindDeviceInfo(SoundDeviceID id) const; + SoundDeviceInfo FindDeviceInfo(const std::wstring &identifier) const; bool OpenDriverSettings(SoundDeviceID id, ISoundMessageReceiver *messageReceiver = nullptr, ISoundDevice *currentSoundDevice = nullptr); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |