From: <man...@us...> - 2014-02-05 13:33:12
|
Revision: 3662 http://sourceforge.net/p/modplug/code/3662 Author: manxorist Date: 2014-02-05 13:33:04 +0000 (Wed, 05 Feb 2014) Log Message: ----------- [New] Mod Export: Allow selecting or disabling dither. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/mod2wave.h trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/soundlib/Dither.cpp trunk/OpenMPT/soundlib/Dither.h Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2014-02-05 02:27:35 UTC (rev 3661) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2014-02-05 13:33:04 UTC (rev 3662) @@ -119,6 +119,7 @@ ON_CBN_SELCHANGE(IDC_COMBO5, OnFileTypeChanged) ON_CBN_SELCHANGE(IDC_COMBO1, OnSamplerateChanged) ON_CBN_SELCHANGE(IDC_COMBO4, OnChannelsChanged) + ON_CBN_SELCHANGE(IDC_COMBO6, OnDitherChanged) ON_CBN_SELCHANGE(IDC_COMBO2, OnFormatChanged) END_MESSAGE_MAP() @@ -153,6 +154,7 @@ DDX_Control(pDX, IDC_COMBO5, m_CbnFileType); DDX_Control(pDX, IDC_COMBO1, m_CbnSampleRate); DDX_Control(pDX, IDC_COMBO4, m_CbnChannels); + DDX_Control(pDX, IDC_COMBO6, m_CbnDither); DDX_Control(pDX, IDC_COMBO2, m_CbnSampleFormat); DDX_Control(pDX, IDC_SPIN3, m_SpinMinOrder); DDX_Control(pDX, IDC_SPIN4, m_SpinMaxOrder); @@ -196,6 +198,7 @@ FillSamplerates(); FillChannels(); FillFormats(); + FillDither(); LoadTags(); @@ -520,6 +523,33 @@ } +void CWaveConvert::FillDither() +//----------------------------- +{ + Encoder::Settings &encSettings = m_Settings.GetEncoderSettings(); + m_CbnDither.CComboBox::ResetContent(); + int format = m_CbnSampleFormat.GetItemData(m_CbnSampleFormat.GetCurSel()) & 0xffff; + if((encTraits->modes & Encoder::ModeEnumerated) && encTraits->formats[format].Sampleformat != SampleFormatInvalid && encTraits->formats[format].Sampleformat != SampleFormatFloat32) + { + m_CbnDither.EnableWindow(TRUE); + for(int dither = 0; dither < NumDitherModes; ++dither) + { + int ndx = m_CbnDither.AddString(mpt::ToCString(Dither::GetModeName((DitherMode)dither) + L" dither")); + m_CbnDither.SetItemData(ndx, dither); + } + } else + { + m_CbnDither.EnableWindow(FALSE); + for(int dither = 0; dither < NumDitherModes; ++dither) + { + int ndx = m_CbnDither.AddString(mpt::ToCString(Dither::GetModeName(DitherNone) + L" dither")); + m_CbnDither.SetItemData(ndx, dither); + } + } + m_CbnDither.SetCurSel(encSettings.Dither); +} + + void CWaveConvert::OnFileTypeChanged() //------------------------------------ { @@ -530,6 +560,7 @@ FillSamplerates(); FillChannels(); FillFormats(); + FillDither(); FillTags(); } @@ -540,6 +571,7 @@ SaveEncoderSettings(); //DWORD dwSamplerate = m_CbnSampleRate.GetItemData(m_CbnSampleRate.GetCurSel()); FillFormats(); + FillDither(); } @@ -549,14 +581,23 @@ SaveEncoderSettings(); //UINT nChannels = m_CbnChannels.GetItemData(m_CbnChannels.GetCurSel()); FillFormats(); + FillDither(); } +void CWaveConvert::OnDitherChanged() +//---------------------------------- +{ + SaveEncoderSettings(); +} + + void CWaveConvert::OnFormatChanged() //---------------------------------- { SaveEncoderSettings(); //DWORD dwFormat = m_CbnSampleFormat.GetItemData(m_CbnSampleFormat.GetCurSel()); + FillDither(); FillTags(); } @@ -755,6 +796,7 @@ { m_Settings.FinalSampleFormat = encTraits->formats[format].Sampleformat; } + encSettings.Dither = m_CbnDither.GetItemData(m_CbnDither.GetCurSel()); encSettings.Format = format; encSettings.Mode = Encoder::ModeEnumerated; encSettings.Bitrate = encTraits->formats[format].Bitrate != 0 ? encTraits->formats[format].Bitrate : encTraits->defaultBitrate; @@ -762,6 +804,7 @@ } else { m_Settings.FinalSampleFormat = SampleFormatFloat32; + encSettings.Dither = m_CbnDither.GetItemData(m_CbnDither.GetCurSel()); Encoder::Mode mode = (Encoder::Mode)((dwFormat >> 24) & 0xff); int quality = (int)((dwFormat >> 0) & 0xff); int bitrate = (int)((dwFormat >> 0) & 0xffff); Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-02-05 02:27:35 UTC (rev 3661) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-02-05 13:33:04 UTC (rev 3662) @@ -390,20 +390,20 @@ if(sampleFormat.IsInt()) { m_CbnDither.EnableWindow(TRUE); - m_CbnDither.AddString("no dithering"); - m_CbnDither.AddString("default dithering"); - m_CbnDither.AddString("0.5bit dithering"); - m_CbnDither.AddString("1bit dithering"); + for(int i=0; i<NumDitherModes; ++i) + { + m_CbnDither.AddString(mpt::ToCString(Dither::GetModeName((DitherMode)i) + L" dithering")); + } } else if(m_CurrentDeviceCaps.HasInternalDither) { m_CbnDither.EnableWindow(TRUE); - m_CbnDither.AddString("no dithering"); - m_CbnDither.AddString("default dithering"); + m_CbnDither.AddString(mpt::ToCString(Dither::GetModeName(DitherNone) + L" dithering")); + m_CbnDither.AddString(mpt::ToCString(Dither::GetModeName(DitherDefault) + L" dithering")); } else { m_CbnDither.EnableWindow(FALSE); - m_CbnDither.AddString("no dithering"); - m_CbnDither.AddString("no dithering"); + m_CbnDither.AddString(mpt::ToCString(Dither::GetModeName(DitherNone) + L" dithering")); + m_CbnDither.AddString(mpt::ToCString(Dither::GetModeName(DitherNone) + L" dithering")); } if(m_Settings.DitherType < 0 || m_Settings.DitherType > m_CbnDither.GetCount()) { Modified: trunk/OpenMPT/mptrack/mod2wave.h =================================================================== --- trunk/OpenMPT/mptrack/mod2wave.h 2014-02-05 02:27:35 UTC (rev 3661) +++ trunk/OpenMPT/mptrack/mod2wave.h 2014-02-05 13:33:04 UTC (rev 3662) @@ -71,7 +71,7 @@ uint64 m_dwFileLimit, m_dwSongLimit; ORDERINDEX m_nNumOrders; - CComboBox m_CbnFileType, m_CbnSampleRate, m_CbnChannels, m_CbnSampleFormat; + CComboBox m_CbnFileType, m_CbnSampleRate, m_CbnChannels, m_CbnDither, m_CbnSampleFormat; CSpinButtonCtrl m_SpinLoopCount, m_SpinMinOrder, m_SpinMaxOrder; bool m_bGivePlugsIdleTime; @@ -88,6 +88,7 @@ void FillSamplerates(); void FillChannels(); void FillFormats(); + void FillDither(); void FillTags(); void LoadTags(); @@ -110,6 +111,7 @@ afx_msg void OnFileTypeChanged(); afx_msg void OnSamplerateChanged(); afx_msg void OnChannelsChanged(); + afx_msg void OnDitherChanged(); afx_msg void OnFormatChanged(); afx_msg void OnPlayerOptions(); //rewbs.resamplerConf DECLARE_MESSAGE_MAP() Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2014-02-05 02:27:35 UTC (rev 3661) +++ trunk/OpenMPT/mptrack/mptrack.rc 2014-02-05 13:33:04 UTC (rev 3662) @@ -470,8 +470,9 @@ GROUPBOX "Format",IDC_STATIC,6,6,186,66 COMBOBOX IDC_COMBO5,12,18,90,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Encoder Information",IDC_BUTTON1,108,18,78,12 - COMBOBOX IDC_COMBO1,12,36,90,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_COMBO4,108,36,78,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_COMBO1,12,36,54,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_COMBO4,72,36,42,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_COMBO6,120,36,66,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_COMBO2,12,54,174,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP GROUPBOX "Render",IDC_STATIC,6,78,186,84 PUSHBUTTON "Player &Options",IDC_PLAYEROPTIONS,12,90,60,14,BS_CENTER Modified: trunk/OpenMPT/soundlib/Dither.cpp =================================================================== --- trunk/OpenMPT/soundlib/Dither.cpp 2014-02-05 02:27:35 UTC (rev 3661) +++ trunk/OpenMPT/soundlib/Dither.cpp 2014-02-05 13:33:04 UTC (rev 3662) @@ -19,6 +19,21 @@ ////////////////////////////////////////////////////////////////////////// // Noise Shaping (Dithering) + +std::wstring Dither::GetModeName(DitherMode mode) +//----------------------------------------------- +{ + switch(mode) + { + case DitherNone : return L"no" ; break; + case DitherDefault: return L"default"; break; + case DitherModPlug: return L"0.5 bit"; break; + case DitherSimple : return L"1 bit" ; break; + default : return L"" ; break; + } +} + + #if MPT_COMPILER_MSVC #pragma warning(disable:4731) // ebp modified #endif Modified: trunk/OpenMPT/soundlib/Dither.h =================================================================== --- trunk/OpenMPT/soundlib/Dither.h 2014-02-05 02:27:35 UTC (rev 3661) +++ trunk/OpenMPT/soundlib/Dither.h 2014-02-05 13:33:04 UTC (rev 3662) @@ -47,7 +47,8 @@ DitherNone = 0, DitherDefault = 1, // chosen by OpenMPT code, might change DitherModPlug = 2, // rectangular, 0.5 bit depth, no noise shaping (original ModPlug Tracker) - DitherSimple = 3 // rectangular, 1 bit depth, simple 1st order noise shaping + DitherSimple = 3, // rectangular, 1 bit depth, simple 1st order noise shaping + NumDitherModes }; class Dither @@ -61,4 +62,5 @@ DitherMode GetMode() const; void Reset(); void Process(int *mixbuffer, std::size_t count, std::size_t channels, int bits); + static std::wstring GetModeName(DitherMode mode); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |