From: <sag...@us...> - 2013-07-06 18:19:28
|
Revision: 2507 http://sourceforge.net/p/modplug/code/2507 Author: saga-games Date: 2013-07-06 18:19:22 +0000 (Sat, 06 Jul 2013) Log Message: ----------- [Fix] Treeview: Editing sequence names can now be ended with Enter key. [Fix] Treeview: Editing sequence name was not possible if there was only one sequence. [Fix] Treeview: Editing an instrument name didn't update the instrument list in the tree view instantly. [Fix] Treeview: Editing a pattern name didn't show the previous pattern name on edit start. [Mod] OpenMPT: Version is now 1.22.03.10 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/View_tre.cpp Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2013-07-06 17:43:52 UTC (rev 2506) +++ trunk/OpenMPT/common/versionNumber.h 2013-07-06 18:19:22 UTC (rev 2507) @@ -17,7 +17,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 22 #define VER_MINOR 03 -#define VER_MINORMINOR 09 +#define VER_MINORMINOR 10 //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/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2013-07-06 17:43:52 UTC (rev 2506) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2013-07-06 18:19:22 UTC (rev 2507) @@ -193,6 +193,13 @@ return TRUE; } else if (pMsg->wParam == VK_RETURN) { + if(doLabelEdit) + { + // End editing by making edit box lose focus. + SetFocus(); + return TRUE; + } + if (!(pMsg->lParam & 0x40000000)) { HTREEITEM hItem = GetSelectedItem(); @@ -783,10 +790,10 @@ SEQUENCEINDEX nSeqMin = 0, nSeqMax = sndFile.Order.GetNumSequences() - 1; SEQUENCEINDEX nHintParam = lHint >> HINT_SHIFT_SEQUENCE; - if ((hintFlagPart == HINT_SEQNAMES) && (nHintParam <= nSeqMax)) nSeqMin = nSeqMax = nHintParam; + if ((hintFlagPart & HINT_SEQNAMES) && (nHintParam <= nSeqMax)) nSeqMin = nSeqMax = nHintParam; // Adjust caption of the "Sequence" node (if only one sequence exists, it should be labeled with the sequence name) - if(((hintFlagPart == HINT_SEQNAMES) && sndFile.Order.GetNumSequences() == 1) || adjustParentNode) + if(((hintFlagPart & HINT_SEQNAMES) && sndFile.Order.GetNumSequences() == 1) || adjustParentNode) { CString sSeqName = sndFile.Order.GetSequence(0).m_sName; if(sSeqName.IsEmpty() || sndFile.Order.GetNumSequences() > 1) @@ -3025,7 +3032,6 @@ const uint32 modItemID = modItem.val1; CModDoc *pModDoc = GetDocumentFromItem(hItem); - CSoundFile *pSndFile = (pModDoc != nullptr) ? pModDoc->GetSoundFile() : nullptr; if(pModDoc) { @@ -3404,63 +3410,72 @@ if(editCtrl != nullptr && modDoc != nullptr) { - const CSoundFile *sndFile = modDoc->GetSoundFile(); - const CModSpecifications &modSpecs = sndFile->GetModSpecifications(); - char const *text = nullptr; - CString tempText; + const CSoundFile &sndFile = modDoc->GetrSoundFile(); + const CModSpecifications &modSpecs = sndFile.GetModSpecifications(); + std::string text; + doLabelEdit = false; switch(modItem.type) { case MODITEM_ORDER: { - PATTERNINDEX pat = sndFile->Order.GetSequence(static_cast<SEQUENCEINDEX>(modItem.val2)).At(static_cast<ORDERINDEX>(modItem.val1)); - if(pat == sndFile->Order.GetInvalidPatIndex()) - tempText = "---"; - else if(pat == sndFile->Order.GetIgnoreIndex()) - tempText = "+++"; + PATTERNINDEX pat = sndFile.Order.GetSequence(static_cast<SEQUENCEINDEX>(modItem.val2)).At(static_cast<ORDERINDEX>(modItem.val1)); + if(pat == sndFile.Order.GetInvalidPatIndex()) + text = "---"; + else if(pat == sndFile.Order.GetIgnoreIndex()) + text = "+++"; else - tempText.Format("%u", pat); - text = tempText; + text = Stringify(pat); + doLabelEdit = true; } break; + case MODITEM_HDR_ORDERS: + if(sndFile.Order.GetNumSequences() != 1 || sndFile.GetType() != MOD_TYPE_MPT) + { + break; + } + // Intentional fall-through case MODITEM_SEQUENCE: - if(modItem.val1 < sndFile->Order.GetNumSequences()) + if(modItem.val1 < sndFile.Order.GetNumSequences()) { - text = sndFile->Order.GetSequence(static_cast<SEQUENCEINDEX>(modItem.val1)).m_sName; + text = sndFile.Order.GetSequence(static_cast<SEQUENCEINDEX>(modItem.val1)).m_sName; + doLabelEdit = true; } break; case MODITEM_PATTERN: - if(modItem.val1 < sndFile->Patterns.GetNumPatterns() && modSpecs.hasPatternNames) + if(modItem.val1 < sndFile.Patterns.GetNumPatterns() && modSpecs.hasPatternNames) { - text = sndFile->Patterns[modItem.val1].GetName(); + text = sndFile.Patterns[modItem.val1].GetName(); editCtrl->SetLimitText(MAX_PATTERNNAME - 1); + doLabelEdit = true; } break; case MODITEM_SAMPLE: - if(modItem.val1 <= sndFile->GetNumSamples()) + if(modItem.val1 <= sndFile.GetNumSamples()) { - text = sndFile->m_szNames[modItem.val1]; + text = sndFile.m_szNames[modItem.val1]; editCtrl->SetLimitText(modSpecs.sampleNameLengthMax); + doLabelEdit = true; } break; case MODITEM_INSTRUMENT: - if(modItem.val1 <= sndFile->GetNumInstruments() && sndFile->Instruments[modItem.val1] != nullptr) + if(modItem.val1 <= sndFile.GetNumInstruments() && sndFile.Instruments[modItem.val1] != nullptr) { - text = sndFile->Instruments[modItem.val1]->name; + text = sndFile.Instruments[modItem.val1]->name; editCtrl->SetLimitText(modSpecs.instrNameLengthMax); + doLabelEdit = true; } break; } - if(text) + if(doLabelEdit) { - doLabelEdit = true; CMainFrame::GetMainFrame()->GetInputHandler()->Bypass(true); - editCtrl->SetWindowText(text); + editCtrl->SetWindowText(text.c_str()); *result = FALSE; return; } @@ -3478,7 +3493,6 @@ NMTVDISPINFO *info = reinterpret_cast<NMTVDISPINFO *>(nmhdr); const ModItem modItem = GetModItem(info->item.hItem); - const uint32 modItemID = modItem.val1; CModDoc *modDoc = GetDocumentFromItem(info->item.hItem); if(info->item.pszText != nullptr && modDoc != nullptr) @@ -3506,7 +3520,7 @@ { valid = (pat < sndFile.Patterns.GetNumPatterns()); } - PATTERNINDEX &target = sndFile.Order.GetSequence(static_cast<SEQUENCEINDEX>(modItemID >> 16)).At(static_cast<ORDERINDEX>(modItemID & 0xFFFF)); + PATTERNINDEX &target = sndFile.Order.GetSequence(static_cast<SEQUENCEINDEX>(modItem.val1 >> 16)).At(static_cast<ORDERINDEX>(modItem.val1 & 0xFFFF)); if(valid && pat != target) { target = pat; @@ -3516,39 +3530,40 @@ } break; + case MODITEM_HDR_ORDERS: case MODITEM_SEQUENCE: - if(modItemID < sndFile.Order.GetNumSequences() && sndFile.Order.GetSequence(static_cast<SEQUENCEINDEX>(modItemID)).m_sName != info->item.pszText) + if(modItem.val1 < sndFile.Order.GetNumSequences() && sndFile.Order.GetSequence(static_cast<SEQUENCEINDEX>(modItem.val1)).m_sName != info->item.pszText) { - sndFile.Order.GetSequence(static_cast<SEQUENCEINDEX>(modItemID)).m_sName = info->item.pszText; + sndFile.Order.GetSequence(static_cast<SEQUENCEINDEX>(modItem.val1)).m_sName = info->item.pszText; modDoc->SetModified(); - modDoc->UpdateAllViews(NULL, HINT_MODSEQUENCE, NULL); + modDoc->UpdateAllViews(NULL, HINT_SEQNAMES | HINT_MODSEQUENCE, NULL); } break; case MODITEM_PATTERN: - if(modItemID < sndFile.Patterns.GetNumPatterns() && modSpecs.hasPatternNames && sndFile.Patterns[modItemID].GetName() != info->item.pszText) + if(modItem.val1 < sndFile.Patterns.GetNumPatterns() && modSpecs.hasPatternNames && sndFile.Patterns[modItem.val1].GetName() != info->item.pszText) { - sndFile.Patterns[modItemID].SetName(info->item.pszText); + sndFile.Patterns[modItem.val1].SetName(info->item.pszText); modDoc->SetModified(); - modDoc->UpdateAllViews(NULL, (UINT(modItemID) << HINT_SHIFT_PAT) | HINT_PATTERNDATA | HINT_PATNAMES); + modDoc->UpdateAllViews(NULL, (UINT(modItem.val1) << HINT_SHIFT_PAT) | HINT_PATTERNDATA | HINT_PATNAMES); } break; case MODITEM_SAMPLE: - if(modItemID <= sndFile.GetNumSamples() && strcmp(sndFile.m_szNames[modItemID], info->item.pszText)) + if(modItem.val1 <= sndFile.GetNumSamples() && strcmp(sndFile.m_szNames[modItem.val1], info->item.pszText)) { - mpt::String::CopyN(sndFile.m_szNames[modItemID], info->item.pszText, modSpecs.sampleNameLengthMax); + mpt::String::CopyN(sndFile.m_szNames[modItem.val1], info->item.pszText, modSpecs.sampleNameLengthMax); modDoc->SetModified(); - modDoc->UpdateAllViews(NULL, (UINT(modItemID) << HINT_SHIFT_SMP) | HINT_SMPNAMES | HINT_SAMPLEDATA | HINT_SAMPLEINFO); + modDoc->UpdateAllViews(NULL, (UINT(modItem.val1) << HINT_SHIFT_SMP) | HINT_SMPNAMES | HINT_SAMPLEDATA | HINT_SAMPLEINFO); } break; case MODITEM_INSTRUMENT: - if(modItemID <= sndFile.GetNumInstruments() && sndFile.Instruments[modItemID] != nullptr && strcmp(sndFile.Instruments[modItemID]->name, info->item.pszText)) + if(modItem.val1 <= sndFile.GetNumInstruments() && sndFile.Instruments[modItem.val1] != nullptr && strcmp(sndFile.Instruments[modItem.val1]->name, info->item.pszText)) { - mpt::String::CopyN(sndFile.Instruments[modItemID]->name, info->item.pszText, modSpecs.instrNameLengthMax); + mpt::String::CopyN(sndFile.Instruments[modItem.val1]->name, info->item.pszText, modSpecs.instrNameLengthMax); modDoc->SetModified(); - modDoc->UpdateAllViews(NULL, (UINT(modItemID) << HINT_SHIFT_INS) | HINT_ENVELOPE | HINT_INSTRUMENT); + modDoc->UpdateAllViews(NULL, (UINT(modItem.val1) << HINT_SHIFT_INS) | HINT_INSNAMES | HINT_INSTRUMENT); } break; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-07-06 22:27:16
|
Revision: 2510 http://sourceforge.net/p/modplug/code/2510 Author: manxorist Date: 2013-07-06 22:27:05 +0000 (Sat, 06 Jul 2013) Log Message: ----------- [Mod] libopenmpt: Merge up and down volume ramping settings into a single volume ramping strength setting with not exactly defined semantics (should roughly map to milliseconds though). More fine-grained settings will be added again later via the ctl interface. [Mod] xmp-openmpt / in_openmpt: Adjust settings dialog accordingly. [Mod] openmpt123: Replace --volrampin and --volrampout with --ramping. [Ref] openmpt123: --buffer command line argument is only meaningful when portaudio is available. Do not support it otherwise. [Ref] openmpt123: Project file cleanup. Modified Paths: -------------- trunk/OpenMPT/libopenmpt/SettingsForm.h trunk/OpenMPT/libopenmpt/libopenmpt.h trunk/OpenMPT/libopenmpt/libopenmpt.hpp trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp trunk/OpenMPT/libopenmpt/libopenmpt_settings.cpp trunk/OpenMPT/libopenmpt/libopenmpt_settings.h trunk/OpenMPT/libopenmpt/libopenmpt_winamp.cpp trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp trunk/OpenMPT/openmpt123/openmpt123.cpp trunk/OpenMPT/openmpt123/openmpt123.hpp trunk/OpenMPT/openmpt123/openmpt123.vcxproj.filters Modified: trunk/OpenMPT/libopenmpt/SettingsForm.h =================================================================== --- trunk/OpenMPT/libopenmpt/SettingsForm.h 2013-07-06 18:35:25 UTC (rev 2509) +++ trunk/OpenMPT/libopenmpt/SettingsForm.h 2013-07-06 22:27:05 UTC (rev 2510) @@ -73,8 +73,7 @@ trackBarStereoSeparation->Value = settings->stereoseparation; - trackBarVolrampin->Value = settings->volrampinus; - trackBarVolrampout->Value = settings->volrampoutus; + trackBarVolramping->Value = settings->ramping; // //TODO: Add the constructor code here @@ -108,12 +107,14 @@ private: System::Windows::Forms::ComboBox^ comboBoxRepeat; private: System::Windows::Forms::Label^ labelStereoSeparation; private: System::Windows::Forms::TrackBar^ trackBarStereoSeparation; - private: System::Windows::Forms::Label^ labelVolrampin; - private: System::Windows::Forms::Label^ labelVolrampout; - private: System::Windows::Forms::TrackBar^ trackBarVolrampin; - private: System::Windows::Forms::TrackBar^ trackBarVolrampout; + private: System::Windows::Forms::Label^ labelVolramping; + private: System::Windows::Forms::TrackBar^ trackBarVolramping; + + + + protected: private: @@ -142,14 +143,11 @@ this->comboBoxRepeat = (gcnew System::Windows::Forms::ComboBox()); this->labelStereoSeparation = (gcnew System::Windows::Forms::Label()); this->trackBarStereoSeparation = (gcnew System::Windows::Forms::TrackBar()); - this->labelVolrampin = (gcnew System::Windows::Forms::Label()); - this->labelVolrampout = (gcnew System::Windows::Forms::Label()); - this->trackBarVolrampin = (gcnew System::Windows::Forms::TrackBar()); - this->trackBarVolrampout = (gcnew System::Windows::Forms::TrackBar()); + this->labelVolramping = (gcnew System::Windows::Forms::Label()); + this->trackBarVolramping = (gcnew System::Windows::Forms::TrackBar()); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->trackBarGain))->BeginInit(); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->trackBarStereoSeparation))->BeginInit(); - (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->trackBarVolrampin))->BeginInit(); - (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->trackBarVolrampout))->BeginInit(); + (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->trackBarVolramping))->BeginInit(); this->SuspendLayout(); // // comboBoxSamplerate @@ -173,7 +171,7 @@ // // buttonOK // - this->buttonOK->Location = System::Drawing::Point(15, 309); + this->buttonOK->Location = System::Drawing::Point(15, 261); this->buttonOK->Name = L"buttonOK"; this->buttonOK->Size = System::Drawing::Size(212, 23); this->buttonOK->TabIndex = 2; @@ -287,50 +285,26 @@ this->trackBarStereoSeparation->Value = 100; this->trackBarStereoSeparation->Scroll += gcnew System::EventHandler(this, &SettingsForm::trackBarStereoSeparation_Scroll); // - // labelVolrampin + // labelVolramping // - this->labelVolrampin->AutoSize = true; - this->labelVolrampin->Location = System::Drawing::Point(12, 226); - this->labelVolrampin->Name = L"labelVolrampin"; - this->labelVolrampin->Size = System::Drawing::Size(78, 13); - this->labelVolrampin->TabIndex = 15; - this->labelVolrampin->Text = L"volume ramp in"; + this->labelVolramping->AutoSize = true; + this->labelVolramping->Location = System::Drawing::Point(12, 226); + this->labelVolramping->Name = L"labelVolramping"; + this->labelVolramping->Size = System::Drawing::Size(81, 13); + this->labelVolramping->TabIndex = 15; + this->labelVolramping->Text = L"volume ramping"; // - // labelVolrampout + // trackBarVolramping // - this->labelVolrampout->AutoSize = true; - this->labelVolrampout->Location = System::Drawing::Point(12, 273); - this->labelVolrampout->Name = L"labelVolrampout"; - this->labelVolrampout->Size = System::Drawing::Size(85, 13); - this->labelVolrampout->TabIndex = 16; - this->labelVolrampout->Text = L"volume ramp out"; + this->trackBarVolramping->LargeChange = 1; + this->trackBarVolramping->Location = System::Drawing::Point(106, 213); + this->trackBarVolramping->Name = L"trackBarVolramping"; + this->trackBarVolramping->Size = System::Drawing::Size(121, 42); + this->trackBarVolramping->TabIndex = 17; + this->trackBarVolramping->TickStyle = System::Windows::Forms::TickStyle::Both; + this->trackBarVolramping->Value = 1; + this->trackBarVolramping->Scroll += gcnew System::EventHandler(this, &SettingsForm::trackBarVolramping_Scroll); // - // trackBarVolrampin - // - this->trackBarVolrampin->LargeChange = 1000; - this->trackBarVolrampin->Location = System::Drawing::Point(106, 213); - this->trackBarVolrampin->Maximum = 10000; - this->trackBarVolrampin->Name = L"trackBarVolrampin"; - this->trackBarVolrampin->Size = System::Drawing::Size(121, 42); - this->trackBarVolrampin->TabIndex = 17; - this->trackBarVolrampin->TickFrequency = 1000; - this->trackBarVolrampin->TickStyle = System::Windows::Forms::TickStyle::Both; - this->trackBarVolrampin->Value = 363; - this->trackBarVolrampin->Scroll += gcnew System::EventHandler(this, &SettingsForm::trackBarVolrampin_Scroll); - // - // trackBarVolrampout - // - this->trackBarVolrampout->LargeChange = 1000; - this->trackBarVolrampout->Location = System::Drawing::Point(106, 261); - this->trackBarVolrampout->Maximum = 10000; - this->trackBarVolrampout->Name = L"trackBarVolrampout"; - this->trackBarVolrampout->Size = System::Drawing::Size(121, 42); - this->trackBarVolrampout->TabIndex = 18; - this->trackBarVolrampout->TickFrequency = 1000; - this->trackBarVolrampout->TickStyle = System::Windows::Forms::TickStyle::Both; - this->trackBarVolrampout->Value = 952; - this->trackBarVolrampout->Scroll += gcnew System::EventHandler(this, &SettingsForm::trackBarVolrampout_Scroll); - // // SettingsForm // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); @@ -338,10 +312,8 @@ this->AutoSize = true; this->AutoSizeMode = System::Windows::Forms::AutoSizeMode::GrowAndShrink; this->ClientSize = System::Drawing::Size(436, 477); - this->Controls->Add(this->trackBarVolrampout); - this->Controls->Add(this->trackBarVolrampin); - this->Controls->Add(this->labelVolrampout); - this->Controls->Add(this->labelVolrampin); + this->Controls->Add(this->trackBarVolramping); + this->Controls->Add(this->labelVolramping); this->Controls->Add(this->trackBarStereoSeparation); this->Controls->Add(this->labelStereoSeparation); this->Controls->Add(this->comboBoxRepeat); @@ -365,8 +337,7 @@ this->Text = L"SettingsForm"; (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->trackBarGain))->EndInit(); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->trackBarStereoSeparation))->EndInit(); - (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->trackBarVolrampin))->EndInit(); - (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->trackBarVolrampout))->EndInit(); + (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->trackBarVolramping))->EndInit(); this->ResumeLayout(false); this->PerformLayout(); @@ -427,13 +398,9 @@ settings->stereoseparation = (int)trackBarStereoSeparation->Value; settings->changed(); } -private: System::Void trackBarVolrampin_Scroll(System::Object^ sender, System::EventArgs^ e) { - settings->volrampinus = (int)trackBarVolrampin->Value; +private: System::Void trackBarVolramping_Scroll(System::Object^ sender, System::EventArgs^ e) { + settings->ramping = (int)trackBarVolramping->Value; settings->changed(); } -private: System::Void trackBarVolrampout_Scroll(System::Object^ sender, System::EventArgs^ e) { - settings->volrampoutus = (int)trackBarVolrampout->Value; - settings->changed(); - } }; } Modified: trunk/OpenMPT/libopenmpt/libopenmpt.h =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.h 2013-07-06 18:35:25 UTC (rev 2509) +++ trunk/OpenMPT/libopenmpt/libopenmpt.h 2013-07-06 22:27:05 UTC (rev 2510) @@ -67,8 +67,7 @@ #define OPENMPT_MODULE_RENDER_MASTERGAIN_MILLIBEL 1 #define OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT 2 #define OPENMPT_MODULE_RENDER_INTERPOLATION_FILTER_LENGTH 3 -#define OPENMPT_MODULE_RENDER_VOLUMERAMP_UP_MICROSECONDS 4 -#define OPENMPT_MODULE_RENDER_VOLUMERAMP_DOWN_MICROSECONDS 5 +#define OPENMPT_MODULE_RENDER_VOLUMERAMPING_STRENGTH 4 #define OPENMPT_MODULE_COMMAND_NOTE 0 #define OPENMPT_MODULE_COMMAND_INSTRUMENT 1 Modified: trunk/OpenMPT/libopenmpt/libopenmpt.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2013-07-06 18:35:25 UTC (rev 2509) +++ trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2013-07-06 22:27:05 UTC (rev 2510) @@ -77,8 +77,7 @@ RENDER_MASTERGAIN_MILLIBEL = 1, RENDER_STEREOSEPARATION_PERCENT = 2, RENDER_INTERPOLATION_FILTER_LENGTH = 3, - RENDER_VOLUMERAMP_UP_MICROSECONDS = 4, - RENDER_VOLUMERAMP_DOWN_MICROSECONDS = 5 + RENDER_VOLUMERAMPING_STRENGTH = 4, }; enum command_index { Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-07-06 18:35:25 UTC (rev 2509) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-07-06 22:27:05 UTC (rev 2510) @@ -129,6 +129,32 @@ } } +static void ramping_to_mixersettings( MixerSettings & settings, int ramping ) { + if ( ramping == -1 ) { + settings.SetVolumeRampUpMicroseconds( MixerSettings().GetVolumeRampUpMicroseconds() ); + settings.SetVolumeRampDownMicroseconds( MixerSettings().GetVolumeRampDownMicroseconds() ); + } else if ( ramping <= 0 ) { + settings.SetVolumeRampUpMicroseconds( 0 ); + settings.SetVolumeRampDownMicroseconds( 0 ); + } else { + settings.SetVolumeRampUpMicroseconds( ramping * 1000 ); + settings.SetVolumeRampDownMicroseconds( ramping * 1000 ); + } +} +static void mixersettings_to_ramping( int & ramping, const MixerSettings & settings ) { + std::int32_t ramp_us = std::max<std::int32_t>( settings.GetVolumeRampUpMicroseconds(), settings.GetVolumeRampDownMicroseconds() ); + if ( true + && settings.GetVolumeRampUpMicroseconds() == MixerSettings().GetVolumeRampUpMicroseconds() + && settings.GetVolumeRampDownMicroseconds() == MixerSettings().GetVolumeRampDownMicroseconds() + ) { + ramping = -1; + } else if ( ramp_us <= 0 ) { + ramping = 0; + } else { + ramping = ( ramp_us + 500 ) / 1000; + } +} + void module_impl::apply_mixer_settings( std::int32_t samplerate, int channels, bool format_float ) { SampleFormat format = ( format_float ? SampleFormatFloat32 : SampleFormatInt16 ); if ( @@ -327,12 +353,11 @@ case module::RENDER_INTERPOLATION_FILTER_LENGTH: { return resamplingmode_to_filterlength( m_sndFile->m_Resampler.m_Settings.SrcMode ); } break; - case module::RENDER_VOLUMERAMP_UP_MICROSECONDS: { - return m_sndFile->m_MixerSettings.GetVolumeRampUpMicroseconds(); + case module::RENDER_VOLUMERAMPING_STRENGTH: { + int ramping = 0; + mixersettings_to_ramping( ramping, m_sndFile->m_MixerSettings ); + return ramping; } break; - case module::RENDER_VOLUMERAMP_DOWN_MICROSECONDS: { - return m_sndFile->m_MixerSettings.GetVolumeRampDownMicroseconds(); - } break; default: throw openmpt::exception("unknown render param"); break; } return 0; @@ -362,20 +387,13 @@ m_sndFile->SetResamplerSettings( newsettings ); } } break; - case module::RENDER_VOLUMERAMP_UP_MICROSECONDS: { + case module::RENDER_VOLUMERAMPING_STRENGTH: { MixerSettings newsettings = m_sndFile->m_MixerSettings; - newsettings.SetVolumeRampUpMicroseconds( value ); - if ( m_sndFile->m_MixerSettings.glVolumeRampUpSamples != newsettings.glVolumeRampUpSamples ) { + ramping_to_mixersettings( newsettings, value ); + if ( m_sndFile->m_MixerSettings.glVolumeRampUpSamples != newsettings.glVolumeRampUpSamples || m_sndFile->m_MixerSettings.glVolumeRampDownSamples != newsettings.glVolumeRampDownSamples ) { m_sndFile->SetMixerSettings( newsettings ); } } break; - case module::RENDER_VOLUMERAMP_DOWN_MICROSECONDS: { - MixerSettings newsettings = m_sndFile->m_MixerSettings; - newsettings.SetVolumeRampDownMicroseconds( value ); - if ( m_sndFile->m_MixerSettings.glVolumeRampDownSamples != newsettings.glVolumeRampDownSamples ) { - m_sndFile->SetMixerSettings( newsettings ); - } - } break; default: throw openmpt::exception("unknown render param"); break; } } Modified: trunk/OpenMPT/libopenmpt/libopenmpt_settings.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_settings.cpp 2013-07-06 18:35:25 UTC (rev 2509) +++ trunk/OpenMPT/libopenmpt/libopenmpt_settings.cpp 2013-07-06 22:27:05 UTC (rev 2510) @@ -15,7 +15,7 @@ namespace openmpt { namespace settings { - + static void read_setting( const char * subkey, const char * key, int & val ) { System::String ^ net_root = "HKEY_CURRENT_USER\\Software\\libopenmpt\\"; System::String ^ net_path = gcnew System::String( subkey ); @@ -42,8 +42,7 @@ read_setting( subkey, "SeteroSeparation_Percent", s.stereoseparation ); read_setting( subkey, "RepeatCount", s.repeatcount ); read_setting( subkey, "InterpolationFilterLength", s.interpolationfilterlength ); - read_setting( subkey, "VolumeRampingIn_microseconds", s.volrampinus ); - read_setting( subkey, "VolumeRampingOut_microseconds", s.volrampoutus ); + read_setting( subkey, "VolumeRampingStrength", s.ramping ); } void save( const settings & s, const char * subkey ) { @@ -53,8 +52,7 @@ write_setting( subkey, "SeteroSeparation_Percent", s.stereoseparation ); write_setting( subkey, "RepeatCount", s.repeatcount ); write_setting( subkey, "InterpolationFilterLength", s.interpolationfilterlength ); - write_setting( subkey, "VolumeRampingIn_microseconds", s.volrampinus ); - write_setting( subkey, "VolumeRampingOut_microseconds", s.volrampoutus ); + write_setting( subkey, "VolumeRampingStrength", s.ramping ); } void edit( settings & s, HWND parent, const char * title ) { @@ -63,4 +61,5 @@ form->Show(w); } + } } // namespace openmpt::settings Modified: trunk/OpenMPT/libopenmpt/libopenmpt_settings.h =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_settings.h 2013-07-06 18:35:25 UTC (rev 2509) +++ trunk/OpenMPT/libopenmpt/libopenmpt_settings.h 2013-07-06 22:27:05 UTC (rev 2510) @@ -38,8 +38,7 @@ int stereoseparation; int repeatcount; int interpolationfilterlength; - int volrampinus; - int volrampoutus; + int ramping; changed_func changed; }; @@ -51,8 +50,7 @@ s.stereoseparation = 100; s.repeatcount = 0; s.interpolationfilterlength = 8; - s.volrampinus = 363; - s.volrampoutus = 952; + s.ramping = 1; s.changed = 0; } Modified: trunk/OpenMPT/libopenmpt/libopenmpt_winamp.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_winamp.cpp 2013-07-06 18:35:25 UTC (rev 2509) +++ trunk/OpenMPT/libopenmpt/libopenmpt_winamp.cpp 2013-07-06 22:27:05 UTC (rev 2510) @@ -100,8 +100,7 @@ self->mod->set_render_param( openmpt::module::RENDER_MASTERGAIN_MILLIBEL, self->settings.mastergain_millibel ); self->mod->set_render_param( openmpt::module::RENDER_STEREOSEPARATION_PERCENT, self->settings.stereoseparation ); self->mod->set_render_param( openmpt::module::RENDER_INTERPOLATION_FILTER_LENGTH, self->settings.interpolationfilterlength ); - self->mod->set_render_param( openmpt::module::RENDER_VOLUMERAMP_UP_MICROSECONDS, self->settings.volrampinus ); - self->mod->set_render_param( openmpt::module::RENDER_VOLUMERAMP_DOWN_MICROSECONDS, self->settings.volrampoutus ); + self->mod->set_render_param( openmpt::module::RENDER_VOLUMERAMPING_STRENGTH, self->settings.ramping ); } if ( settings_dll ) { openmpt::settings::save( self->settings, SHORT_TITLE ); Modified: trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp 2013-07-06 18:35:25 UTC (rev 2509) +++ trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp 2013-07-06 22:27:05 UTC (rev 2510) @@ -84,8 +84,7 @@ result[ "SeteroSeparation_Percent" ] = s.stereoseparation; result[ "RepeatCount" ] = s.repeatcount; result[ "InterpolationFilterLength" ] = s.interpolationfilterlength; - result[ "VolumeRampingIn_microseconds" ] = s.volrampinus; - result[ "VolumeRampingOut_microseconds" ] = s.volrampoutus; + result[ "VolumeRampingStrength" ] = s.ramping; } static inline void load_map_setting( const std::map<std::string,int> & map, const std::string & key, int & val ) { @@ -102,8 +101,7 @@ load_map_setting( map, "SeteroSeparation_Percent", s.stereoseparation ); load_map_setting( map, "RepeatCount", s.repeatcount ); load_map_setting( map, "InterpolationFilterLength", s.interpolationfilterlength ); - load_map_setting( map, "VolumeRampingIn_microseconds", s.volrampinus ); - load_map_setting( map, "VolumeRampingOut_microseconds", s.volrampoutus ); + load_map_setting( map, "VolumeRampingStrength", s.ramping ); } static void load_settings_from_xml( openmpt::settings::settings & s, const std::string & xml ) { @@ -136,8 +134,7 @@ self->mod->set_render_param( openmpt::module::RENDER_MASTERGAIN_MILLIBEL, self->settings.mastergain_millibel ); self->mod->set_render_param( openmpt::module::RENDER_STEREOSEPARATION_PERCENT, self->settings.stereoseparation ); self->mod->set_render_param( openmpt::module::RENDER_INTERPOLATION_FILTER_LENGTH, self->settings.interpolationfilterlength ); - self->mod->set_render_param( openmpt::module::RENDER_VOLUMERAMP_UP_MICROSECONDS, self->settings.volrampinus ); - self->mod->set_render_param( openmpt::module::RENDER_VOLUMERAMP_DOWN_MICROSECONDS, self->settings.volrampoutus ); + self->mod->set_render_param( openmpt::module::RENDER_VOLUMERAMPING_STRENGTH, self->settings.ramping ); } } Modified: trunk/OpenMPT/openmpt123/openmpt123.cpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-07-06 18:35:25 UTC (rev 2509) +++ trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-07-06 22:27:05 UTC (rev 2510) @@ -93,13 +93,14 @@ s << "Show progress: " << flags.show_progress << std::endl; #ifdef MPT_WITH_PORTAUDIO s << "Device: " << flags.device << std::endl; + s << "Buffer: " << flags.buffer << std::endl; #endif s << "Channels: " << flags.channels << std::endl; - s << "Buffer: " << flags.buffer << std::endl; s << "Repeat count: " << flags.repeatcount << std::endl; s << "Sample rate: " << flags.samplerate << std::endl; s << "Gain: " << flags.gain / 100.0 << std::endl; s << "Filter taps: " << flags.filtertaps << std::endl; + s << "Volume ramping strength: " << flags.ramping << std::endl; s << "Seek target: " << flags.seek_target << std::endl; s << "Float: " << flags.use_float << std::endl; s << "Standard output: " << flags.use_stdout << std::endl; @@ -218,6 +219,7 @@ #ifdef MPT_WITH_PORTAUDIO std::clog << " --device n Set output device [default: " << get_device_string( commandlineflags().device ) << "]," << std::endl; std::clog << " use --device help to show available devices" << std::endl; + std::clog << " --buffer n Set output buffer size to n ms [default: " << commandlineflags().buffer << "]" << std::endl; #endif std::clog << " --stdout Write raw audio data to stdout [default: " << commandlineflags().use_stdout << "]" << std::endl; #if defined(MPT_WITH_FLAC) || defined(MPT_WITH_MMIO) || defined(MPT_WITH_SNDFILE) @@ -226,14 +228,12 @@ #endif std::clog << " --channels n use n [1,2,4] output channels [default: " << commandlineflags().channels << "]" << std::endl; std::clog << " --[no]-float Output 32bit floating point instead of 16bit integer [default: " << commandlineflags().use_float << "]" << std::endl; - std::clog << " --buffer n Set output buffer size to n ms [default: " << commandlineflags().buffer << "]," << std::endl; std::clog << " --samplerate n Set samplerate to n Hz [default: " << commandlineflags().samplerate << "]" << std::endl; std::clog << " --gain n Set output gain to n dB [default: " << commandlineflags().gain / 100.0 << "]" << std::endl; std::clog << " --repeat n Repeat song n times (-1 means forever) [default: " << commandlineflags().repeatcount << "]" << std::endl; std::clog << " --filtertaps n Set interpolation filter taps to n % [default: " << commandlineflags().filtertaps << "]" << std::endl; std::clog << " --seek n Seek to n seconds on start [default: " << commandlineflags().seek_target << "]" << std::endl; - std::clog << " --volrampup n Use n microseconds volume ramping up [default: " << commandlineflags().rampupus << "]" << std::endl; - std::clog << " --volrampdown n Use n microseconds volume ramping down [default: " << commandlineflags().rampdownus << "]" << std::endl; + std::clog << " --ramping n Set volume ramping strength n [0..5] [default: " << commandlineflags().ramping << "]" << std::endl; std::clog << std::endl; std::clog << " -- Interpret further arguments as filenames" << std::endl; std::clog << std::endl; @@ -475,8 +475,7 @@ mod.set_render_param( openmpt::module::RENDER_INTERPOLATION_FILTER_LENGTH, flags.filtertaps ); mod.set_render_param( openmpt::module::RENDER_MASTERGAIN_MILLIBEL, flags.gain ); - mod.set_render_param( openmpt::module::RENDER_VOLUMERAMP_UP_MICROSECONDS, flags.rampupus ); - mod.set_render_param( openmpt::module::RENDER_VOLUMERAMP_DOWN_MICROSECONDS, flags.rampdownus ); + mod.set_render_param( openmpt::module::RENDER_VOLUMERAMPING_STRENGTH, flags.ramping ); render_mod_file( flags, filename, mod, log, audio_stream ); @@ -599,6 +598,12 @@ #endif } ++i; +#ifdef MPT_WITH_PORTAUDIO + } else if ( arg == "--buffer" && nextarg != "" ) { + std::istringstream istr( nextarg ); + istr >> flags.buffer; + ++i; +#endif } else if ( arg == "--stdout" ) { flags.use_stdout = true; #if defined(MPT_WITH_FLAC) || defined(MPT_WITH_MMIO) || defined(MPT_WITH_SNDFILE) @@ -616,10 +621,6 @@ flags.use_float = true; } else if ( arg == "--no-float" ) { flags.use_float = false; - } else if ( arg == "--buffer" && nextarg != "" ) { - std::istringstream istr( nextarg ); - istr >> flags.buffer; - ++i; } else if ( arg == "--samplerate" && nextarg != "" ) { std::istringstream istr( nextarg ); istr >> flags.samplerate; @@ -642,14 +643,10 @@ std::istringstream istr( nextarg ); istr >> flags.seek_target; ++i; - } else if ( arg == "--volrampup" && nextarg != "" ) { + } else if ( arg == "--ramping" && nextarg != "" ) { std::istringstream istr( nextarg ); - istr >> flags.rampupus; + istr >> flags.ramping; ++i; - } else if ( arg == "--volrampdown" && nextarg != "" ) { - std::istringstream istr( nextarg ); - istr >> flags.rampdownus; - ++i; } else if ( arg == "--runtests" ) { flags.run_tests = true; } else if ( arg.size() > 0 && arg.substr( 0, 1 ) == "-" ) { Modified: trunk/OpenMPT/openmpt123/openmpt123.hpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.hpp 2013-07-06 18:35:25 UTC (rev 2509) +++ trunk/OpenMPT/openmpt123/openmpt123.hpp 2013-07-06 22:27:05 UTC (rev 2510) @@ -62,16 +62,15 @@ bool modplug123; #ifdef MPT_WITH_PORTAUDIO int device; + std::int32_t buffer; #endif std::int32_t channels; - std::int32_t buffer; std::int32_t repeatcount; std::int32_t samplerate; std::int32_t gain; std::int32_t quality; std::int32_t filtertaps; - std::int32_t rampupus; - std::int32_t rampdownus; + int ramping; // ramping strength : -1:default 0:off 1 2 3 4 5 // roughly milliseconds bool quiet; bool verbose; bool use_ui; @@ -91,16 +90,15 @@ modplug123 = false; #ifdef MPT_WITH_PORTAUDIO device = -1; + buffer = 250; #endif channels = 2; - buffer = 250; repeatcount = 0; samplerate = 48000; gain = 0; quality = 100; filtertaps = 8; - rampupus = ( 16 * 1000000 + ( 44100 / 2 ) ) / 44100; // openmpt defaults at 44KHz, rounded - rampdownus = ( 42 * 1000000 + ( 44100 / 2 ) ) / 44100; // openmpt defaults at 44KHz, rounded + ramping = -1; quiet = false; verbose = false; show_info = true; Modified: trunk/OpenMPT/openmpt123/openmpt123.vcxproj.filters =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.vcxproj.filters 2013-07-06 18:35:25 UTC (rev 2509) +++ trunk/OpenMPT/openmpt123/openmpt123.vcxproj.filters 2013-07-06 22:27:05 UTC (rev 2510) @@ -9,10 +9,6 @@ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions> </Filter> - <Filter Include="Resource Files"> - <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> - <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> - </Filter> </ItemGroup> <ItemGroup> <ClCompile Include="openmpt123.cpp"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-07-06 23:14:30
|
Revision: 2512 http://sourceforge.net/p/modplug/code/2512 Author: manxorist Date: 2013-07-06 23:14:22 +0000 (Sat, 06 Jul 2013) Log Message: ----------- [Ref] libopenmpt: Add separate project configuration for test suite and do not build tests by default for VS2010. Modified Paths: -------------- trunk/OpenMPT/common/BuildSettings.h trunk/OpenMPT/libopenmpt/libopenmpt.cpp trunk/OpenMPT/libopenmpt/libopenmpt.sln trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj Property Changed: ---------------- trunk/OpenMPT/libopenmpt/ Modified: trunk/OpenMPT/common/BuildSettings.h =================================================================== --- trunk/OpenMPT/common/BuildSettings.h 2013-07-06 22:47:52 UTC (rev 2511) +++ trunk/OpenMPT/common/BuildSettings.h 2013-07-06 23:14:22 UTC (rev 2512) @@ -132,8 +132,11 @@ #elif defined(LIBOPENMPT_BUILD) +#if !defined(_MSC_VER) || defined(LIBOPENMPT_BUILD_TEST) #define ENABLE_TESTS -//#define MODPLUG_NO_FILESAVE +#else +#define MODPLUG_NO_FILESAVE +#endif //#define NO_LOGGING #define NO_ARCHIVE_SUPPORT //#define NO_FILEREADER_STD_ISTREAM Index: trunk/OpenMPT/libopenmpt =================================================================== --- trunk/OpenMPT/libopenmpt 2013-07-06 22:47:52 UTC (rev 2511) +++ trunk/OpenMPT/libopenmpt 2013-07-06 23:14:22 UTC (rev 2512) Property changes on: trunk/OpenMPT/libopenmpt ___________________________________________________________________ Modified: svn:ignore ## -1,17 +1,18 ## +*.d DebugStatic Release ReleaseStatic +Test ipch libopenmpt.opensdf libopenmpt.sdf libopenmpt.suo libopenmpt.vcxproj.user +libopenmpt_foobar2000.opensdf libopenmpt_foobar2000.sdf +libopenmpt_foobar2000.suo libopenmpt_foobar2000.vcxproj.user libopenmpt_settings-Debug libopenmpt_settings-Release libopenmpt_settings.vcxproj.user -libopenmpt_foobar2000.opensdf -libopenmpt_foobar2000.suo x64 -*.d Modified: trunk/OpenMPT/libopenmpt/libopenmpt.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.cpp 2013-07-06 22:47:52 UTC (rev 2511) +++ trunk/OpenMPT/libopenmpt/libopenmpt.cpp 2013-07-06 23:14:22 UTC (rev 2512) @@ -25,6 +25,23 @@ } // namespace openmpt +#if defined( LIBOPENMPT_BUILD_TEST ) + +int main( int argc, char * argv [] ) { + try { + MptTest::DoTests(); + } catch ( const std::exception & e ) { + std::cerr << "TEST ERROR: exception: " << ( e.what() ? e.what() : "" ) << std::endl; + return 1; + } catch ( ... ) { + std::cerr << "TEST ERROR: unknown exception" << std::endl; + return 1; + } + return 0; +} + +#endif // LIBOPENMPT_BUILD_TEST + #if defined( LIBOPENMPT_BUILD_DLL ) #if defined( _WIN32 ) Modified: trunk/OpenMPT/libopenmpt/libopenmpt.sln =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.sln 2013-07-06 22:47:52 UTC (rev 2511) +++ trunk/OpenMPT/libopenmpt/libopenmpt.sln 2013-07-06 23:14:22 UTC (rev 2512) @@ -16,6 +16,8 @@ Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 + Test|Win32 = Test|Win32 + Test|x64 = Test|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {812A654D-99BE-4D13-B97F-86332AD3E363}.Debug|Win32.ActiveCfg = Debug|Win32 @@ -26,6 +28,10 @@ {812A654D-99BE-4D13-B97F-86332AD3E363}.Release|Win32.Build.0 = Release|Win32 {812A654D-99BE-4D13-B97F-86332AD3E363}.Release|x64.ActiveCfg = Release|x64 {812A654D-99BE-4D13-B97F-86332AD3E363}.Release|x64.Build.0 = Release|x64 + {812A654D-99BE-4D13-B97F-86332AD3E363}.Test|Win32.ActiveCfg = Test|Win32 + {812A654D-99BE-4D13-B97F-86332AD3E363}.Test|Win32.Build.0 = Test|Win32 + {812A654D-99BE-4D13-B97F-86332AD3E363}.Test|x64.ActiveCfg = Test|x64 + {812A654D-99BE-4D13-B97F-86332AD3E363}.Test|x64.Build.0 = Test|x64 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.ActiveCfg = Debug|Win32 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.Build.0 = Debug|Win32 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.ActiveCfg = Debug|x64 @@ -34,12 +40,19 @@ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.Build.0 = ReleaseWithoutAsm|Win32 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.ActiveCfg = ReleaseWithoutAsm|x64 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.Build.0 = ReleaseWithoutAsm|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Test|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Test|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Test|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Test|x64.Build.0 = ReleaseWithoutAsm|x64 {B2B6EE07-F662-496D-980C-FCA7CA144DBC}.Debug|Win32.ActiveCfg = Debug|Win32 {B2B6EE07-F662-496D-980C-FCA7CA144DBC}.Debug|Win32.Build.0 = Debug|Win32 {B2B6EE07-F662-496D-980C-FCA7CA144DBC}.Debug|x64.ActiveCfg = Debug|Win32 {B2B6EE07-F662-496D-980C-FCA7CA144DBC}.Release|Win32.ActiveCfg = Release|Win32 {B2B6EE07-F662-496D-980C-FCA7CA144DBC}.Release|Win32.Build.0 = Release|Win32 {B2B6EE07-F662-496D-980C-FCA7CA144DBC}.Release|x64.ActiveCfg = Release|Win32 + {B2B6EE07-F662-496D-980C-FCA7CA144DBC}.Test|Win32.ActiveCfg = Release|Win32 + {B2B6EE07-F662-496D-980C-FCA7CA144DBC}.Test|Win32.Build.0 = Release|Win32 + {B2B6EE07-F662-496D-980C-FCA7CA144DBC}.Test|x64.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2013-07-06 22:47:52 UTC (rev 2511) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2013-07-06 23:14:22 UTC (rev 2512) @@ -33,6 +33,14 @@ <Configuration>Release</Configuration> <Platform>x64</Platform> </ProjectConfiguration> + <ProjectConfiguration Include="Test|Win32"> + <Configuration>Test</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Test|x64"> + <Configuration>Test</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> </ItemGroup> <PropertyGroup Label="Globals"> <ProjectGuid>{812A654D-99BE-4D13-B97F-86332AD3E363}</ProjectGuid> @@ -65,12 +73,24 @@ <WholeProgramOptimization>false</WholeProgramOptimization> <CharacterSet>NotSet</CharacterSet> </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Test|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>false</WholeProgramOptimization> + <CharacterSet>NotSet</CharacterSet> + </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>false</WholeProgramOptimization> <CharacterSet>NotSet</CharacterSet> </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Test|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>false</WholeProgramOptimization> + <CharacterSet>NotSet</CharacterSet> + </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseStatic|Win32'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> @@ -101,9 +121,15 @@ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Test|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Test|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseStatic|Win32'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> @@ -114,10 +140,18 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <OutDir>bin\</OutDir> </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Test|Win32'"> + <OutDir>bin\</OutDir> + <TargetName>$(ProjectName)-test</TargetName> + </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <OutDir>bin\</OutDir> <TargetName>$(ProjectName)64</TargetName> </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Test|x64'"> + <OutDir>bin\</OutDir> + <TargetName>$(ProjectName)64-test</TargetName> + </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" /> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> @@ -228,6 +262,34 @@ </Command> </PostBuildEvent> </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Test|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Full</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <MultiProcessorCompilation>true</MultiProcessorCompilation> + <FloatingPointModel>Fast</FloatingPointModel> + <PreprocessorDefinitions>_WINDLL;LIBOPENMPT_BUILD;LIBOPENMPT_BUILD_TEST;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <AdditionalIncludeDirectories>..;../common;../common/svn_version_subwcrev;../common/svn_version_default;../include;../include/modplug/include;../include/pugixml/src</AdditionalIncludeDirectories> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> + <StringPooling>true</StringPooling> + <WholeProgramOptimization>false</WholeProgramOptimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + <DelayLoadDLLs>libopenmpt_settings.dll</DelayLoadDLLs> + <SubSystem>Console</SubSystem> + </Link> + <PreBuildEvent> + <Command>subwcrev .. ..\common\svn_version_subwcrev\svn_version.template.h ..\common\svn_version_subwcrev\svn_version.h || del ..\common\svn_version_subwcrev\svn_version.h || true</Command> + </PreBuildEvent> + <PostBuildEvent /> + </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ClCompile> <WarningLevel>Level3</WarningLevel> @@ -258,6 +320,34 @@ </Command> </PostBuildEvent> </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Test|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Full</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <MultiProcessorCompilation>true</MultiProcessorCompilation> + <FloatingPointModel>Fast</FloatingPointModel> + <PreprocessorDefinitions>_WINDLL;LIBOPENMPT_BUILD;LIBOPENMPT_BUILD_TEST;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <AdditionalIncludeDirectories>..;../common;../common/svn_version_subwcrev;../common/svn_version_default;../include;../include/modplug/include;../include/pugixml/src</AdditionalIncludeDirectories> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> + <StringPooling>true</StringPooling> + <WholeProgramOptimization>false</WholeProgramOptimization> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + <DelayLoadDLLs>libopenmpt_settings.dll</DelayLoadDLLs> + <SubSystem>Console</SubSystem> + </Link> + <PreBuildEvent> + <Command>subwcrev .. ..\common\svn_version_subwcrev\svn_version.template.h ..\common\svn_version_subwcrev\svn_version.h || del ..\common\svn_version_subwcrev\svn_version.h || true</Command> + </PreBuildEvent> + <PostBuildEvent /> + </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseStatic|Win32'"> <ClCompile> <WarningLevel>Level3</WarningLevel> @@ -467,7 +557,9 @@ <CompileAs Condition="'$(Configuration)|$(Platform)'=='ReleaseStatic|Win32'">CompileAsC</CompileAs> <CompileAs Condition="'$(Configuration)|$(Platform)'=='ReleaseStatic|x64'">CompileAsC</CompileAs> <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsC</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Test|Win32'">CompileAsC</CompileAs> <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">CompileAsC</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Test|x64'">CompileAsC</CompileAs> </ClCompile> <ClCompile Include="libopenmpt_version.cpp" /> <ClCompile Include="libopenmpt_winamp.cpp" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-07-06 23:56:09
|
Revision: 2515 http://sourceforge.net/p/modplug/code/2515 Author: manxorist Date: 2013-07-06 23:56:03 +0000 (Sat, 06 Jul 2013) Log Message: ----------- [Ref] libopenmpt: Do not build testcases on unix by default and add a separate test application bin/libopenmpt_test which gets built with 'make TEST=1'. [Ref] openmpt123: Remove --runtests command line switch. Modified Paths: -------------- trunk/OpenMPT/common/BuildSettings.h trunk/OpenMPT/libopenmpt/libopenmpt_internal.h trunk/OpenMPT/libopenmpt/libopenmpt_test.cpp trunk/OpenMPT/openmpt123/Makefile trunk/OpenMPT/openmpt123/openmpt123.cpp trunk/OpenMPT/openmpt123/openmpt123.hpp Modified: trunk/OpenMPT/common/BuildSettings.h =================================================================== --- trunk/OpenMPT/common/BuildSettings.h 2013-07-06 23:24:04 UTC (rev 2514) +++ trunk/OpenMPT/common/BuildSettings.h 2013-07-06 23:56:03 UTC (rev 2515) @@ -132,7 +132,7 @@ #elif defined(LIBOPENMPT_BUILD) -#if !defined(_MSC_VER) || defined(LIBOPENMPT_BUILD_TEST) +#if defined(LIBOPENMPT_BUILD_TEST) #define ENABLE_TESTS #else #define MODPLUG_NO_FILESAVE Modified: trunk/OpenMPT/libopenmpt/libopenmpt_internal.h =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_internal.h 2013-07-06 23:24:04 UTC (rev 2514) +++ trunk/OpenMPT/libopenmpt/libopenmpt_internal.h 2013-07-06 23:56:03 UTC (rev 2515) @@ -40,11 +40,13 @@ #endif #endif +#if defined( LIBOPENMPT_BUILD_TEST ) #ifdef __cplusplus namespace openmpt { LIBOPENMPT_CXX_API void run_tests(); } // namespace openmpt #endif +#endif #ifdef __cplusplus namespace openmpt { namespace version { Modified: trunk/OpenMPT/libopenmpt/libopenmpt_test.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_test.cpp 2013-07-06 23:24:04 UTC (rev 2514) +++ trunk/OpenMPT/libopenmpt/libopenmpt_test.cpp 2013-07-06 23:56:03 UTC (rev 2515) @@ -13,21 +13,17 @@ #include "libopenmpt.hpp" #include "libopenmpt.h" -namespace MptTest { - void DoTests(); -} // namespace MptTest +#if defined( LIBOPENMPT_BUILD_TEST ) -#if defined( LIBOPENMPT_BUILD_TEST ) && ( defined( _MSC_VER ) || defined( LIBOPENMPT_TEST_MAIN ) ) - -int main( int argc, char * argv [] ) { +int main( int /*argc*/, char * /*argv*/ [] ) { try { - MptTest::DoTests(); + openmpt::run_tests(); } catch ( const std::exception & e ) { std::cerr << "TEST ERROR: exception: " << ( e.what() ? e.what() : "" ) << std::endl; - return 1; + return -1; } catch ( ... ) { std::cerr << "TEST ERROR: unknown exception" << std::endl; - return 1; + return -1; } return 0; } Modified: trunk/OpenMPT/openmpt123/Makefile =================================================================== --- trunk/OpenMPT/openmpt123/Makefile 2013-07-06 23:24:04 UTC (rev 2514) +++ trunk/OpenMPT/openmpt123/Makefile 2013-07-06 23:56:03 UTC (rev 2515) @@ -47,6 +47,10 @@ CFLAGS += -O3 -fno-strict-aliasing -ffast-math endif +ifeq ($(TEST),1) +CPPFLAGS += -DLIBOPENMPT_BUILD_TEST +endif + CXXFLAGS += -Wall -Wextra -Wcast-align CFLAGS += -Wall -Wextra -Wcast-align @@ -190,6 +194,24 @@ ALL_OBJECTS += $(OPENMPT123_OBJECTS) ALL_DEPENDS += $(OPENMPT123_DEPENDS) + +ifeq ($(DYNLINK),1) +LIBOPENMPTTEST_CXX_SOURCES += \ + ../libopenmpt/libopenmpt_test.cpp \ + +else +LIBOPENMPTTEST_CXX_SOURCES += \ + $(LIBOPENMPT_CXX_SOURCES) \ + ../libopenmpt/libopenmpt_test.cpp \ + +endif + +LIBOPENMPTTEST_OBJECTS += $(LIBOPENMPTTEST_CXX_SOURCES:.cpp=.o) +LIBOPENMPTTEST_DEPENDS = $(LIBOPENMPTEST_OBJECTS:.o=.d) +ALL_OBJECTS += $(LIBOPENMPTTEST_OBJECTS) +ALL_DEPENDS += $(LIBOPENMPTTEST_DEPENDS) + + EXAMPLES_CXX_SOURCES += $(wildcard ../libopenmpt/examples/*.cpp) EXAMPLES_C_SOURCES += $(wildcard ../libopenmpt/examples/*.c) @@ -216,13 +238,20 @@ OUTPUTS += bin/libopenmpt_example_c_mem OUTPUTS += bin/libopenmpt_example_cxx endif +ifeq ($(TEST),1) +OUTPUTS += bin/libopenmpt_test +endif all: $(OUTPUTS) .PHONY: test -test: all - bin/openmpt123 --runtests +test: bin/libopenmpt_test + bin/libopenmpt_test +bin/libopenmpt_test: $(LIBOPENMPTTEST_OBJECTS) $(OUTPUT_LIBOPENMPT) + $(INFO) [LD ] $@ + $(SILENT)$(LINK.cc) $(LDFLAGS_LIBOPENMPT) $(LIBOPENMPTTEST_OBJECTS) $(LOADLIBES) $(LDLIBS) $(LDLIBS_LIBOPENMPT) -o $@ + bin/openmpt.a: $(LIBOPENMPT_OBJECTS) $(INFO) [AR ] $@ $(SILENT)$(AR) $(ARFLAGS) $@ $^ Modified: trunk/OpenMPT/openmpt123/openmpt123.cpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-07-06 23:24:04 UTC (rev 2514) +++ trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-07-06 23:56:03 UTC (rev 2515) @@ -46,10 +46,6 @@ #include "openmpt123_stdout.hpp" #include "openmpt123_portaudio.hpp" -namespace openmpt { -LIBOPENMPT_CXX_API void run_tests(); -} // namespace openmpt - namespace openmpt123 { struct silent_exit_exception : public std::exception { @@ -647,8 +643,6 @@ std::istringstream istr( nextarg ); istr >> flags.ramping; ++i; - } else if ( arg == "--runtests" ) { - flags.run_tests = true; } else if ( arg.size() > 0 && arg.substr( 0, 1 ) == "-" ) { throw show_help_exception(); } @@ -705,19 +699,6 @@ } - if ( flags.run_tests ) { - try { - openmpt::run_tests(); - } catch ( std::exception & e ) { - std::cerr << "FAIL: " << e.what() << std::endl; - return -1; - } catch ( ... ) { - std::cerr << "FAIL" << std::endl; - return -1; - } - return 0; - } - if ( args.size() <= 1 ) { throw show_help_exception( "", false ); } Modified: trunk/OpenMPT/openmpt123/openmpt123.hpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.hpp 2013-07-06 23:24:04 UTC (rev 2514) +++ trunk/OpenMPT/openmpt123/openmpt123.hpp 2013-07-06 23:56:03 UTC (rev 2515) @@ -58,7 +58,6 @@ } struct commandlineflags { - bool run_tests; bool modplug123; #ifdef MPT_WITH_PORTAUDIO int device; @@ -86,7 +85,6 @@ bool force_overwrite; #endif commandlineflags() { - run_tests = false; modplug123 = false; #ifdef MPT_WITH_PORTAUDIO device = -1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-07-08 00:13:10
|
Revision: 2521 http://sourceforge.net/p/modplug/code/2521 Author: manxorist Date: 2013-07-08 00:13:03 +0000 (Mon, 08 Jul 2013) Log Message: ----------- [Ref] libopenmpt: Make spacing in render param constant names consistent. Modified Paths: -------------- trunk/OpenMPT/libopenmpt/libopenmpt.h trunk/OpenMPT/libopenmpt/libopenmpt.hpp trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp trunk/OpenMPT/libopenmpt/libopenmpt_modplug.c trunk/OpenMPT/libopenmpt/libopenmpt_winamp.cpp trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp trunk/OpenMPT/openmpt123/openmpt123.cpp Modified: trunk/OpenMPT/libopenmpt/libopenmpt.h =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.h 2013-07-07 23:40:28 UTC (rev 2520) +++ trunk/OpenMPT/libopenmpt/libopenmpt.h 2013-07-08 00:13:03 UTC (rev 2521) @@ -64,10 +64,10 @@ LIBOPENMPT_API void openmpt_module_destroy( openmpt_module * mod ); -#define OPENMPT_MODULE_RENDER_MASTERGAIN_MILLIBEL 1 -#define OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT 2 -#define OPENMPT_MODULE_RENDER_INTERPOLATION_FILTER_LENGTH 3 -#define OPENMPT_MODULE_RENDER_VOLUMERAMPING_STRENGTH 4 +#define OPENMPT_MODULE_RENDER_MASTERGAIN_MILLIBEL 1 +#define OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT 2 +#define OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH 3 +#define OPENMPT_MODULE_RENDER_VOLUMERAMPING_STRENGTH 4 #define OPENMPT_MODULE_COMMAND_NOTE 0 #define OPENMPT_MODULE_COMMAND_INSTRUMENT 1 Modified: trunk/OpenMPT/libopenmpt/libopenmpt.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2013-07-07 23:40:28 UTC (rev 2520) +++ trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2013-07-08 00:13:03 UTC (rev 2521) @@ -74,10 +74,10 @@ public: enum render_param { - RENDER_MASTERGAIN_MILLIBEL = 1, - RENDER_STEREOSEPARATION_PERCENT = 2, - RENDER_INTERPOLATION_FILTER_LENGTH = 3, - RENDER_VOLUMERAMPING_STRENGTH = 4, + RENDER_MASTERGAIN_MILLIBEL = 1, + RENDER_STEREOSEPARATION_PERCENT = 2, + RENDER_INTERPOLATIONFILTER_LENGTH = 3, + RENDER_VOLUMERAMPING_STRENGTH = 4, }; enum command_index { Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-07-07 23:40:28 UTC (rev 2520) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-07-08 00:13:03 UTC (rev 2521) @@ -350,7 +350,7 @@ case module::RENDER_STEREOSEPARATION_PERCENT: { return m_sndFile->m_MixerSettings.m_nStereoSeparation * 100 / 128; } break; - case module::RENDER_INTERPOLATION_FILTER_LENGTH: { + case module::RENDER_INTERPOLATIONFILTER_LENGTH: { return resamplingmode_to_filterlength( m_sndFile->m_Resampler.m_Settings.SrcMode ); } break; case module::RENDER_VOLUMERAMPING_STRENGTH: { @@ -380,7 +380,7 @@ m_sndFile->SetMixerSettings( settings ); } } break; - case module::RENDER_INTERPOLATION_FILTER_LENGTH: { + case module::RENDER_INTERPOLATIONFILTER_LENGTH: { CResamplerSettings newsettings; newsettings.SrcMode = filterlength_to_resamplingmode( value ); if ( newsettings != m_sndFile->m_Resampler.m_Settings ) { Modified: trunk/OpenMPT/libopenmpt/libopenmpt_modplug.c =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_modplug.c 2013-07-07 23:40:28 UTC (rev 2520) +++ trunk/OpenMPT/libopenmpt/libopenmpt_modplug.c 2013-07-08 00:13:03 UTC (rev 2521) @@ -132,7 +132,7 @@ file->name = openmpt_module_get_metadata(file->mod,"title"); file->message = openmpt_module_get_metadata(file->mod,"message"); openmpt_module_set_render_param(file->mod,OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT,file->settings.mStereoSeparation*100/128); - openmpt_module_set_render_param(file->mod,OPENMPT_MODULE_RENDER_INTERPOLATION_FILTER_LENGTH,modplugresamplingmode_to_filterlength(file->settings.mResamplingMode)); + openmpt_module_set_render_param(file->mod,OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH,modplugresamplingmode_to_filterlength(file->settings.mResamplingMode)); return file; } Modified: trunk/OpenMPT/libopenmpt/libopenmpt_winamp.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_winamp.cpp 2013-07-07 23:40:28 UTC (rev 2520) +++ trunk/OpenMPT/libopenmpt/libopenmpt_winamp.cpp 2013-07-08 00:13:03 UTC (rev 2521) @@ -99,7 +99,7 @@ self->mod->set_repeat_count( self->settings.repeatcount ); self->mod->set_render_param( openmpt::module::RENDER_MASTERGAIN_MILLIBEL, self->settings.mastergain_millibel ); self->mod->set_render_param( openmpt::module::RENDER_STEREOSEPARATION_PERCENT, self->settings.stereoseparation ); - self->mod->set_render_param( openmpt::module::RENDER_INTERPOLATION_FILTER_LENGTH, self->settings.interpolationfilterlength ); + self->mod->set_render_param( openmpt::module::RENDER_INTERPOLATIONFILTER_LENGTH, self->settings.interpolationfilterlength ); self->mod->set_render_param( openmpt::module::RENDER_VOLUMERAMPING_STRENGTH, self->settings.ramping ); } if ( settings_dll ) { Modified: trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp 2013-07-07 23:40:28 UTC (rev 2520) +++ trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp 2013-07-08 00:13:03 UTC (rev 2521) @@ -133,7 +133,7 @@ self->mod->set_repeat_count( self->settings.repeatcount ); self->mod->set_render_param( openmpt::module::RENDER_MASTERGAIN_MILLIBEL, self->settings.mastergain_millibel ); self->mod->set_render_param( openmpt::module::RENDER_STEREOSEPARATION_PERCENT, self->settings.stereoseparation ); - self->mod->set_render_param( openmpt::module::RENDER_INTERPOLATION_FILTER_LENGTH, self->settings.interpolationfilterlength ); + self->mod->set_render_param( openmpt::module::RENDER_INTERPOLATIONFILTER_LENGTH, self->settings.interpolationfilterlength ); self->mod->set_render_param( openmpt::module::RENDER_VOLUMERAMPING_STRENGTH, self->settings.ramping ); } } Modified: trunk/OpenMPT/openmpt123/openmpt123.cpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-07-07 23:40:28 UTC (rev 2520) +++ trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-07-08 00:13:03 UTC (rev 2521) @@ -332,7 +332,7 @@ flags.ramping = std::max( flags.ramping, -1 ); mod.set_render_param( openmpt::module::RENDER_MASTERGAIN_MILLIBEL, flags.gain ); mod.set_render_param( openmpt::module::RENDER_STEREOSEPARATION_PERCENT, flags.separation ); - mod.set_render_param( openmpt::module::RENDER_INTERPOLATION_FILTER_LENGTH, flags.filtertaps ); + mod.set_render_param( openmpt::module::RENDER_INTERPOLATIONFILTER_LENGTH, flags.filtertaps ); mod.set_render_param( openmpt::module::RENDER_VOLUMERAMPING_STRENGTH, flags.ramping ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-07-13 15:59:47
|
Revision: 2538 http://sourceforge.net/p/modplug/code/2538 Author: manxorist Date: 2013-07-13 15:59:38 +0000 (Sat, 13 Jul 2013) Log Message: ----------- [New] OpenMPT normalizes 24bit und 32bit integer and floating point samples on load to increase precision (because OpenMPT currently only supports 16bit integer samples internally) and to transparently support floating point samples with wrong full scale range. This adjusts the relative volume of samples which do not contain full amplitude values (or which have higher peaks). This is not always desireable, e.g. when sample were specifically recorded in the same environment and their relative maximum peak is different on purpose. This behaviour can now be globally disabled by setting the hidden setting "[Sample Editor]MayNormalizeSamplesOnLoad=0" (default is the old behaviour). [Mod] When loading such high resolution .wav files which are part of a DLS bank, OpenMPT now never normalizes them, ignoring the new setting. The rationale is, in a soundbank of multiple instruments you almost always want to preserve their relative volume. [Mod] On the other hand, when loading .wav files as a module, OpenMPT always normalizes because there is little use in not doing it here. [Mod] Furthermore, for samples which did get normalized, we now adjust the global sample volume so that their relative volume stays at least roughly in the same range as before normalization. Because of lack of precision of the global volume field and the fact that it only can attenuate and not amplify the sample, this is really just a rough approximation. [New] Support reading floating point .wav files written with old versions of Syntrillium CoolEdit. CoolEdit calls these formats 16.8 float and 24.0 float, referencing the amplitude of full scale values. These formats use a non-standard WAVEFORMAT. Details are documented in the code. [Fix] Adjust the heuristic of never trusting the WAVEFORMAT header value BlockAlign (which is a useful heuristic to load some corrupted samples) to only not trust BlockAlign if the value really is 0 or at least twice as big as expected. This fixes support for 20bit-in-24bit integer PCM .wav files without WAVEFORMATEXTENSIBLE. Modified Paths: -------------- trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/Load_itp.cpp trunk/OpenMPT/soundlib/Load_umx.cpp trunk/OpenMPT/soundlib/Load_wav.cpp trunk/OpenMPT/soundlib/SampleFormatConverters.h trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/SampleIO.cpp trunk/OpenMPT/soundlib/SampleIO.h trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/WAVTools.cpp trunk/OpenMPT/soundlib/WAVTools.h Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2013-07-13 15:48:20 UTC (rev 2537) +++ trunk/OpenMPT/common/misc_util.h 2013-07-13 15:59:38 UTC (rev 2538) @@ -403,6 +403,16 @@ return static_cast<int32>( ( static_cast<int64>(a) * b + ( c / 2 ) ) / c ); } + // Do not use overloading because catching unsigned version by accident results in slower X86 code. + inline uint32 muldiv_unsigned(uint32 a, uint32 b, uint32 c) + { + return static_cast<uint32>( ( static_cast<uint64>(a) * b ) / c ); + } + inline uint32 muldivr_unsigned(uint32 a, uint32 b, uint32 c) + { + return static_cast<uint32>( ( static_cast<uint64>(a) * b + ( c / 2 ) ) / c ); + } + inline int32 muldivrfloor(int64 a, uint32 b, uint32 c) { a *= b; Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2013-07-13 15:48:20 UTC (rev 2537) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2013-07-13 15:59:38 UTC (rev 2538) @@ -1419,7 +1419,7 @@ m_modDoc.SetModified(); } if (!m_nInstrument) m_nInstrument = 1; - if (m_sndFile.ReadInstrumentFromFile(m_nInstrument, lpFile, len)) + if (m_sndFile.ReadInstrumentFromFile(m_nInstrument, lpFile, len, TrackerSettings::Instance().m_MayNormalizeSamplesOnLoad)) { m_modDoc.UpdateAllViews(NULL, HINT_SAMPLEINFO | HINT_MODTYPE, NULL); // -> CODE#0023 Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-07-13 15:48:20 UTC (rev 2537) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-07-13 15:59:38 UTC (rev 2538) @@ -754,7 +754,7 @@ { m_modDoc.GetSampleUndo().PrepareUndo(m_nSample, sundo_replace); FileReader file(lpFile, len); - bOk = m_sndFile.ReadSampleFromFile(m_nSample, file); + bOk = m_sndFile.ReadSampleFromFile(m_nSample, file, TrackerSettings::Instance().m_MayNormalizeSamplesOnLoad); } if (!bOk) @@ -779,6 +779,11 @@ SampleIO sampleIO = dlg.GetSampleFormat(); + if(TrackerSettings::Instance().m_MayNormalizeSamplesOnLoad) + { + sampleIO.MayNormalize(); + } + if(sampleIO.GetBitDepth() != 8) { sample.nLength /= 2; Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-07-13 15:48:20 UTC (rev 2537) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-07-13 15:59:38 UTC (rev 2538) @@ -1575,13 +1575,13 @@ // Avoid hanging audio while reading file - we have removed all sample and instrument references before, // so it's safe to replace the sample / instrument now. cs.Leave(); - ok = m_WaveFile.ReadInstrumentFromFile(1, p, dwLen); + ok = m_WaveFile.ReadInstrumentFromFile(1, p, dwLen, TrackerSettings::Instance().m_MayNormalizeSamplesOnLoad); cs.Enter(); if(!ok) { // Try reading as sample if reading as instrument fails FileReader file(p, dwLen); - ok = m_WaveFile.ReadSampleFromFile(1, file); + ok = m_WaveFile.ReadSampleFromFile(1, file, TrackerSettings::Instance().m_MayNormalizeSamplesOnLoad); m_WaveFile.AllocateInstrument(1, 1); } } Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-07-13 15:48:20 UTC (rev 2537) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-07-13 15:59:38 UTC (rev 2538) @@ -342,7 +342,7 @@ if ((len) && ((lpFile = (LPBYTE)GlobalAllocPtr(GHND, len)) != NULL)) { f.Read(lpFile, len); - m_SndFile.ReadInstrumentFromFile(nIns, lpFile, len); + m_SndFile.ReadInstrumentFromFile(nIns, lpFile, len, TrackerSettings::Instance().m_MayNormalizeSamplesOnLoad); _splitpath(pszMidiMapName, NULL, NULL, szName, szExt); strncat(szName, szExt, sizeof(szName)); pIns = m_SndFile.Instruments[nIns]; Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-07-13 15:48:20 UTC (rev 2537) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-07-13 15:59:38 UTC (rev 2538) @@ -106,6 +106,7 @@ // Sample Editor m_nSampleUndoMaxBuffer = 0; // Real sample buffer undo size will be set later. + m_MayNormalizeSamplesOnLoad = true; GetDefaultColourScheme(rgbCustomColors); @@ -469,6 +470,7 @@ m_nSampleUndoMaxBuffer = CMainFrame::GetPrivateProfileLong("Sample Editor" , "UndoBufferSize", m_nSampleUndoMaxBuffer >> 20, iniFile); m_nSampleUndoMaxBuffer = MAX(1, m_nSampleUndoMaxBuffer) << 20; + m_MayNormalizeSamplesOnLoad = CMainFrame::GetPrivateProfileBool("Sample Editor" , "MayNormalizeSamplesOnLoad", m_MayNormalizeSamplesOnLoad, iniFile); PatternClipboard::SetClipboardSize(GetPrivateProfileInt("Pattern Editor", "NumClipboards", PatternClipboard::GetClipboardSize(), iniFile)); @@ -870,6 +872,8 @@ CMainFrame::WritePrivateProfileDWord("Pattern Editor", "NumClipboards", PatternClipboard::GetClipboardSize(), iniFile); + CMainFrame::WritePrivateProfileBool("Sample Editor", "MayNormalizeSamplesOnLoad", m_MayNormalizeSamplesOnLoad, iniFile); + // Write default paths const bool bConvertPaths = theApp.IsPortableMode(); TCHAR szPath[_MAX_PATH] = ""; Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2013-07-13 15:48:20 UTC (rev 2537) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2013-07-13 15:59:38 UTC (rev 2538) @@ -211,6 +211,7 @@ // Sample Editor Setup UINT m_nSampleUndoMaxBuffer; + bool m_MayNormalizeSamplesOnLoad; // key config TCHAR m_szKbdFile[_MAX_PATH]; Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2013-07-13 15:48:20 UTC (rev 2537) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2013-07-13 15:59:38 UTC (rev 2538) @@ -1969,7 +1969,7 @@ memcpy(s, pSndFile->m_szNames[m_nSample], 32); memcpy(s2, sample.filename, 22); FileReader file(p, dwMemSize); - pSndFile->ReadSampleFromFile(m_nSample, file); + pSndFile->ReadSampleFromFile(m_nSample, file, TrackerSettings::Instance().m_MayNormalizeSamplesOnLoad); if (!pSndFile->m_szNames[m_nSample][0]) { memcpy(pSndFile->m_szNames[m_nSample], s, 32); Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.cpp 2013-07-13 15:48:20 UTC (rev 2537) +++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2013-07-13 15:59:38 UTC (rev 2538) @@ -1565,7 +1565,7 @@ } else { FileReader file(pWaveForm, dwLen); - bWaveForm = sndFile.ReadWAVSample(nSample, file, &wsmpChunk); + bWaveForm = sndFile.ReadWAVSample(nSample, file, false, &wsmpChunk); } if (bWaveForm) { Modified: trunk/OpenMPT/soundlib/Load_itp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_itp.cpp 2013-07-13 15:48:20 UTC (rev 2537) +++ trunk/OpenMPT/soundlib/Load_itp.cpp 2013-07-13 15:59:38 UTC (rev 2538) @@ -16,6 +16,7 @@ #include "stdafx.h" #ifdef MODPLUG_TRACKER #include "../mptrack/mptrack.h" +#include "../mptrack/TrackerSettings.h" #endif #include "../common/version.h" #include "Loaders.h" @@ -228,7 +229,7 @@ LPBYTE lpFile = f.Lock(size); if(!lpFile) { f.Close(); continue; } - ReadInstrumentFromFile(ins + 1, lpFile, size); + ReadInstrumentFromFile(ins + 1, lpFile, size, TrackerSettings::Instance().m_MayNormalizeSamplesOnLoad); f.Close(); } Modified: trunk/OpenMPT/soundlib/Load_umx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_umx.cpp 2013-07-13 15:48:20 UTC (rev 2537) +++ trunk/OpenMPT/soundlib/Load_umx.cpp 2013-07-13 15:59:38 UTC (rev 2538) @@ -291,7 +291,7 @@ } else if(isSound && GetNumSamples() < MAX_SAMPLES - 1) { // Read as sample - if(ReadSampleFromFile(GetNumSamples() + 1, fileChunk)) + if(ReadSampleFromFile(GetNumSamples() + 1, fileChunk, true)) { m_nSamples++; if(static_cast<size_t>(objName) < names.size()) Modified: trunk/OpenMPT/soundlib/Load_wav.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_wav.cpp 2013-07-13 15:48:20 UTC (rev 2537) +++ trunk/OpenMPT/soundlib/Load_wav.cpp 2013-07-13 15:59:38 UTC (rev 2538) @@ -19,14 +19,14 @@ // WAV file support -template <typename SampleConverter> -bool CopyWavChannel(ModSample &sample, const FileReader &file, size_t channelIndex, size_t numChannels) -//----------------------------------------------------------------------------------------------------- +template <typename SampleConversion> +bool CopyWavChannel(ModSample &sample, const FileReader &file, size_t channelIndex, size_t numChannels, SampleConversion conv = SampleConversion()) +//------------------------------------------------------------------------------------------------------------------------------------------------- { ASSERT(sample.GetNumChannels() == 1); - ASSERT(sample.GetElementarySampleSize() == sizeof(typename SampleConverter::output_t)); + ASSERT(sample.GetElementarySampleSize() == sizeof(typename SampleConversion::output_t)); - const size_t offset = channelIndex * sizeof(typename SampleConverter::input_t) * SampleConverter::input_inc; + const size_t offset = channelIndex * sizeof(typename SampleConversion::input_t) * SampleConversion::input_inc; if(sample.AllocateSample() == 0 || !file.CanRead(offset)) { @@ -34,7 +34,7 @@ } const char *inBuf = file.GetRawData(); - CopySample<SampleConverter>(reinterpret_cast<typename SampleConverter::output_t*>(sample.pSample), sample.nLength, 1, inBuf + offset, file.BytesLeft() - offset, numChannels); + CopySample<SampleConversion>(reinterpret_cast<typename SampleConversion::output_t*>(sample.pSample), sample.nLength, 1, inBuf + offset, file.BytesLeft() - offset, numChannels, conv); CSoundFile::AdjustSampleLoop(sample); return true; } @@ -155,7 +155,7 @@ if(wavFile.GetSampleFormat() == WAVFormatChunk::fmtFloat) { - CopyWavChannel<SC::ConversionChain<SC::Convert<int16, float32>, SC::DecodeFloat32<littleEndian32> > >(sample, sampleChunk, channel, wavFile.GetNumChannels()); + CopyWavChannel<SC::NormalizationChain<SC::Convert<int16, float32>, SC::DecodeFloat32<littleEndian32> > >(sample, sampleChunk, channel, wavFile.GetNumChannels()); } else { if(wavFile.GetBitsPerSample() <= 8) @@ -166,10 +166,10 @@ CopyWavChannel<SC::DecodeInt16<0, littleEndian16> >(sample, sampleChunk, channel, wavFile.GetNumChannels()); } else if(wavFile.GetBitsPerSample() <= 24) { - CopyWavChannel<SC::ConversionChain<SC::Convert<int16, int32>, SC::DecodeInt24<0, littleEndian24> > >(sample, sampleChunk, channel, wavFile.GetNumChannels()); + CopyWavChannel<SC::NormalizationChain<SC::Convert<int16, int32>, SC::DecodeInt24<0, littleEndian24> > >(sample, sampleChunk, channel, wavFile.GetNumChannels()); } else if(wavFile.GetBitsPerSample() <= 32) { - CopyWavChannel<SC::ConversionChain<SC::Convert<int16, int32>, SC::DecodeInt32<0, littleEndian32> > >(sample, sampleChunk, channel, wavFile.GetNumChannels()); + CopyWavChannel<SC::NormalizationChain<SC::Convert<int16, int32>, SC::DecodeInt32<0, littleEndian32> > >(sample, sampleChunk, channel, wavFile.GetNumChannels()); } } Modified: trunk/OpenMPT/soundlib/SampleFormatConverters.h =================================================================== --- trunk/OpenMPT/soundlib/SampleFormatConverters.h 2013-07-13 15:48:20 UTC (rev 2537) +++ trunk/OpenMPT/soundlib/SampleFormatConverters.h 2013-07-13 15:59:38 UTC (rev 2538) @@ -163,6 +163,24 @@ } }; +template <size_t loLoByteIndex, size_t loHiByteIndex, size_t hiLoByteIndex, size_t hiHiByteIndex> +struct DecodeScaledFloat32 +{ + typedef char input_t; + typedef float32 output_t; + static const int input_inc = 4; + float factor; + forceinline output_t operator() (const input_t *inBuf) + { + return factor * DecodeFloatLE(uint8_4(uint8(inBuf[loLoByteIndex]), uint8(inBuf[loHiByteIndex]), uint8(inBuf[hiLoByteIndex]), uint8(inBuf[hiHiByteIndex]))); + } + forceinline DecodeScaledFloat32(float scaleFactor) + : factor(scaleFactor) + { + return; + } +}; + template <typename Tsample> struct ReadSample { @@ -307,6 +325,12 @@ typename Func1::output_t tmp = func1(inBuf); return func2(&tmp); } + forceinline ConversionChain(Func2 f2 = Func2(), Func1 f1 = Func1()) + : func1(f1) + , func2(f2) + { + return; + } }; @@ -319,6 +343,7 @@ { typedef int32 input_t; typedef int32 output_t; + typedef uint32 peak_t; static const int input_inc = 1; uint32 maxVal; Normalize() : maxVal(0) { } @@ -347,6 +372,10 @@ { return Util::muldivrfloor(*inBuf, (uint32)1 << 31, maxVal); } + forceinline peak_t GetSrcPeak() const + { + return maxVal; + } }; template <> @@ -354,6 +383,7 @@ { typedef float32 input_t; typedef float32 output_t; + typedef float32 peak_t; static const int input_inc = 1; uint32 intMaxVal; float maxValInv; @@ -386,6 +416,10 @@ { return *inBuf * maxValInv; } + forceinline peak_t GetSrcPeak() const + { + return DecodeFloatNE(intMaxVal); + } }; @@ -397,10 +431,12 @@ struct NormalizationChain { typedef typename Func1::input_t input_t; + typedef typename Func1::output_t normalize_t; + typedef typename Normalize<normalize_t>::peak_t peak_t; typedef typename Func2::output_t output_t; static const int input_inc = Func1::input_inc; Func1 func1; - Normalize<typename Func1::output_t> normalize; + Normalize<normalize_t> normalize; Func2 func2; forceinline void FindMax(const input_t *inBuf) { @@ -414,10 +450,20 @@ forceinline output_t operator() (const input_t *inBuf) { typename Func1::output_t tmp1 = func1(inBuf); - typename Func1::output_t norm = normalize(&tmp1); + normalize_t norm = normalize(&tmp1); typename Func2::output_t tmp2 = func2(&norm); return tmp2; } + forceinline peak_t GetSrcPeak() const + { + return normalize.GetSrcPeak(); + } + forceinline NormalizationChain(Func2 f2 = Func2(), Func1 f1 = Func1()) + : func1(f1) + , func2(f2) + { + return; + } }; @@ -440,14 +486,14 @@ // Template arguments: // SampleConversion: Functor of type SampleConversionFunctor to apply sample conversion (see above for existing functors). template <typename SampleConversion> -size_t CopySample(typename SampleConversion::output_t *outBuf, size_t numSamples, size_t incTarget, const typename SampleConversion::input_t *inBuf, size_t sourceSize, size_t incSource) -//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +size_t CopySample(typename SampleConversion::output_t *outBuf, size_t numSamples, size_t incTarget, const typename SampleConversion::input_t *inBuf, size_t sourceSize, size_t incSource, SampleConversion conv = SampleConversion()) +//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- { const size_t sampleSize = incSource * SampleConversion::input_inc; LimitMax(numSamples, sourceSize / sampleSize); const size_t copySize = numSamples * sampleSize; - SampleConversion sampleConv; + SampleConversion sampleConv(conv); while(numSamples--) { *outBuf = sampleConv(inBuf); @@ -461,8 +507,8 @@ // Copy a mono sample data buffer. template <typename SampleConversion> -size_t CopyMonoSample(ModSample &sample, const char *sourceBuffer, size_t sourceSize) -//----------------------------------------------------------------------------------- +size_t CopyMonoSample(ModSample &sample, const char *sourceBuffer, size_t sourceSize, SampleConversion conv = SampleConversion()) +//------------------------------------------------------------------------------------------------------------------------------- { ASSERT(sample.GetNumChannels() == 1); ASSERT(sample.GetElementarySampleSize() == sizeof(typename SampleConversion::output_t)); @@ -470,7 +516,7 @@ const size_t frameSize = SampleConversion::input_inc; const size_t countFrames = std::min<size_t>(sourceSize / frameSize, sample.nLength); size_t numFrames = countFrames; - SampleConversion sampleConv; + SampleConversion sampleConv(conv); const char * inBuf = sourceBuffer; typename SampleConversion::output_t * outBuf = reinterpret_cast<typename SampleConversion::output_t *>(sample.pSample); while(numFrames--) @@ -485,8 +531,8 @@ // Copy a stereo interleaved sample data buffer. template <typename SampleConversion> -size_t CopyStereoInterleavedSample(ModSample &sample, const char *sourceBuffer, size_t sourceSize) -//------------------------------------------------------------------------------------------------ +size_t CopyStereoInterleavedSample(ModSample &sample, const char *sourceBuffer, size_t sourceSize, SampleConversion conv = SampleConversion()) +//-------------------------------------------------------------------------------------------------------------------------------------------- { ASSERT(sample.GetNumChannels() == 2); ASSERT(sample.GetElementarySampleSize() == sizeof(typename SampleConversion::output_t)); @@ -494,8 +540,8 @@ const size_t frameSize = 2 * SampleConversion::input_inc; const size_t countFrames = std::min<size_t>(sourceSize / frameSize, sample.nLength); size_t numFrames = countFrames; - SampleConversion sampleConvLeft; - SampleConversion sampleConvRight; + SampleConversion sampleConvLeft(conv); + SampleConversion sampleConvRight(conv); const char * inBuf = sourceBuffer; typename SampleConversion::output_t * outBuf = reinterpret_cast<typename SampleConversion::output_t *>(sample.pSample); while(numFrames--) @@ -513,8 +559,8 @@ // Copy a stereo split sample data buffer. template <typename SampleConversion> -size_t CopyStereoSplitSample(ModSample &sample, const char *sourceBuffer, size_t sourceSize) -//------------------------------------------------------------------------------------------ +size_t CopyStereoSplitSample(ModSample &sample, const char *sourceBuffer, size_t sourceSize, SampleConversion conv = SampleConversion()) +//-------------------------------------------------------------------------------------------------------------------------------------- { ASSERT(sample.GetNumChannels() == 2); ASSERT(sample.GetElementarySampleSize() == sizeof(typename SampleConversion::output_t)); @@ -522,8 +568,8 @@ const size_t frameSize = 2 * SampleConversion::input_inc; const size_t countFrames = std::min<size_t>(sourceSize / frameSize, sample.nLength); size_t numFrames = countFrames; - SampleConversion sampleConvLeft; - SampleConversion sampleConvRight; + SampleConversion sampleConvLeft(conv); + SampleConversion sampleConvRight(conv); const char * inBufLeft = sourceBuffer; const char * inBufRight = sourceBuffer + sample.nLength * SampleConversion::input_inc; typename SampleConversion::output_t * outBuf = reinterpret_cast<typename SampleConversion::output_t *>(sample.pSample); @@ -542,8 +588,8 @@ // Copy a sample data buffer and normalize it. Requires slightly advanced sample conversion functor. template<typename SampleConversion> -size_t CopyAndNormalizeSample(ModSample &sample, const char *sourceBuffer, size_t sourceSize) -//------------------------------------------------------------------------------------------- +size_t CopyAndNormalizeSample(ModSample &sample, const char *sourceBuffer, size_t sourceSize, typename SampleConversion::peak_t *srcPeak = nullptr, SampleConversion conv = SampleConversion()) +//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- { const size_t inSize = sizeof(typename SampleConversion::input_t); @@ -554,7 +600,7 @@ const char * inBuf = sourceBuffer; // Finding max value - SampleConversion sampleConv; + SampleConversion sampleConv(conv); for(size_t i = numSamples; i != 0; i--) { sampleConv.FindMax(inBuf); @@ -576,5 +622,10 @@ } } + if(srcPeak) + { + *srcPeak = sampleConv.GetSrcPeak(); + } + return numSamples * inSize; } Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-07-13 15:48:20 UTC (rev 2537) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-07-13 15:59:38 UTC (rev 2538) @@ -57,8 +57,8 @@ #endif // NO_MP3_SAMPLES -bool CSoundFile::ReadSampleFromFile(SAMPLEINDEX nSample, FileReader &file) -//------------------------------------------------------------------------ +bool CSoundFile::ReadSampleFromFile(SAMPLEINDEX nSample, FileReader &file, bool mayNormalize) +//------------------------------------------------------------------------------------------- { file.Rewind(); @@ -66,10 +66,10 @@ const DWORD dwFileLength = file.GetLength(); if(!nSample || nSample >= MAX_SAMPLES) return false; - if(!ReadWAVSample(nSample, file) + if(!ReadWAVSample(nSample, file, mayNormalize) && !ReadXISample(nSample, file) && !ReadITISample(nSample, file) - && !ReadAIFFSample(nSample, file) + && !ReadAIFFSample(nSample, file, mayNormalize) && !ReadITSSample(nSample, file) && !ReadPATSample(nSample, const_cast<BYTE*>(lpMemFile), dwFileLength) && !Read8SVXSample(nSample, const_cast<BYTE*>(lpMemFile), dwFileLength) @@ -88,8 +88,8 @@ } -bool CSoundFile::ReadInstrumentFromFile(INSTRUMENTINDEX nInstr, const LPBYTE lpMemFile, DWORD dwFileLength) -//--------------------------------------------------------------------------------------------------------- +bool CSoundFile::ReadInstrumentFromFile(INSTRUMENTINDEX nInstr, const LPBYTE lpMemFile, DWORD dwFileLength, bool mayNormalize) +//---------------------------------------------------------------------------------------------------------------------------- { FileReader file(lpMemFile, dwFileLength); if ((!nInstr) || (nInstr >= MAX_INSTRUMENTS)) return false; @@ -97,15 +97,15 @@ && (!ReadPATInstrument(nInstr, lpMemFile, dwFileLength)) && (!ReadITIInstrument(nInstr, file)) // Generic read - && (!ReadSampleAsInstrument(nInstr, file))) return false; + && (!ReadSampleAsInstrument(nInstr, file, mayNormalize))) return false; if(nInstr > GetNumInstruments()) m_nInstruments = nInstr; return true; } -bool CSoundFile::ReadSampleAsInstrument(INSTRUMENTINDEX nInstr, FileReader &file) -//------------------------------------------------------------------------------- +bool CSoundFile::ReadSampleAsInstrument(INSTRUMENTINDEX nInstr, FileReader &file, bool mayNormalize) +//-------------------------------------------------------------------------------------------------- { file.Rewind(); @@ -153,7 +153,7 @@ DestroyInstrument(nInstr, deleteAssociatedSamples); Instruments[nInstr] = pIns; - ReadSampleFromFile(nSample, file); + ReadSampleFromFile(nSample, file, mayNormalize); return true; } return false; @@ -352,8 +352,8 @@ extern bool IMAADPCMUnpack16(int16 *target, SmpLength sampleLen, FileReader file, uint16 blockAlign); -bool CSoundFile::ReadWAVSample(SAMPLEINDEX nSample, FileReader &file, FileReader *wsmpChunk) -//------------------------------------------------------------------------------------------ +bool CSoundFile::ReadWAVSample(SAMPLEINDEX nSample, FileReader &file, bool mayNormalize, FileReader *wsmpChunk) +//------------------------------------------------------------------------------------------------------------- { WAVReader wavFile(file); @@ -393,6 +393,31 @@ { // MP3 in WAV return ReadMP3Sample(nSample, sampleChunk); + } else if(!wavFile.IsExtensibleFormat() && wavFile.MayBeCoolEdit16_8() && wavFile.GetSampleFormat() == WAVFormatChunk::fmtPCM && wavFile.GetBitsPerSample() == 32 && wavFile.GetBlockAlign() == wavFile.GetNumChannels() * 4) + { + // Syntrillium Cool Edit hack to store IEEE 32bit floating point + // Format is described as 32bit integer PCM contained in 32bit blocks and an WAVEFORMATEX extension size of 2 which contains a single 16 bit little endian value of 1. + // (This is parsed in WAVTools.cpp and returned via MayBeCoolEdit16_8()). + // The data actually stored in this case is little endian 32bit floating point PCM with 2**15 full scale. + // Cool Edit calls this format "16.8 float". + SampleIO sampleIO( + SampleIO::_32bit, + (wavFile.GetNumChannels() > 1) ? SampleIO::stereoInterleaved : SampleIO::mono, + SampleIO::littleEndian, + SampleIO::floatPCM15); + sampleIO.ReadSample(sample, sampleChunk); + } else if(!wavFile.IsExtensibleFormat() && wavFile.GetSampleFormat() == WAVFormatChunk::fmtPCM && wavFile.GetBitsPerSample() == 24 && wavFile.GetBlockAlign() == wavFile.GetNumChannels() * 4) + { + // Syntrillium Cool Edit hack to store IEEE 32bit floating point + // Format is described as 24bit integer PCM contained in 32bit blocks. + // The data actually stored in this case is little endian 32bit floating point PCM with 2**23 full scale. + // Cool Edit calls this format "24.0 float". + SampleIO sampleIO( + SampleIO::_32bit, + (wavFile.GetNumChannels() > 1) ? SampleIO::stereoInterleaved : SampleIO::mono, + SampleIO::littleEndian, + SampleIO::floatPCM23); + sampleIO.ReadSample(sample, sampleChunk); } else { // PCM / Float @@ -409,6 +434,11 @@ sampleIO |= SampleIO::floatPCM; } + if(mayNormalize) + { + sampleIO.MayNormalize(); + } + sampleIO.ReadSample(sample, sampleChunk); } @@ -1247,8 +1277,8 @@ #endif -bool CSoundFile::ReadAIFFSample(SAMPLEINDEX nSample, FileReader &file) -//-------------------------------------------------------------------- +bool CSoundFile::ReadAIFFSample(SAMPLEINDEX nSample, FileReader &file, bool mayNormalize) +//--------------------------------------------------------------------------------------- { file.Rewind(); ChunkReader chunkFile(file); @@ -1316,6 +1346,11 @@ sampleIO |= SampleIO::floatPCM; } + if(mayNormalize) + { + sampleIO.MayNormalize(); + } + soundChunk.Skip(sampleHeader.offset); ModSample &mptSample = Samples[nSample]; Modified: trunk/OpenMPT/soundlib/SampleIO.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleIO.cpp 2013-07-13 15:48:20 UTC (rev 2537) +++ trunk/OpenMPT/soundlib/SampleIO.cpp 2013-07-13 15:59:38 UTC (rev 2538) @@ -230,54 +230,228 @@ } ////////////////////////////////////////////////////// + // 24-Bit / Signed / Mono / PCM + else if(GetBitDepth() == 24 && GetChannelFormat() == mono && GetEncoding() == signedPCM) + { + if(GetEndianness() == littleEndian) + { + bytesRead = CopyMonoSample<SC::ConversionChain<SC::Convert<int16, int32>, SC::DecodeInt24<0, littleEndian24> > >(sample, sourceBuf, fileSize); + } else + { + bytesRead = CopyMonoSample<SC::ConversionChain<SC::Convert<int16, int32>, SC::DecodeInt24<0, bigEndian24> > >(sample, sourceBuf, fileSize); + } + } + + ////////////////////////////////////////////////////// + // 24-Bit / Signed / Stereo Interleaved / PCM + else if(GetBitDepth() == 24 && GetChannelFormat() == stereoInterleaved && GetEncoding() == signedPCM) + { + if(GetEndianness() == littleEndian) + { + bytesRead = CopyStereoInterleavedSample<SC::ConversionChain<SC::Convert<int16, int32>, SC::DecodeInt24<0, littleEndian24> > >(sample, sourceBuf, fileSize); + } else + { + bytesRead = CopyStereoInterleavedSample<SC::ConversionChain<SC::Convert<int16, int32>, SC::DecodeInt24<0, bigEndian24> > >(sample, sourceBuf, fileSize); + } + } + + ////////////////////////////////////////////////////// + // 32-Bit / Signed / Mono / PCM + else if(GetBitDepth() == 32 && GetChannelFormat() == mono && GetEncoding() == signedPCM) + { + if(GetEndianness() == littleEndian) + { + bytesRead = CopyMonoSample<SC::ConversionChain<SC::Convert<int16, int32>, SC::DecodeInt32<0, littleEndian32> > >(sample, sourceBuf, fileSize); + } else + { + bytesRead = CopyMonoSample<SC::ConversionChain<SC::Convert<int16, int32>, SC::DecodeInt32<0, bigEndian32> > >(sample, sourceBuf, fileSize); + } + } + + ////////////////////////////////////////////////////// + // 32-Bit / Signed / Stereo Interleaved / PCM + else if(GetBitDepth() == 32 && GetChannelFormat() == stereoInterleaved && GetEncoding() == signedPCM) + { + if(GetEndianness() == littleEndian) + { + bytesRead = CopyStereoInterleavedSample<SC::ConversionChain<SC::Convert<int16, int32>, SC::DecodeInt32<0, littleEndian32> > >(sample, sourceBuf, fileSize); + } else + { + bytesRead = CopyStereoInterleavedSample<SC::ConversionChain<SC::Convert<int16, int32>, SC::DecodeInt32<0, bigEndian32> > >(sample, sourceBuf, fileSize); + } + } + + ////////////////////////////////////////////////////// + // 32-Bit / Float / Mono / PCM + else if(GetBitDepth() == 32 && GetChannelFormat() == mono && GetEncoding() == floatPCM) + { + if(GetEndianness() == littleEndian) + { + bytesRead = CopyMonoSample<SC::ConversionChain<SC::Convert<int16, float32>, SC::DecodeFloat32<littleEndian32> > >(sample, sourceBuf, fileSize); + } else + { + bytesRead = CopyMonoSample<SC::ConversionChain<SC::Convert<int16, float32>, SC::DecodeFloat32<bigEndian32> > >(sample, sourceBuf, fileSize); + } + } + + ////////////////////////////////////////////////////// + // 32-Bit / Float / Stereo Interleaved / PCM + else if(GetBitDepth() == 32 && GetChannelFormat() == stereoInterleaved && GetEncoding() == floatPCM) + { + if(GetEndianness() == littleEndian) + { + bytesRead = CopyStereoInterleavedSample<SC::ConversionChain<SC::Convert<int16, float32>, SC::DecodeFloat32<littleEndian32> > >(sample, sourceBuf, fileSize); + } else + { + bytesRead = CopyStereoInterleavedSample<SC::ConversionChain<SC::Convert<int16, float32>, SC::DecodeFloat32<bigEndian32> > >(sample, sourceBuf, fileSize); + } + } + + ////////////////////////////////////////////////////// // 24-Bit / Signed / Mono, Stereo Interleaved / PCM - else if(GetBitDepth() == 24 && (GetChannelFormat() == mono || GetChannelFormat() == stereoInterleaved) && GetEncoding() == signedPCM) + else if(GetBitDepth() == 24 && (GetChannelFormat() == mono || GetChannelFormat() == stereoInterleaved) && GetEncoding() == signedPCMnormalize) { // Normalize to 16-Bit + uint32 srcPeak = uint32(1)<<31; if(GetEndianness() == littleEndian) { - bytesRead = CopyAndNormalizeSample<SC::NormalizationChain<SC::Convert<int16, int32>, SC::DecodeInt24<0, littleEndian24> > >(sample, sourceBuf, fileSize); - //bytesRead = CopyMonoSample<SC::ConversionChain<SC::Convert<int16, int32>, SC::DecodeInt24<0, littleEndian24> > >(sample, sourceBuf, fileSize); + bytesRead = CopyAndNormalizeSample<SC::NormalizationChain<SC::Convert<int16, int32>, SC::DecodeInt24<0, littleEndian24> > >(sample, sourceBuf, fileSize, &srcPeak); } else { - bytesRead = CopyAndNormalizeSample<SC::NormalizationChain<SC::Convert<int16, int32>, SC::DecodeInt24<0, bigEndian24> > >(sample, sourceBuf, fileSize); - //bytesRead = CopyMonoSample<SC::ConversionChain<SC::Convert<int16, int32>, SC::DecodeInt24<0, bigEndian24> > >(sample, sourceBuf, fileSize); + bytesRead = CopyAndNormalizeSample<SC::NormalizationChain<SC::Convert<int16, int32>, SC::DecodeInt24<0, bigEndian24> > >(sample, sourceBuf, fileSize, &srcPeak); } + if(bytesRead) + { + // Adjust sample volume so we do not affect relative volume of the sample. Normalizing is only done to increase precision. + sample.nGlobalVol = static_cast<uint16>(Clamp(Util::muldivr_unsigned(sample.nGlobalVol, srcPeak, uint32(1)<<31), uint32(0), uint32(64))); + } } ////////////////////////////////////////////////////// // 32-Bit / Signed / Mono, Stereo Interleaved / PCM - else if(GetBitDepth() == 32 && (GetChannelFormat() == mono || GetChannelFormat() == stereoInterleaved) && GetEncoding() == signedPCM) + else if(GetBitDepth() == 32 && (GetChannelFormat() == mono || GetChannelFormat() == stereoInterleaved) && GetEncoding() == signedPCMnormalize) { // Normalize to 16-Bit + uint32 srcPeak = uint32(1)<<31; if(GetEndianness() == littleEndian) { - bytesRead = CopyAndNormalizeSample<SC::NormalizationChain<SC::Convert<int16, int32>, SC::DecodeInt32<0, littleEndian32> > >(sample, sourceBuf, fileSize); - //bytesRead = CopyMonoSample<SC::ConversionChain<SC::Convert<int16, int32>, SC::DecodeInt32<0, littleEndian32> > >(sample, sourceBuf, fileSize); + bytesRead = CopyAndNormalizeSample<SC::NormalizationChain<SC::Convert<int16, int32>, SC::DecodeInt32<0, littleEndian32> > >(sample, sourceBuf, fileSize, &srcPeak); } else { - bytesRead = CopyAndNormalizeSample<SC::NormalizationChain<SC::Convert<int16, int32>, SC::DecodeInt32<0, bigEndian32> > >(sample, sourceBuf, fileSize); - //bytesRead = CopyMonoSample<SC::ConversionChain<SC::Convert<int16, int32>, SC::DecodeInt32<0, bigEndian32> > >(sample, sourceBuf, fileSize); + bytesRead = CopyAndNormalizeSample<SC::NormalizationChain<SC::Convert<int16, int32>, SC::DecodeInt32<0, bigEndian32> > >(sample, sourceBuf, fileSize, &srcPeak); } + if(bytesRead) + { + // Adjust sample volume so we do not affect relative volume of the sample. Normalizing is only done to increase precision. + sample.nGlobalVol = static_cast<uint16>(Clamp(Util::muldivr_unsigned(sample.nGlobalVol, srcPeak, uint32(1)<<31), uint32(0), uint32(64))); + } } ////////////////////////////////////////////////////// // 32-Bit / Float / Mono, Stereo Interleaved / PCM - else if(GetBitDepth() == 32 && (GetChannelFormat() == mono || GetChannelFormat() == stereoInterleaved) && GetEncoding() == floatPCM) + else if(GetBitDepth() == 32 && (GetChannelFormat() == mono || GetChannelFormat() == stereoInterleaved) && GetEncoding() == floatPCMnormalize) { // Normalize to 16-Bit + float32 srcPeak = 1.0f; if(GetEndianness() == littleEndian) { - bytesRead = CopyAndNormalizeSample<SC::NormalizationChain<SC::Convert<int16, float32>, SC::DecodeFloat32<littleEndian32> > >(sample, sourceBuf, fileSize); - //bytesRead = CopyMonoSample<SC::ConversionChain<SC::Convert<int16, float32>, SC::DecodeFloat32<littleEndian32> > >(sample, sourceBuf, fileSize); + bytesRead = CopyAndNormalizeSample<SC::NormalizationChain<SC::Convert<int16, float32>, SC::DecodeFloat32<littleEndian32> > >(sample, sourceBuf, fileSize, &srcPeak); } else { - bytesRead = CopyAndNormalizeSample<SC::NormalizationChain<SC::Convert<int16, float32>, SC::DecodeFloat32<bigEndian32> > >(sample, sourceBuf, fileSize); - //bytesRead = CopyMonoSample<SC::ConversionChain<SC::Convert<int16, float32>, SC::DecodeFloat32<bigEndian32> > >(sample, sourceBuf, fileSize); + bytesRead = CopyAndNormalizeSample<SC::NormalizationChain<SC::Convert<int16, float32>, SC::DecodeFloat32<bigEndian32> > >(sample, sourceBuf, fileSize, &srcPeak); } + if(bytesRead) + { + // Adjust sample volume so we do not affect relative volume of the sample. Normalizing is only done to increase precision. + sample.nGlobalVol = Util::Round<uint16>(Clamp(sample.nGlobalVol * srcPeak, 0.0f, 64.0f)); + } } ////////////////////////////////////////////////////// + // 32-Bit / Float / Mono / PCM / full scale 2^15 + else if(GetBitDepth() == 32 && GetChannelFormat() == mono && GetEncoding() == floatPCM15) + { + if(GetEndianness() == littleEndian) + { + bytesRead = CopyMonoSample + (sample, sourceBuf, fileSize, + SC::ConversionChain<SC::Convert<int16, float32>, SC::DecodeScaledFloat32<littleEndian32> > + (SC::Convert<int16, float32>(), SC::DecodeScaledFloat32<littleEndian32>(1.0f / static_cast<float>(1<<15))) + ); + } else + { + bytesRead = CopyMonoSample + (sample, sourceBuf, fileSize, + SC::ConversionChain<SC::Convert<int16, float32>, SC::DecodeScaledFloat32<bigEndian32> > + (SC::Convert<int16, float32>(), SC::DecodeScaledFloat32<bigEndian32>(1.0f / static_cast<float>(1<<15))) + ); + } + } + + ////////////////////////////////////////////////////// + // 32-Bit / Float / Stereo Interleaved / PCM / full scale 2^15 + else if(GetBitDepth() == 32 && GetChannelFormat() == stereoInterleaved && GetEncoding() == floatPCM15) + { + if(GetEndianness() == littleEndian) + { + bytesRead = CopyStereoInterleavedSample + (sample, sourceBuf, fileSize, + SC::ConversionChain<SC::Convert<int16, float32>, SC::DecodeScaledFloat32<littleEndian32> > + (SC::Convert<int16, float32>(), SC::DecodeScaledFloat32<littleEndian32>(1.0f / static_cast<float>(1<<15))) + ); + } else + { + bytesRead = CopyStereoInterleavedSample + (sample, sourceBuf, fileSize, + SC::ConversionChain<SC::Convert<int16, float32>, SC::DecodeScaledFloat32<bigEndian32> > + (SC::Convert<int16, float32>(), SC::DecodeScaledFloat32<bigEndian32>(1.0f / static_cast<float>(1<<15))) + ); + } + } + + ////////////////////////////////////////////////////// + // 32-Bit / Float / Stereo Interleaved / PCM / full scale 2^23 + else if(GetBitDepth() == 32 && GetChannelFormat() == mono && GetEncoding() == floatPCM23) + { + if(GetEndianness() == littleEndian) + { + bytesRead = CopyMonoSample + (sample, sourceBuf, fileSize, + SC::ConversionChain<SC::Convert<int16, float32>, SC::DecodeScaledFloat32<littleEndian32> > + (SC::Convert<int16, float32>(), SC::DecodeScaledFloat32<littleEndian32>(1.0f / static_cast<float>(1<<23))) + ); + } else + { + bytesRead = CopyMonoSample + (sample, sourceBuf, fileSize, + SC::ConversionChain<SC::Convert<int16, float32>, SC::DecodeScaledFloat32<bigEndian32> > + (SC::Convert<int16, float32>(), SC::DecodeScaledFloat32<bigEndian32>(1.0f / static_cast<float>(1<<23))) + ); + } + } + + ////////////////////////////////////////////////////// + // 32-Bit / Float / Stereo Interleaved / PCM / full scale 2^23 + else if(GetBitDepth() == 32 && GetChannelFormat() == stereoInterleaved && GetEncoding() == floatPCM23) + { + if(GetEndianness() == littleEndian) + { + bytesRead = CopyStereoInterleavedSample + (sample, sourceBuf, fileSize, + SC::ConversionChain<SC::Convert<int16, float32>, SC::DecodeScaledFloat32<littleEndian32> > + (SC::Convert<int16, float32>(), SC::DecodeScaledFloat32<littleEndian32>(1.0f / static_cast<float>(1<<23))) + ); + } else + { + bytesRead = CopyStereoInterleavedSample + (sample, sourceBuf, fileSize, + SC::ConversionChain<SC::Convert<int16, float32>, SC::DecodeScaledFloat32<bigEndian32> > + (SC::Convert<int16, float32>(), SC::DecodeScaledFloat32<bigEndian32>(1.0f / static_cast<float>(1<<23))) + ); + } + } + + ////////////////////////////////////////////////////// // Compressed samples if(*this == SampleIO(_8bit, mono, littleEndian, ADPCM)) { Modified: trunk/OpenMPT/soundlib/SampleIO.h =================================================================== --- trunk/OpenMPT/soundlib/SampleIO.h 2013-07-13 15:48:20 UTC (rev 2537) +++ trunk/OpenMPT/soundlib/SampleIO.h 2013-07-13 15:59:38 UTC (rev 2538) @@ -66,19 +66,23 @@ // Sample encoding enum Encoding { - signedPCM = 0, // Integer PCM, signed - unsignedPCM, // Integer PCM, unsigned - deltaPCM, // Integer PCM, delta-encoded - floatPCM, // Floating point PCM - IT214, // Impulse Tracker 2.14 compressed - IT215, // Impulse Tracker 2.15 compressed - AMS, // AMS / Velvet Studio packed - DMF, // DMF Huffman compression - MDL, // MDL Huffman compression - PTM8Dto16, // PTM 8-Bit delta value -> 16-Bit sample - PCM7to8, // 8-Bit sample data with unused high bit - ADPCM, // 4-Bit ADPCM-packed - MT2, // MadTracker 2 stereo delta encoding + signedPCM = 0, // Integer PCM, signed + unsignedPCM, // Integer PCM, unsigned + deltaPCM, // Integer PCM, delta-encoded + floatPCM, // Floating point PCM + IT214, // Impulse Tracker 2.14 compressed + IT215, // Impulse Tracker 2.15 compressed + AMS, // AMS / Velvet Studio packed + DMF, // DMF Huffman compression + MDL, // MDL Huffman compression + PTM8Dto16, // PTM 8-Bit delta value -> 16-Bit sample + PCM7to8, // 8-Bit sample data with unused high bit + ADPCM, // 4-Bit ADPCM-packed + MT2, // MadTracker 2 stereo delta encoding + floatPCM15, // Floating point PCM with 2^15 full scale + floatPCM23, // Floating point PCM with 2^23 full scale + floatPCMnormalize, // Floating point PCM and data will be normalized while reading + signedPCMnormalize, // Integer PCM and data will be normalized while reading }; SampleIO(Bitdepth bits = _8bit, Channels channels = mono, Endianness endianness = littleEndian, Encoding encoding = signedPCM) @@ -117,6 +121,20 @@ format = (format & ~encodingMask) | (encoding << encodingOffset); } + void MayNormalize() + { + if(GetBitDepth() == 24 || GetBitDepth() == 32) + { + if(GetEncoding() == SampleIO::signedPCM) + { + (*this) |= SampleIO::signedPCMnormalize; + } else if(GetEncoding() == SampleIO::floatPCM) + { + (*this) |= SampleIO::floatPCMnormalize; + } + } + } + // Get bits per sample uint8 GetBitDepth() const { Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-07-13 15:48:20 UTC (rev 2537) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-07-13 15:59:38 UTC (rev 2538) @@ -784,11 +784,11 @@ static void AdjustSampleLoop(ModSample &sample); // Samples file I/O - bool ReadSampleFromFile(SAMPLEINDEX nSample, FileReader &file); - bool ReadWAVSample(SAMPLEINDEX nSample, FileReader &file, FileReader *wsmpChunk = nullptr); + bool ReadSampleFromFile(SAMPLEINDEX nSample, FileReader &file, bool mayNormalize=false); + bool ReadWAVSample(SAMPLEINDEX nSample, FileReader &file, bool mayNormalize=false, FileReader *wsmpChunk = nullptr); bool ReadPATSample(SAMPLEINDEX nSample, const LPBYTE lpMemFile, DWORD dwFileLength); bool ReadS3ISample(SAMPLEINDEX nSample, FileReader &file); - bool ReadAIFFSample(SAMPLEINDEX nSample, FileReader &file); + bool ReadAIFFSample(SAMPLEINDEX nSample, FileReader &file, bool mayNormalize=false); bool ReadXISample(SAMPLEINDEX nSample, FileReader &file); bool ReadITSSample(SAMPLEINDEX nSample, FileReader &file, bool rewind = true); bool ReadITISample(SAMPLEINDEX nSample, FileReader &file); @@ -802,11 +802,11 @@ #endif // Instrument file I/O - bool ReadInstrumentFromFile(INSTRUMENTINDEX nInstr, const LPBYTE lpMemFile, DWORD dwFileLength); + bool ReadInstrumentFromFile(INSTRUMENTINDEX nInstr, const LPBYTE lpMemFile, DWORD dwFileLength, bool mayNormalize=false); bool ReadXIInstrument(INSTRUMENTINDEX nInstr, FileReader &file); bool ReadITIInstrument(INSTRUMENTINDEX nInstr, FileReader &file); bool ReadPATInstrument(INSTRUMENTINDEX nInstr, const LPBYTE lpMemFile, DWORD dwFileLength); - bool ReadSampleAsInstrument(INSTRUMENTINDEX nInstr, FileReader &file); + bool ReadSampleAsInstrument(INSTRUMENTINDEX nInstr, FileReader &file, bool mayNormalize=false); #ifndef MODPLUG_NO_FILESAVE bool SaveXIInstrument(INSTRUMENTINDEX nInstr, const LPCSTR lpszFileName) const; bool SaveITIInstrument(INSTRUMENTINDEX nInstr, const LPCSTR lpszFileName, bool compress) const; Modified: trunk/OpenMPT/soundlib/WAVTools.cpp =================================================================== --- trunk/OpenMPT/soundlib/WAVTools.cpp 2013-07-13 15:48:20 UTC (rev 2537) +++ trunk/OpenMPT/soundlib/WAVTools.cpp 2013-07-13 15:59:38 UTC (rev 2538) @@ -24,6 +24,8 @@ RIFFHeader fileHeader; isDLS = false; + extFormat = 0; + mayBeCoolEdit16_8 = false; if(!file.ReadConvertEndianness(fileHeader) || (fileHeader.magic != RIFFHeader::idRIFF && fileHeader.magic != RIFFHeader::idLIST) || (fileHeader.type != RIFFHeader::idWAVE && fileHeader.type != RIFFHeader::idwave)) @@ -62,14 +64,24 @@ { return; } - if(formatInfo.format == WAVFormatChunk::fmtExtensible) + if(formatInfo.format == WAVFormatChunk::fmtPCM && formatChunk.BytesLeft() == 4) { + uint16 size = formatChunk.ReadIntLE<uint16>(); + uint16 value = formatChunk.ReadIntLE<uint16>(); + if(size == 2 && value == 1) + { + // May be Cool Edit 16.8 format. + // See SampleFormats.cpp for details. + mayBeCoolEdit16_8 = true; + } + } else if(formatInfo.format == WAVFormatChunk::fmtExtensible) + { WAVFormatChunkExtension extFormat; if(!formatChunk.ReadConvertEndianness(extFormat)) { return; } - formatInfo.format = extFormat.subFormat; + this->extFormat = extFormat.subFormat; } // Read sample data @@ -87,8 +99,17 @@ if((formatInfo.format != WAVFormatChunk::fmtIMA_ADPCM || sampleLength == 0) && GetSampleSize() != 0) { - // Some samples have an incorrect blockAlign / sample size set (e.g. it's 8 in SQUARE.WAV while it should be 1), so let's better not trust this value. - sampleLength = sampleData.GetLength() / GetSampleSize(); + if((GetBlockAlign() == 0) || (GetBlockAlign() / GetNumChannels() >= 2 * GetSampleSize())) + { + // Some samples have an incorrect blockAlign / sample size set (e.g. it's 8 in SQUARE.WAV while it should be 1), so let's better not always trust this value. + // The idea here is, if block align is off by twice or more, it is unlikely to be describing sample padding inside the block. + // Ignore it in this case and calculate the length based on the single sample size and number of channels instead. + sampleLength = sampleData.GetLength() / GetSampleSize(); + } else + { + // Correct case (so that 20bit WAVEFORMATEX files work). + sampleLength = sampleData.GetLength() / GetBlockAlign(); + } } // Check for loop points, texts, etc... Modified: trunk/OpenMPT/soundlib/WAVTools.h =================================================================== --- trunk/OpenMPT/soundlib/WAVTools.h 2013-07-13 15:48:20 UTC (rev 2537) +++ trunk/OpenMPT/soundlib/WAVTools.h 2013-07-13 15:59:38 UTC (rev 2538) @@ -334,6 +334,8 @@ FileReader::off_t sampleLength; bool isDLS; WAVFormatChunk formatInfo; + uint16 extFormat; + bool mayBeCoolEdit16_8; public: WAVReader(FileReader &inputFile); @@ -343,13 +345,15 @@ void FindMetadataChunks(ChunkReader::ChunkList<RIFFChunk> &chunks); // Self-explanatory getters. - WAVFormatChunk::SampleFormats GetSampleFormat() const { return static_cast<WAVFormatChunk::SampleFormats>(formatInfo.format); } + WAVFormatChunk::SampleFormats GetSampleFormat() const { return IsExtensibleFormat() ? static_cast<WAVFormatChunk::SampleFormats>(extFormat) : static_cast<WAVFormatChunk::SampleFormats>(formatInfo.format); } uint16 GetNumChannels() const { return formatInfo.numChannels; } uint16 GetBitsPerSample() const { return formatInfo.bitsPerSample; } uint32 GetSampleRate() const { return formatInfo.sampleRate; } uint16 GetBlockAlign() const { return formatInfo.blockAlign; } FileReader GetSampleData() const { return sampleData; } FileReader GetWsmpChunk() const { return wsmpChunk; } + bool IsExtensibleFormat() const { return formatInfo.format == WAVFormatChunk::fmtExtensible; } + bool MayBeCoolEdit16_8() const { return mayBeCoolEdit16_8; } // Get size of a single sample point, in bytes. uint16 GetSampleSize() const { return ((GetNumChannels() * GetBitsPerSample()) + 7) / 8; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-07-20 15:42:48
|
Revision: 2540 http://sourceforge.net/p/modplug/code/2540 Author: saga-games Date: 2013-07-20 15:42:35 +0000 (Sat, 20 Jul 2013) Log Message: ----------- [New] Added option to ignore certain MIDI CCs in CC to pattern functionality [Fix] Revision 2494 (pattern editor crash) was missing some lines of code to actually fix the issue. [Mod] OpenMPT: Version is now 1.22.03.11 Revision Links: -------------- http://sourceforge.net/p/modplug/code/2494 Modified Paths: -------------- trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/mptrack.rc Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2013-07-13 17:33:15 UTC (rev 2539) +++ trunk/OpenMPT/common/misc_util.h 2013-07-20 15:42:35 UTC (rev 2540) @@ -35,6 +35,9 @@ else return o.str(); } +template<> inline std::string Stringify(const signed char& x) { return Stringify((signed int)x); } +template<> inline std::string Stringify(const unsigned char& x) { return Stringify((unsigned int)x); } + //Convert string to number. template<class T> inline T ConvertStrTo(const char *str) @@ -95,7 +98,7 @@ // Saturate the value of src to the domain of Tdst template <typename Tdst, typename Tsrc> inline Tdst saturate_cast(Tsrc src) -//------------------------------------- +//--------------------------------- { // This code tries not only to obviously avoid overflows but also to avoid signed/unsigned comparison warnings and type truncation warnings (which in fact would be safe here) by explicit casting. STATIC_ASSERT(std::numeric_limits<Tdst>::is_integer); Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2013-07-13 17:33:15 UTC (rev 2539) +++ trunk/OpenMPT/common/versionNumber.h 2013-07-20 15:42:35 UTC (rev 2540) @@ -17,7 +17,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 22 #define VER_MINOR 03 -#define VER_MINORMINOR 10 +#define VER_MINORMINOR 11 //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/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-07-13 17:33:15 UTC (rev 2539) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-07-20 15:42:35 UTC (rev 2540) @@ -1153,6 +1153,7 @@ ON_COMMAND(IDC_MIDIPLAYCONTROL, OnSettingsChanged) ON_COMMAND(IDC_MIDIPLAYPATTERNONMIDIIN, OnSettingsChanged) ON_EN_CHANGE(IDC_EDIT3, OnSettingsChanged) + ON_EN_CHANGE(IDC_EDIT4, OnSettingsChanged) END_MESSAGE_MAP() @@ -1226,6 +1227,8 @@ SetDlgItemInt(IDC_EDIT3, TrackerSettings::Instance().midiVelocityAmp); m_SpinAmp.SetRange(1, 10000); + SetDlgItemText(IDC_EDIT4, TrackerSettings::Instance().IgnoredCCsToString().c_str()); + // Midi Import settings SetDlgItemInt(IDC_EDIT1, TrackerSettings::Instance().midiImportSpeed); SetDlgItemInt(IDC_EDIT2, TrackerSettings::Instance().midiImportPatternLen); @@ -1262,6 +1265,11 @@ TrackerSettings::Instance().midiImportSpeed = GetDlgItemInt(IDC_EDIT1); TrackerSettings::Instance().midiImportPatternLen = GetDlgItemInt(IDC_EDIT2); TrackerSettings::Instance().midiVelocityAmp = static_cast<uint16>(Clamp(GetDlgItemInt(IDC_EDIT3), 1u, 10000u)); + + CString cc; + GetDlgItemText(IDC_EDIT4, cc); + TrackerSettings::Instance().ParseIgnoredCCs(cc); + if (pMainFrm) pMainFrm->SetupMidi(m_dwMidiSetup, m_nMidiDevice); CPropertyPage::OnOK(); } Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-07-13 17:33:15 UTC (rev 2539) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-07-20 15:42:35 UTC (rev 2540) @@ -425,6 +425,7 @@ m_MixerSettings.glVolumeRampUpSamples = CMainFrame::GetPrivateProfileLong("Sound Settings", "VolumeRampUpSamples", m_MixerSettings.glVolumeRampUpSamples, iniFile); m_MixerSettings.glVolumeRampDownSamples = CMainFrame::GetPrivateProfileLong("Sound Settings", "VolumeRampDownSamples", m_MixerSettings.glVolumeRampDownSamples, iniFile); + // MIDI Setup m_dwMidiSetup = CMainFrame::GetPrivateProfileDWord("MIDI Settings", "MidiSetup", m_dwMidiSetup, iniFile); m_nMidiDevice = CMainFrame::GetPrivateProfileDWord("MIDI Settings", "MidiDevice", m_nMidiDevice, iniFile); aftertouchBehaviour = static_cast<RecordAftertouchOptions>(CMainFrame::GetPrivateProfileDWord("MIDI Settings", "AftertouchBehaviour", aftertouchBehaviour, iniFile)); @@ -437,6 +438,7 @@ midiVelocityAmp = 200; m_dwMidiSetup &= ~0x40; } + ParseIgnoredCCs(CMainFrame::GetPrivateProfileCString("MIDI Settings", "IgnoredCCs", "", iniFile)); m_dwPatternSetup = CMainFrame::GetPrivateProfileDWord("Pattern Editor", "PatternSetup", m_dwPatternSetup, iniFile); if(vIniVersion < MAKE_VERSION_NUMERIC(1, 17, 02, 50)) @@ -852,12 +854,14 @@ CMainFrame::WritePrivateProfileLong("Sound Settings", "VolumeRampUpSamples", m_MixerSettings.glVolumeRampUpSamples, iniFile); CMainFrame::WritePrivateProfileLong("Sound Settings", "VolumeRampDownSamples", m_MixerSettings.glVolumeRampDownSamples, iniFile); + // MIDI Settings CMainFrame::WritePrivateProfileDWord("MIDI Settings", "MidiSetup", m_dwMidiSetup, iniFile); CMainFrame::WritePrivateProfileDWord("MIDI Settings", "MidiDevice", m_nMidiDevice, iniFile); CMainFrame::WritePrivateProfileDWord("MIDI Settings", "AftertouchBehaviour", aftertouchBehaviour, iniFile); CMainFrame::WritePrivateProfileLong("MIDI Settings", "MidiVelocityAmp", midiVelocityAmp, iniFile); CMainFrame::WritePrivateProfileLong("MIDI Settings", "MidiImportSpeed", midiImportSpeed, iniFile); CMainFrame::WritePrivateProfileLong("MIDI Settings", "MidiImportPatLen", midiImportPatternLen, iniFile); + WritePrivateProfileString("MIDI Settings", "IgnoredCCs", IgnoredCCsToString().c_str(), iniFile); CMainFrame::WritePrivateProfileDWord("Pattern Editor", "PatternSetup", m_dwPatternSetup, iniFile); CMainFrame::WritePrivateProfileDWord("Pattern Editor", "RowSpacing", m_nRowHighlightMeasures, iniFile); @@ -989,6 +993,43 @@ } +std::string TrackerSettings::IgnoredCCsToString() const +//----------------------------------------------------- +{ + std::string cc; + bool first = true; + for(int i = 0; i < 128; i++) + { + if(midiIgnoreCCs[i]) + { + if(!first) + { + cc += ","; + } + cc += Stringify(i); + first = false; + } + } + return cc; +} + + +void TrackerSettings::ParseIgnoredCCs(CString cc) +//----------------------------------------------- +{ + midiIgnoreCCs.reset(); + int curPos = 0; + CString ccToken= cc.Tokenize(_T(", "), curPos); + while(ccToken != _T("")) + { + int ccNumber = ConvertStrTo<int>(ccToken); + if(ccNumber >= 0 && ccNumber <= 127) + midiIgnoreCCs.set(ccNumber); + ccToken = cc.Tokenize(_T(", "), curPos); + }; +} + + // retrieve / set default directory from given string and store it our setup variables void TrackerSettings::SetDirectory(const LPCTSTR szFilenameFrom, Directory dir, TCHAR (&directories)[NUM_DIRS][_MAX_PATH], bool bStripFilename) //--------------------------------------------------------------------------------------------------------------------------------------------- Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2013-07-13 17:33:15 UTC (rev 2539) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2013-07-20 15:42:35 UTC (rev 2540) @@ -16,6 +16,7 @@ #include "../sounddsp/EQ.h" #include "../sounddsp/DSP.h" #include "../sounddsp/Reverb.h" +#include <bitset> ///////////////////////////////////////////////////////////////////////// // Default directories @@ -198,6 +199,7 @@ DWORD m_dwMidiSetup; RecordAftertouchOptions aftertouchBehaviour; uint16 midiVelocityAmp; + std::bitset<128> midiIgnoreCCs; // Pattern Setup UINT gnPatternSpacing; @@ -270,6 +272,9 @@ // Get settings object singleton static TrackerSettings &Instance() { return settings; } + std::string IgnoredCCsToString() const; + void ParseIgnoredCCs(CString cc); + protected: void LoadINISettings(const CString &iniFile); Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2013-07-13 17:33:15 UTC (rev 2539) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2013-07-20 15:42:35 UTC (rev 2540) @@ -1361,6 +1361,7 @@ { UpdateScrollSize(); InvalidatePattern(true); + SanitizeCursor(); } } } @@ -3288,6 +3289,7 @@ { InvalidatePattern(true); } + SanitizeCursor(); } } } @@ -3855,7 +3857,10 @@ // Checking whether to record MIDI controller change as MIDI macro change. // Don't write this if command was already written by MIDI mapping. - if((paramValue == uint8_max || sndFile.GetType() != MOD_TYPE_MPT) && IsEditingEnabled() && (TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_MIDIMACROCONTROL)) + if((paramValue == uint8_max || sndFile.GetType() != MOD_TYPE_MPT) + && IsEditingEnabled() + && (TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_MIDIMACROCONTROL) + && !TrackerSettings::Instance().midiIgnoreCCs[nByte1 & 0x7F]) { const bool liveRecord = IsLiveRecord(); Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2013-07-13 17:33:15 UTC (rev 2539) +++ trunk/OpenMPT/mptrack/mptrack.rc 2013-07-20 15:42:35 UTC (rev 2540) @@ -568,7 +568,7 @@ GROUPBOX "Colour Presets",IDC_STATIC,6,234,264,42 END -IDD_OPTIONS_MIDI DIALOGEX 0, 0, 272, 281 +IDD_OPTIONS_MIDI DIALOGEX 0, 0, 272, 269 STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "MIDI" FONT 8, "MS Shell Dlg", 0, 0, 0x0 @@ -585,7 +585,7 @@ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,84,237,12 CONTROL "Pass MIDI to active instrument plugin",IDC_MIDI_TO_PLUGIN, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,96,237,12 - GROUPBOX "MIDI Recording - Volume and Controllers",IDC_STATIC,6,120,258,78 + GROUPBOX "MIDI Recording - Volume and Controllers",IDC_STATIC,6,120,258,90 CONTROL "Record MIDI Note Velocity, amplify by",IDC_CHECK1, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,138,144,10 EDITTEXT IDC_EDIT3,162,137,42,12,ES_AUTOHSCROLL | ES_NUMBER @@ -595,15 +595,17 @@ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,150,237,12 CONTROL "Record MIDI Controller changes as MIDI Macro changes in pattern",IDC_MIDI_MACRO_CONTROL, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,162,237,12 - LTEXT "Record Aftertouch Messages",IDC_STATIC,30,174,108,12,SS_CENTERIMAGE - COMBOBOX IDC_COMBO2,138,174,120,12,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - GROUPBOX "MIDI File Import",IDC_STATIC,6,204,260,36 - LTEXT "Speed:",IDC_STATIC,18,222,24,8 - EDITTEXT IDC_EDIT1,48,220,39,12,ES_AUTOHSCROLL | ES_NUMBER - CONTROL "Spin1",IDC_SPIN1,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_NOTHOUSANDS,78,222,11,14 - LTEXT "Pattern Size:",IDC_STATIC,102,222,56,8 - EDITTEXT IDC_EDIT2,156,220,39,12,ES_AUTOHSCROLL | ES_NUMBER - CONTROL "Spin1",IDC_SPIN2,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_NOTHOUSANDS,180,222,11,14 + LTEXT "Ignore CCs (e.g. 1,123,127)",IDC_STATIC,30,176,108,8 + EDITTEXT IDC_EDIT4,138,174,120,12,ES_AUTOHSCROLL + LTEXT "Record Aftertouch Messages",IDC_STATIC,30,192,108,12,SS_CENTERIMAGE + COMBOBOX IDC_COMBO2,138,192,120,12,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + GROUPBOX "MIDI File Import",IDC_STATIC,6,216,260,36 + LTEXT "Speed:",IDC_STATIC,18,234,24,8 + EDITTEXT IDC_EDIT1,48,232,39,12,ES_AUTOHSCROLL | ES_NUMBER + CONTROL "Spin1",IDC_SPIN1,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_NOTHOUSANDS,78,234,11,14 + LTEXT "Pattern Size:",IDC_STATIC,102,234,56,8 + EDITTEXT IDC_EDIT2,156,232,39,12,ES_AUTOHSCROLL | ES_NUMBER + CONTROL "Spin1",IDC_SPIN2,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_NOTHOUSANDS,180,234,11,14 END IDD_LOADRAWSAMPLE DIALOGEX 0, 0, 178, 95 @@ -1634,7 +1636,7 @@ IDD_OPTIONS_MIDI, DIALOG BEGIN RIGHTMARGIN, 240 - BOTTOMMARGIN, 278 + BOTTOMMARGIN, 266 END IDD_LOADRAWSAMPLE, DIALOG This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-07-21 12:51:30
|
Revision: 2545 http://sourceforge.net/p/modplug/code/2545 Author: saga-games Date: 2013-07-21 12:51:21 +0000 (Sun, 21 Jul 2013) Log Message: ----------- [Fix] In compatible and "old random variation" mode, pan swing was not applied if the same instrument also had a panning envelope. [Fix] Pitch / Pan separation wasn't applied if the channel was panned way to the left. [Mod] OpenMPT: Version is now 1.22.03.12 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2013-07-20 23:02:23 UTC (rev 2544) +++ trunk/OpenMPT/common/versionNumber.h 2013-07-21 12:51:21 UTC (rev 2545) @@ -17,7 +17,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 22 #define VER_MINOR 03 -#define VER_MINORMINOR 11 +#define VER_MINORMINOR 12 //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/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-07-20 23:02:23 UTC (rev 2544) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-07-21 12:51:21 UTC (rev 2545) @@ -2236,7 +2236,7 @@ // Previously the values were just added up, so let's fix this! m.volcmd = VOLCMD_NONE; const uint16 param = static_cast<uint16>(m.param) + static_cast<uint16>(m.vol << 4); - m.param = static_cast<uint8>(std::min(param, uint16(0xFF))); + m.param = mpt::saturate_cast<uint8>(param); } } @@ -2303,10 +2303,13 @@ { bool instrPlugs = false; // Old pitch wheel commands were closest to sample pitch bend commands if the PWD is 13. - for(INSTRUMENTINDEX i = 1; i <= GetNumInstruments(); i++) if(Instruments[i] != nullptr && Instruments[i]->nMidiChannel != MidiNoChannel) + for(INSTRUMENTINDEX i = 1; i <= GetNumInstruments(); i++) { - Instruments[i]->midiPWD = 13; - instrPlugs = true; + if(Instruments[i] != nullptr && Instruments[i]->nMidiChannel != MidiNoChannel) + { + Instruments[i]->midiPWD = 13; + instrPlugs = true; + } } if(instrPlugs) { @@ -2314,5 +2317,21 @@ } } + if(m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 22, 03, 12) + && m_dwLastSavedWithVersion != MAKE_VERSION_NUMERIC(1, 22, 00, 00) + && (GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) + && (IsCompatibleMode(TRK_IMPULSETRACKER) || GetModFlag(MSF_OLDVOLSWING))) + { + // The "correct" pan swing implementation did nothing if the instrument also had a pan envelope. + // If there's a pan envelope, disable pan swing for such modules. + for(INSTRUMENTINDEX i = 1; i <= GetNumInstruments(); i++) + { + if(Instruments[i] != nullptr && Instruments[i]->nPanSwing != 0 && Instruments[i]->PanEnv.dwFlags[ENV_ENABLED]) + { + Instruments[i]->nPanSwing = 0; + } + } + } + Patterns.ForEachModCommand(UpgradePatternData(*this)); } \ No newline at end of file Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-07-20 23:02:23 UTC (rev 2544) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-07-21 12:51:21 UTC (rev 2545) @@ -939,7 +939,7 @@ // Get values in [-32, 32] const int envval = Util::Round<int>((pIns->PanEnv.GetValueFromPosition(envpos) - 0.5f) * 64.0f); - int pan = pChn->nPan; + int pan = pChn->nRealPan; if(pan >= 128) { pan += (envval * (256 - pan)) / 32; @@ -1160,7 +1160,7 @@ { const ModInstrument *pIns = pChn->pModInstrument; - if ((pIns->nPPS) && (pChn->nRealPan) && (pChn->nNote)) + if ((pIns->nPPS) && (pChn->nNote != NOTE_NONE)) { // PPS value is 1/512, i.e. PPS=1 will adjust by 8/512 = 1/64 for each 8 semitones // with PPS = 32 / PPC = C-5, E-6 will pan hard right (and D#6 will not) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-07-28 17:09:43
|
Revision: 2549 http://sourceforge.net/p/modplug/code/2549 Author: manxorist Date: 2013-07-28 17:09:33 +0000 (Sun, 28 Jul 2013) Log Message: ----------- [Ref] Calculate stereo vu meters also in libopenmpt and remove #define ENABLE_STEREOVU. [Ref] Remove unused ModChannel::nVUMeter. [New] libopenmpt: Add stereo vu meters per channel. [New] libopenmpt: Add functions to format each pattern cell as a string of given length. [Ref] xmp-openmpt: Improve pattern display (still disabled because it is still too slow). [New] openmpt123: Add channel peak meters. [Imp] openmpt123: Make terminal width user-overridable. Modified Paths: -------------- trunk/OpenMPT/libopenmpt/libopenmpt.h trunk/OpenMPT/libopenmpt/libopenmpt.hpp trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp trunk/OpenMPT/openmpt123/openmpt123.cpp trunk/OpenMPT/openmpt123/openmpt123.hpp trunk/OpenMPT/soundlib/ModChannel.h trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/libopenmpt/libopenmpt.h =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.h 2013-07-28 14:28:52 UTC (rev 2548) +++ trunk/OpenMPT/libopenmpt/libopenmpt.h 2013-07-28 17:09:33 UTC (rev 2549) @@ -114,6 +114,9 @@ LIBOPENMPT_API int32_t openmpt_module_get_current_row( openmpt_module * mod ); LIBOPENMPT_API int32_t openmpt_module_get_current_playing_channels( openmpt_module * mod ); +LIBOPENMPT_API float openmpt_module_get_current_channel_vu_left( openmpt_module * mod, int32_t channel ); +LIBOPENMPT_API float openmpt_module_get_current_channel_vu_right( openmpt_module * mod, int32_t channel ); + LIBOPENMPT_API int32_t openmpt_module_get_num_subsongs( openmpt_module * mod ); LIBOPENMPT_API int32_t openmpt_module_get_num_channels( openmpt_module * mod ); LIBOPENMPT_API int32_t openmpt_module_get_num_orders( openmpt_module * mod ); @@ -133,6 +136,9 @@ LIBOPENMPT_API uint8_t openmpt_module_get_pattern_row_channel_command( openmpt_module * mod, int32_t pattern, int32_t row, int32_t channel, int command ); +LIBOPENMPT_API const char * openmpt_module_format_pattern_row_channel( openmpt_module * mod, int32_t pattern, int32_t row, int32_t channel, size_t width, int pad ); +LIBOPENMPT_API const char * openmpt_module_highlight_pattern_row_channel( openmpt_module * mod, int32_t pattern, int32_t row, int32_t channel, size_t width, int pad ); + LIBOPENMPT_API const char * openmpt_module_get_ctls( openmpt_module * mod ); LIBOPENMPT_API const char * openmpt_module_ctl_get( openmpt_module * mod, const char * ctl ); LIBOPENMPT_API int openmpt_module_ctl_set( openmpt_module * mod, const char * ctl, const char * value ); Modified: trunk/OpenMPT/libopenmpt/libopenmpt.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2013-07-28 14:28:52 UTC (rev 2548) +++ trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2013-07-28 17:09:33 UTC (rev 2549) @@ -155,6 +155,9 @@ std::int32_t get_current_row() const; std::int32_t get_current_playing_channels() const; + float get_current_channel_vu_left( std::int32_t channel ) const; + float get_current_channel_vu_right( std::int32_t channel ) const; + std::int32_t get_num_subsongs() const; std::int32_t get_num_channels() const; std::int32_t get_num_orders() const; @@ -175,6 +178,9 @@ std::uint8_t get_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const; + std::string format_pattern_row_channel( std::int32_t pattern, std::int32_t row, std::int32_t channel, std::size_t width = 0, bool pad = true ) const; + std::string highlight_pattern_row_channel( std::int32_t pattern, std::int32_t row, std::int32_t channel, std::size_t width = 0, bool pad = true ) const; + std::vector<std::string> get_ctls() const; std::string ctl_get( const std::string & ctl ) const; Modified: trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp 2013-07-28 14:28:52 UTC (rev 2548) +++ trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp 2013-07-28 17:09:33 UTC (rev 2549) @@ -560,6 +560,21 @@ return 0; } +LIBOPENMPT_API float openmpt_module_get_current_channel_vu_left( openmpt_module * mod, int32_t channel ) { + try { + OPENMPT_INTERFACE_CHECK_SOUNDFILE( mod ); + return mod->impl->get_current_channel_vu_left( channel ); + } OPENMPT_INTERFACE_CATCH_TO_LOG; + return 0.0; +} +LIBOPENMPT_API float openmpt_module_get_current_channel_vu_right( openmpt_module * mod, int32_t channel ) { + try { + OPENMPT_INTERFACE_CHECK_SOUNDFILE( mod ); + return mod->impl->get_current_channel_vu_right( channel ); + } OPENMPT_INTERFACE_CATCH_TO_LOG; + return 0.0; +} + LIBOPENMPT_API int32_t openmpt_module_get_num_subsongs( openmpt_module * mod ) { try { OPENMPT_INTERFACE_CHECK_SOUNDFILE( mod ); @@ -712,6 +727,22 @@ return 0; } +LIBOPENMPT_API const char * openmpt_module_format_pattern_row_channel( openmpt_module * mod, int32_t pattern, int32_t row, int32_t channel, size_t width, int pad ) { + try { + OPENMPT_INTERFACE_CHECK_SOUNDFILE( mod ); + return openmpt::strdup( mod->impl->format_pattern_row_channel( pattern, row, channel, width, pad ? true : false ).c_str() ); + } OPENMPT_INTERFACE_CATCH_TO_LOG; + return 0; +} + +LIBOPENMPT_API const char * openmpt_module_highlight_pattern_row_channel( openmpt_module * mod, int32_t pattern, int32_t row, int32_t channel, size_t width, int pad ) { + try { + OPENMPT_INTERFACE_CHECK_SOUNDFILE( mod ); + return openmpt::strdup( mod->impl->highlight_pattern_row_channel( pattern, row, channel, width, pad ? true : false ).c_str() ); + } OPENMPT_INTERFACE_CATCH_TO_LOG; + return 0; +} + const char * openmpt_module_get_ctls( openmpt_module * mod ) { try { OPENMPT_INTERFACE_CHECK_SOUNDFILE( mod ); Modified: trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp 2013-07-28 14:28:52 UTC (rev 2548) +++ trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp 2013-07-28 17:09:33 UTC (rev 2549) @@ -211,6 +211,13 @@ return impl->get_current_playing_channels(); } +float module::get_current_channel_vu_left( std::int32_t channel ) const { + return impl->get_current_channel_vu_left( channel ); +} +float module::get_current_channel_vu_right( std::int32_t channel ) const { + return impl->get_current_channel_vu_right( channel ); +} + std::int32_t module::get_num_subsongs() const { return impl->get_num_subsongs(); } @@ -260,6 +267,13 @@ return impl->get_pattern_row_channel_command( pattern, row, channel, command ); } +std::string module::format_pattern_row_channel( std::int32_t pattern, std::int32_t row, std::int32_t channel, std::size_t width, bool pad ) const { + return impl->format_pattern_row_channel( pattern, row, channel, width, pad ); +} +std::string module::highlight_pattern_row_channel( std::int32_t pattern, std::int32_t row, std::int32_t channel, std::size_t width, bool pad ) const { + return impl->highlight_pattern_row_channel( pattern, row, channel, width, pad ); +} + std::vector<std::string> module::get_ctls() const { return impl->get_ctls(); } Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-07-28 14:28:52 UTC (rev 2548) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-07-28 17:09:33 UTC (rev 2549) @@ -590,6 +590,7 @@ } return ""; } + std::int32_t module_impl::get_current_speed() const { return m_sndFile->m_nMusicSpeed; } @@ -608,6 +609,19 @@ std::int32_t module_impl::get_current_playing_channels() const { return m_sndFile->m_nMixChannels; } +float module_impl::get_current_channel_vu_left( std::int32_t channel ) const { + if ( channel < 0 || channel >= m_sndFile->GetNumChannels() ) { + return 0.0f; + } + return m_sndFile->Chn[channel].nLeftVU * (1.0f/128.0f); +} +float module_impl::get_current_channel_vu_right( std::int32_t channel ) const { + if ( channel < 0 || channel >= m_sndFile->GetNumChannels() ) { + return 0.0f; + } + return m_sndFile->Chn[channel].nRightVU * (1.0f/128.0f); +} + std::int32_t module_impl::get_num_subsongs() const { return m_sndFile->Order.GetNumSequences(); } @@ -719,6 +733,65 @@ return 0; } +std::pair< std::string, std::string > module_impl::format_and_highlight_pattern_row_channel( std::int32_t p, std::int32_t r, std::int32_t c, std::size_t width, bool pad ) const { + std::string text = pad ? std::string( width, ' ' ) : std::string(); + std::string high = pad ? std::string( width, ' ' ) : std::string(); + const CHANNELINDEX numchannels = m_sndFile->GetNumChannels(); + if ( p < 0 || p >= m_sndFile->Patterns.Size() ) { + return std::make_pair( text, high ); + } + if ( r < 0 || r >= (std::int32_t)m_sndFile->Patterns[p].GetNumRows() ) { + return std::make_pair( text, high ); + } + if ( c < 0 || c >= numchannels ) { + return std::make_pair( text, high ); + } + if ( width == 0 ) { + return std::make_pair( text, high ); + } + // 0000000001111 + // 1234567890123 + // "NNN IIvVV EFF" + const ModCommand cell = m_sndFile->Patterns[p][r*numchannels+c]; + text.clear(); + high.clear(); + text += cell.IsNote() ? m_sndFile->GetNoteName( cell.note, cell.instr ) : std::string("..."); + high += cell.IsNote() ? std::string("nnn") : std::string("..."); + if ( width >= 6 ) { + text += std::string(" "); + high += std::string(" "); + text += cell.instr ? mpt::String::Format( "%02X", cell.instr ) : std::string(".."); + high += cell.instr ? std::string("ii") : std::string(".."); + } + if ( width >= 9 ) { + text += cell.IsPcNote() ? mpt::String::Format( " %02X", cell.GetValueVolCol() & 0xff ) : cell.volcmd != VOLCMD_NONE ? mpt::String::Format( "%1c%02X", m_sndFile->GetModSpecifications().GetVolEffectLetter( cell.volcmd ), cell.vol ) : std::string(" .."); + high += cell.IsPcNote() ? std::string(" vv") : cell.volcmd != VOLCMD_NONE ? std::string("wvv") : std::string(" .."); + } + if ( width >= 13 ) { + text += std::string(" "); + high += std::string(" "); + text += cell.IsPcNote() ? mpt::String::Format( "%03X", cell.GetValueEffectCol() & 0x0fff ) : cell.command != CMD_NONE ? mpt::String::Format( "%1c%02X", m_sndFile->GetModSpecifications().GetEffectLetter( cell.command ), cell.param ) : std::string("..."); + high += cell.IsPcNote() ? std::string("eff") : cell.command != CMD_NONE ? std::string("eff") : std::string("..."); + } + if ( text.length() > width ) { + text = text.substr( 0, width ); + } else if ( pad ) { + text += std::string( width - text.length(), ' ' ); + } + if ( high.length() > width ) { + high = high.substr( 0, width ); + } else if ( pad ) { + high += std::string( width - high.length(), ' ' ); + } + return std::make_pair( text, high ); +} +std::string module_impl::format_pattern_row_channel( std::int32_t p, std::int32_t r, std::int32_t c, std::size_t width, bool pad ) const { + return format_and_highlight_pattern_row_channel( p, r, c, width, pad ).first; +} +std::string module_impl::highlight_pattern_row_channel( std::int32_t p, std::int32_t r, std::int32_t c, std::size_t width, bool pad ) const { + return format_and_highlight_pattern_row_channel( p, r, c, width, pad ).second; +} + std::vector<std::string> module_impl::get_ctls() const { std::vector<std::string> retval; return retval; Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp 2013-07-28 14:28:52 UTC (rev 2548) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp 2013-07-28 17:09:33 UTC (rev 2549) @@ -70,6 +70,7 @@ std::size_t read_wrapper( std::size_t count, float * left, float * right, float * rear_left, float * rear_right ); std::size_t read_interleaved_wrapper( std::size_t count, std::size_t channels, std::int16_t * interleaved ); std::size_t read_interleaved_wrapper( std::size_t count, std::size_t channels, float * interleaved ); + std::pair< std::string, std::string > format_and_highlight_pattern_row_channel( std::int32_t p, std::int32_t r, std::int32_t c, std::size_t width, bool pad ) const; public: static std::vector<std::string> get_supported_extensions(); static bool is_extension_supported( const std::string & extension ); @@ -108,6 +109,8 @@ std::int32_t get_current_pattern() const; std::int32_t get_current_row() const; std::int32_t get_current_playing_channels() const; + float get_current_channel_vu_left( std::int32_t channel ) const; + float get_current_channel_vu_right( std::int32_t channel ) const; std::int32_t get_num_subsongs() const; std::int32_t get_num_channels() const; std::int32_t get_num_orders() const; @@ -123,6 +126,8 @@ std::int32_t get_order_pattern( std::int32_t o ) const; std::int32_t get_pattern_num_rows( std::int32_t p ) const; std::uint8_t get_pattern_row_channel_command( std::int32_t p, std::int32_t r, std::int32_t c, int cmd ) const; + std::string format_pattern_row_channel( std::int32_t p, std::int32_t r, std::int32_t c, std::size_t width, bool pad ) const; + std::string highlight_pattern_row_channel( std::int32_t p, std::int32_t r, std::int32_t c, std::size_t width, bool pad ) const; std::vector<std::string> get_ctls() const; std::string ctl_get( const std::string & ctl ) const; void ctl_set( const std::string & ctl, const std::string & value ); Modified: trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp 2013-07-28 14:28:52 UTC (rev 2548) +++ trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp 2013-07-28 17:09:33 UTC (rev 2549) @@ -193,8 +193,8 @@ timeinfo_position += (double)count / (double)samplerate; timeinfo info; info.seconds = timeinfo_position; - info.pattern = mod->get_current_pattern(); - info.row = mod->get_current_row(); + info.pattern = self->mod->get_current_pattern(); + info.row = self->mod->get_current_row(); timeinfos.push( info ); } @@ -204,13 +204,11 @@ timeinfo info = current_timeinfo; #if 0 info.seconds = timeinfo_position; - info.pattern = mod->get_current_pattern(); - info.row = mod->get_current_row(); + info.pattern = self->mod->get_current_pattern(); + info.row = self->mod->get_current_row(); #endif while ( timeinfos.size() > 0 && timeinfos.front().seconds < seconds ) { - info.seconds = timeinfos.front().seconds; - info.pattern = timeinfos.front().pattern; - info.row = timeinfos.front().row; + info = timeinfos.front(); timeinfos.pop(); } current_timeinfo = info; @@ -743,7 +741,7 @@ #ifdef EXPERIMENTAL_VIS -std::vector< std::vector< std::vector < std::uint8_t > > > patterns; +std::vector< std::vector< std::string > > patterns_rows; DWORD viscolors[3]; HPEN vispens[3]; HBRUSH visbrushs[3]; @@ -765,16 +763,18 @@ visbrushs[0] = CreateSolidBrush( viscolors[0] ); visbrushs[1] = CreateSolidBrush( viscolors[1] ); visbrushs[2] = CreateSolidBrush( viscolors[2] ); - if ( !mod ) { + if ( !self->mod ) { return FALSE; } - patterns.resize( mod->get_num_patterns() ); - for ( std::size_t pattern = 0; pattern < mod->get_num_patterns(); pattern++ ) { - patterns[pattern].resize( mod->get_pattern_num_rows( pattern ) ); - for ( std::size_t row = 0; row < mod->get_pattern_num_rows( pattern ); row++ ) { - patterns[pattern][row].resize( mod->get_num_channels() ); - for ( std::size_t channel = 0; channel < mod->get_num_channels(); channel++ ) { - patterns[pattern][row][channel] = mod->get_pattern_row_channel_command( pattern, row, channel, openmpt::module::command_note ); + patterns_rows.resize( self->mod->get_num_patterns() ); + for ( std::size_t pattern = 0; pattern < (std::size_t)self->mod->get_num_patterns(); pattern++ ) { + patterns_rows[pattern].resize( self->mod->get_pattern_num_rows( pattern ) ); + for ( std::size_t row = 0; row < (std::size_t)self->mod->get_pattern_num_rows( pattern ); row++ ) { + for ( std::size_t channel = 0; channel < (std::size_t)self->mod->get_num_channels(); channel++ ) { + if ( channel > 0 ) { + patterns_rows[pattern][row] += "|"; + } + patterns_rows[pattern][row] += self->mod->format_pattern_row_channel( pattern, row, channel, 3 ); } } } @@ -806,29 +806,20 @@ int top = 0; - int channels = mod->get_num_channels(); + int channels = self->mod->get_num_channels(); #if 0 - int pattern = mod->get_current_pattern(); - int current_row = mod->get_current_row(); + int pattern = self->mod->get_current_pattern(); + int current_row = self->mod->get_current_row(); #else - timeinfo info = lookup_timeinfo( timeinfo_position - ( (double)xmpfstatus->GetLatency() / (double)samplerate ) ); + timeinfo info = lookup_timeinfo( timeinfo_position - ( (double)xmpfstatus->GetLatency() / (double)self->num_channels / (double)self->samplerate ) ); int pattern = info.pattern; int current_row = info.row; #endif - int rows = mod->get_pattern_num_rows( pattern ); + std::size_t rows = self->mod->get_pattern_num_rows( pattern ); - static char buf[1<<16]; - char * dst; - dst = buf; for ( std::size_t row = 0; row < rows; row++ ) { - dst = buf; - for ( std::size_t channel = 0; channel < channels; channel++ ) { - *dst++ = nibble_to_char( ( patterns[pattern][row][channel] >> 4 ) &0xf ); - *dst++ = nibble_to_char( ( patterns[pattern][row][channel] >> 0 ) &0xf ); - } - *dst++ = '\0'; if ( row == current_row ) { //SelectObject( dc, vispens[2] ); SetTextColor( dc, viscolors[2] ); @@ -838,7 +829,7 @@ rect.left = 0; rect.right = size.cx; rect.bottom = size.cy; - DrawText( dc, buf, strlen( buf ), &rect, DT_LEFT ); + DrawText( dc, patterns_rows[pattern][row].c_str(), patterns_rows[pattern][row].length(), &rect, DT_LEFT ); top += tm.tmHeight; if ( row == current_row ) { //SelectObject( dc, vispens[1] ); Modified: trunk/OpenMPT/openmpt123/openmpt123.cpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-07-28 14:28:52 UTC (rev 2548) +++ trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-07-28 17:09:33 UTC (rev 2549) @@ -21,6 +21,7 @@ #include <cmath> #include <cstdint> +#include <cstdlib> #include <cstring> #include <ctime> @@ -150,6 +151,7 @@ s << "Mode : " << mode_to_string( flags.mode ) << std::endl; s << "Show progress: " << flags.show_progress << std::endl; s << "Show peak meters: " << flags.show_meters << std::endl; + s << "Show channel peak meters: " << flags.show_channel_meters << std::endl; s << "Show details: " << flags.show_details << std::endl; s << "Show message: " << flags.show_message << std::endl; #ifdef MPT_WITH_PORTAUDIO @@ -328,8 +330,11 @@ return; } std::clog << std::endl; + std::clog << " --terminal-width n Assume terminal is n characters wide [default: " << commandlineflags().terminal_width << "]" << std::endl; + std::clog << std::endl; std::clog << " --[no-]progress Show playback progress [default: " << commandlineflags().show_progress << "]" << std::endl; std::clog << " --[no-]meters Show peak meters [default: " << commandlineflags().show_meters << "]" << std::endl; + std::clog << " --[no-]channel-meters Show channel peak meters [default: " << commandlineflags().show_channel_meters << "]" << std::endl; std::clog << std::endl; std::clog << " --[no-]details Show song details [default: " << commandlineflags().show_details << "]" << std::endl; std::clog << " --[no-]message Show song message [default: " << commandlineflags().show_message << "]" << std::endl; @@ -570,6 +575,57 @@ } } +static char peak_to_char( float peak ) { + if ( peak >= 1.0f ) { + return '#'; + } else if ( peak >= 0.5f ) { + return 'O'; + } else if ( peak >= 0.25f ) { + return 'o'; + } else if ( peak >= 0.125f ) { + return '.'; + } else { + return ' '; + } +} + +static std::string peak_to_string_left( float peak, int width ) { + std::string result; + float thresh = 1.0f; + while ( width-- ) { + if ( peak >= thresh ) { + if ( thresh == 1.0f ) { + result.push_back( '#' ); + } else { + result.push_back( '<' ); + } + } else { + result.push_back( ' ' ); + } + thresh *= 0.5f; + } + return result; +} + +static std::string peak_to_string_right( float peak, int width ) { + std::string result; + float thresh = 1.0f; + while ( width-- ) { + if ( peak >= thresh ) { + if ( thresh == 1.0f ) { + result.push_back( '#' ); + } else { + result.push_back( '>' ); + } + } else { + result.push_back( ' ' ); + } + thresh *= 0.5f; + } + std::reverse( result.begin(), result.end() ); + return result; +} + static void draw_meters( std::ostream & log, const meter_type & meter, const commandlineflags & flags ) { for ( int channel = 0; channel < flags.channels; ++channel ) { log << channel_to_string( flags.channels, channel, meter.channels[channel] ) << std::endl; @@ -582,6 +638,21 @@ } } +static void draw_channel_meters_tiny( std::ostream & log, float peak ) { + log << peak_to_char( peak ); +} + +static void draw_channel_meters_tiny( std::ostream & log, float peak_left, float peak_right ) { + log << peak_to_char( peak_left ) << peak_to_char( peak_right ); +} + +static void draw_channel_meters( std::ostream & log, float peak_left, float peak_right, int width ) { + if ( width >= 8 + 1 + 8 ) { + width = 8 + 1 + 8; + } + log << peak_to_string_left( peak_left, width / 2 ) << ( width % 1 == 1 ? "|" : "" ) << peak_to_string_right( peak_right, width / 2 ); +} + template < typename Tsample, typename Tmod > void render_loop( commandlineflags & flags, Tmod & mod, double & duration, std::ostream & log, write_buffers_interface & audio_stream ) { @@ -776,6 +847,27 @@ if ( flags.show_progress ) { log << "Position...: " << seconds_to_string( mod.get_position_seconds() ) << " / " << seconds_to_string( duration ) << " " << std::endl; } + } else if ( flags.show_channel_meters ) { + if ( flags.show_ui || flags.show_details || flags.show_progress ) { + int width = flags.terminal_width / mod.get_num_channels(); + log << " "; + for ( std::int32_t channel = 0; channel < mod.get_num_channels(); ++channel ) { + if ( width >= 3 ) { + log << "|"; + } + if ( width == 1 ) { + draw_channel_meters_tiny( log, ( mod.get_current_channel_vu_left( channel ) + mod.get_current_channel_vu_right( channel ) ) * (1.0f/std::sqrt(2.0f)) ); + } else if ( width == 2 || width == 3 ) { + draw_channel_meters_tiny( log, mod.get_current_channel_vu_left( channel ), mod.get_current_channel_vu_right( channel ) ); + } else { + draw_channel_meters( log, mod.get_current_channel_vu_left( channel ), mod.get_current_channel_vu_right( channel ), width - 1 ); + } + } + if ( width >= 3 ) { + log << "|"; + } + } + log << " " << "\r"; } else { if ( flags.show_ui ) { log << " "; @@ -1062,6 +1154,10 @@ flags.mode = ModeBatch; } else if ( arg == "--render" ) { flags.mode = ModeRender; + } else if ( arg == "--terminal-width" && nextarg != "" ) { + std::istringstream istr( nextarg ); + istr >> flags.terminal_width; + ++i; } else if ( arg == "--progress" ) { flags.show_progress = true; } else if ( arg == "--no-progress" ) { @@ -1070,6 +1166,10 @@ flags.show_meters = true; } else if ( arg == "--no-meters" ) { flags.show_meters = false; + } else if ( arg == "--channel-meters" ) { + flags.show_channel_meters = true; + } else if ( arg == "--no-channel-meters" ) { + flags.show_channel_meters = false; } else if ( arg == "--details" ) { flags.show_details = true; } else if ( arg == "--no-details" ) { Modified: trunk/OpenMPT/openmpt123/openmpt123.hpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.hpp 2013-07-28 14:28:52 UTC (rev 2548) +++ trunk/OpenMPT/openmpt123/openmpt123.hpp 2013-07-28 17:09:33 UTC (rev 2549) @@ -97,11 +97,13 @@ double seek_target; bool quiet; bool verbose; + int terminal_width; bool show_details; bool show_message; bool show_ui; bool show_progress; bool show_meters; + bool show_channel_meters; bool use_float; bool use_stdout; std::vector<std::string> filenames; @@ -128,6 +130,19 @@ seek_target = 0.0; quiet = false; verbose = false; + terminal_width = 72; +#if !defined(_MSC_VER) + if ( isatty( STDERR_FILENO ) ) { + if ( std::getenv( "COLUMNS" ) ) { + std::istringstream istr( std::getenv( "COLUMNS" ) ); + int tmp = 0; + istr >> tmp; + if ( tmp > 0 ) { + terminal_width = tmp; + } + } + } +#endif show_details = true; show_message = false; #if defined(_MSC_VER) @@ -140,6 +155,7 @@ show_ui = canUI; show_progress = canProgress; show_meters = canUI && canProgress; + show_channel_meters = false; use_stdout = false; #if defined(MPT_WITH_FLAC) || defined(MPT_WITH_MMIO) || defined(MPT_WITH_SNDFILE) output_extension = "wav"; @@ -184,14 +200,18 @@ case ModeInfo: show_ui = false; show_progress = false; + show_meters = false; + show_channel_meters = false; break; case ModeUI: break; case ModeBatch: show_meters = false; + show_channel_meters = false; break; case ModeRender: show_meters = false; + show_channel_meters = false; show_ui = false; break; } @@ -200,6 +220,7 @@ show_ui = false; show_details = false; show_progress = false; + show_channel_meters = false; } if ( verbose ) { show_details = true; Modified: trunk/OpenMPT/soundlib/ModChannel.h =================================================================== --- trunk/OpenMPT/soundlib/ModChannel.h 2013-07-28 14:28:52 UTC (rev 2548) +++ trunk/OpenMPT/soundlib/ModChannel.h 2013-07-28 17:09:33 UTC (rev 2549) @@ -67,7 +67,6 @@ int32 nPeriod, nC5Speed, nPortamentoDest; int32 nCalcVolume; // Calculated channel volume, 14-Bit (without global volume, pre-amp etc applied) - for MIDI macros EnvInfo VolEnv, PanEnv, PitchEnv; // Envelope playback info - uint32 nVUMeter; int32 nGlobalVol; // Channel volume (CV in ITTECH.TXT) int32 nInsVol; // Sample / Instrument volume (SV * IV in ITTECH.TXT) int32 nFineTune, nTranspose; Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-07-28 14:28:52 UTC (rev 2548) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-07-28 17:09:33 UTC (rev 2549) @@ -1176,7 +1176,6 @@ // Enable Ramping if(!bPorta) { - pChn->nVUMeter = 0x100; pChn->nLeftVU = pChn->nRightVU = 0xFF; pChn->dwFlags.reset(CHN_FILTER); pChn->dwFlags.set(CHN_FASTVOLRAMP); Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-07-28 14:28:52 UTC (rev 2548) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-07-28 17:09:33 UTC (rev 2549) @@ -19,10 +19,6 @@ #include "../mptrack/TrackerSettings.h" #endif -#ifdef MODPLUG_TRACKER -#define ENABLE_STEREOVU -#endif - // VU-Meter #define VUMETER_DECAY 4 @@ -1757,12 +1753,7 @@ // Process MIDI macros on channels that are currently muted. ProcessMacroOnChannel(nChn); } - - pChn->nVUMeter = 0; -#ifdef ENABLE_STEREOVU pChn->nLeftVU = pChn->nRightVU = 0; -#endif - continue; } // Reset channel data @@ -1982,10 +1973,8 @@ // Volume ramping pChn->dwFlags.set(CHN_VOLUMERAMP, (pChn->nRealVolume | pChn->rightVol | pChn->leftVol) != 0); -#ifdef ENABLE_STEREOVU if (pChn->nLeftVU > VUMETER_DECAY) pChn->nLeftVU -= VUMETER_DECAY; else pChn->nLeftVU = 0; if (pChn->nRightVU > VUMETER_DECAY) pChn->nRightVU -= VUMETER_DECAY; else pChn->nRightVU = 0; -#endif // Check for too big nInc if (((pChn->nInc >> 16) + 1) >= (LONG)(pChn->nLoopEnd - pChn->nLoopStart)) pChn->dwFlags.reset(CHN_LOOP); @@ -1994,7 +1983,6 @@ if (pChn->pCurrentSample) { // Update VU-Meter (nRealVolume is 14-bit) -#ifdef ENABLE_STEREOVU UINT vul = (pChn->nRealVolume * pChn->nRealPan) >> 14; if (vul > 127) vul = 127; if (pChn->nLeftVU > 127) pChn->nLeftVU = (BYTE)vul; @@ -2005,7 +1993,6 @@ if (pChn->nRightVU > 127) pChn->nRightVU = (BYTE)vur; vur >>= 1; if (pChn->nRightVU < vur) pChn->nRightVU = (BYTE)vur; -#endif #ifdef MODPLUG_TRACKER const UINT kChnMasterVol = pChn->dwFlags[CHN_EXTRALOUD] ? (UINT)m_PlayConfig.getNormalSamplePreAmp() : nMasterVol; @@ -2095,12 +2082,10 @@ ChnMix[m_nMixChannels++] = nChn; } else { -#ifdef ENABLE_STEREOVU // Note change but no sample if (pChn->nLeftVU > 128) pChn->nLeftVU = 0; if (pChn->nRightVU > 128) pChn->nRightVU = 0; -#endif // ENABLE_STEREOVU - if (pChn->nVUMeter > 0xFF) pChn->nVUMeter = 0; + pChn->rightVol = pChn->leftVol = 0; pChn->nLength = 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-07-30 08:29:42
|
Revision: 2552 http://sourceforge.net/p/modplug/code/2552 Author: manxorist Date: 2013-07-30 08:29:28 +0000 (Tue, 30 Jul 2013) Log Message: ----------- [Ref] Move dithering code to its own file. Modified Paths: -------------- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/Sndfile.h Added Paths: ----------- trunk/OpenMPT/soundlib/Dither.cpp trunk/OpenMPT/soundlib/Dither.h Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2013-07-30 07:58:16 UTC (rev 2551) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2013-07-30 08:29:28 UTC (rev 2552) @@ -423,6 +423,7 @@ <ClInclude Include="..\include\pugixml\src\pugiconfig.hpp" /> <ClInclude Include="..\include\pugixml\src\pugixml.hpp" /> <ClInclude Include="..\soundlib\ChunkReader.h" /> + <ClInclude Include="..\soundlib\Dither.h" /> <ClInclude Include="..\soundlib\Dlsbank.h" /> <ClInclude Include="..\soundlib\Endianness.h" /> <ClInclude Include="..\soundlib\FileReader.h" /> @@ -479,6 +480,7 @@ <ClCompile Include="..\common\typedefs.cpp" /> <ClCompile Include="..\common\version.cpp" /> <ClCompile Include="..\include\pugixml\src\pugixml.cpp" /> + <ClCompile Include="..\soundlib\Dither.cpp" /> <ClCompile Include="..\soundlib\Dlsbank.cpp" /> <ClCompile Include="..\soundlib\Fastmix.cpp" /> <ClCompile Include="..\soundlib\ITCompression.cpp" /> Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2013-07-30 07:58:16 UTC (rev 2551) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2013-07-30 08:29:28 UTC (rev 2552) @@ -233,6 +233,9 @@ <ClInclude Include="..\common\svn_version_subwcrev\svn_version.template.h"> <Filter>Header Files\common</Filter> </ClInclude> + <ClInclude Include="..\soundlib\Dither.h"> + <Filter>Header Files\soundlib</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="..\common\AudioCriticalSection.cpp"> @@ -487,5 +490,8 @@ <ClCompile Include="libopenmpt_test.cpp"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="..\soundlib\Dither.cpp"> + <Filter>Source Files\soundlib</Filter> + </ClCompile> </ItemGroup> </Project> \ No newline at end of file Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-07-30 07:58:16 UTC (rev 2551) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-07-30 08:29:28 UTC (rev 2552) @@ -311,6 +311,10 @@ > </File> <File + RelativePath="..\soundlib\Dither.cpp" + > + </File> + <File RelativePath="..\soundlib\dlsbank.cpp" > </File> @@ -877,6 +881,10 @@ > </File> <File + RelativePath="..\soundlib\Dither.h" + > + </File> + <File RelativePath="..\Soundlib\Dlsbank.h" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-07-30 07:58:16 UTC (rev 2551) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-07-30 08:29:28 UTC (rev 2552) @@ -265,6 +265,7 @@ <ClCompile Include="..\sounddsp\DSP.cpp" /> <ClCompile Include="..\sounddsp\EQ.cpp" /> <ClCompile Include="..\sounddsp\Reverb.cpp" /> + <ClCompile Include="..\soundlib\Dither.cpp" /> <ClCompile Include="..\soundlib\Dlsbank.cpp" /> <ClCompile Include="..\soundlib\Fastmix.cpp" /> <ClCompile Include="..\soundlib\ITCompression.cpp" /> @@ -482,6 +483,7 @@ <ClInclude Include="..\sounddsp\EQ.h" /> <ClInclude Include="..\sounddsp\Reverb.h" /> <ClInclude Include="..\soundlib\ChunkReader.h" /> + <ClInclude Include="..\soundlib\Dither.h" /> <ClInclude Include="..\soundlib\Dlsbank.h" /> <ClInclude Include="..\soundlib\Endianness.h" /> <ClInclude Include="..\soundlib\FileReader.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-07-30 07:58:16 UTC (rev 2551) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-07-30 08:29:28 UTC (rev 2552) @@ -478,6 +478,9 @@ <ClCompile Include="..\soundlib\S3MTools.cpp"> <Filter>Source Files\soundlib\Module Loaders</Filter> </ClCompile> + <ClCompile Include="..\soundlib\Dither.cpp"> + <Filter>Source Files\soundlib</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\soundlib\Loaders.h"> @@ -882,6 +885,9 @@ <ClInclude Include="..\common\svn_version_subwcrev\svn_version.template.h"> <Filter>Header Files\common</Filter> </ClInclude> + <ClInclude Include="..\soundlib\Dither.h"> + <Filter>Header Files\soundlib</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> Copied: trunk/OpenMPT/soundlib/Dither.cpp (from rev 2551, trunk/OpenMPT/soundlib/Fastmix.cpp) =================================================================== --- trunk/OpenMPT/soundlib/Dither.cpp (rev 0) +++ trunk/OpenMPT/soundlib/Dither.cpp 2013-07-30 08:29:28 UTC (rev 2552) @@ -0,0 +1,157 @@ +/* + * Dither.cpp + * ---------- + * Purpose: Dithering when converting to lower resolution sample formats. + * Notes : (currently none) + * Authors: Olivier Lapicque + * OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#include "stdafx.h" + +#include "Dither.h" + +#include "Snd_defs.h" + + + +////////////////////////////////////////////////////////////////////////// +// Noise Shaping (Dithering) + +#if MPT_COMPILER_MSVC +#pragma warning(disable:4731) // ebp modified +#endif + + +#ifdef ENABLE_X86 + +void X86_Dither(int *pBuffer, UINT nSamples, UINT nBits, DitherModPlugState *state) +//--------------------------------------------------------------------------------- +{ + if(nBits + MIXING_ATTENUATION + 1 >= 32) //if(nBits>16) + { + return; + } + + static int gDitherA_global, gDitherB_global; + + int gDitherA = state ? state->rng_a : gDitherA_global; + int gDitherB = state ? state->rng_b : gDitherB_global; + + _asm { + mov esi, pBuffer // esi = pBuffer+i + mov eax, nSamples // ebp = i + mov ecx, nBits // ecx = number of bits of noise + mov edi, gDitherA // Noise generation + mov ebx, gDitherB + add ecx, MIXING_ATTENUATION+1 + push ebp + mov ebp, eax +noiseloop: + rol edi, 1 + mov eax, dword ptr [esi] + xor edi, 0x10204080 + add esi, 4 + lea edi, [ebx*4+edi+0x78649E7D] + mov edx, edi + rol edx, 16 + lea edx, [edx*4+edx] + add ebx, edx + mov edx, ebx + sar edx, cl + add eax, edx + dec ebp + mov dword ptr [esi-4], eax + jnz noiseloop + pop ebp + mov gDitherA, edi + mov gDitherB, ebx + } + + if(state) state->rng_a = gDitherA; else gDitherA_global = gDitherA; + if(state) state->rng_b = gDitherB; else gDitherB_global = gDitherB; + +} + +#endif // ENABLE_X86 + + +static forceinline int32 dither_rand(uint32 &a, uint32 &b) +//-------------------------------------------------------- +{ + a = (a << 1) | (a >> 31); + a ^= 0x10204080u; + a += 0x78649E7Du + (b * 4); + b += ((a << 16 ) | (a >> 16)) * 5; + return (int32)b; +} + +static void C_Dither(int *pBuffer, UINT nSamples, UINT nBits, DitherModPlugState *state) +//-------------------------------------------------------------------------------------- +{ + if(nBits + MIXING_ATTENUATION + 1 >= 32) //if(nBits>16) + { + return; + } + + static uint32 global_a = 0; + static uint32 global_b = 0; + + uint32 a = state ? state->rng_a : global_a; + uint32 b = state ? state->rng_b : global_b; + + while(nSamples--) + { + *pBuffer += dither_rand(a, b) >> (nBits + MIXING_ATTENUATION + 1); + pBuffer++; + } + + if(state) state->rng_a = a; else global_a = a; + if(state) state->rng_b = b; else global_b = b; + +} + +static void Dither_ModPlug(int *pBuffer, UINT nSamples, UINT nChannels, UINT nBits, DitherModPlugState &state) +//------------------------------------------------------------------------------------------------------------ +{ + #ifdef ENABLE_X86 + X86_Dither(pBuffer, nSamples * nChannels, nBits, &state); + #else // !ENABLE_X86 + C_Dither(pBuffer, nSamples * nChannels, nBits, &state); + #endif // ENABLE_X86 +} + + +void Dither::Reset() +{ + state = DitherState(); +} + +Dither::Dither() +{ + mode = DitherModPlug; +} + +void Dither::SetMode(DitherMode &mode_) +{ + mode = mode_; +} + +DitherMode Dither::GetMode() const +{ + return mode; +} + +void Dither::Process(int *mixbuffer, std::size_t count, std::size_t channels, int bits) +{ + switch(mode) + { + case DitherNone: + // nothing + break; + case DitherModPlug: + Dither_ModPlug(mixbuffer, count, channels, bits, state.modplug); + break; + } +} Property changes on: trunk/OpenMPT/soundlib/Dither.cpp ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-c++src \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/OpenMPT/soundlib/Dither.h =================================================================== --- trunk/OpenMPT/soundlib/Dither.h (rev 0) +++ trunk/OpenMPT/soundlib/Dither.h 2013-07-30 08:29:28 UTC (rev 2552) @@ -0,0 +1,48 @@ +/* + * Dither.h + * -------- + * Purpose: Dithering when converting to lower resolution sample formats. + * Notes : (currently none) + * Authors: Olivier Lapicque + * OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#pragma once + + +struct DitherModPlugState +{ + uint32 rng_a; + uint32 rng_b; + DitherModPlugState() + { + rng_a = 0; + rng_b = 0; + } +}; + +struct DitherState +{ + DitherModPlugState modplug; +}; + +enum DitherMode +{ + DitherNone = 0, + DitherModPlug = 1 +}; + +class Dither +{ +private: + DitherState state; + DitherMode mode; +public: + Dither(); + void SetMode(DitherMode &mode); + DitherMode GetMode() const; + void Reset(); + void Process(int *mixbuffer, std::size_t count, std::size_t channels, int bits); +}; Property changes on: trunk/OpenMPT/soundlib/Dither.h ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-chdr \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/OpenMPT/soundlib/Fastmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-07-30 07:58:16 UTC (rev 2551) +++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-07-30 08:29:28 UTC (rev 2552) @@ -1881,147 +1881,12 @@ ////////////////////////////////////////////////////////////////////////// -// Noise Shaping (Dithering) #if MPT_COMPILER_MSVC #pragma warning(disable:4731) // ebp modified #endif - #ifdef ENABLE_X86 - -void X86_Dither(int *pBuffer, UINT nSamples, UINT nBits, DitherModPlugState *state) -//--------------------------------------------------------------------------------- -{ - if(nBits + MIXING_ATTENUATION + 1 >= 32) //if(nBits>16) - { - return; - } - - static int gDitherA_global, gDitherB_global; - - int gDitherA = state ? state->rng_a : gDitherA_global; - int gDitherB = state ? state->rng_b : gDitherB_global; - - _asm { - mov esi, pBuffer // esi = pBuffer+i - mov eax, nSamples // ebp = i - mov ecx, nBits // ecx = number of bits of noise - mov edi, gDitherA // Noise generation - mov ebx, gDitherB - add ecx, MIXING_ATTENUATION+1 - push ebp - mov ebp, eax -noiseloop: - rol edi, 1 - mov eax, dword ptr [esi] - xor edi, 0x10204080 - add esi, 4 - lea edi, [ebx*4+edi+0x78649E7D] - mov edx, edi - rol edx, 16 - lea edx, [edx*4+edx] - add ebx, edx - mov edx, ebx - sar edx, cl - add eax, edx - dec ebp - mov dword ptr [esi-4], eax - jnz noiseloop - pop ebp - mov gDitherA, edi - mov gDitherB, ebx - } - - if(state) state->rng_a = gDitherA; else gDitherA_global = gDitherA; - if(state) state->rng_b = gDitherB; else gDitherB_global = gDitherB; - -} - -#endif // ENABLE_X86 - - -static forceinline int32 dither_rand(uint32 &a, uint32 &b) -//-------------------------------------------------------- -{ - a = (a << 1) | (a >> 31); - a ^= 0x10204080u; - a += 0x78649E7Du + (b * 4); - b += ((a << 16 ) | (a >> 16)) * 5; - return (int32)b; -} - -static void C_Dither(int *pBuffer, UINT nSamples, UINT nBits, DitherModPlugState *state) -//-------------------------------------------------------------------------------------- -{ - if(nBits + MIXING_ATTENUATION + 1 >= 32) //if(nBits>16) - { - return; - } - - static uint32 global_a = 0; - static uint32 global_b = 0; - - uint32 a = state ? state->rng_a : global_a; - uint32 b = state ? state->rng_b : global_b; - - while(nSamples--) - { - *pBuffer += dither_rand(a, b) >> (nBits + MIXING_ATTENUATION + 1); - pBuffer++; - } - - if(state) state->rng_a = a; else global_a = a; - if(state) state->rng_b = b; else global_b = b; - -} - -static void Dither_ModPlug(int *pBuffer, UINT nSamples, UINT nChannels, UINT nBits, DitherModPlugState &state) -//------------------------------------------------------------------------------------------------------------ -{ - #ifdef ENABLE_X86 - X86_Dither(pBuffer, nSamples * nChannels, nBits, &state); - #else // !ENABLE_X86 - C_Dither(pBuffer, nSamples * nChannels, nBits, &state); - #endif // ENABLE_X86 -} - - -void Dither::Reset() -{ - state = DitherState(); -} - -Dither::Dither() -{ - mode = DitherModPlug; -} - -void Dither::SetMode(DitherMode &mode_) -{ - mode = mode_; -} - -DitherMode Dither::GetMode() const -{ - return mode; -} - -void Dither::Process(int *mixbuffer, std::size_t count, std::size_t channels, int bits) -{ - switch(mode) - { - case DitherNone: - // nothing - break; - case DitherModPlug: - Dither_ModPlug(mixbuffer, count, channels, bits, state.modplug); - break; - } -} - - -#ifdef ENABLE_X86 static void X86_InterleaveFrontRear(int *pFrontBuf, int *pRearBuf, DWORD nFrames) //------------------------------------------------------------------------------- { Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-07-30 07:58:16 UTC (rev 2551) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-07-30 08:29:28 UTC (rev 2552) @@ -39,6 +39,7 @@ #include "../sounddsp/AGC.h" #include "../sounddsp/DSP.h" #include "../sounddsp/EQ.h" +#include "Dither.h" class FileReader; @@ -186,42 +187,7 @@ class CModDoc; #endif // MODPLUG_TRACKER -struct DitherModPlugState -{ - uint32 rng_a; - uint32 rng_b; - DitherModPlugState() - { - rng_a = 0; - rng_b = 0; - } -}; -struct DitherState -{ - DitherModPlugState modplug; -}; - -enum DitherMode -{ - DitherNone = 0, - DitherModPlug = 1 -}; - -class Dither -{ -private: - DitherState state; - DitherMode mode; -public: - Dither(); - void SetMode(DitherMode &mode); - DitherMode GetMode() const; - void Reset(); - void Process(int *mixbuffer, std::size_t count, std::size_t channels, int bits); -}; - - void StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc); void FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic); void MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-08-05 22:19:11
|
Revision: 2580 http://sourceforge.net/p/modplug/code/2580 Author: saga-games Date: 2013-08-05 22:19:00 +0000 (Mon, 05 Aug 2013) Log Message: ----------- [Var] Updated installer documentation [Mod] Updated release documents [Mod] Improved DBM slide command accuracy (only affects libopenmpt) [Mod] OpenMPT: Version is now 1.22.04.00 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/installer/install-unmo3-free-itd.iss trunk/OpenMPT/installer/install-unmo3-free.iss trunk/OpenMPT/packageTemplate/History.txt trunk/OpenMPT/packageTemplate/OMPT_1.22_ReleaseNotes.html trunk/OpenMPT/packageTemplate/readme.txt trunk/OpenMPT/soundlib/Snd_fx.cpp Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2013-08-03 05:13:25 UTC (rev 2579) +++ trunk/OpenMPT/common/versionNumber.h 2013-08-05 22:19:00 UTC (rev 2580) @@ -16,8 +16,8 @@ //Version definitions. The only thing that needs to be changed when changing version number. #define VER_MAJORMAJOR 1 #define VER_MAJOR 22 -#define VER_MINOR 03 -#define VER_MINORMINOR 12 +#define VER_MINOR 04 +#define VER_MINORMINOR 00 //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/installer/install-unmo3-free-itd.iss =================================================================== --- trunk/OpenMPT/installer/install-unmo3-free-itd.iss 2013-08-03 05:13:25 UTC (rev 2579) +++ trunk/OpenMPT/installer/install-unmo3-free-itd.iss 2013-08-05 22:19:00 UTC (rev 2580) @@ -6,8 +6,8 @@ ; This file is provided for creating an install package without the proprietary unmo3.dll (for example for the SourceForge package). ; Instead of including the file in the setup package, the user instead has the possibility to automatically download unmo3.dll from ; our servers. -; The download code requires the InnoIDE with its downloader extension which currently only works in ANSI version! -; To download and install InnoIDE, get the Inno Setup QuickStart Pack from http://www.jrsoftware.org/isdl.php#qsp (don't use the unicode pack!) +; The download code requires the InnoTools Downloader available at +; http://www.sherlocksoftware.org/page.php?id=50 ; it_download.iss and it_download.dll have to be placed in same directory as the file you are currently viewing. #define DOWNLOAD_MO3 Modified: trunk/OpenMPT/installer/install-unmo3-free.iss =================================================================== --- trunk/OpenMPT/installer/install-unmo3-free.iss 2013-08-03 05:13:25 UTC (rev 2579) +++ trunk/OpenMPT/installer/install-unmo3-free.iss 2013-08-05 22:19:00 UTC (rev 2580) @@ -6,9 +6,9 @@ ; This file is provided for creating an install package without the proprietary unmo3.dll (for example for the SourceForge package). ; Instead of including the file in the setup package, the user instead has the possibility to automatically download unmo3.dll from ; our servers. -; The download code requires the InnoScript Studio or ISTool IDE with its downloader extension. -; You can download InnoScript Studio from https://www.kymoto.org/products/inno-script-studio/overview -; or download ISTool from http://www.istool.org/ +; The download code requires the ISTool IDE with its downloader extension. +; You can download ISTool from http://www.istool.org/ +; This installer is deprecated. Use install-unmo3-free-itd.iss instead. #define DOWNLOAD_MO3 #define BaseNameAddition "_sf" Modified: trunk/OpenMPT/packageTemplate/History.txt =================================================================== --- trunk/OpenMPT/packageTemplate/History.txt 2013-08-03 05:13:25 UTC (rev 2579) +++ trunk/OpenMPT/packageTemplate/History.txt 2013-08-05 22:19:00 UTC (rev 2580) @@ -25,6 +25,92 @@ <ks> coda / Ken Snyder +v1.22.04.00 (5 August 2013, revision 2564) +------------------------------------------ +Pattern Editor + [Imp] <js> If more than one channel is selected, channel record select and channel reset shortcuts are now applied to all selected channels (tx coda). + [Imp] <js> Also show name of unsupported commands in status text. Only really useful when importing files that contain effects not compatible with the current edit format. + [Fix] <js> When removing channels or rows from a pattern, a crash could occour when the cursor was previously placed in a now inaccesible part of the pattern. + [Fix] <js> After stopping playback, scrolling to previously invisible channels would reveal their last visible VU meter state (broke in OpenMPT 1.22). + +Sample Editor + [New] <jh> Support for floating point .wav files written with old versions of Syntrillium CoolEdit. + [Mod] <jh> Normalization of 24-/32-bit samples on load is now optional. Disable it by setting MayNormalizeSamplesOnLoad=0 in the [Sample Editor] section of mptrack.ini. + [Mod] <jh> When normalizing of 24-/32-bit samples on load, the sample's global volume is now adjusted to reflect the volume change if possible. + [Fix] <js> Fixed crash when trying to trigger a note > B-9. + [Fix] <jh> Reduce quantization noise by correcting the rounding and scaling in floating point conversion and float or 24-/32-Bit normalization when loading such WAV samples. + +Tree view + [Imp] <js> Can now load more than 64 soundfonts. + [Fix] <js> Fixed a rare crash when switching between previewed files in tree view (probably present since OpenMPT 1.22.01). + [Fix] <js> Fixed various issues with editing sequence / instrument / pattern names. + +VST / DMO Plugins + [Imp] <js> Plugin Selection Dialog: When using the name filter, highlight matching plugin by default instead of the "no plugin" entry (tx coda). + [Fix] <js> Preset names with ampersand characters in them weren't drawn properly in the plugin editor. + +Playback + [Imp] <js> Improved internal sample frequency precision. + [Imp] <jh> Improved precision of polyphase 8-tap resampling filter tables by 1 bit. + [Mod] <js> Disabled some questionable "optimisations" with cubic spline and linear interpolation that would disable interpolation depending on volume levels and sample frequency. + [Fix] <js> In IT compatible and "old random variation" mode, panning variation was not applied if the same instrument also had a panning envelope. + [Fix] <js> Pitch / Pan separation wasn't applied if the channel was panned way to the left. + [Fix] <jh> Dithering is also applied when using 24-Bit output. + [Fix] <jh> When applying global volume, ramping up and down lengths were mixed up. For stereo or quad output, the global volume ramping length was also only half the configured length. + [Fix] <jh> In quad channel output mode, also apply equalizer to rear channels. + [Fix] <jh> Avoid tiny rounding errors when converting between integer and floating point samples in the mixer. + [Fix] <jh> Apply AGC volume changes to all channels at once instead of potentially decrementing volume in between processing different output channels. Also, limit ramp down speed to 1 step per sample (as it was for mono output). + +MPTM::Loading + [Mod] <js> Removed order truncation note for old MPTM files with long order lists (the order list was not actually truncated). + +IT::Compatible Playback Mode + [Fix] <js> Fine volume slides in the volume column are only executed on the first tick, and not on multiples of the first tick in case of a pattern delay. + +XM + [New] <js & jh> Added extra smooth ramping option in Song Properties to emulate Fasttracker 2's ramping algorithm (kills most percussion sounds). Set SmoothFT2Ramping=1 in the [Misc] section of mptrack.ini to automatically detect if an XM file was made with Fasttracker 2 to enable this settings automatically. + +XM::Loading and Saving + [Fix] <js> A default speed / tempo of 0 should be ignored in XM headers (fixes transwave by jazz & motion). + [Fix] <js> Saving XM files with non-existing patterns past the highest existing pattern number in the order list does no longer crash. + +XM::Compatible Playback Mode + [Fix] <js> Emulate FT2's very weird frequency wraparound behaviour with 2xx effects (http://bugs.openmpt.org/view.php?id=386). + [Fix] <js> Note-Off + Note Delay + Panning ignores the panning effect. + [Fix] <js> Arpeggio emulation is now finally 100% accurate with speeds greater than 16. + +MOD + [Fix] <js> EEx + Dxx on the same row causes the target row of Dxx to be skipped in ProTracker (fixes condom_corruption by Travolta). + [Fix] <js> When using EEx, there should be only one "first tick" event. Ticks that are multiples of the song speed are longer treated as first ticks. + [Fix] <js> Frequency limiting was not always correct in PT 1.x mode (Fixes black_queen.mod). + [Fix] <js> SoundTracker modules with "hidden" patterns in their order list didn't play properly anymore (probably since v1.22.03, affected e.g. Bad Dudes soundtrack). + +Other formats + [Imp] <js> AMS: Added support for reversed sample loops (starting at sample end). + [Imp] <js> PTM: Note Cut and some other commands should work better, added support for effects Jxx - Mxx (note slides) and Nxx (reverse sample + offset). Some effects show up as "?" in patterns now, this does not affect playback. + [Mod] <jh> Replaced LHA unpacker by lhasa. Should be more reliable and support more LHA variants, including PMA and LZS. + [Fix] <js> RAR support broke in OpenMPT 1.22.02. + [Fix] <js> MT2: Repeated pattern events are now loaded correctly. + [Fix] <js> MT2: Convert effects from XM to IT on loading, this fixes e.g. global volume commands. + [Fix] <js> DSMI AMF: Version 8 / 9 files didn't load correctly. + +Module cleanup + [Mod] <js> "Remove unused patterns" no longer automatically executes "rearrange patterns". + +Misc + [New] <js> Added option in the MIDI configuration to ignore certain MIDI CCs when recording to pattern. + [Imp] <jh> WAV export: Normalizing is now also available for 32-Bit output. + [Mod] <jh> Always enable "Export as MP3" menu entry and display a useful message box when no MP3 codec is found. + [Mod] <jh> Removed /nomp3 command line switch as MP3 support is now initialized on demand instead of when launching OpenMPT. + [Mod] <jh> 24-/32-bit samples in DLS files are no longer normalized on load. + [Fix] <jh> WAV export: Rendered output is not clamped before normalizing anymore. WAV output is now dithered properly. + [Fix] <js> Song Length Estimation handles some pattern loops more correctly now (http://bugs.openmpt.org/view.php?id=416). + [Fix] <js> Song Length Estimation doesn't break with some tempo slide down commands anymore (http://bugs.openmpt.org/view.php?id=416). + [Reg] <jh> Enable MMX / 3DNow! / SSE acceleration is gone. This option is now always enabled when available. + [Reg] <jh> Remove possibility to export MP3 encapsulated in .wav files. It's not 1999 anymore. + [Reg] <js> Removed hidden setting ITCompressionVerification (algorithmn has been proved to be stable and verification is now part of the internal test suite). + + v1.22.03.00 (18 May 2013, revision 2094) ---------------------------------------- Pattern Editor @@ -91,7 +177,10 @@ ------------------------------------------ Instrument tab [Mod] <js> When importing DLS drum samples into an XM instrument, pick the center of the sample's assigned note range as a transpose amount instead of the lowest note of the note range (http://bugs.openmpt.org/view.php?id=376). - + +Tree view + [Mod] <js> Instrument previews in the tree view are now played at 0dB. + VST / DMO Plugins [Imp] <js> If a plugin editor is focussed, MIDI is now always routed to that plugin. [Mod] <js> effBeginSetProgram and effEndSetProgram opcodes are sent when performing a program change. @@ -120,7 +209,6 @@ [Imp] <js> When changing MIDI input devices, the change is applied instantly. Previously the old MIDI device was kept open. [Imp] <jh> Support for exclusive device access has been added for WASAPI devices. [Mod] <jh> Renamed "Use secondary buffers" option to the negated form "Use primary buffer". - [Mod] <js> Instrument previews in the tree view are now played at 0dB. [Fix] <jh> Fixed a possible crash when stopping a Wave Out device and possible freezes with ASIO / WASAPI devices. [Fix] <js> Time display was not updated anymore in OpenMPT 1.22.01.00 when jumping around in the order list without actually playing the module. [Fix] <js> Options dialog: Pre-amp warning was also shown when changing stereo separation. @@ -2295,7 +2383,7 @@ v1.17.02.29 ----------- - [Fix] <rf> Fixed 3 digit instrument numbers when there are less than 100 instruments. (http://www.modplug.com/forum/viewtopic.php?p=42006) + [Fix] <rf> Fixed 3 digit instrument numbers when there are less than 100 instruments. (http://www.modplug.com/forum/viewtopic.php?p=42006) [Fix] <rf> Fixed crash in plugin DNA/NNA check we transitionning between existing and non existing instruments. (http://www.modplug.com/forum/viewtopic.php?p=42006) Modified: trunk/OpenMPT/packageTemplate/OMPT_1.22_ReleaseNotes.html =================================================================== --- trunk/OpenMPT/packageTemplate/OMPT_1.22_ReleaseNotes.html 2013-08-03 05:13:25 UTC (rev 2579) +++ trunk/OpenMPT/packageTemplate/OMPT_1.22_ReleaseNotes.html 2013-08-05 22:19:00 UTC (rev 2580) @@ -131,6 +131,7 @@ <li>The Chord Editor features a <strong>relative base note mode</strong>, which enters chords that are relative to a previously entered base note instead of a fixed base note. Chord mode also works without having to select any record channel beforehand now.</li> <li>Higher <strong>live record precision</strong>.</li> <li>When using Insert Rows, the selection is not cleared anymore, allowing the user to execute the same command several times in a row.</li> + <li>It is now possible to <strong>ignore specified MIDI CCs</strong> when using the MIDI CC to pattern recording functionality.</li> </ul> <h3>Tree view</h3> Modified: trunk/OpenMPT/packageTemplate/readme.txt =================================================================== --- trunk/OpenMPT/packageTemplate/readme.txt 2013-08-03 05:13:25 UTC (rev 2579) +++ trunk/OpenMPT/packageTemplate/readme.txt 2013-08-05 22:19:00 UTC (rev 2580) @@ -169,4 +169,9 @@ --------- OpenMPT makes use of libmpg123, which is released under the LGPL license. A copy of the LGPL license can be found in SoundTouch\COPYING.TXT -Visit http://mpg123.de/ for more information. \ No newline at end of file +Visit http://mpg123.de/ for more information. + +lhasa +----- +OpenMPT makes use of lhasa, which is released under the ISC license. +Visit https://github.com/fragglet/lhasa for more information. \ No newline at end of file Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-08-03 05:13:25 UTC (rev 2579) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-08-05 22:19:00 UTC (rev 2580) @@ -2739,13 +2739,13 @@ if ((param & 0xF0) == 0xF0) { FinePortamentoUp(pChn, param & 0x0F); - } else - if ((param & 0xF0) == 0xE0) + return; + } else if ((param & 0xF0) == 0xE0 && GetType() != MOD_TYPE_DBM) { ExtraFinePortamentoUp(pChn, param & 0x0F); + return; } } - return; } // Regular Slide if(!m_SongFlags[SONG_FIRSTTICK]) @@ -2787,13 +2787,13 @@ if ((param & 0xF0) == 0xF0) { FinePortamentoDown(pChn, param & 0x0F); - } else - if ((param & 0xF0) == 0xE0) + return; + } else if ((param & 0xF0) == 0xE0 && GetType() != MOD_TYPE_DBM) { ExtraFinePortamentoDown(pChn, param & 0x0F); + return; } } - return; } if(!m_SongFlags[SONG_FIRSTTICK]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-08-06 11:46:01
|
Revision: 2583 http://sourceforge.net/p/modplug/code/2583 Author: manxorist Date: 2013-08-06 11:45:45 +0000 (Tue, 06 Aug 2013) Log Message: ----------- Merged revision(s) 2554-2582 from branches/manx/sampleformat-ref: [Ref] First step towards decoupling SampleFormat from MixerSettings. ........ [Ref] Move SampleFormat out of struct MixerSettings. ........ [Ref] Make CMainFrame::AudioRead a tiny bit more readable. ........ [Ref] Support mixbuffer sample format (28.4 fixed point, called int28q4 here) as output format in CSoundFile::Read(). ........ [Ref] Move output sample format conversion out of CSoundFile. ........ [Ref] Move Dither state out of CSoundFile. ........ [Ref] Make CSoundFile::Read() public. [Ref] Minor cleanups. ........ [Ref] For consistency, make Convert32ToInterleaved also take an explicit channels parameter. ........ [Ref] Remove global mixer callback hook. Implement stereo VU meters via a wrapper around the sample format conversion sink that gets passed to CSoundFile::Read(). ........ [Ref] Split sample format conversion functors into decoding and converting functors. Remove ::input_inc from converting functors and let them take the value by value instead of a pointer to the value. ........ [Ref] Add fixed point conversion functors usable to convert mixbuffer format to output sample formats to SampleFormatConverters.h. [Ref] Base Convert32ToInterleaved() and Convert32ToNonInterleaved() on SampleFormatConverters.h. ........ [Ref] Update comments in SampleFormatConverters.h . ........ [Ref] Move output sample format conversion loops from Fastmix.cpp to SampleFormatConverters.h . Remove the wrapper functions. ........ [Ref] Merge ISoundDevice::Open/Configure and make them not require a struct WAVEFORMATEX. Build struct WAVEFORMATEXTENSIBLE internally for the APIs that need it. ........ [Fix] ConvertFixedPoint<float32, int32> used a wrong amplification factor. ........ [New] sounddev: Support 32bit floating point output. [New] Make floating point output selectable in options dialog. ........ [Ref] Correct typo. ........ [Ref] Move ApplyFinalOutputGain() out of CSoundFile and rename it to ApplyGain(). ........ [Ref] Template SoundFileDefaultSink based on the sample type. ........ [Ref] Rename SoundFileDefaultSink to AudioStreamSinkToBuffer. ........ [Ref] Move CSoundFile::ReadInterleaved out of CSoundFile to the one single user that's left ( Mod2wave.cpp ). ........ [Ref] Factor out output gain handling from AudioStreamSinkToBuffer because it is only used in libopenmpt and not mptrack. ........ [Ref] Small cleanups. ........ [Fix] GCC 4.4 build fixes. ........ [Ref] Better distinguish between attenuation/headroom and fixedpoint/fractional interpretation of the mixbuffer format. [Ref] Rename misnamed int28q4 to fixed5p27 . ........ [Ref] Rename IAudioStreamSink to IAudioReadTarget and related renamings. ........ Modified Paths: -------------- trunk/OpenMPT/common/typedefs.h trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/Mpdlgs.h trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/sounddev/SoundDevice.h trunk/OpenMPT/sounddev/SoundDevices.h trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/MixerSettings.cpp trunk/OpenMPT/soundlib/MixerSettings.h trunk/OpenMPT/soundlib/SampleFormatConverters.h trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Property Changed: ---------------- trunk/OpenMPT/ Index: trunk/OpenMPT =================================================================== --- trunk/OpenMPT 2013-08-06 11:28:29 UTC (rev 2582) +++ trunk/OpenMPT 2013-08-06 11:45:45 UTC (rev 2583) Property changes on: trunk/OpenMPT ___________________________________________________________________ Modified: svn:mergeinfo ## -6,6 +6,7 ## /branches/manx/nonglobal-mixer:1715-1841 /branches/manx/profiler:1813 /branches/manx/project-files-cleanups:1378-1382 +/branches/manx/sampleformat-ref:2554-2582 /branches/manx/serialization-utils-cleanup:2382-2386,2395 /branches/manx/snddev-fixes:1605-1713 /branches/manx/stdstring-names:2223,2228 \ No newline at end of property Modified: trunk/OpenMPT/common/typedefs.h =================================================================== --- trunk/OpenMPT/common/typedefs.h 2013-08-06 11:28:29 UTC (rev 2582) +++ trunk/OpenMPT/common/typedefs.h 2013-08-06 11:45:45 UTC (rev 2583) @@ -231,6 +231,22 @@ #define int24_min (0-0x00800000) #define int24_max (0+0x007fffff) +struct fixed5p27 +{ + // 5 integer bits (including sign) + // 27 fractional bits + int32 raw; + + static fixed5p27 Raw(int32 x) { return fixed5p27().SetRaw(x); } + + fixed5p27& SetRaw(int32 x) { raw = x; return *this; } + int32 GetRaw() const { return raw; } + +}; +STATIC_ASSERT(sizeof(fixed5p27) == 4); +#define fixed5p27_min fixed5p27::Raw(int32_min) +#define fixed5p27_max fixed5p27::Raw(int32_max) + struct uint8_4 { uint8 x[4]; Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-08-06 11:28:29 UTC (rev 2582) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-08-06 11:45:45 UTC (rev 2583) @@ -23,6 +23,8 @@ #include <cstring> #include "soundlib/Sndfile.h" +#include "soundlib/Dither.h" +#include "soundlib/SampleFormatConverters.h" #include "soundlib/FileReader.h" namespace openmpt { @@ -62,13 +64,6 @@ } }; // class log_forwarder -static std::int32_t float_to_fx16( float x ) { - return static_cast<std::int32_t>( x * (1<<16) ); -} -static float fx16_to_float( std::int32_t x ) { - return static_cast<float>( x * (1.0f/(1<<16)) ); -} - class loader_log : public ILog { private: mutable std::vector<std::pair<LogLevel,std::string> > m_Messages; @@ -155,19 +150,16 @@ } } -void module_impl::apply_mixer_settings( std::int32_t samplerate, int channels, bool format_float ) { - SampleFormat format = ( format_float ? SampleFormatFloat32 : SampleFormatInt16 ); +void module_impl::apply_mixer_settings( std::int32_t samplerate, int channels ) { if ( static_cast<std::int32_t>( m_sndFile->m_MixerSettings.gdwMixingFreq ) != samplerate || - static_cast<int>( m_sndFile->m_MixerSettings.gnChannels ) != channels || - m_sndFile->m_MixerSettings.m_SampleFormat != format + static_cast<int>( m_sndFile->m_MixerSettings.gnChannels ) != channels ) { MixerSettings mixersettings = m_sndFile->m_MixerSettings; std::int32_t volrampin_us = mixersettings.GetVolumeRampUpMicroseconds(); std::int32_t volrampout_us = mixersettings.GetVolumeRampDownMicroseconds(); mixersettings.gdwMixingFreq = samplerate; mixersettings.gnChannels = channels; - mixersettings.m_SampleFormat = format; mixersettings.SetVolumeRampUpMicroseconds( volrampin_us ); mixersettings.SetVolumeRampDownMicroseconds( volrampout_us ); m_sndFile->SetMixerSettings( mixersettings ); @@ -178,9 +170,11 @@ } void module_impl::init( const std::map< std::string, std::string > & ctls ) { m_sndFile = std::unique_ptr<CSoundFile>(new CSoundFile()); + m_Dither = std::unique_ptr<Dither>(new Dither()); m_LogForwarder = std::unique_ptr<log_forwarder>(new log_forwarder(m_Log)); m_sndFile->SetCustomLog( m_LogForwarder.get() ); m_currentPositionSeconds = 0.0; + m_Gain = 1.0f; for ( std::map< std::string, std::string >::const_iterator i = ctls.begin(); i != ctls.end(); ++i ) { ctl_set( i->first, i->second ); } @@ -205,9 +199,10 @@ std::size_t count_read = 0; while ( count > 0 ) { std::int16_t * const buffers[4] = { left + count_read, right + count_read, rear_left + count_read, rear_right + count_read }; - std::size_t count_chunk = m_sndFile->ReadNonInterleaved( - reinterpret_cast<void*const*>( buffers ), - static_cast<CSoundFile::samplecount_t>( std::min<std::uint64_t>( count, std::numeric_limits<CSoundFile::samplecount_t>::max() / 2 / 4 / 4 ) ) // safety margin / samplesize / channels + AudioReadTargetGainBuffer<std::int16_t> target(*m_Dither, 0, buffers, m_Gain); + std::size_t count_chunk = m_sndFile->Read( + static_cast<CSoundFile::samplecount_t>( std::min<std::uint64_t>( count, std::numeric_limits<CSoundFile::samplecount_t>::max() / 2 / 4 / 4 ) ), // safety margin / samplesize / channels + target ); if ( count_chunk == 0 ) { break; @@ -221,9 +216,10 @@ std::size_t count_read = 0; while ( count > 0 ) { float * const buffers[4] = { left + count_read, right + count_read, rear_left + count_read, rear_right + count_read }; - std::size_t count_chunk = m_sndFile->ReadNonInterleaved( - reinterpret_cast<void*const*>( buffers ), - static_cast<CSoundFile::samplecount_t>( std::min<std::uint64_t>( count, std::numeric_limits<CSoundFile::samplecount_t>::max() / 2 / 4 / 4 ) ) // safety margin / samplesize / channels + AudioReadTargetGainBuffer<float> target(*m_Dither, 0, buffers, m_Gain); + std::size_t count_chunk = m_sndFile->Read( + static_cast<CSoundFile::samplecount_t>( std::min<std::uint64_t>( count, std::numeric_limits<CSoundFile::samplecount_t>::max() / 2 / 4 / 4 ) ), // safety margin / samplesize / channels + target ); if ( count_chunk == 0 ) { break; @@ -236,9 +232,10 @@ std::size_t module_impl::read_interleaved_wrapper( std::size_t count, std::size_t channels, std::int16_t * interleaved ) { std::size_t count_read = 0; while ( count > 0 ) { - std::size_t count_chunk = m_sndFile->ReadInterleaved( - reinterpret_cast<void*>( interleaved + count_read * channels ), - static_cast<CSoundFile::samplecount_t>( std::min<std::uint64_t>( count, std::numeric_limits<CSoundFile::samplecount_t>::max() / 2 / 4 / 4 ) ) // safety margin / samplesize / channels + AudioReadTargetGainBuffer<std::int16_t> target(*m_Dither, interleaved + count_read * channels, 0, m_Gain); + std::size_t count_chunk = m_sndFile->Read( + static_cast<CSoundFile::samplecount_t>( std::min<std::uint64_t>( count, std::numeric_limits<CSoundFile::samplecount_t>::max() / 2 / 4 / 4 ) ), // safety margin / samplesize / channels + target ); if ( count_chunk == 0 ) { break; @@ -251,9 +248,10 @@ std::size_t module_impl::read_interleaved_wrapper( std::size_t count, std::size_t channels, float * interleaved ) { std::size_t count_read = 0; while ( count > 0 ) { - std::size_t count_chunk = m_sndFile->ReadInterleaved( - reinterpret_cast<void*>( interleaved + count_read * channels ), - static_cast<CSoundFile::samplecount_t>( std::min<std::uint64_t>( count, std::numeric_limits<CSoundFile::samplecount_t>::max() / 2 / 4 / 4 ) ) // safety margin / samplesize / channels + AudioReadTargetGainBuffer<float> target(*m_Dither, interleaved + count_read * channels, 0, m_Gain); + std::size_t count_chunk = m_sndFile->Read( + static_cast<CSoundFile::samplecount_t>( std::min<std::uint64_t>( count, std::numeric_limits<CSoundFile::samplecount_t>::max() / 2 / 4 / 4 ) ), // safety margin / samplesize / channels + target ); if ( count_chunk == 0 ) { break; @@ -348,7 +346,7 @@ std::int32_t module_impl::get_render_param( int param ) const { switch ( param ) { case module::RENDER_MASTERGAIN_MILLIBEL: { - return static_cast<std::int32_t>( 1000.0f * 2.0f * std::log10( fx16_to_float( m_sndFile->m_MixerSettings.m_FinalOutputGain ) ) ); + return static_cast<std::int32_t>( 1000.0f * 2.0f * std::log10( m_Gain ) ); } break; case module::RENDER_STEREOSEPARATION_PERCENT: { return m_sndFile->m_MixerSettings.m_nStereoSeparation * 100 / 128; @@ -368,12 +366,7 @@ void module_impl::set_render_param( int param, std::int32_t value ) { switch ( param ) { case module::RENDER_MASTERGAIN_MILLIBEL: { - float gainFactor = static_cast<float>( std::pow( 10.0f, value * 0.001f * 0.5f ) ); - if ( static_cast<std::int32_t>( m_sndFile->m_MixerSettings.m_FinalOutputGain ) != float_to_fx16( gainFactor ) ) { - MixerSettings settings = m_sndFile->m_MixerSettings; - settings.m_FinalOutputGain = float_to_fx16( gainFactor ); - m_sndFile->SetMixerSettings( settings ); - } + m_Gain = static_cast<float>( std::pow( 10.0f, value * 0.001f * 0.5f ) ); } break; case module::RENDER_STEREOSEPARATION_PERCENT: { std::int32_t newvalue = value * 128 / 100; @@ -405,7 +398,7 @@ if ( !mono ) { throw openmpt::exception("null pointer"); } - apply_mixer_settings( samplerate, 1, false ); + apply_mixer_settings( samplerate, 1 ); count = read_wrapper( count, mono, 0, 0, 0 ); m_currentPositionSeconds += static_cast<double>( count ) / static_cast<double>( samplerate ); return count; @@ -414,7 +407,7 @@ if ( !left || !right ) { throw openmpt::exception("null pointer"); } - apply_mixer_settings( samplerate, 2, false ); + apply_mixer_settings( samplerate, 2 ); count = read_wrapper( count, left, right, 0, 0 ); m_currentPositionSeconds += static_cast<double>( count ) / static_cast<double>( samplerate ); return count; @@ -423,7 +416,7 @@ if ( !left || !right || !rear_left || !rear_right ) { throw openmpt::exception("null pointer"); } - apply_mixer_settings( samplerate, 4, false ); + apply_mixer_settings( samplerate, 4 ); count = read_wrapper( count, left, right, rear_left, rear_right ); m_currentPositionSeconds += static_cast<double>( count ) / static_cast<double>( samplerate ); return count; @@ -432,7 +425,7 @@ if ( !mono ) { throw openmpt::exception("null pointer"); } - apply_mixer_settings( samplerate, 1, true ); + apply_mixer_settings( samplerate, 1 ); count = read_wrapper( count, mono, 0, 0, 0 ); m_currentPositionSeconds += static_cast<double>( count ) / static_cast<double>( samplerate ); return count; @@ -441,7 +434,7 @@ if ( !left || !right ) { throw openmpt::exception("null pointer"); } - apply_mixer_settings( samplerate, 2, true ); + apply_mixer_settings( samplerate, 2 ); count = read_wrapper( count, left, right, 0, 0 ); m_currentPositionSeconds += static_cast<double>( count ) / static_cast<double>( samplerate ); return count; @@ -450,7 +443,7 @@ if ( !left || !right || !rear_left || !rear_right ) { throw openmpt::exception("null pointer"); } - apply_mixer_settings( samplerate, 4, true ); + apply_mixer_settings( samplerate, 4 ); count = read_wrapper( count, left, right, rear_left, rear_right ); m_currentPositionSeconds += static_cast<double>( count ) / static_cast<double>( samplerate ); return count; @@ -459,7 +452,7 @@ if ( !interleaved_stereo ) { throw openmpt::exception("null pointer"); } - apply_mixer_settings( samplerate, 2, false ); + apply_mixer_settings( samplerate, 2 ); count = read_interleaved_wrapper( count, 2, interleaved_stereo ); m_currentPositionSeconds += static_cast<double>( count ) / static_cast<double>( samplerate ); return count; @@ -468,7 +461,7 @@ if ( !interleaved_quad ) { throw openmpt::exception("null pointer"); } - apply_mixer_settings( samplerate, 4, false ); + apply_mixer_settings( samplerate, 4 ); count = read_interleaved_wrapper( count, 4, interleaved_quad ); m_currentPositionSeconds += static_cast<double>( count ) / static_cast<double>( samplerate ); return count; @@ -477,7 +470,7 @@ if ( !interleaved_stereo ) { throw openmpt::exception("null pointer"); } - apply_mixer_settings( samplerate, 2, true ); + apply_mixer_settings( samplerate, 2 ); count = read_interleaved_wrapper( count, 2, interleaved_stereo ); m_currentPositionSeconds += static_cast<double>( count ) / static_cast<double>( samplerate ); return count; @@ -486,7 +479,7 @@ if ( !interleaved_quad ) { throw openmpt::exception("null pointer"); } - apply_mixer_settings( samplerate, 4, true ); + apply_mixer_settings( samplerate, 4 ); count = read_interleaved_wrapper( count, 4, interleaved_quad ); m_currentPositionSeconds += static_cast<double>( count ) / static_cast<double>( samplerate ); return count; Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp 2013-08-06 11:28:29 UTC (rev 2582) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp 2013-08-06 11:45:45 UTC (rev 2583) @@ -19,6 +19,7 @@ // forward declarations class FileReader; class CSoundFile; +class Dither; namespace openmpt { @@ -56,12 +57,14 @@ std::unique_ptr<log_forwarder> m_LogForwarder; double m_currentPositionSeconds; std::unique_ptr<CSoundFile> m_sndFile; + std::unique_ptr<Dither> m_Dither; + float m_Gain; std::vector<std::string> m_loaderMessages; public: void PushToCSoundFileLog( const std::string & text ) const; void PushToCSoundFileLog( int loglevel, const std::string & text ) const; private: - void apply_mixer_settings( std::int32_t samplerate, int channels, bool format_float ); + void apply_mixer_settings( std::int32_t samplerate, int channels ); void apply_libopenmpt_defaults(); void init( const std::map< std::string, std::string > & ctls ); static void load( CSoundFile & sndFile, const FileReader & file ); Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-08-06 11:28:29 UTC (rev 2582) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-08-06 11:45:45 UTC (rev 2583) @@ -12,6 +12,7 @@ #include "mptrack.h" #include "MainFrm.h" #include "../sounddev/SoundDevice.h" +#include "../soundlib/SampleFormatConverters.h" #include "moddoc.h" #include "childfrm.h" #include "Dlsbank.h" @@ -242,8 +243,6 @@ SetTitle(title); OnUpdateFrameTitle(false); - CSoundFile::gpSndMixHook = CalcStereoVuMeters; - // Check for valid sound device if (!EnumerateSoundDevices(SNDDEV_GET_TYPE(TrackerSettings::Instance().m_nWaveDevice), SNDDEV_GET_NUMBER(TrackerSettings::Instance().m_nWaveDevice), nullptr, 0)) { @@ -371,8 +370,6 @@ BOOL CMainFrame::DestroyWindow() //------------------------------ { - CSoundFile::gpSndMixHook = nullptr; - // Uninstall Keyboard Hook if (ghKbdHook) { @@ -780,19 +777,92 @@ } +//============================== +class StereoVuMeterTargetWrapper +//============================== + : public IAudioReadTarget +{ +private: + const SampleFormat sampleFormat; + Dither &dither; + void *buffer; +public: + StereoVuMeterTargetWrapper(SampleFormat sampleFormat_, Dither &dither_, void *buffer_) + : sampleFormat(sampleFormat_) + , dither(dither_) + , buffer(buffer_) + { + ALWAYS_ASSERT(sampleFormat.IsValid()); + } + virtual void DataCallback(int *MixSoundBuffer, std::size_t channels, std::size_t countChunk) + { + CMainFrame::CalcStereoVuMeters(MixSoundBuffer, countChunk, channels); + switch(sampleFormat.value) + { + case SampleFormatUnsigned8: + { + typedef SampleFormatToType<SampleFormatUnsigned8>::type Tsample; + AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(buffer), nullptr); + target.DataCallback(MixSoundBuffer, channels, countChunk); + } + break; + case SampleFormatInt16: + { + typedef SampleFormatToType<SampleFormatInt16>::type Tsample; + AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(buffer), nullptr); + target.DataCallback(MixSoundBuffer, channels, countChunk); + } + break; + case SampleFormatInt24: + { + typedef SampleFormatToType<SampleFormatInt24>::type Tsample; + AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(buffer), nullptr); + target.DataCallback(MixSoundBuffer, channels, countChunk); + } + break; + case SampleFormatInt32: + { + typedef SampleFormatToType<SampleFormatInt32>::type Tsample; + AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(buffer), nullptr); + target.DataCallback(MixSoundBuffer, channels, countChunk); + } + break; + case SampleFormatFloat32: + { + typedef SampleFormatToType<SampleFormatFloat32>::type Tsample; + AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(buffer), nullptr); + target.DataCallback(MixSoundBuffer, channels, countChunk); + } + break; + case SampleFormatFixed5p27: + { + typedef SampleFormatToType<SampleFormatFixed5p27>::type Tsample; + AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(buffer), nullptr); + target.DataCallback(MixSoundBuffer, channels, countChunk); + } + break; + } + // increment output buffer for potentially next callback + buffer = (char*)buffer + (sampleFormat.GetBitsPerSample()/8) * channels * countChunk; + } +}; + + void CMainFrame::AudioRead(PVOID pvData, ULONG NumFrames) //------------------------------------------------------- { OPENMPT_PROFILE_FUNCTION(Profiler::Audio); - CSoundFile::samplecount_t renderedFrames = m_pSndFile->ReadInterleaved(pvData, NumFrames); + const SampleFormat sampleFormat = TrackerSettings::Instance().m_SampleFormat; + StereoVuMeterTargetWrapper target(sampleFormat, m_Dither, pvData); + CSoundFile::samplecount_t renderedFrames = m_pSndFile->Read(NumFrames, target); ASSERT(renderedFrames <= NumFrames); CSoundFile::samplecount_t remainingFrames = NumFrames - renderedFrames; if(remainingFrames > 0) { // The sound device interface expects the whole buffer to be filled, always. // Clear remaining buffer if not enough samples got rendered. - std::size_t frameSize = m_pSndFile->m_MixerSettings.gnChannels * (m_pSndFile->m_MixerSettings.GetBitsPerSample()/8); - if(m_pSndFile->m_MixerSettings.IsUnsignedSampleFormat()) + std::size_t frameSize = m_pSndFile->m_MixerSettings.gnChannels * (sampleFormat.GetBitsPerSample()/8); + if(sampleFormat.IsUnsigned()) { std::memset((char*)(pvData) + renderedFrames * frameSize, 0x80, remainingFrames * frameSize); } else @@ -819,51 +889,35 @@ } -bool CMainFrame::audioTryOpeningDevice(UINT channels, UINT bits, UINT samplespersec) -//---------------------------------------------------------------------------------- +bool CMainFrame::audioTryOpeningDevice(UINT channels, SampleFormat sampleFormat, UINT samplespersec) +//-------------------------------------------------------------------------------------------------- { - WAVEFORMATEXTENSIBLE WaveFormat; - - UINT bytespersample = (bits/8) * channels; - WaveFormat.Format.wFormatTag = WAVE_FORMAT_PCM; - WaveFormat.Format.nChannels = (unsigned short) channels; - WaveFormat.Format.nSamplesPerSec = samplespersec; - WaveFormat.Format.nAvgBytesPerSec = samplespersec * bytespersample; - WaveFormat.Format.nBlockAlign = (unsigned short)bytespersample; - WaveFormat.Format.wBitsPerSample = (unsigned short)bits; - WaveFormat.Format.cbSize = 0; - // MultiChannel configuration - if ((WaveFormat.Format.wBitsPerSample == 32) || (WaveFormat.Format.nChannels > 2)) + Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); + const UINT nDevType = SNDDEV_GET_TYPE(TrackerSettings::Instance().m_nWaveDevice); + if(gpSoundDevice && (gpSoundDevice->GetDeviceType() != nDevType)) { - const GUID guid_MEDIASUBTYPE_PCM = {0x00000001, 0x0000, 0x0010, 0x80, 0x00, 0x0, 0xAA, 0x0, 0x38, 0x9B, 0x71}; - WaveFormat.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; - WaveFormat.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX); - WaveFormat.Samples.wValidBitsPerSample = WaveFormat.Format.wBitsPerSample; - switch(WaveFormat.Format.nChannels) - { - case 1: WaveFormat.dwChannelMask = 0x0004; break; // FRONT_CENTER - case 2: WaveFormat.dwChannelMask = 0x0003; break; // FRONT_LEFT | FRONT_RIGHT - case 3: WaveFormat.dwChannelMask = 0x0103; break; // FRONT_LEFT|FRONT_RIGHT|BACK_CENTER - case 4: WaveFormat.dwChannelMask = 0x0033; break; // FRONT_LEFT|FRONT_RIGHT|BACK_LEFT|BACK_RIGHT - default: WaveFormat.dwChannelMask = 0; return false; break; - } - WaveFormat.SubFormat = guid_MEDIASUBTYPE_PCM; + delete gpSoundDevice; + gpSoundDevice = NULL; } + if(!gpSoundDevice) { - Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); - UINT nDevType = SNDDEV_GET_TYPE(TrackerSettings::Instance().m_nWaveDevice); - if(gpSoundDevice && (gpSoundDevice->GetDeviceType() != nDevType)) - { - delete gpSoundDevice; - gpSoundDevice = NULL; - } - if(!gpSoundDevice) gpSoundDevice = CreateSoundDevice(nDevType); - if(!gpSoundDevice) return false; - gpSoundDevice->SetSource(this); - gpSoundDevice->Configure(m_hWnd, TrackerSettings::Instance().m_LatencyMS, TrackerSettings::Instance().m_UpdateIntervalMS, TrackerSettings::Instance().GetSoundDeviceFlags()); - if (!gpSoundDevice->Open(SNDDEV_GET_NUMBER(TrackerSettings::Instance().m_nWaveDevice), &WaveFormat.Format)) return false; + gpSoundDevice = CreateSoundDevice(nDevType); } - return true; + if(!gpSoundDevice) + { + return false; + } + gpSoundDevice->SetSource(this); + SoundDeviceSettings settings; + settings.hWnd = m_hWnd; + settings.LatencyMS = TrackerSettings::Instance().m_LatencyMS; + settings.UpdateIntervalMS = TrackerSettings::Instance().m_UpdateIntervalMS; + settings.fulCfgOptions = TrackerSettings::Instance().GetSoundDeviceFlags(); + settings.Samplerate = samplespersec; + settings.Channels = (uint8)channels; + settings.BitsPerSample = (uint8)sampleFormat.GetBitsPerSample(); + settings.FloatingPoint = sampleFormat.IsFloat(); + return gpSoundDevice->Open(SNDDEV_GET_NUMBER(TrackerSettings::Instance().m_nWaveDevice), settings); } @@ -886,18 +940,18 @@ if(!err) { err = !audioTryOpeningDevice(TrackerSettings::Instance().m_MixerSettings.gnChannels, - TrackerSettings::Instance().m_MixerSettings.m_SampleFormat, + TrackerSettings::Instance().m_SampleFormat, TrackerSettings::Instance().m_MixerSettings.gdwMixingFreq); SampleFormat fixedBitsPerSample = SampleFormatInvalid; { Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); - fixedBitsPerSample = (gpSoundDevice) ? static_cast<SampleFormat>(gpSoundDevice->HasFixedBitsPerSample()) : SampleFormatInvalid; + fixedBitsPerSample = (gpSoundDevice) ? SampleFormat(gpSoundDevice->HasFixedBitsPerSample()) : SampleFormatInvalid; } - if(err && (fixedBitsPerSample && (fixedBitsPerSample != TrackerSettings::Instance().m_MixerSettings.m_SampleFormat))) + if(err && (fixedBitsPerSample.IsValid() && (fixedBitsPerSample != TrackerSettings::Instance().m_SampleFormat))) { - if(fixedBitsPerSample) TrackerSettings::Instance().m_MixerSettings.m_SampleFormat = fixedBitsPerSample; + TrackerSettings::Instance().m_SampleFormat = fixedBitsPerSample; err = !audioTryOpeningDevice(TrackerSettings::Instance().m_MixerSettings.gnChannels, - TrackerSettings::Instance().m_MixerSettings.m_SampleFormat, + TrackerSettings::Instance().m_SampleFormat, TrackerSettings::Instance().m_MixerSettings.gdwMixingFreq); } } @@ -1701,7 +1755,7 @@ BOOL CMainFrame::SetupSoundCard(DWORD deviceflags, DWORD rate, SampleFormat sampleformat, UINT nChns, UINT latency_ms, UINT updateinterval_ms, LONG wd) -//--------------------------------------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------------------------------------------- { const bool isPlaying = IsPlaying(); if ((TrackerSettings::Instance().GetSoundDeviceFlags() != deviceflags) @@ -1709,7 +1763,7 @@ || (TrackerSettings::Instance().m_nWaveDevice != wd) || (TrackerSettings::Instance().m_LatencyMS != latency_ms) || (TrackerSettings::Instance().m_UpdateIntervalMS != updateinterval_ms) - || (TrackerSettings::Instance().m_MixerSettings.m_SampleFormat != sampleformat) + || (TrackerSettings::Instance().m_SampleFormat != sampleformat) || (TrackerSettings::Instance().m_MixerSettings.gnChannels != nChns)) { CModDoc *pActiveMod = NULL; @@ -1723,7 +1777,7 @@ TrackerSettings::Instance().SetSoundDeviceFlags(deviceflags); TrackerSettings::Instance().m_LatencyMS = latency_ms; TrackerSettings::Instance().m_UpdateIntervalMS = updateinterval_ms; - TrackerSettings::Instance().m_MixerSettings.m_SampleFormat = sampleformat; + TrackerSettings::Instance().m_SampleFormat = sampleformat; TrackerSettings::Instance().m_MixerSettings.gnChannels = nChns; { CriticalSection cs; @@ -1892,7 +1946,7 @@ CPropertySheet dlg("OpenMPT Setup", this, m_nLastOptionsPage); COptionsGeneral general; - COptionsSoundcard sounddlg(TrackerSettings::Instance().m_MixerSettings.gdwMixingFreq, TrackerSettings::Instance().GetSoundDeviceFlags(), TrackerSettings::Instance().m_MixerSettings.m_SampleFormat, TrackerSettings::Instance().m_MixerSettings.gnChannels, TrackerSettings::Instance().m_LatencyMS, TrackerSettings::Instance().m_UpdateIntervalMS, TrackerSettings::Instance().m_nWaveDevice); + COptionsSoundcard sounddlg(TrackerSettings::Instance().m_MixerSettings.gdwMixingFreq, TrackerSettings::Instance().GetSoundDeviceFlags(), TrackerSettings::Instance().m_SampleFormat, TrackerSettings::Instance().m_MixerSettings.gnChannels, TrackerSettings::Instance().m_LatencyMS, TrackerSettings::Instance().m_UpdateIntervalMS, TrackerSettings::Instance().m_nWaveDevice); COptionsKeyboard keyboard; COptionsColors colors; COptionsPlayer playerdlg; Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-08-06 11:28:29 UTC (rev 2582) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-08-06 11:45:45 UTC (rev 2583) @@ -16,6 +16,7 @@ #include "../common/mutex.h" #include "../sounddev/SoundDevice.h" #include "../soundlib/Sndfile.h" +#include "../soundlib/Dither.h" class CInputHandler; class CModDoc; @@ -272,6 +273,7 @@ // Low-Level Audio mutable Util::mutex m_SoundDeviceMutex; ISoundDevice *gpSoundDevice; + Dither m_Dither; HANDLE m_hNotifyWakeUp; HANDLE m_hNotifyThread; DWORD m_dwNotifyThreadId; @@ -328,7 +330,7 @@ void AudioDone(ULONG NumSamples, ULONG SamplesLatency); void AudioDone(ULONG NumSamples); - bool audioTryOpeningDevice(UINT channels, UINT bits, UINT samplespersec); + bool audioTryOpeningDevice(UINT channels, SampleFormat sampleFormat, UINT samplespersec); bool audioOpenDevice(); bool audioReopenDevice(); void audioCloseDevice(); Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-08-06 11:28:29 UTC (rev 2582) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-08-06 11:45:45 UTC (rev 2583) @@ -20,12 +20,67 @@ #include "WAVTools.h" #include "../common/version.h" #include "ACMConvert.h" +#include "../soundlib/Dither.h" +#include "../soundlib/SampleFormatConverters.h" #include <fstream> extern UINT nMixingRates[NUMMIXRATE]; extern LPCSTR gszChnCfgNames[3]; + +static CSoundFile::samplecount_t ReadInterleaved(CSoundFile &sndFile, void *outputBuffer, CSoundFile::samplecount_t count, SampleFormat sampleFormat, Dither &dither) +//------------------------------------------------------------------------------------------------------------------------------------------------------------------- +{ + switch(sampleFormat.value) + { + case SampleFormatUnsigned8: + { + typedef SampleFormatToType<SampleFormatUnsigned8>::type Tsample; + AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(outputBuffer), nullptr); + return sndFile.Read(count, target); + } + break; + case SampleFormatInt16: + { + typedef SampleFormatToType<SampleFormatInt16>::type Tsample; + AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(outputBuffer), nullptr); + return sndFile.Read(count, target); + } + break; + case SampleFormatInt24: + { + typedef SampleFormatToType<SampleFormatInt24>::type Tsample; + AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(outputBuffer), nullptr); + return sndFile.Read(count, target); + } + break; + case SampleFormatInt32: + { + typedef SampleFormatToType<SampleFormatInt32>::type Tsample; + AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(outputBuffer), nullptr); + return sndFile.Read(count, target); + } + break; + case SampleFormatFloat32: + { + typedef SampleFormatToType<SampleFormatFloat32>::type Tsample; + AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(outputBuffer), nullptr); + return sndFile.Read(count, target); + } + break; + case SampleFormatFixed5p27: + { + typedef SampleFormatToType<SampleFormatFixed5p27>::type Tsample; + AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(outputBuffer), nullptr); + return sndFile.Read(count, target); + } + break; + } + return 0; +} + + static const GUID guid_MEDIASUBTYPE_PCM = {0x00000001, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71}; static const GUID guid_MEDIASUBTYPE_IEEE_FLOAT = {0x00000003, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71}; @@ -635,15 +690,17 @@ file.Open(m_lpszFileName); } + Dither dither; + + SampleFormat sampleFormat = (m_pWaveFormat->wFormatTag == WAVE_FORMAT_IEEE_FLOAT) ? SampleFormatFloat32 : (SampleFormat)m_pWaveFormat->wBitsPerSample; MixerSettings oldmixersettings = m_pSndFile->m_MixerSettings; MixerSettings mixersettings = TrackerSettings::Instance().m_MixerSettings; mixersettings.gdwMixingFreq = m_pWaveFormat->nSamplesPerSec; - mixersettings.m_SampleFormat = (m_pWaveFormat->wFormatTag == WAVE_FORMAT_IEEE_FLOAT) ? SampleFormatFloat32 : (SampleFormat)m_pWaveFormat->wBitsPerSample; mixersettings.gnChannels = m_pWaveFormat->nChannels; m_pSndFile->m_SongFlags.reset(SONG_PAUSED | SONG_STEP); if(m_bNormalize) { - mixersettings.m_SampleFormat = SampleFormatFloat32; + sampleFormat = SampleFormatFloat32; #ifndef NO_AGC mixersettings.DSPMask &= ~SNDDSP_AGC; #endif @@ -705,10 +762,10 @@ UINT lRead = 0; if(m_bNormalize) { - lRead = m_pSndFile->ReadInterleaved(floatbuffer, MIXBUFFERSIZE); + lRead = ReadInterleaved(*m_pSndFile, floatbuffer, MIXBUFFERSIZE, sampleFormat, dither); } else { - lRead = m_pSndFile->ReadInterleaved(buffer, MIXBUFFERSIZE); + lRead = ReadInterleaved(*m_pSndFile, buffer, MIXBUFFERSIZE, sampleFormat, dither); } // Process cue points (add base offset), if there are any to process. @@ -753,7 +810,7 @@ } else { - UINT lWrite = fwrite(buffer, 1, lRead * m_pSndFile->m_MixerSettings.gnChannels * (m_pSndFile->m_MixerSettings.GetBitsPerSample()/8), file.GetFile()); + UINT lWrite = fwrite(buffer, 1, lRead * m_pSndFile->m_MixerSettings.gnChannels * (sampleFormat.GetBitsPerSample()/8), file.GetFile()); if (!lWrite) break; bytesWritten += lWrite; @@ -815,7 +872,6 @@ ::SendMessage(progress, PBM_SETRANGE, 0, MAKELPARAM(0, 100)); const float normalizeFactor = (normalizePeak != 0.0f) ? (1.0f / normalizePeak) : 1.0f; - Dither dither; const DWORD dwBitSize = m_pWaveFormat->wBitsPerSample / 8; const uint64 framesTotal = ullSamples; @@ -854,10 +910,10 @@ dither.Process(mixbuffer, framesChunk, m_pWaveFormat->nChannels, m_pWaveFormat->wBitsPerSample); switch(dwBitSize) { - case 1: Convert32ToInterleaved(reinterpret_cast<uint8*>(buffer), mixbuffer, samplesChunk); break; - case 2: Convert32ToInterleaved(reinterpret_cast<int16*>(buffer), mixbuffer, samplesChunk); break; - case 3: Convert32ToInterleaved(reinterpret_cast<int24*>(buffer), mixbuffer, samplesChunk); break; - case 4: Convert32ToInterleaved(reinterpret_cast<int32*>(buffer), mixbuffer, samplesChunk); break; + case 1: ConvertInterleavedFixedPointToInterleaved<MIXING_FRACTIONAL_BITS>(reinterpret_cast<uint8*>(buffer), mixbuffer, m_pWaveFormat->nChannels, framesChunk); break; + case 2: ConvertInterleavedFixedPointToInterleaved<MIXING_FRACTIONAL_BITS>(reinterpret_cast<int16*>(buffer), mixbuffer, m_pWaveFormat->nChannels, framesChunk); break; + case 3: ConvertInterleavedFixedPointToInterleaved<MIXING_FRACTIONAL_BITS>(reinterpret_cast<int24*>(buffer), mixbuffer, m_pWaveFormat->nChannels, framesChunk); break; + case 4: ConvertInterleavedFixedPointToInterleaved<MIXING_FRACTIONAL_BITS>(reinterpret_cast<int32*>(buffer), mixbuffer, m_pWaveFormat->nChannels, framesChunk); break; default: ASSERT(false); break; } } @@ -1002,6 +1058,8 @@ FILE *f; MixerSettings mixersettings = TrackerSettings::Instance().m_MixerSettings; + SampleFormat sampleFormat = SampleFormatInvalid; + Dither dither; progress = ::GetDlgItem(m_hWnd, IDC_PROGRESS1); if ((!m_pSndFile) || (!m_lpszFileName) || (!m_pwfx) || (!m_hadid)) goto OnError; @@ -1056,11 +1114,11 @@ // Write ID3v2.4 Tags m_FileTags.WriteID3v2Tags(f); } + sampleFormat = SampleFormatInt16; DWORD oldsndcfg = m_pSndFile->m_MixerSettings.MixerFlags; oldrepeat = m_pSndFile->GetRepeatCount(); const uint64 dwSongTime = static_cast<uint64>(m_pSndFile->GetSongTime() + 0.5); mixersettings.gdwMixingFreq = wfxSrc.nSamplesPerSec; - mixersettings.m_SampleFormat = SampleFormatInt16; mixersettings.gnChannels = wfxSrc.nChannels; m_pSndFile->SetRepeatCount(0); m_pSndFile->ResetChannels(); @@ -1104,7 +1162,7 @@ UINT lRead = 0; if (!bFinished) { - lRead = m_pSndFile->ReadInterleaved(pcmBuffer + WAVECONVERTBUFSIZE - pcmBufSize, pcmBufSize/(m_pSndFile->m_MixerSettings.gnChannels*m_pSndFile->m_MixerSettings.GetBitsPerSample()/8)); + lRead = ReadInterleaved(*m_pSndFile, pcmBuffer + WAVECONVERTBUFSIZE - pcmBufSize, pcmBufSize/(m_pSndFile->m_MixerSettings.gnChannels*sampleFormat.GetBitsPerSample()/8), sampleFormat, dither); if (!lRead) bFinished = true; } ullSamples += lRead; Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-08-06 11:28:29 UTC (rev 2582) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-08-06 11:45:45 UTC (rev 2583) @@ -249,26 +249,53 @@ } UpdateControls(m_nSoundDevice); } + + UpdateChannelsFormat(m_nSoundDevice); + + return TRUE; +} + + +void COptionsSoundcard::UpdateChannelsFormat(int dev) +//--------------------------------------------------- +{ // Sample Format + CHAR s[128]; + UINT n = 0; + m_CbnQuality.ResetContent(); + for(UINT channels = 4; channels >= 1; channels /= 2) { - UINT n = 0; - for (UINT i=0; i<3*3; i++) + for(UINT bits = 32; bits >= 8; bits -= 8) { - UINT j = 3*3-1-i; - UINT nBits = 8 << (j % 3); - UINT nChannels = 1 << (j/3); - if ((((nChannels <= 2) && (nBits <= 16)) || (theApp.IsWaveExEnabled()) || (bAsio)) - && ((nBits >= 16) || (nChannels <= 2))) + if(channels > 2 && bits > 16 && !theApp.IsWaveExEnabled()) { - wsprintf(s, "%s, %d Bit", gszChnCfgNames[j/3], nBits); + continue; + } + if(bits != 16 && bits !=32 && SNDDEV_GET_TYPE(dev) == SNDDEV_ASIO) + { + // CASIODevice only supports 16bit or 32bit input for now + continue; + } + if(bits == 32 && SNDDEV_GET_TYPE(dev) != SNDDEV_ASIO) + { + wsprintf(s, "%s, %d Bits, Float", gszChnCfgNames[(channels+2)/2-1], bits); UINT ndx = m_CbnQuality.AddString(s); - m_CbnQuality.SetItemData( ndx, (nChannels << 8) | nBits ); - if (((SampleFormat)nBits == m_SampleFormat) && (nChannels == m_nChannels)) n = ndx; + m_CbnQuality.SetItemData(ndx, (channels << 8) | (32+128)); + if((SampleFormat)(32+128) == m_SampleFormat && channels == m_nChannels) + { + n = ndx; + } } + wsprintf(s, "%s, %d Bit", gszChnCfgNames[(channels+2)/2-1], bits); + UINT ndx = m_CbnQuality.AddString(s); + m_CbnQuality.SetItemData(ndx, (channels << 8) | bits); + if((SampleFormat)bits == m_SampleFormat && channels == m_nChannels) + { + n = ndx; + } } - m_CbnQuality.SetCurSel(n); } - return TRUE; + m_CbnQuality.SetCurSel(n); } @@ -338,6 +365,7 @@ int dev = m_CbnDevice.GetItemData(n); UpdateControls(dev); UpdateSampleRates(dev); + UpdateChannelsFormat(dev); OnSettingsChanged(); } } Modified: trunk/OpenMPT/mptrack/Mpdlgs.h =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.h 2013-08-06 11:28:29 UTC (rev 2582) +++ trunk/OpenMPT/mptrack/Mpdlgs.h 2013-08-06 11:45:45 UTC (rev 2583) @@ -41,6 +41,7 @@ private: void UpdateSampleRates(int dev); + void UpdateChannelsFormat(int dev); void UpdateControls(int dev); void SetPreAmpSliderPosition(); Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-08-06 11:28:29 UTC (rev 2582) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-08-06 11:45:45 UTC (rev 2583) @@ -76,6 +76,7 @@ m_UpdateIntervalMS = SNDDEV_DEFAULT_UPDATEINTERVAL_MS; m_SoundDeviceExclusiveMode = false; m_SoundDeviceBoostThreadPriority = true; + m_SampleFormat = SampleFormatInt16; #ifndef NO_EQ // Default EQ settings @@ -360,7 +361,7 @@ m_MixerSettings.DSPMask = CMainFrame::GetPrivateProfileDWord("Sound Settings", "Quality", m_MixerSettings.DSPMask, iniFile); m_ResamplerSettings.SrcMode = (ResamplingMode)CMainFrame::GetPrivateProfileDWord("Sound Settings", "SrcMode", m_ResamplerSettings.SrcMode, iniFile); m_MixerSettings.gdwMixingFreq = CMainFrame::GetPrivateProfileDWord("Sound Settings", "Mixing_Rate", 0, iniFile); - m_MixerSettings.m_SampleFormat = (SampleFormat)CMainFrame::GetPrivateProfileDWord("Sound Settings", "BitsPerSample", (DWORD)m_MixerSettings.m_SampleFormat, iniFile); + m_SampleFormat = CMainFrame::GetPrivateProfileLong("Sound Settings", "BitsPerSample", m_SampleFormat, iniFile); m_MixerSettings.gnChannels = CMainFrame::GetPrivateProfileDWord("Sound Settings", "ChannelMode", m_MixerSettings.gnChannels, iniFile); DWORD LatencyMS = CMainFrame::GetPrivateProfileDWord("Sound Settings", "Latency", 0, iniFile); DWORD UpdateIntervalMS = CMainFrame::GetPrivateProfileDWord("Sound Settings", "UpdateInterval", 0, iniFile); @@ -693,9 +694,9 @@ RegQueryValueEx(key, "RowSpacing", NULL, &dwREG_DWORD, (LPBYTE)&m_nRowHighlightMeasures, &dwDWORDSize); RegQueryValueEx(key, "RowSpacing2", NULL, &dwREG_DWORD, (LPBYTE)&m_nRowHighlightBeats, &dwDWORDSize); RegQueryValueEx(key, "LoopSong", NULL, &dwREG_DWORD, (LPBYTE)&gbLoopSong, &dwDWORDSize); - DWORD dummy_sampleformat = (DWORD)m_MixerSettings.m_SampleFormat; + DWORD dummy_sampleformat = m_SampleFormat; RegQueryValueEx(key, "BitsPerSample", NULL, &dwREG_DWORD, (LPBYTE)&dummy_sampleformat, &dwDWORDSize); - m_MixerSettings.m_SampleFormat = (SampleFormat)dummy_sampleformat; + m_SampleFormat = (long)dummy_sampleformat; RegQueryValueEx(key, "ChannelMode", NULL, &dwREG_DWORD, (LPBYTE)&m_MixerSettings.gnChannels, &dwDWORDSize); RegQueryValueEx(key, "MidiImportSpeed", NULL, &dwREG_DWORD, (LPBYTE)&midiImportSpeed, &dwDWORDSize); RegQueryValueEx(key, "MidiImportPatLen", NULL, &dwREG_DWORD, (LPBYTE)&midiImportPatternLen, &dwDWORDSize); @@ -841,7 +842,7 @@ CMainFrame::WritePrivateProfileDWord("Sound Settings", "Quality", m_MixerSettings.DSPMask, iniFile); CMainFrame::WritePrivateProfileDWord("Sound Settings", "SrcMode", m_ResamplerSettings.SrcMode, iniFile); CMainFrame::WritePrivateProfileDWord("Sound Settings", "Mixing_Rate", m_MixerSettings.gdwMixingFreq, iniFile); - CMainFrame::WritePrivateProfileDWord("Sound Settings", "BitsPerSample", (DWORD)m_MixerSettings.m_SampleFormat, iniFile); + CMainFrame::WritePrivateProfileLong("Sound Settings", "BitsPerSample", m_SampleFormat, iniFile); CMainFrame::WritePrivateProfileDWord("Sound Settings", "ChannelMode", m_MixerSettings.gnChannels, iniFile); CMainFrame::WritePrivateProfileDWord("Sound Settings", "Latency", m_LatencyMS, iniFile); CMainFrame::WritePrivateProfileDWord("Sound Settings", "UpdateInterval", m_UpdateIntervalMS, iniFile); Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2013-08-06 11:28:29 UTC (rev 2582) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2013-08-06 11:45:45 UTC (rev 2583) @@ -220,6 +220,7 @@ COLORREF rgbCustomColors[MAX_MODCOLORS]; MixerSettings m_MixerSettings; + SampleFormat m_SampleFormat; CResamplerSettings m_ResamplerSettings; #ifndef NO_REVERB CReverbSettings m_ReverbSettings; Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-08-06 11:28:29 UTC (rev 2582) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-08-06 11:45:45 UTC (rev 2583) @@ -32,12 +32,9 @@ //-------------------------- { m_Source = nullptr; - m_LatencyMS = SNDDEV_DEFAULT_LATENCY_MS; - m_UpdateIntervalMS = SNDDEV_DEFAULT_UPDATEINTERVAL_MS; - m_fulCfgOptions = 0; - m_RealLatencyMS = static_cast<float>(m_LatencyMS); - m_RealUpdateIntervalMS = static_cast<float>(m_UpdateIntervalMS); + m_RealLatencyMS = static_cast<float>(m_Settings.LatencyMS); + m_RealUpdateIntervalMS = static_cast<float>(m_Settings.UpdateIntervalMS); m_IsPlaying = false; } @@ -46,25 +43,65 @@ ISoundDevice::~ISoundDevice() //--------------------------- { + return; } -void ISoundDevice::Configure(HWND hwnd, UINT LatencyMS, UINT UpdateIntervalMS, DWORD fdwCfgOptions) -//------------------------------------------------------------------------------------------------- +bool ISoundDevice::FillWaveFormatExtensible(WAVEFORMATEXTENSIBLE &WaveFormat) +//--------------------------------------------------------------------------- { - if(LatencyMS < SNDDEV_MINLATENCY_MS) LatencyMS = SNDDEV_MINLATENCY_MS; - if(LatencyMS > SNDDEV_MAXLATENCY_MS) LatencyMS = SNDDEV_MAXLATENCY_MS; - if(UpdateIntervalMS < SNDDEV_MINUPDATEINTERVAL_MS) UpdateIntervalMS = SNDDEV_MINUPDATEINTERVAL_MS; - if(UpdateIntervalMS > SNDDEV_MAXUPDATEINTERVAL_MS) UpdateIntervalMS = SNDDEV_MAXUPDATEINTERVAL_MS; - m_LatencyMS = LatencyMS; - m_UpdateIntervalMS = UpdateIntervalMS; - m_fulCfgOptions = fdwCfgOptions; - m_hWnd = hwnd; - m_RealLatencyMS = static_cast<float>(m_LatencyMS); - m_RealUpdateIntervalMS = static_cast<float>(m_UpdateIntervalMS); + MemsetZero(WaveFormat); + UINT bytespersample = (m_Settings.BitsPerSample/8) * m_Settings.Channels; + if(m_Settings.FloatingPoint && m_Settings.BitsPerSample != 32) return false; + WaveFormat.Format.wFormatTag = m_Settings.FloatingPoint ? WAVE_FORMAT_IEEE_FLOAT : WAVE_FORMAT_PCM; + WaveFormat.Format.nChannels = (WORD)m_Settings.Channels; + WaveFormat.Format.nSamplesPerSec = m_Settings.Samplerate; + WaveFormat.Format.nAvgBytesPerSec = m_Settings.Samplerate * bytespersample; + WaveFormat.Format.nBlockAlign = (WORD)bytespersample; + WaveFormat.Format.wBitsPerSample = (WORD)m_Settings.BitsPerSample; + WaveFormat.Format.cbSize = 0; + if((WaveFormat.Format.wBitsPerSample > 16 && !m_Settings.FloatingPoint) || (WaveFormat.Format.nChannels > 2)) + { + WaveFormat.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; + WaveFormat.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX); + WaveFormat.Samples.wValidBitsPerSample = WaveFormat.Format.wBitsPerSample; + switch(WaveFormat.Format.nChannels) + { + case 1: WaveFormat.dwChannelMask = SPEAKER_FRONT_CENTER; break; + case 2: WaveFormat.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT; break; + case 3: WaveFormat.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_CENTER; break; + case 4: WaveFormat.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT; break; + default: WaveFormat.dwChannelMask = 0; return false; break; + } + const GUID guid_MEDIASUBTYPE_PCM = {0x00000001, 0x0000, 0x0010, 0x80, 0x00, 0x0, 0xAA, 0x0, 0x38, 0x9B, 0x71}; + const GUID guid_MEDIASUBTYPE_IEEE_FLOAT = {0x00000003, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71}; + WaveFormat.SubFormat = m_Settings.FloatingPoint ? guid_MEDIASUBTYPE_IEEE_FLOAT : guid_MEDIASUBTYPE_PCM; + } + return true; } +bool ISoundDevice::Open(UINT device, const SoundDeviceSettings &settings) +//----------------------------------------------------------------------- +{ + m_Settings = settings; + if(m_Settings.LatencyMS < SNDDEV_MINLATENCY_MS) m_Settings.LatencyMS = SNDDEV_MINLATENCY_MS; + if(m_Settings.LatencyMS > SNDDEV_MAXLATENCY_MS) m_Settings.LatencyMS = SNDDEV_MAXLATENCY_MS; + if(m_Settings.UpdateIntervalMS < SNDDEV_MINUPDATEINTERVAL_MS) m_Settings.UpdateIntervalMS = SNDDEV_MINUPDATEINTERVAL_MS; + if(m_Settings.UpdateIntervalMS > SNDDEV_MAXUPDATEINTERVAL_MS) m_Settings.UpdateIntervalMS = SNDDEV_MAXUPDATEINTERVAL_MS; + m_RealLatencyMS = static_cast<float>(m_Settings.LatencyMS); + m_RealUpdateIntervalMS = static_cast<float>(m_Settings.UpdateIntervalMS); + return InternalOpen(device); +} + + +bool ISoundDevice::Close() +//------------------------ +{ + return InternalClose(); +} + + void ISoundDevice::SourceFillAudioBufferLocked() //---------------------------------------------- { @@ -430,7 +467,7 @@ if(!terminate) { - CPriorityBooster priorityBooster(*this, (m_SoundDevice.m_fulCfgOptions & SNDDEV_OPTIONS_BOOSTTHREADPRIORITY)?true:false); + CPriorityBooster priorityBooster(*this, (m_SoundDevice.m_Settings.fulCfgOptions & SNDDEV_OPTIONS_BOOSTTHREADPRIORITY)?true:false); CPeriodicWaker periodicWaker(*this, 0.001 * m_SoundDevice.GetRealUpdateIntervalMS()); m_SoundDevice.StartFromSoundThread(); @@ -546,9 +583,13 @@ } -BOOL CWaveDevice::Open(UINT nDevice, LPWAVEFORMATEX pwfx) -//------------------------------------------------------- +bool CWaveDevice::InternalOpen(UINT nDevice) +//------------------------------------------ { + WAVEFORMATEXTENSIBLE wfext; + if(!FillWaveFormatExtensible(wfext)) return false; + WAVEFORMATEX *pwfx = &wfext.Format; + LONG nWaveDev; if (m_hWaveOut) Close(); @@ -557,15 +598,15 @@ { sndPlaySound(NULL, 0); LONG err = waveOutOpen(&m_hWaveOut, nWaveDev, pwfx, (DWORD_PTR)WaveOutCallBack, (DWORD_PTR)this, CALLBACK_FUNCTION); - if (err) return FALSE; + if (err) return false; } m_nBytesPerSec = pwfx->nAvgBytesPerSec; m_BytesPerSample = (pwfx->wBitsPerSample/8) * pwfx->nChannels; - m_nWaveBufferSize = (m_UpdateIntervalMS * pwfx->nAvgBytesPerSec) / 1000; + m_nWaveBufferSize = (m_Settings.UpdateIntervalMS * pwfx->nAvgBytesPerSec) / 1000; m_nWaveBufferSize = (m_nWaveBufferSize + 7) & ~7; if (m_nWaveBufferSize < WAVEOUT_MINBUFFERSIZE) m_nWaveBufferSize = WAVEOUT_MINBUFFERSIZE; if (m_nWaveBufferSize > WAVEOUT_MAXBUFFERSIZE) m_nWaveBufferSize = WAVEOUT_MAXBUFFERSIZE; - ULONG NumBuffers = m_LatencyMS * pwfx->nAvgBytesPerSec / ( m_nWaveBufferSize * 1000 ); + ULONG NumBuffers = m_Settings.LatencyMS * pwfx->nAvgBytesPerSec / ( m_nWaveBufferSize * 1000 ); NumBuffers = CLAMP(NumBuffers, 3, WAVEOUT_MAXBUFFERS); m_nPreparedHeaders = 0; m_WaveBuffers.resize(NumBuffers); @@ -586,17 +627,17 @@ if (!m_nPreparedHeaders) { Close(); - return FALSE; + return false; } m_RealLatencyMS = m_nWaveBufferSize * m_nPreparedHeaders * 1000.0f / m_nBytesPerSec; m_RealUpdateIntervalMS = m_nWaveBufferSize * 1000.0f / m_nBytesPerSec; m_nBuffersPending = 0; m_nWriteBuffer = 0; - return TRUE; + return true; } -BOOL CWaveDevice::Close() -//----------------------- +bool CWaveDevice::InternalClose() +//------------------------------- { Reset(); if (m_hWaveOut) @@ -612,7 +653,7 @@ m_hWaveOut = NULL; Sleep(1); // Linux WINE-friendly } - return TRUE; + return true; } @@ -815,28 +856,32 @@ } -BOOL CDSoundDevice::Open(UINT nDevice, LPWAVEFORMATEX pwfx) -//--------------------------------------------------------- +bool CDSoundDevice::InternalOpen(UINT nDevice) +//-------------------------------------------- { + WAVEFORMATEXTENSIBLE wfext; + if(!FillWaveFormatExtensible(wfext)) return false; + WAVEFORMATEX *pwfx = &wfext.Format; + DSBUFFERDESC dsbd; DSBCAPS dsc; - UINT nPriorityLevel = (m_fulCfgOptions & SNDDEV_OPTIONS_EXCLUSIVE) ? DSSCL_WRITEPRIMARY : DSSCL_PRIORITY; + UINT nPriorityLevel = (m_Settings.fulCfgOptions & SNDDEV_OPTIONS_EXCLUSIVE) ? DSSCL_WRITEPRIMARY : DSSCL_PRIORITY; - if (m_piDS) return TRUE; - if (!gpDSoundEnumerate) return FALSE; + if (m_piDS) return true; + if (!gpDSoundEnumerate) return false; if (!gbDSoundEnumerated) gpDSoundEnumerate((LPDSENUMCALLBACK)DSEnumCallback, NULL); - if ((nDevice >= gnDSoundDevices) || (!gpDSoundCreate)) return FALSE; - if (gpDSoundCreate(glpDSoundGUID[nDevice], &m_piDS, NULL) != DS_OK) return FALSE; - if (!m_piDS) return FALSE; - m_piDS->SetCooperativeLevel(m_hWnd, nPriorityLevel); + if ((nDevice >= gnDSoundDevices) || (!gpDSoundCreate)) return false; + if (gpDSoundCreate(glpDSoundGUID[nDevice], &m_piDS, NULL) != DS_OK) return false; + if (!m_piDS) return false; + m_piDS->SetCooperativeLevel(m_Settings.hWnd, nPriorityLevel); m_bMixRunning = FALSE; - m_nDSoundBufferSize = (m_LatencyMS * pwfx->nAvgBytesPerSec) / 1000; + m_nDSoundBufferSize = (m_Settings.LatencyMS * pwfx->nAvgBytesPerSec) / 1000; m_nDSoundBufferSize = (m_nDSoundBufferSize + 15) & ~15; if(m_nDSoundBufferSize < DSOUND_MINBUFFERSIZE) m_nDSoundBufferSize = DSOUND_MINBUFFERSIZE; if(m_nDSoundBufferSize > DSOUND_MAXBUFFERSIZE) m_nDSoundBufferSize = DSOUND_MAXBUFFERSIZE; m_nBytesPerSec = pwfx->nAvgBytesPerSec; m_BytesPerSample = (pwfx->wBitsPerSample/8) * pwfx->nChannels; - if(!(m_fulCfgOptions & SNDDEV_OPTIONS_EXCLUSIVE)) + if(!(m_Settings.fulCfgOptions & SNDDEV_OPTIONS_EXCLUSIVE)) { // Set the format of the primary buffer dsbd.dwSize = sizeof(dsbd); @@ -847,7 +892,7 @@ if (m_piDS->CreateSoundBuffer(&dsbd, &m_pPrimary, NULL) != DS_OK) { Close(); - return FALSE; + return false; } m_pPrimary->SetFormat(pwfx); /////////////////////////////////////////////////// @@ -860,7 +905,7 @@ if (m_piDS->CreateSoundBuffer(&dsbd, &m_pMixBuffer, NULL) != DS_OK) { Close(); - return FALSE; + return false; } } else { @@ -872,18 +917,18 @@ if (m_piDS->CreateSoundBuffer(&dsbd, &m_pPrimary, NULL) != DS_OK) { Close(); - return FALSE; + return false; } if (m_pPrimary->SetFormat(pwfx) != DS_OK) { Close(); - return FALSE; + return false; } dsc.dwSize = sizeof(dsc); if (m_pPrimary->GetCaps(&dsc) != DS_OK) { Close(); - return FALSE; + return false; } m_nDSoundBufferSize = dsc.dwBufferBytes; m_pMixBuffer = m_pPrimary; @@ -904,14 +949,14 @@ if (dwStat & DSBSTATUS_BUFFERLOST) m_pMixBuffer->Restore(); } m_RealLatencyMS = m_nDSoundBufferSize * 1000.0f / m_nBytesPerSec; - m_RealUpdateIntervalMS = CLAMP(static_cast<float>(m_UpdateIntervalMS), 1.0f, m_nDSoundBufferSize * 1000.0f / ( 2.0f * m_nBytesPerSec ) ); + m_RealUpdateIntervalMS = CLAMP(static_cast<float>(m_Settings.UpdateIntervalMS), 1.0f, m_nDSoundBufferSize * 1000.0f / ( 2.0f * m_nBytesPerSec ) ); m_dwWritePos = 0xFFFFFFFF; - return TRUE; + return true; } -BOOL CDSoundDevice::Close() -//------------------------- +bool CDSoundDevice::InternalClose() +//--------------------------------- { if (m_pMixBuffer) { @@ -929,7 +974,7 @@ m_piDS = NULL; } m_bMixRunning = FALSE; - return TRUE; + return true; } @@ -1173,7 +1218,6 @@ m_Callbacks.bufferSwitchTimeInfo = BufferSwitchTimeInfo; m_nBitsPerSample = 0; // Unknown m_nCurrentDevice = (ULONG)-1; - m_nSamplesPerSec = 0; m_bMixRunning = FALSE; InterlockedExchange(&m_RenderSilence, 0); InterlockedExchange(&m_RenderingSilence, 0); @@ -1188,14 +1232,16 @@ } -BOOL CASIODevice::Open(UINT nDevice, LPWAVEFORMATEX pwfx) -//------------------------------------------------------- +bool CASIODevice::InternalOpen(UINT nDevice) +//------------------------------------------ { - BOOL bOk = FALSE; + bool bOk = false; + if(m_Settings.FloatingPoint) return false; // for now + if (IsOpen()) Close(); if (!gbAsioEnumerated) EnumerateDevices(nDevice, NULL, 0); - if (nDevice >= gnNumAsioDrivers) return FALSE; + if (nDevice >= gnNumAsioDrivers) return false; if (nDevice != m_nCurrentDevice) { m_nCurrentDevice = nDevice; @@ -1203,7 +1249,7 @@ } #ifdef ASIO_LOG Log("CASIODevice::Open(%d:\"%s\"): %d-bit, %d channels, %dHz\n", - nDevice, gAsioDrivers[nDevice].name, pwfx->wBitsPerSample, pwfx->nChannels, pwfx->nSamplesPerSec); + nDevice, gAsioDrivers[nDevice].name, m_Settings.BitsPerSample, m_Settings.Channels, m_Settings.Samplerate); #endif OpenDevice(nDevice); @@ -1212,23 +1258,23 @@ long nInputChannels = 0, nOutputChannels = 0; long minSize = 0, maxSize = 0, preferredSize = 0, granularity = 0; - if ((pwfx->nChannels > ASIO_MAX_CHANNELS) - || ((pwfx->wBitsPerSample != 16) && (pwfx->wBitsPerSample != 32))) goto abort; - m_nChannels = pwfx->nChannels; + if ((m_Settings.Channels > ASIO_MAX_CHANNELS) + || ((m_Settings.BitsPerSample != 16) && (m_Settings.BitsPerSample != 32))) goto abort; + m_nChannels = m_Settings.Channels; m_pAsioDrv->getChannels(&nInputChannels, &nOutputChannels); #ifdef ASIO_LOG Log(" getChannels: %d inputs, %d outputs\n", nInputChannels, nOutputChannels); #endif - if (pwfx->nChannels > nOutputChannels) goto abort; - if (m_pAsioDrv->setSampleRate(pwfx->nSamplesPerSec) != ASE_OK) + if (m_Settings.Channels > nOutputChannels) goto abort; + if (m_pAsioDrv->setSampleRate(m_Settings.Samplerate) != ASE_OK) { #ifdef ASIO_LOG - Log(" setSampleRate(%d) failed (sample rate not supported)!\n", pwfx->nSamplesPerSec); + Log(" setSampleRate(%d) failed (sample rate not supported)!\n", m_Settings.Samplerate); #endif goto abort; } - m_nBitsPerSample = pwfx->wBitsPerSample; - for (UINT ich=0; ich<pwfx->nChannels; ich++) + m_nBitsPerSample = m_Settings.BitsPerSample; + for (UINT ich=0; ich<m_Settings.Channels; ich++) { m_ChannelInfo[ich].channel = ich; m_ChannelInfo[ich].isInput = ASIOFalse; @@ -1269,7 +1315,7 @@ Log(" getBufferSize(): minSize=%d maxSize=%d preferredSize=%d granularity=%d\n", minSize, maxSize, preferredSize, granularity); #endif - m_nAsioBufferLen = ((m_LatencyMS * pwfx->nSamplesPerSec) / 2000); + m_nAsioBufferLen = ((m_Settings.LatencyMS * m_Settings.Samplerate) / 2000); if (m_nAsioBufferLen < (UINT)minSize) m_nAsioBufferLen = minSize; else if (m_nAsioBufferLen > (UINT)maxSize) m_nAsioBufferLen = maxSize; else if (granularity < 0) @@ -1297,9 +1343,8 @@ } m_nAsioBufferLen = n; } - m_nSamplesPerSec = pwfx->nSamplesPerSec; - m_RealLatencyMS = m_nAsioBufferLen * 2 * 1000.0f / m_nSamplesPerSec; - m_RealUpdateIntervalMS = m_nAsioBufferLen * 1000.0f / m_nSamplesPerSec; + m_RealLatencyMS = m_nAsioBufferLen * 2 * 1000.0f / m_Settings.Samplerate; + m_RealUpdateIntervalMS = m_nAsioBufferLen * 1000.0f / m_Settings.Samplerate; #ifdef ASIO_LOG Log(" Using buffersize=%d samples\n", m_nAsioBufferLen); #endif @@ -1317,7 +1362,7 @@ } } m_bPostOutput = (m_pAsioDrv->outputReady() == ASE_OK) ? TRUE : FALSE; - bOk = TRUE; + bOk = true; } #ifdef ASIO_LOG else Log(" createBuffers failed!\n"); @@ -1417,8 +1462,8 @@ } -BOOL CASIODevice::Close() -//----------------------- +bool CASIODevice::InternalClose() +//------------------------------- { if (IsOpen()) { @@ -1450,7 +1495,7 @@ { gpCurrentAsio = NULL; } - return TRUE; + return true; } @@ -1489,7 +1534,7 @@ CLSID clsid = gAsioDrivers[nDevice].clsid; if (CoCreateInstance(clsid,0,CLSCTX_INPROC_SERVER, clsid, (void **)&m_pAsioDrv) == S_OK) { - m_pAsioDrv->init((void *)m_hWnd); + m_pAsioDrv->init((void *)m_Settings.hWnd); } else { #ifdef ASIO_LOG @@ -2039,8 +2084,8 @@ } -BOOL CPortaudioDevice::Open(UINT nDevice, LPWAVEFORMATEX pwfx) -//------------------------------------------------------------ +bool CPortaudioDevice::InternalOpen(UINT nDevice) +//----------------------------------------------- { MemsetZero(m_StreamParameters); m_Stream = 0; @@ -2048,18 +2093,25 @@ m_CurrentFrameCount = 0; m_StreamParameters.device = HostApiOutputIndexToGlobalDeviceIndex(nDevice, m_HostApi); if(m_StreamParameters.device == -1) return false; - m_StreamParameters.channelCount = pwfx->nChannels; - switch(pwfx->wBitsPerSample) + m_StreamParameters.channelCount = m_Settings.Channels; + if(m_Settings.FloatingPoint) { + if(m_Settings.BitsPerSample != 32) return false; + m_StreamParameters.sampleFormat = paFloat32; + } else + { + switch... [truncated message content] |
From: <man...@us...> - 2013-08-07 05:53:34
|
Revision: 2591 http://sourceforge.net/p/modplug/code/2591 Author: manxorist Date: 2013-08-07 05:53:27 +0000 (Wed, 07 Aug 2013) Log Message: ----------- [Ref] Move AudioReadTarget into its own file. Modified Paths: -------------- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Added Paths: ----------- trunk/OpenMPT/soundlib/AudioReadTarget.h Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2013-08-06 18:45:59 UTC (rev 2590) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2013-08-07 05:53:27 UTC (rev 2591) @@ -422,6 +422,7 @@ <ClInclude Include="..\common\versionNumber.h" /> <ClInclude Include="..\include\pugixml\src\pugiconfig.hpp" /> <ClInclude Include="..\include\pugixml\src\pugixml.hpp" /> + <ClInclude Include="..\soundlib\AudioReadTarget.h" /> <ClInclude Include="..\soundlib\ChunkReader.h" /> <ClInclude Include="..\soundlib\Dither.h" /> <ClInclude Include="..\soundlib\Dlsbank.h" /> Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2013-08-06 18:45:59 UTC (rev 2590) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2013-08-07 05:53:27 UTC (rev 2591) @@ -236,6 +236,9 @@ <ClInclude Include="..\soundlib\Dither.h"> <Filter>Header Files\soundlib</Filter> </ClInclude> + <ClInclude Include="..\soundlib\AudioReadTarget.h"> + <Filter>Header Files\soundlib</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="..\common\AudioCriticalSection.cpp"> Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-08-06 18:45:59 UTC (rev 2590) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-08-07 05:53:27 UTC (rev 2591) @@ -23,8 +23,7 @@ #include <cstring> #include "soundlib/Sndfile.h" -#include "soundlib/Dither.h" -#include "soundlib/SampleFormatConverters.h" +#include "soundlib/AudioReadTarget.h" #include "soundlib/FileReader.h" namespace openmpt { Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-08-06 18:45:59 UTC (rev 2590) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-08-07 05:53:27 UTC (rev 2591) @@ -12,7 +12,7 @@ #include "mptrack.h" #include "MainFrm.h" #include "../sounddev/SoundDevice.h" -#include "../soundlib/SampleFormatConverters.h" +#include "../soundlib/AudioReadTarget.h" #include "moddoc.h" #include "childfrm.h" #include "Dlsbank.h" Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-08-06 18:45:59 UTC (rev 2590) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-08-07 05:53:27 UTC (rev 2591) @@ -21,7 +21,7 @@ #include "../common/version.h" #include "ACMConvert.h" #include "../soundlib/Dither.h" -#include "../soundlib/SampleFormatConverters.h" +#include "../soundlib/AudioReadTarget.h" #include <fstream> Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-08-06 18:45:59 UTC (rev 2590) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-08-07 05:53:27 UTC (rev 2591) @@ -821,6 +821,10 @@ > </File> <File + RelativePath="..\soundlib\AudioReadTarget.h" + > + </File> + <File RelativePath=".\AutoSaver.h" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-08-06 18:45:59 UTC (rev 2590) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-08-07 05:53:27 UTC (rev 2591) @@ -482,6 +482,7 @@ <ClInclude Include="..\sounddsp\DSP.h" /> <ClInclude Include="..\sounddsp\EQ.h" /> <ClInclude Include="..\sounddsp\Reverb.h" /> + <ClInclude Include="..\soundlib\AudioReadTarget.h" /> <ClInclude Include="..\soundlib\ChunkReader.h" /> <ClInclude Include="..\soundlib\Dither.h" /> <ClInclude Include="..\soundlib\Dlsbank.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-08-06 18:45:59 UTC (rev 2590) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-08-07 05:53:27 UTC (rev 2591) @@ -888,6 +888,9 @@ <ClInclude Include="..\soundlib\Dither.h"> <Filter>Header Files\soundlib</Filter> </ClInclude> + <ClInclude Include="..\soundlib\AudioReadTarget.h"> + <Filter>Header Files\soundlib</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> Added: trunk/OpenMPT/soundlib/AudioReadTarget.h =================================================================== --- trunk/OpenMPT/soundlib/AudioReadTarget.h (rev 0) +++ trunk/OpenMPT/soundlib/AudioReadTarget.h 2013-08-07 05:53:27 UTC (rev 2591) @@ -0,0 +1,109 @@ +/* + * AudioReadTarget.h + * ----------------- + * Purpose: Callback class implementations for audio data read via CSoundFile::Read. + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#include "Sndfile.h" +#include "Dither.h" +#include "SampleFormatConverters.h" + + +template<typename Tsample> +class AudioReadTargetBuffer + : public IAudioReadTarget +{ +private: + std::size_t countRendered; + Dither &dither; +protected: + Tsample *outputBuffer; + Tsample * const *outputBuffers; +public: + AudioReadTargetBuffer(Dither &dither_, Tsample *buffer, Tsample * const *buffers) + : countRendered(0) + , dither(dither_) + , outputBuffer(buffer) + , outputBuffers(buffers) + { + ASSERT(SampleFormat(SampleFormatTraits<Tsample>::sampleFormat).IsValid()); + } + virtual ~AudioReadTargetBuffer() { } + std::size_t GetRenderedCount() const { return countRendered; } +public: + virtual void DataCallback(int *MixSoundBuffer, std::size_t channels, std::size_t countChunk) + { + // Convert to output sample format and optionally perform dithering and clipping if needed + + const SampleFormat sampleFormat = SampleFormatTraits<Tsample>::sampleFormat; + + if(sampleFormat.IsInt()) + { + dither.Process(MixSoundBuffer, countChunk, channels, sampleFormat.GetBitsPerSample()); + } + + if(outputBuffer) + { + ConvertInterleavedFixedPointToInterleaved<MIXING_FRACTIONAL_BITS>(outputBuffer + (channels * countRendered), MixSoundBuffer, channels, countChunk); + } + if(outputBuffers) + { + Tsample *buffers[4] = { nullptr, nullptr, nullptr, nullptr }; + for(std::size_t channel = 0; channel < channels; ++channel) + { + buffers[channel] = outputBuffers[channel] + countRendered; + } + ConvertInterleavedFixedPointToNonInterleaved<MIXING_FRACTIONAL_BITS>(buffers, MixSoundBuffer, channels, countChunk); + } + + countRendered += countChunk; + } +}; + + +#ifndef MODPLUG_TRACKER + +template<typename Tsample> +class AudioReadTargetGainBuffer + : public AudioReadTargetBuffer<Tsample> +{ +private: + typedef AudioReadTargetBuffer<Tsample> Tbase; +private: + const float gainFactor; +public: + AudioReadTargetGainBuffer(Dither &dither, Tsample *buffer, Tsample * const *buffers, float gainFactor_) + : Tbase(dither, buffer, buffers) + , gainFactor(gainFactor_) + { + return; + } + virtual ~AudioReadTargetGainBuffer() { } +public: + virtual void DataCallback(int *MixSoundBuffer, std::size_t channels, std::size_t countChunk) + { + const SampleFormat sampleFormat = SampleFormatTraits<Tsample>::sampleFormat; + const std::size_t countRendered = Tbase::GetRenderedCount(); + + if(sampleFormat.IsInt()) + { + // Apply final output gain for non floating point output + ApplyGain(MixSoundBuffer, channels, countChunk, Util::Round<int32>(gainFactor * (1<<16))); + } + + Tbase::DataCallback(MixSoundBuffer, channels, countChunk); + + if(sampleFormat.IsFloat()) + { + // Apply final output gain for floating point output after conversion so we do not suffer underflow or clipping + ApplyGain(reinterpret_cast<float*>(Tbase::outputBuffer), reinterpret_cast<float*const*>(Tbase::outputBuffers), countRendered, channels, countChunk, gainFactor); + } + + } +}; + +#endif // !MODPLUG_TRACKER Property changes on: trunk/OpenMPT/soundlib/AudioReadTarget.h ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-chdr \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-08-06 18:45:59 UTC (rev 2590) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-08-07 05:53:27 UTC (rev 2591) @@ -39,8 +39,6 @@ #include "../sounddsp/AGC.h" #include "../sounddsp/DSP.h" #include "../sounddsp/EQ.h" -#include "Dither.h" -#include "SampleFormatConverters.h" class FileReader; @@ -207,102 +205,6 @@ }; -template<typename Tsample> -class AudioReadTargetBuffer - : public IAudioReadTarget -{ -private: - std::size_t countRendered; - Dither &dither; -protected: - Tsample *outputBuffer; - Tsample * const *outputBuffers; -public: - AudioReadTargetBuffer(Dither &dither_, Tsample *buffer, Tsample * const *buffers) - : countRendered(0) - , dither(dither_) - , outputBuffer(buffer) - , outputBuffers(buffers) - { - ASSERT(SampleFormat(SampleFormatTraits<Tsample>::sampleFormat).IsValid()); - } - virtual ~AudioReadTargetBuffer() { } - std::size_t GetRenderedCount() const { return countRendered; } -public: - virtual void DataCallback(int *MixSoundBuffer, std::size_t channels, std::size_t countChunk) - { - // Convert to output sample format and optionally perform dithering and clipping if needed - - const SampleFormat sampleFormat = SampleFormatTraits<Tsample>::sampleFormat; - - if(sampleFormat.IsInt()) - { - dither.Process(MixSoundBuffer, countChunk, channels, sampleFormat.GetBitsPerSample()); - } - - if(outputBuffer) - { - ConvertInterleavedFixedPointToInterleaved<MIXING_FRACTIONAL_BITS>(outputBuffer + (channels * countRendered), MixSoundBuffer, channels, countChunk); - } - if(outputBuffers) - { - Tsample *buffers[4] = { nullptr, nullptr, nullptr, nullptr }; - for(std::size_t channel = 0; channel < channels; ++channel) - { - buffers[channel] = outputBuffers[channel] + countRendered; - } - ConvertInterleavedFixedPointToNonInterleaved<MIXING_FRACTIONAL_BITS>(buffers, MixSoundBuffer, channels, countChunk); - } - - countRendered += countChunk; - } -}; - - -#ifndef MODPLUG_TRACKER - -template<typename Tsample> -class AudioReadTargetGainBuffer - : public AudioReadTargetBuffer<Tsample> -{ -private: - typedef AudioReadTargetBuffer<Tsample> Tbase; -private: - const float gainFactor; -public: - AudioReadTargetGainBuffer(Dither &dither, Tsample *buffer, Tsample * const *buffers, float gainFactor_) - : Tbase(dither, buffer, buffers) - , gainFactor(gainFactor_) - { - return; - } - virtual ~AudioReadTargetGainBuffer() { } -public: - virtual void DataCallback(int *MixSoundBuffer, std::size_t channels, std::size_t countChunk) - { - const SampleFormat sampleFormat = SampleFormatTraits<Tsample>::sampleFormat; - const std::size_t countRendered = Tbase::GetRenderedCount(); - - if(sampleFormat.IsInt()) - { - // Apply final output gain for non floating point output - ApplyGain(MixSoundBuffer, channels, countChunk, Util::Round<int32>(gainFactor * (1<<16))); - } - - Tbase::DataCallback(MixSoundBuffer, channels, countChunk); - - if(sampleFormat.IsFloat()) - { - // Apply final output gain for floating point output after conversion so we do not suffer underflow or clipping - ApplyGain(reinterpret_cast<float*>(Tbase::outputBuffer), reinterpret_cast<float*const*>(Tbase::outputBuffers), countRendered, channels, countChunk, gainFactor); - } - - } -}; - -#endif // !MODPLUG_TRACKER - - #if MPT_COMPILER_MSVC #pragma warning(disable:4324) //structure was padded due to __declspec(align()) #endif Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-08-06 18:45:59 UTC (rev 2590) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-08-07 05:53:27 UTC (rev 2591) @@ -15,8 +15,6 @@ #include "MIDIEvents.h" #include "tuning.h" #include "Tables.h" -#include "Dither.h" -#include "SampleFormatConverters.h" #ifdef MODPLUG_TRACKER #include "../mptrack/TrackerSettings.h" #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-08-08 11:15:28
|
Revision: 2593 http://sourceforge.net/p/modplug/code/2593 Author: manxorist Date: 2013-08-08 11:15:18 +0000 (Thu, 08 Aug 2013) Log Message: ----------- [Ref] Move mixer-related helper inner loops from Fastmix.cpp and Mmx_mix.cpp into new file MixerLoops.cpp . Add a proper header MixerLoops.h instead of declaring these functions in Sndfile.h or just where needed. Delete now-empty Mmx_mix.cpp . Modified Paths: -------------- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/sounddsp/EQ.cpp trunk/OpenMPT/soundlib/AudioReadTarget.h trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Added Paths: ----------- trunk/OpenMPT/soundlib/MixerLoops.cpp trunk/OpenMPT/soundlib/MixerLoops.h Removed Paths: ------------- trunk/OpenMPT/soundlib/Mmx_mix.cpp Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2013-08-07 10:28:47 UTC (rev 2592) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2013-08-08 11:15:18 UTC (rev 2593) @@ -434,6 +434,7 @@ <ClInclude Include="..\soundlib\Message.h" /> <ClInclude Include="..\soundlib\MIDIEvents.h" /> <ClInclude Include="..\soundlib\MIDIMacros.h" /> + <ClInclude Include="..\soundlib\MixerLoops.h" /> <ClInclude Include="..\soundlib\MixerSettings.h" /> <ClInclude Include="..\soundlib\ModChannel.h" /> <ClInclude Include="..\soundlib\modcommand.h" /> @@ -518,9 +519,9 @@ <ClCompile Include="..\soundlib\Message.cpp" /> <ClCompile Include="..\soundlib\MIDIEvents.cpp" /> <ClCompile Include="..\soundlib\MIDIMacros.cpp" /> + <ClCompile Include="..\soundlib\MixerLoops.cpp" /> <ClCompile Include="..\soundlib\MixerSettings.cpp" /> <ClCompile Include="..\soundlib\Mmcmp.cpp" /> - <ClCompile Include="..\soundlib\Mmx_mix.cpp" /> <ClCompile Include="..\soundlib\ModChannel.cpp" /> <ClCompile Include="..\soundlib\modcommand.cpp" /> <ClCompile Include="..\soundlib\ModInstrument.cpp" /> Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2013-08-07 10:28:47 UTC (rev 2592) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2013-08-08 11:15:18 UTC (rev 2593) @@ -239,6 +239,9 @@ <ClInclude Include="..\soundlib\AudioReadTarget.h"> <Filter>Header Files\soundlib</Filter> </ClInclude> + <ClInclude Include="..\soundlib\MixerLoops.h"> + <Filter>Header Files\soundlib</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="..\common\AudioCriticalSection.cpp"> @@ -379,9 +382,6 @@ <ClCompile Include="..\soundlib\Mmcmp.cpp"> <Filter>Source Files\soundlib</Filter> </ClCompile> - <ClCompile Include="..\soundlib\Mmx_mix.cpp"> - <Filter>Source Files\soundlib</Filter> - </ClCompile> <ClCompile Include="..\soundlib\mod_specifications.cpp"> <Filter>Source Files\soundlib</Filter> </ClCompile> @@ -496,5 +496,8 @@ <ClCompile Include="..\soundlib\Dither.cpp"> <Filter>Source Files\soundlib</Filter> </ClCompile> + <ClCompile Include="..\soundlib\MixerLoops.cpp"> + <Filter>Source Files\soundlib</Filter> + </ClCompile> </ItemGroup> </Project> \ No newline at end of file Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-08-07 10:28:47 UTC (rev 2592) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-08-08 11:15:18 UTC (rev 2593) @@ -20,6 +20,7 @@ #include "WAVTools.h" #include "../common/version.h" #include "ACMConvert.h" +#include "../soundlib/MixerLoops.h" #include "../soundlib/Dither.h" #include "../soundlib/AudioReadTarget.h" Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-08-07 10:28:47 UTC (rev 2592) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-08-08 11:15:18 UTC (rev 2593) @@ -395,7 +395,7 @@ > </File> <File - RelativePath="..\soundlib\Mmx_mix.cpp" + RelativePath="..\soundlib\MixerLoops.cpp" > </File> <File @@ -961,6 +961,10 @@ > </File> <File + RelativePath="..\soundlib\MixerLoops.h" + > + </File> + <File RelativePath="..\soundlib\MixerSettings.h" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-08-07 10:28:47 UTC (rev 2592) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-08-08 11:15:18 UTC (rev 2593) @@ -274,9 +274,9 @@ <ClCompile Include="..\soundlib\Message.cpp" /> <ClCompile Include="..\soundlib\MIDIEvents.cpp" /> <ClCompile Include="..\soundlib\MIDIMacros.cpp" /> + <ClCompile Include="..\soundlib\MixerLoops.cpp" /> <ClCompile Include="..\soundlib\MixerSettings.cpp" /> <ClCompile Include="..\soundlib\Mmcmp.cpp" /> - <ClCompile Include="..\soundlib\Mmx_mix.cpp" /> <ClCompile Include="..\soundlib\ModChannel.cpp" /> <ClCompile Include="..\soundlib\modcommand.cpp" /> <ClCompile Include="..\soundlib\ModInstrument.cpp" /> @@ -493,6 +493,7 @@ <ClInclude Include="..\soundlib\Message.h" /> <ClInclude Include="..\soundlib\MIDIEvents.h" /> <ClInclude Include="..\soundlib\MIDIMacros.h" /> + <ClInclude Include="..\soundlib\MixerLoops.h" /> <ClInclude Include="..\soundlib\MixerSettings.h" /> <ClInclude Include="..\soundlib\ModChannel.h" /> <ClInclude Include="..\soundlib\modcommand.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-08-07 10:28:47 UTC (rev 2592) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-08-08 11:15:18 UTC (rev 2593) @@ -199,9 +199,6 @@ <ClCompile Include="..\soundlib\Mmcmp.cpp"> <Filter>Source Files\soundlib</Filter> </ClCompile> - <ClCompile Include="..\soundlib\Mmx_mix.cpp"> - <Filter>Source Files\soundlib</Filter> - </ClCompile> <ClCompile Include="..\soundlib\mod_specifications.cpp"> <Filter>Source Files\soundlib</Filter> </ClCompile> @@ -481,6 +478,9 @@ <ClCompile Include="..\soundlib\Dither.cpp"> <Filter>Source Files\soundlib</Filter> </ClCompile> + <ClCompile Include="..\soundlib\MixerLoops.cpp"> + <Filter>Source Files\soundlib</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\soundlib\Loaders.h"> @@ -891,6 +891,9 @@ <ClInclude Include="..\soundlib\AudioReadTarget.h"> <Filter>Header Files\soundlib</Filter> </ClInclude> + <ClInclude Include="..\soundlib\MixerLoops.h"> + <Filter>Header Files\soundlib</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> Modified: trunk/OpenMPT/sounddsp/EQ.cpp =================================================================== --- trunk/OpenMPT/sounddsp/EQ.cpp 2013-08-07 10:28:47 UTC (rev 2592) +++ trunk/OpenMPT/sounddsp/EQ.cpp 2013-08-08 11:15:18 UTC (rev 2593) @@ -11,6 +11,7 @@ #include "stdafx.h" #include "../soundlib/Sndfile.h" +#include "../soundlib/MixerLoops.h" #include "../sounddsp/EQ.h" Modified: trunk/OpenMPT/soundlib/AudioReadTarget.h =================================================================== --- trunk/OpenMPT/soundlib/AudioReadTarget.h 2013-08-07 10:28:47 UTC (rev 2592) +++ trunk/OpenMPT/soundlib/AudioReadTarget.h 2013-08-08 11:15:18 UTC (rev 2593) @@ -11,6 +11,7 @@ #include "Sndfile.h" #include "Dither.h" #include "SampleFormatConverters.h" +#include "MixerLoops.h" template<typename Tsample> Modified: trunk/OpenMPT/soundlib/Fastmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-08-07 10:28:47 UTC (rev 2592) +++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-08-08 11:15:18 UTC (rev 2593) @@ -15,6 +15,7 @@ #include "stdafx.h" #include "Sndfile.h" +#include "MixerLoops.h" #include "Resampler.h" #include "WindowedFIR.h" @@ -459,14 +460,6 @@ ///////////////////////////////////////////////////// -// - -void InitMixBuffer(int *pBuffer, UINT nSamples); -void EndChannelOfs(ModChannel *pChannel, int *pBuffer, UINT nSamples); -void StereoFill(int *pBuffer, UINT nSamples, LPLONG lpROfs, LPLONG lpLOfs); - - -///////////////////////////////////////////////////// // Mono samples functions BEGIN_MIX_INTERFACE(Mono8BitMix) @@ -1605,6 +1598,8 @@ void CSoundFile::ProcessPlugins(UINT nCount) //------------------------------------------ { + const float IntToFloat = m_PlayConfig.getIntToFloat(); + const float FloatToInt = m_PlayConfig.getFloatToInt(); // Setup float inputs for(PLUGINDEX plug = 0; plug < MAX_MIXPLUGINS; plug++) { @@ -1629,12 +1624,12 @@ // Setup float input if (pState->dwFlags & SNDMIXPLUGINSTATE::psfMixReady) { - StereoMixToFloat(pState->pMixBuffer, pState->pOutBufferL, pState->pOutBufferR, nCount); + StereoMixToFloat(pState->pMixBuffer, pState->pOutBufferL, pState->pOutBufferR, nCount, IntToFloat); } else if (pState->nVolDecayR|pState->nVolDecayL) { StereoFill(pState->pMixBuffer, nCount, &pState->nVolDecayR, &pState->nVolDecayL); - StereoMixToFloat(pState->pMixBuffer, pState->pOutBufferL, pState->pOutBufferR, nCount); + StereoMixToFloat(pState->pMixBuffer, pState->pOutBufferL, pState->pOutBufferR, nCount, IntToFloat); } else { memset(pState->pOutBufferL, 0, nCount * sizeof(float)); @@ -1644,7 +1639,7 @@ } } // Convert mix buffer - StereoMixToFloat(MixSoundBuffer, MixFloatBuffer, MixFloatBuffer + MIXBUFFERSIZE, nCount); + StereoMixToFloat(MixSoundBuffer, MixFloatBuffer, MixFloatBuffer + MIXBUFFERSIZE, nCount, IntToFloat); float *pMixL = MixFloatBuffer; float *pMixR = MixFloatBuffer + MIXBUFFERSIZE; @@ -1730,365 +1725,6 @@ } } } - FloatToStereoMix(pMixL, pMixR, MixSoundBuffer, nCount); + FloatToStereoMix(pMixL, pMixR, MixSoundBuffer, nCount, FloatToInt); } - -////////////////////////////////////////////////////////////////////////////////////////// - - -void InitMixBuffer(int *pBuffer, UINT nSamples) -//--------------------------------------------- -{ - memset(pBuffer, 0, nSamples * sizeof(int)); -} - -#if MPT_COMPILER_MSVC -#pragma warning(disable:4731) // ebp modified -#endif - -#ifdef ENABLE_X86 -static void X86_InterleaveFrontRear(int *pFrontBuf, int *pRearBuf, DWORD nFrames) -//------------------------------------------------------------------------------- -{ - _asm { - mov ecx, nFrames // ecx = framecount - mov esi, pFrontBuf // esi = front buffer - mov edi, pRearBuf // edi = rear buffer - lea esi, [esi+ecx*8] // esi = &front[N*2] - lea edi, [edi+ecx*8] // edi = &rear[N*2] - lea ebx, [esi+ecx*8] // ebx = &front[N*4] - push ebp -interleaveloop: - mov eax, dword ptr [esi-8] - mov edx, dword ptr [esi-4] - sub ebx, 16 - mov ebp, dword ptr [edi-8] - mov dword ptr [ebx], eax - mov dword ptr [ebx+4], edx - mov eax, dword ptr [edi-4] - sub esi, 8 - sub edi, 8 - dec ecx - mov dword ptr [ebx+8], ebp - mov dword ptr [ebx+12], eax - jnz interleaveloop - pop ebp - } -} -#endif - -static void C_InterleaveFrontRear(int *pFrontBuf, int *pRearBuf, DWORD nFrames) -//----------------------------------------------------------------------------- -{ - // copy backwards as we are writing back into FrontBuf - for(int i=nFrames-1; i>=0; i--) - { - pFrontBuf[i*4+3] = pRearBuf[i*2+1]; - pFrontBuf[i*4+2] = pRearBuf[i*2+0]; - pFrontBuf[i*4+1] = pFrontBuf[i*2+1]; - pFrontBuf[i*4+0] = pFrontBuf[i*2+0]; - } -} - -void InterleaveFrontRear(int *pFrontBuf, int *pRearBuf, DWORD nFrames) -//-------------------------------------------------------------------- -{ - #ifdef ENABLE_X86 - X86_InterleaveFrontRear(pFrontBuf, pRearBuf, nFrames); - #else - C_InterleaveFrontRear(pFrontBuf, pRearBuf, nFrames); - #endif -} - - -#ifdef ENABLE_X86 -static void X86_MonoFromStereo(int *pMixBuf, UINT nSamples) -//--------------------------------------------------------- -{ - _asm { - mov ecx, nSamples - mov esi, pMixBuf - mov edi, esi -stloop: - mov eax, dword ptr [esi] - mov edx, dword ptr [esi+4] - add edi, 4 - add esi, 8 - add eax, edx - sar eax, 1 - dec ecx - mov dword ptr [edi-4], eax - jnz stloop - } -} -#endif - -static void C_MonoFromStereo(int *pMixBuf, UINT nSamples) -//------------------------------------------------------- -{ - for(UINT i=0; i<nSamples; ++i) - { - pMixBuf[i] = (pMixBuf[i*2] + pMixBuf[i*2+1]) / 2; - } -} - -void MonoFromStereo(int *pMixBuf, UINT nSamples) -//---------------------------------------------- -{ - #ifdef ENABLE_X86 - X86_MonoFromStereo(pMixBuf, nSamples); - #else - C_MonoFromStereo(pMixBuf, nSamples); - #endif -} - - -#define OFSDECAYSHIFT 8 -#define OFSDECAYMASK 0xFF - - -#ifdef ENABLE_X86 -static void X86_StereoFill(int *pBuffer, UINT nSamples, LPLONG lpROfs, LPLONG lpLOfs) -//----------------------------------------------------------------------------------- -{ - _asm { - mov edi, pBuffer - mov ecx, nSamples - mov eax, lpROfs - mov edx, lpLOfs - mov eax, [eax] - mov edx, [edx] - or ecx, ecx - jz fill_loop - mov ebx, eax - or ebx, edx - jz fill_loop -ofsloop: - mov ebx, eax - mov esi, edx - neg ebx - neg esi - sar ebx, 31 - sar esi, 31 - and ebx, OFSDECAYMASK - and esi, OFSDECAYMASK - add ebx, eax - add esi, edx - sar ebx, OFSDECAYSHIFT - sar esi, OFSDECAYSHIFT - sub eax, ebx - sub edx, esi - mov ebx, eax - or ebx, edx - jz fill_loop - add edi, 8 - dec ecx - mov [edi-8], eax - mov [edi-4], edx - jnz ofsloop -fill_loop: - mov ebx, ecx - and ebx, 3 - jz fill4x -fill1x: - mov [edi], eax - mov [edi+4], edx - add edi, 8 - dec ebx - jnz fill1x -fill4x: - shr ecx, 2 - or ecx, ecx - jz done -fill4xloop: - mov [edi], eax - mov [edi+4], edx - mov [edi+8], eax - mov [edi+12], edx - add edi, 8*4 - dec ecx - mov [edi-16], eax - mov [edi-12], edx - mov [edi-8], eax - mov [edi-4], edx - jnz fill4xloop -done: - mov esi, lpROfs - mov edi, lpLOfs - mov [esi], eax - mov [edi], edx - } -} -#endif - -// c implementation taken from libmodplug -static void C_StereoFill(int *pBuffer, UINT nSamples, LPLONG lpROfs, LPLONG lpLOfs) -//--------------------------------------------------------------------------------- -{ - int rofs = *lpROfs; - int lofs = *lpLOfs; - - if ((!rofs) && (!lofs)) - { - InitMixBuffer(pBuffer, nSamples*2); - return; - } - for (UINT i=0; i<nSamples; i++) - { - int x_r = (rofs + (((-rofs)>>31) & OFSDECAYMASK)) >> OFSDECAYSHIFT; - int x_l = (lofs + (((-lofs)>>31) & OFSDECAYMASK)) >> OFSDECAYSHIFT; - rofs -= x_r; - lofs -= x_l; - pBuffer[i*2] = x_r; - pBuffer[i*2+1] = x_l; - } - *lpROfs = rofs; - *lpLOfs = lofs; -} - -void StereoFill(int *pBuffer, UINT nSamples, LPLONG lpROfs, LPLONG lpLOfs) -//------------------------------------------------------------------------ -{ - #ifdef ENABLE_X86 - X86_StereoFill(pBuffer, nSamples, lpROfs, lpLOfs); - #else - C_StereoFill(pBuffer, nSamples, lpROfs, lpLOfs); - #endif -} - - -#ifdef ENABLE_X86 -typedef ModChannel ModChannel_; -static void X86_EndChannelOfs(ModChannel *pChannel, int *pBuffer, UINT nSamples) -//------------------------------------------------------------------------------ -{ - _asm { - mov esi, pChannel - mov edi, pBuffer - mov ecx, nSamples - mov eax, dword ptr [esi+ModChannel_.nROfs] - mov edx, dword ptr [esi+ModChannel_.nLOfs] - or ecx, ecx - jz brkloop -ofsloop: - mov ebx, eax - mov esi, edx - neg ebx - neg esi - sar ebx, 31 - sar esi, 31 - and ebx, OFSDECAYMASK - and esi, OFSDECAYMASK - add ebx, eax - add esi, edx - sar ebx, OFSDECAYSHIFT - sar esi, OFSDECAYSHIFT - sub eax, ebx - sub edx, esi - mov ebx, eax - add dword ptr [edi], eax - add dword ptr [edi+4], edx - or ebx, edx - jz brkloop - add edi, 8 - dec ecx - jnz ofsloop -brkloop: - mov esi, pChannel - mov dword ptr [esi+ModChannel_.nROfs], eax - mov dword ptr [esi+ModChannel_.nLOfs], edx - } -} -#endif - -// c implementation taken from libmodplug -static void C_EndChannelOfs(ModChannel *pChannel, int *pBuffer, UINT nSamples) -//---------------------------------------------------------------------------- -{ - - int rofs = pChannel->nROfs; - int lofs = pChannel->nLOfs; - - if ((!rofs) && (!lofs)) return; - for (UINT i=0; i<nSamples; i++) - { - int x_r = (rofs + (((-rofs)>>31) & OFSDECAYMASK)) >> OFSDECAYSHIFT; - int x_l = (lofs + (((-lofs)>>31) & OFSDECAYMASK)) >> OFSDECAYSHIFT; - rofs -= x_r; - lofs -= x_l; - pBuffer[i*2] += x_r; - pBuffer[i*2+1] += x_l; - } - pChannel->nROfs = rofs; - pChannel->nLOfs = lofs; -} - -void EndChannelOfs(ModChannel *pChannel, int *pBuffer, UINT nSamples) -//------------------------------------------------------------------- -{ - #ifdef ENABLE_X86 - X86_EndChannelOfs(pChannel, pBuffer, nSamples); - #else - C_EndChannelOfs(pChannel, pBuffer, nSamples); - #endif -} - - - -#ifndef MODPLUG_TRACKER - -void ApplyGain(int *soundBuffer, std::size_t channels, std::size_t countChunk, int32 gainFactor16_16) -//--------------------------------------------------------------------------------------------------- -{ - if(gainFactor16_16 == (1<<16)) - { - // nothing to do, gain == +/- 0dB - return; - } - // no clipping prevention is done here - int * buf = soundBuffer; - for(std::size_t i=0; i<countChunk*channels; ++i) - { - *buf = Util::muldiv(*buf, gainFactor16_16, 1<<16); - buf++; - } -} - -static void ApplyGain(float *beg, float *end, float factor) -//--------------------------------------------------------- -{ - for(float *it = beg; it != end; ++it) - { - *it *= factor; - } -} - -void ApplyGain(float * outputBuffer, float * const *outputBuffers, std::size_t offset, std::size_t channels, std::size_t countChunk, float gainFactor) -//---------------------------------------------------------------------------------------------------------------------------------------------------- -{ - if(gainFactor == 1.0f) - { - // nothing to do, gain == +/- 0dB - return; - } - if(outputBuffer) - { - ApplyGain( - outputBuffer + (channels * offset), - outputBuffer + (channels * (offset + countChunk)), - gainFactor); - } - if(outputBuffers) - { - for(std::size_t channel = 0; channel < channels; ++channel) - { - ApplyGain( - outputBuffers[channel] + offset, - outputBuffers[channel] + offset + countChunk, - gainFactor); - } - } -} - -#endif // !MODPLUG_TRACKER Copied: trunk/OpenMPT/soundlib/MixerLoops.cpp (from rev 2592, trunk/OpenMPT/soundlib/Mmx_mix.cpp) =================================================================== --- trunk/OpenMPT/soundlib/MixerLoops.cpp (rev 0) +++ trunk/OpenMPT/soundlib/MixerLoops.cpp 2013-08-08 11:15:18 UTC (rev 2593) @@ -0,0 +1,823 @@ +/* + * MixerLoops.cpp + * -------------- + * Purpose: Utility inner loops for mixer-related functionality. + * Notes : + * x86 ( AMD/INTEL ) based low level based mixing functions: + * This file contains critical code. The basic X86 functions are + * defined at the bottom of the file. #define's are used to isolate + * the different flavours of functionality: + * ENABLE_MMX, ENABLE_3DNOW, ENABLE_SSE flags must be set to + * to compile the optimized sections of the code. In both cases the + * X86_xxxxxx functions will compile. + * Authors: Olivier Lapicque + * OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#include "stdafx.h" +#include "Sndfile.h" + + +//////////////////////////////////////////////////////////////////////////////////// +// 3DNow! optimizations + +#ifdef ENABLE_X86_AMD + +// Convert integer mix to floating-point +static void AMD_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) +//----------------------------------------------------------------------------------------------------------- +{ + _asm { + movd mm0, _i2fc + mov edx, pSrc + mov edi, pOut1 + mov ebx, pOut2 + mov ecx, nCount + punpckldq mm0, mm0 + inc ecx + shr ecx, 1 +mainloop: + movq mm1, qword ptr [edx] + movq mm2, qword ptr [edx+8] + add edi, 8 + pi2fd mm1, mm1 + pi2fd mm2, mm2 + add ebx, 8 + pfmul mm1, mm0 + pfmul mm2, mm0 + add edx, 16 + movq mm3, mm1 + punpckldq mm3, mm2 + punpckhdq mm1, mm2 + dec ecx + movq qword ptr [edi-8], mm3 + movq qword ptr [ebx-8], mm1 + jnz mainloop + emms + } +} + +static void AMD_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic) +//--------------------------------------------------------------------------------------------------------------- +{ + _asm { + movd mm0, _f2ic + mov eax, pIn1 + mov ebx, pIn2 + mov edx, pOut + mov ecx, nCount + punpckldq mm0, mm0 + inc ecx + shr ecx, 1 + sub edx, 16 +mainloop: + movq mm1, [eax] + movq mm2, [ebx] + add edx, 16 + movq mm3, mm1 + punpckldq mm1, mm2 + punpckhdq mm3, mm2 + add eax, 8 + pfmul mm1, mm0 + pfmul mm3, mm0 + add ebx, 8 + pf2id mm1, mm1 + pf2id mm3, mm3 + dec ecx + movq qword ptr [edx], mm1 + movq qword ptr [edx+8], mm3 + jnz mainloop + emms + } +} + + +static void AMD_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic) +//----------------------------------------------------------------------------------------- +{ + _asm { + movd mm0, _f2ic + mov eax, pIn + mov edx, pOut + mov ecx, nCount + punpckldq mm0, mm0 + add ecx, 3 + shr ecx, 2 + sub edx, 16 +mainloop: + movq mm1, [eax] + movq mm2, [eax+8] + add edx, 16 + pfmul mm1, mm0 + pfmul mm2, mm0 + add eax, 16 + pf2id mm1, mm1 + pf2id mm2, mm2 + dec ecx + movq qword ptr [edx], mm1 + movq qword ptr [edx+8], mm2 + jnz mainloop + emms + } +} + + +static void AMD_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) +//------------------------------------------------------------------------------------------ +{ + _asm { + movd mm0, _i2fc + mov eax, pSrc + mov edx, pOut + mov ecx, nCount + punpckldq mm0, mm0 + add ecx, 3 + shr ecx, 2 + sub edx, 16 +mainloop: + movq mm1, qword ptr [eax] + movq mm2, qword ptr [eax+8] + add edx, 16 + pi2fd mm1, mm1 + pi2fd mm2, mm2 + add eax, 16 + pfmul mm1, mm0 + pfmul mm2, mm0 + dec ecx + movq qword ptr [edx], mm1 + movq qword ptr [edx+8], mm2 + jnz mainloop + emms + } +} + +#endif // ENABLE_X86_AMD + +/////////////////////////////////////////////////////////////////////////////////////// +// SSE Optimizations + +#ifdef ENABLE_SSE + +static void SSE_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) +//----------------------------------------------------------------------------------------------------------- +{ + _asm { + movss xmm0, _i2fc + mov edx, pSrc + mov eax, pOut1 + mov ebx, pOut2 + mov ecx, nCount + shufps xmm0, xmm0, 0x00 + xorps xmm1, xmm1 + xorps xmm2, xmm2 + inc ecx + shr ecx, 1 +mainloop: + cvtpi2ps xmm1, [edx] + cvtpi2ps xmm2, [edx+8] + add eax, 8 + add ebx, 8 + movlhps xmm1, xmm2 + mulps xmm1, xmm0 + add edx, 16 + shufps xmm1, xmm1, 0xD8 + dec ecx + movlps qword ptr [eax-8], xmm1 + movhps qword ptr [ebx-8], xmm1 + jnz mainloop + } +} + + +static void SSE_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) +//------------------------------------------------------------------------------------------ +{ + _asm { + movss xmm0, _i2fc + mov edx, pSrc + mov eax, pOut + mov ecx, nCount + shufps xmm0, xmm0, 0x00 + xorps xmm1, xmm1 + xorps xmm2, xmm2 + add ecx, 3 + shr ecx, 2 +mainloop: + cvtpi2ps xmm1, [edx] + cvtpi2ps xmm2, [edx+8] + add eax, 16 + movlhps xmm1, xmm2 + mulps xmm1, xmm0 + add edx, 16 + dec ecx + movups [eax-16], xmm1 + jnz mainloop + } +} + +#endif // ENABLE_SSE + + + +#ifdef ENABLE_X86 + +// Convert floating-point mix to integer + +static void X86_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic) +//--------------------------------------------------------------------------------------------------------------- +{ + _asm { + mov esi, pIn1 + mov ebx, pIn2 + mov edi, pOut + mov ecx, nCount + fld _f2ic +mainloop: + fld dword ptr [ebx] + add edi, 8 + fld dword ptr [esi] + add ebx, 4 + add esi, 4 + fmul st(0), st(2) + fistp dword ptr [edi-8] + fmul st(0), st(1) + fistp dword ptr [edi-4] + dec ecx + jnz mainloop + fstp st(0) + } +} + + +// Convert integer mix to floating-point + +static void X86_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) +//----------------------------------------------------------------------------------------------------------- +{ + _asm { + mov esi, pSrc + mov edi, pOut1 + mov ebx, pOut2 + mov ecx, nCount + fld _i2fc +mainloop: + fild dword ptr [esi] + fild dword ptr [esi+4] + add ebx, 4 + add edi, 4 + fmul st(0), st(2) + add esi, 8 + fstp dword ptr [ebx-4] + fmul st(0), st(1) + fstp dword ptr [edi-4] + dec ecx + jnz mainloop + fstp st(0) + } +} + + +static void X86_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic) +//----------------------------------------------------------------------------------------- +{ + _asm { + mov edx, pIn + mov eax, pOut + mov ecx, nCount + fld _f2ic + sub eax, 4 +R2I_Loop: + fld DWORD PTR [edx] + add eax, 4 + fmul ST(0), ST(1) + dec ecx + lea edx, [edx+4] + fistp DWORD PTR [eax] + jnz R2I_Loop + fstp st(0) + } +} + + +static void X86_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) +//------------------------------------------------------------------------------------------ +{ + _asm { + mov edx, pOut + mov eax, pSrc + mov ecx, nCount + fld _i2fc + sub edx, 4 +I2R_Loop: + fild DWORD PTR [eax] + add edx, 4 + fmul ST(0), ST(1) + dec ecx + lea eax, [eax+4] + fstp DWORD PTR [edx] + jnz I2R_Loop + fstp st(0) + } +} + +#endif // ENABLE_X86 + + + +static void C_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic) +//------------------------------------------------------------------------------------------------------------- +{ + for(UINT i=0; i<nCount; ++i) + { + *pOut++ = (int)(*pIn1++ * _f2ic); + *pOut++ = (int)(*pIn2++ * _f2ic); + } +} + + +static void C_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) +//--------------------------------------------------------------------------------------------------------- +{ + for(UINT i=0; i<nCount; ++i) + { + *pOut1++ = *pSrc++ * _i2fc; + *pOut2++ = *pSrc++ * _i2fc; + } +} + + +static void C_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic) +//--------------------------------------------------------------------------------------- +{ + for(UINT i=0; i<nCount; ++i) + { + *pOut++ = (int)(*pIn++ * _f2ic); + } +} + + +static void C_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) +//---------------------------------------------------------------------------------------- +{ + for(UINT i=0; i<nCount; ++i) + { + *pOut++ = *pSrc++ * _i2fc; + } +} + + + +void StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) +{ + + #ifdef ENABLE_SSE + if(GetProcSupport() & PROCSUPPORT_SSE) + { + SSE_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, _i2fc); + return; + } + #endif // ENABLE_SSE + #ifdef ENABLE_X86_AMD + if(GetProcSupport() & PROCSUPPORT_AMD_3DNOW) + { + AMD_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, _i2fc); + return; + } + #endif // ENABLE_X86_AMD + + #ifdef ENABLE_X86 + X86_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, _i2fc); + #else // !ENABLE_X86 + C_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, _i2fc); + #endif // ENABLE_X86 + +} + + +void FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic) +{ + + #ifdef ENABLE_X86_AMD + if(GetProcSupport() & PROCSUPPORT_AMD_3DNOW) + { + AMD_FloatToStereoMix(pIn1, pIn2, pOut, nCount, _f2ic); + return; + } + #endif // ENABLE_X86_AMD + + #ifdef ENABLE_X86 + X86_FloatToStereoMix(pIn1, pIn2, pOut, nCount, _f2ic); + #else // !ENABLE_X86 + C_FloatToStereoMix(pIn1, pIn2, pOut, nCount, _f2ic); + #endif // ENABLE_X86 + +} + + +void MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) +{ + + #ifdef ENABLE_SSE + if(GetProcSupport() & PROCSUPPORT_SSE) + { + SSE_MonoMixToFloat(pSrc, pOut, nCount, _i2fc); + return; + } + #endif // ENABLE_SSE + #ifdef ENABLE_X86_AMD + if(GetProcSupport() & PROCSUPPORT_AMD_3DNOW) + { + AMD_MonoMixToFloat(pSrc, pOut, nCount, _i2fc); + return; + } + #endif // ENABLE_X86_AMD + + #ifdef ENABLE_X86 + X86_MonoMixToFloat(pSrc, pOut, nCount, _i2fc); + #else // !ENABLE_X86 + C_MonoMixToFloat(pSrc, pOut, nCount, _i2fc); + #endif // ENABLE_X86 + +} + + +void FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic) +{ + + #ifdef ENABLE_X86_AMD + if(GetProcSupport() & PROCSUPPORT_AMD_3DNOW) + { + AMD_FloatToMonoMix(pIn, pOut, nCount, _f2ic); + return; + } + #endif // ENABLE_X86_AMD + + #ifdef ENABLE_X86 + X86_FloatToMonoMix(pIn, pOut, nCount, _f2ic); + #else // !ENABLE_X86 + C_FloatToMonoMix(pIn, pOut, nCount, _f2ic); + #endif // ENABLE_X86 + +} + + + +////////////////////////////////////////////////////////////////////////////////////////// + + +void InitMixBuffer(int *pBuffer, UINT nSamples) +//--------------------------------------------- +{ + memset(pBuffer, 0, nSamples * sizeof(int)); +} + +#if MPT_COMPILER_MSVC +#pragma warning(disable:4731) // ebp modified +#endif + +#ifdef ENABLE_X86 +static void X86_InterleaveFrontRear(int *pFrontBuf, int *pRearBuf, DWORD nFrames) +//------------------------------------------------------------------------------- +{ + _asm { + mov ecx, nFrames // ecx = framecount + mov esi, pFrontBuf // esi = front buffer + mov edi, pRearBuf // edi = rear buffer + lea esi, [esi+ecx*8] // esi = &front[N*2] + lea edi, [edi+ecx*8] // edi = &rear[N*2] + lea ebx, [esi+ecx*8] // ebx = &front[N*4] + push ebp +interleaveloop: + mov eax, dword ptr [esi-8] + mov edx, dword ptr [esi-4] + sub ebx, 16 + mov ebp, dword ptr [edi-8] + mov dword ptr [ebx], eax + mov dword ptr [ebx+4], edx + mov eax, dword ptr [edi-4] + sub esi, 8 + sub edi, 8 + dec ecx + mov dword ptr [ebx+8], ebp + mov dword ptr [ebx+12], eax + jnz interleaveloop + pop ebp + } +} +#endif + +static void C_InterleaveFrontRear(int *pFrontBuf, int *pRearBuf, DWORD nFrames) +//----------------------------------------------------------------------------- +{ + // copy backwards as we are writing back into FrontBuf + for(int i=nFrames-1; i>=0; i--) + { + pFrontBuf[i*4+3] = pRearBuf[i*2+1]; + pFrontBuf[i*4+2] = pRearBuf[i*2+0]; + pFrontBuf[i*4+1] = pFrontBuf[i*2+1]; + pFrontBuf[i*4+0] = pFrontBuf[i*2+0]; + } +} + +void InterleaveFrontRear(int *pFrontBuf, int *pRearBuf, DWORD nFrames) +//-------------------------------------------------------------------- +{ + #ifdef ENABLE_X86 + X86_InterleaveFrontRear(pFrontBuf, pRearBuf, nFrames); + #else + C_InterleaveFrontRear(pFrontBuf, pRearBuf, nFrames); + #endif +} + + +#ifdef ENABLE_X86 +static void X86_MonoFromStereo(int *pMixBuf, UINT nSamples) +//--------------------------------------------------------- +{ + _asm { + mov ecx, nSamples + mov esi, pMixBuf + mov edi, esi +stloop: + mov eax, dword ptr [esi] + mov edx, dword ptr [esi+4] + add edi, 4 + add esi, 8 + add eax, edx + sar eax, 1 + dec ecx + mov dword ptr [edi-4], eax + jnz stloop + } +} +#endif + +static void C_MonoFromStereo(int *pMixBuf, UINT nSamples) +//------------------------------------------------------- +{ + for(UINT i=0; i<nSamples; ++i) + { + pMixBuf[i] = (pMixBuf[i*2] + pMixBuf[i*2+1]) / 2; + } +} + +void MonoFromStereo(int *pMixBuf, UINT nSamples) +//---------------------------------------------- +{ + #ifdef ENABLE_X86 + X86_MonoFromStereo(pMixBuf, nSamples); + #else + C_MonoFromStereo(pMixBuf, nSamples); + #endif +} + + +#define OFSDECAYSHIFT 8 +#define OFSDECAYMASK 0xFF + + +#ifdef ENABLE_X86 +static void X86_StereoFill(int *pBuffer, UINT nSamples, LPLONG lpROfs, LPLONG lpLOfs) +//----------------------------------------------------------------------------------- +{ + _asm { + mov edi, pBuffer + mov ecx, nSamples + mov eax, lpROfs + mov edx, lpLOfs + mov eax, [eax] + mov edx, [edx] + or ecx, ecx + jz fill_loop + mov ebx, eax + or ebx, edx + jz fill_loop +ofsloop: + mov ebx, eax + mov esi, edx + neg ebx + neg esi + sar ebx, 31 + sar esi, 31 + and ebx, OFSDECAYMASK + and esi, OFSDECAYMASK + add ebx, eax + add esi, edx + sar ebx, OFSDECAYSHIFT + sar esi, OFSDECAYSHIFT + sub eax, ebx + sub edx, esi + mov ebx, eax + or ebx, edx + jz fill_loop + add edi, 8 + dec ecx + mov [edi-8], eax + mov [edi-4], edx + jnz ofsloop +fill_loop: + mov ebx, ecx + and ebx, 3 + jz fill4x +fill1x: + mov [edi], eax + mov [edi+4], edx + add edi, 8 + dec ebx + jnz fill1x +fill4x: + shr ecx, 2 + or ecx, ecx + jz done +fill4xloop: + mov [edi], eax + mov [edi+4], edx + mov [edi+8], eax + mov [edi+12], edx + add edi, 8*4 + dec ecx + mov [edi-16], eax + mov [edi-12], edx + mov [edi-8], eax + mov [edi-4], edx + jnz fill4xloop +done: + mov esi, lpROfs + mov edi, lpLOfs + mov [esi], eax + mov [edi], edx + } +} +#endif + +// c implementation taken from libmodplug +static void C_StereoFill(int *pBuffer, UINT nSamples, LPLONG lpROfs, LPLONG lpLOfs) +//--------------------------------------------------------------------------------- +{ + int rofs = *lpROfs; + int lofs = *lpLOfs; + + if ((!rofs) && (!lofs)) + { + InitMixBuffer(pBuffer, nSamples*2); + return; + } + for (UINT i=0; i<nSamples; i++) + { + int x_r = (rofs + (((-rofs)>>31) & OFSDECAYMASK)) >> OFSDECAYSHIFT; + int x_l = (lofs + (((-lofs)>>31) & OFSDECAYMASK)) >> OFSDECAYSHIFT; + rofs -= x_r; + lofs -= x_l; + pBuffer[i*2] = x_r; + pBuffer[i*2+1] = x_l; + } + *lpROfs = rofs; + *lpLOfs = lofs; +} + +void StereoFill(int *pBuffer, UINT nSamples, LPLONG lpROfs, LPLONG lpLOfs) +//------------------------------------------------------------------------ +{ + #ifdef ENABLE_X86 + X86_StereoFill(pBuffer, nSamples, lpROfs, lpLOfs); + #else + C_StereoFill(pBuffer, nSamples, lpROfs, lpLOfs); + #endif +} + + +#ifdef ENABLE_X86 +typedef ModChannel ModChannel_; +static void X86_EndChannelOfs(ModChannel *pChannel, int *pBuffer, UINT nSamples) +//------------------------------------------------------------------------------ +{ + _asm { + mov esi, pChannel + mov edi, pBuffer + mov ecx, nSamples + mov eax, dword ptr [esi+ModChannel_.nROfs] + mov edx, dword ptr [esi+ModChannel_.nLOfs] + or ecx, ecx + jz brkloop +ofsloop: + mov ebx, eax + mov esi, edx + neg ebx + neg esi + sar ebx, 31 + sar esi, 31 + and ebx, OFSDECAYMASK + and esi, OFSDECAYMASK + add ebx, eax + add esi, edx + sar ebx, OFSDECAYSHIFT + sar esi, OFSDECAYSHIFT + sub eax, ebx + sub edx, esi + mov ebx, eax + add dword ptr [edi], eax + add dword ptr [edi+4], edx + or ebx, edx + jz brkloop + add edi, 8 + dec ecx + jnz ofsloop +brkloop: + mov esi, pChannel + mov dword ptr [esi+ModChannel_.nROfs], eax + mov dword ptr [esi+ModChannel_.nLOfs], edx + } +} +#endif + +// c implementation taken from libmodplug +static void C_EndChannelOfs(ModChannel *pChannel, int *pBuffer, UINT nSamples) +//---------------------------------------------------------------------------- +{ + + int rofs = pChannel->nROfs; + int lofs = pChannel->nLOfs; + + if ((!rofs) && (!lofs)) return; + for (UINT i=0; i<nSamples; i++) + { + int x_r = (rofs + (((-rofs)>>31) & OFSDECAYMASK)) >> OFSDECAYSHIFT; + int x_l = (lofs + (((-lofs)>>31) & OFSDECAYMASK)) >> OFSDECAYSHIFT; + rofs -= x_r; + lofs -= x_l; + pBuffer[i*2] += x_r; + pBuffer[i*2+1] += x_l; + } + pChannel->nROfs = rofs; + pChannel->nLOfs = lofs; +} + +void EndChannelOfs(ModChannel *pChannel, int *pBuffer, UINT nSamples) +//------------------------------------------------------------------- +{ + #ifdef ENABLE_X86 + X86_EndChannelOfs(pChannel, pBuffer, nSamples); + #else + C_EndChannelOfs(pChannel, pBuffer, nSamples); + #endif +} + + +#ifndef MODPLUG_TRACKER + +void ApplyGain(int *soundBuffer, std::size_t channels, std::size_t countChunk, int32 gainFactor16_16) +//--------------------------------------------------------------------------------------------------- +{ + if(gainFactor16_16 == (1<<16)) + { + // nothing to do, gain == +/- 0dB + return; + } + // no clipping prevention is done here + int * buf = soundBuffer; + for(std::size_t i=0; i<countChunk*channels; ++i) + { + *buf = Util::muldiv(*buf, gainFactor16_16, 1<<16); + buf++; + } +} + +static void ApplyGain(float *beg, float *end, float factor) +//--------------------------------------------------------- +{ + for(float *it = beg; it != end; ++it) + { + *it *= factor; + } +} + +void ApplyGain(float * outputBuffer, float * const *outputBuffers, std::size_t offset, std::size_t channels, std::size_t countChunk, float gainFactor) +//---------------------------------------------------------------------------------------------------------------------------------------------------- +{ + if(gainFactor == 1.0f) + { + // nothing to do, gain == +/- 0dB + return; + } + if(outputBuffer) + { + ApplyGain( + outputBuffer + (channels * offset), + outputBuffer + (channels * (offset + countChunk)), + gainFactor); + } + if(outputBuffers) + { + for(std::size_t channel = 0; channel < channels; ++channel) + { + ApplyGain( + outputBuffers[channel] + offset, + outputBuffers[channel] + offset + countChunk, + gainFactor); + } + } +} + +#endif // !MODPLUG_TRACKER Added: trunk/OpenMPT/soundlib/MixerLoops.h =================================================================== --- trunk/OpenMPT/soundlib/MixerLoops.h (rev 0) +++ trunk/OpenMPT/soundlib/MixerLoops.h 2013-08-08 11:15:18 UTC (rev 2593) @@ -0,0 +1,32 @@ +/* + * MixerLoops.h + * ------------ + * Purpose: Utility inner loops for mixer-related functionality. + * Notes : none. + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#pragma once + + +struct ModChannel; + + +void StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc); +void FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic); +void MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); +void FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic); + +#ifndef MODPLUG_TRACKER +void ApplyGain(int *soundBuffer, std::size_t channels, std::size_t countChunk, int32 gainFactor16_16); +void ApplyGain(float *outputBuffer, float * const *outputBuffers, std::size_t offset, std::size_t channels, std::size_t countChunk, float gainFactor); +#endif // !MODPLUG_TRACKER + +void InitMixBuffer(int *pBuffer, UINT nSamples); +void InterleaveFrontRear(int *pFrontBuf, int *pRearBuf, DWORD nFrames); +void MonoFromStereo(int *pMixBuf, UINT nSamples); + +void EndChannelOfs(ModChannel *pChannel, int *pBuffer, UINT nSamples); +void StereoFill(int *pBuffer, UINT nSamples, LPLONG lpROfs, LPLONG lpLOfs); Property changes on: trunk/OpenMPT/soundlib/MixerLoops.h ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-chdr \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Deleted: trunk/OpenMPT/soundlib/Mmx_mix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Mmx_mix.cpp 2013-08-07 10:28:47 UTC (rev 2592) +++ trunk/OpenMPT/soundlib/Mmx_mix.cpp 2013-08-08 11:15:18 UTC (rev 2593) @@ -1,468 +0,0 @@ -/* - * MMX_Mix.cpp - * ----------- - * Purpose: Accelerated mixer code for rendering samples. - * Notes : - * x86 ( AMD/INTEL ) based low level based mixing functions: - * This file contains critical code. The basic X86 functions are - * defined at the bottom of the file. #define's are used to isolate - * the different flavours of functionality: - * ENABLE_MMX, ENABLE_3DNOW, ENABLE_SSE flags must be set to - * to compile the optimized sections of the code. In both cases the - * X86_xxxxxx functions will compile. - * - * NOTE: Resonant filter mixing has been changed to use floating point - * precision. The MMX code hasn't been updated for this, so the filtered - * MMX functions mustn't be used anymore! - * Authors: Olivier Lapicque - * OpenMPT Devs - * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. - */ - - -#include "stdafx.h" -#include "Sndfile.h" - - -//////////////////////////////////////////////////////////////////////////////////// -// 3DNow! optimizations - -#ifdef ENABLE_X86_AMD - -// Convert integer mix to floating-point -static void AMD_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) -//----------------------------------------------------------------------------------------------------------- -{ - _asm { - movd mm0, _i2fc - mov edx, pSrc - mov edi, pOut1 - mov ebx, pOut2 - mov ecx, nCount - punpckldq mm0, mm0 - inc ecx - shr ecx, 1 -mainloop: - movq mm1, qword ptr [edx] - movq mm2, qword ptr [edx+8] - add edi, 8 - pi2fd mm1, mm1 - pi2fd mm2, mm2 - add ebx, 8 - pfmul mm1, mm0 - pfmul mm2, mm0 - add edx, 16 - movq mm3, mm1 - punpckldq mm3, mm2 - punpckhdq mm1, mm2 - dec ecx - movq qword ptr [edi-8], mm3 - movq qword ptr [ebx-8], mm1 - jnz mainloop - emms - } -} - -static void AMD_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic) -//--------------------------------------------------------------------------------------------------------------- -{ - _asm { - movd mm0, _f2ic - mov eax, pIn1 - mov ebx, pIn2 - mov edx, pOut - mov ecx, nCount - punpckldq mm0, mm0 - inc ecx - shr ecx, 1 - sub edx, 16 -mainloop: - movq mm1, [eax] - movq mm2, [ebx] - add edx, 16 - movq mm3, mm1 - punpckldq mm1, mm2 - punpckhdq mm3, mm2 - add eax, 8 - pfmul mm1, mm0 - pfmul mm3, mm0 - add ebx, 8 - pf2id mm1, mm1 - pf2id mm3, mm3 - dec ecx - movq qword ptr [edx], mm1 - movq qword ptr [edx+8], mm3 - jnz mainloop - emms - } -} - - -static void AMD_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic) -//----------------------------------------------------------------------------------------- -{ - _asm { - movd mm0, _f2ic - mov eax, pIn - mov edx, pOut - mov ecx, nCount - punpckldq mm0, mm0 - add ecx, 3 - shr ecx, 2 - sub edx, 16 -mainloop: - movq mm1, [eax] - movq mm2, [eax+8] - add edx, 16 - pfmul mm1, mm0 - pfmul mm2, mm0 - add eax, 16 - pf2id mm1, mm1 - pf2id mm2, mm2 - dec ecx - movq qword ptr [edx], mm1 - movq qword ptr [edx+8], mm2 - jnz mainloop - emms - } -} - - -static void AMD_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) -//------------------------------------------------------------------------------------------ -{ - _asm { - movd mm0, _i2fc - mov eax, pSrc - mov edx, pOut - mov ecx, nCount - punpckldq mm0, mm0 - add ecx, 3 - shr ecx, 2 - sub edx, 16 -mainloop: - movq mm1, qword ptr [eax] - movq mm2, qword ptr [eax+8] - add edx, 16 - pi2fd mm1, mm1 - pi2fd mm2, mm2 - add eax, 16 - pfmul mm1, mm0 - pfmul mm2, mm0 - dec ecx - movq qword ptr [edx], mm1 - movq qword ptr [edx+8], mm2 - jnz mainloop - emms - } -} - -#endif // ENABLE_X86_AMD - -/////////////////////////////////////////////////////////////////////////////////////// -// SSE Optimizations - -#ifdef ENABLE_SSE - -static void SSE_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) -//----------------------------------------------------------------------------------------------------------- -{ - _asm { - movss xmm0, _i2fc - mov edx, pSrc - mov eax, pOut1 - mov ebx, pOut2 - mov ecx, nCount - shufps xmm0, xmm0, 0x00 - xorps xmm1, xmm1 - xorps xmm2, xmm2 - inc ecx - shr ecx, 1 -mainloop: - cvtpi2ps xmm1, [edx] - cvtpi2ps xmm2, [edx+8] - add eax, 8 - add ebx, 8 - movlhps xmm1, xmm2 - mulps xmm1, xmm0 - add edx, 16 - shufps xmm1, xmm1, 0xD8 - dec ecx - movlps qword ptr [eax-8], xmm1 - movhps qword ptr [ebx-8], xmm1 - jnz mainloop - } -} - - -static void SSE_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) -//------------------------------------------------------------------------------------------ -{ - _asm { - movss xmm0, _i2fc - mov edx, pSrc - mov eax, pOut - mov ecx, nCount - shufps xmm0, xmm0, 0x00 - xorps xmm1, xmm1 - xorps xmm2, xmm2 - add ecx, 3 - shr ecx, 2 -mainloop: - cvtpi2ps xmm1, [edx] - cvtpi2ps xmm2, [edx+8] - add eax, 16 - movlhps xmm1, xmm2 - mulps xmm1, xmm0 - add edx, 16 - dec ecx - movups [eax-16], xmm1 - jnz mainloop - } -} - -#endif // ENABLE_SSE - - - -#ifdef ENABLE_X86 - -// Convert floating-point mix to integer - -static void X86_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic) -//--------------------------------------------------------------------------------------------------------------- -{ - _asm { - mov esi, pIn1 - mov ebx, pIn2 - mov edi, pOut - mov ecx, nCount - fld _f2ic -mainloop: - fld dword ptr [ebx] - add edi, 8 - fld dword ptr [esi] - add ebx, 4 - add esi, 4 - fmul st(0), st(2) - fistp dword ptr [edi-8] - fmul st(0), st(1) - fistp dword ptr [edi-4] - dec ecx - jnz mainloop - fstp st(0) - } -} - - -// Convert integer mix to floating-point - -static void X86_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) -//----------------------------------------------------------------------------------------------------------- -{ - _asm { - mov esi, pSrc - mov edi, pOut1 - mov ebx, pOut2 - mov ecx, nCount - fld _i2fc -mainloop: - fild dword ptr [esi] - fild dword ptr [esi+4] - add ebx, 4 - add edi, 4 - fmul st(0), st(2) - add esi, 8 - fstp dword ptr [ebx-4] - fmul st(0), st(1) - fstp dword ptr [edi-4] - dec ecx - jnz mainloop - fstp st(0) - } -} - - -static void X86_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic) -//----------------------------------------------------------------------------------------- -{ - _asm { - mov edx, pIn - mov eax, pOut - mov ecx, nCount - fld _f2ic - sub eax, 4 -R2I_Loop: - fld DWORD PTR [edx] - add eax, 4 - fmul ST(0), ST(1) - dec ecx - lea edx, [edx+4] - fistp DWORD PTR [eax] - jnz R2I_Loop - fstp st(0) - } -} - - -static void X86_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) -//------------------------------------------------------------------------------------------ -{ - _asm { - mov edx, pOut - mov eax, pSrc - mov ecx, nCount - fld _i2fc - sub edx, 4 -I2R_Loop: - fild DWORD PTR [eax] - add edx, 4 - fmul ST(0), ST(1) - dec ecx - lea eax, [eax+4] - fstp DWORD PTR [edx] - jnz I2R_Loop - fstp st(0) - } -} - -#endif // ENABLE_X86 - - - -static void C_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic) -//------------------------------------------------------------------------------------------------------------- -{ - for(UINT i=0; i<nCount; ++i) - { - *pOut++ = (int)(*pIn1++ * _f2ic); - *pOut++ = (int)(*pIn2++ * _f2ic); - } -} - - -static void C_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) -//--------------------------------------------------------------------------------------------------------- -{ - for(UINT i=0; i<nCount; ++i) - { - *pOut1++ = *pSrc++ * _i2fc; - *pOut2++ = *pSrc++ * _i2fc; - } -} - - -static void C_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic) -//--------------------------------------------------------------------------------------- -{ - for(UINT i=0; i<nCount; ++i) - { - *pOut++ = (int)(*pIn++ * _f2ic); - } -} - - -static void C_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) -//---------------------------------------------------------------------------------------- -{ - for(UINT i=0; i<nCount; ++i) - { - *pOut++ = *pSrc++ * _i2fc; - } -} - - - -void StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) -{ - - #ifdef ENABLE_SSE - if(GetProcSupport() & PROCSUPPORT_SSE) - { - SSE_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, _i2fc); - return; - } - #endif // ENABLE_SSE - #ifdef ENABLE_X86_AMD - if(GetProcSupport() & PROCSUPPORT_AMD_3DNOW) - { - AMD_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, _i2fc); - return; - } - #endif // ENABLE_X86_AMD - - #ifdef ENABLE_X86 - X86_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, _i2fc); - #else // !ENABLE_X86 - C_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, _i2fc); - #endif // ENABLE_X86 - -} - - -void FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic) -{ - - #ifdef ENABLE_X86_AMD - if(GetProcSupport() & PROCSUPPORT_AMD_3DNOW) - { - AMD_FloatToStereoMix(pIn1, pIn2, pOut, nCount, _f2ic); - return; - } - #endif // ENABLE_X86_AMD - - #ifdef ENABLE_X86 - X86_FloatToStereoMix(pIn1, pIn2, pOut, nCount, _f2ic); - #else // !ENABLE_X86 - C_FloatToStereoMix(pIn1, pIn2, pOut, nCount, _f2ic); - #endif // ENABLE_X86 - -} - - -void MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) -{ - - #ifdef ENABLE_SSE - if(GetProcSupport() & PROCSUPPORT_SSE) - { - SSE_MonoMixToFloat(pSrc, pOut, nCount, _i2fc); - return; - } - #endif // ENABLE_SSE - #ifdef ENABLE_X86_AMD - if(GetProcSupport() & PROCSUPPORT_AMD_3DNOW) - { - AMD_MonoMixToFloat(pSrc, pOut, nCount, _i2fc); - return; - } - #endif // ENABLE_X86_AMD - - #ifdef ENABLE_X86 - X86_MonoMixToFloat(pSrc, pOut, nCount, _i2fc); - #else // !ENABLE_X86 - C_MonoMixToFloat(pSrc, pOut, nCount, _i2fc); - #endif // ENABLE_X86 - -} - - -void FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic) -{ - - #ifdef ENABLE_X86_AMD - if(GetProcSupport() & PROCSUPPORT_AMD_3DNOW) - { - AMD_FloatToMonoMix(pIn, pOut, nCount, _f2ic); - return; - } - #endif // ENABLE_X86_AMD - - #ifdef ENABLE_X86 - X86_FloatToMonoMix(pIn, pOut, nCount, _f2ic); - #else // !ENABLE_X86 - C_FloatToMonoMix(pIn, pOut, nCount, _f2ic); - #endif // ENABLE_X86 - -} - Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-08-07 10:28:47 UTC (rev 2592) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-08-08 11:15:18 UTC (rev 2593) @@ -187,17 +187,6 @@ #endif // MODPLUG_TRACKER -void StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc); -void FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic); -void MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); -void FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic); - -#ifndef MODPLUG_TRACKER -void ApplyGain(int *soundBuffer, std::size_t channels, std::size_t countChunk, int32 gainFactor16_16); -void ApplyGain(float *outputBuffer, float * const *outputBuffers, std::size_t offset, std::size_t channels, std::size_t countChunk, float gainFactor); -#endif // !MODPLUG_TRACKER - - class IAudioReadTarget { public: @@ -622,16 +611,6 @@ #ifndef NO_EQ void SetEQGains(const UINT *pGains, UINT nBands, const UINT *pFreqs=NULL, BOOL bReset=FALSE) { m_EQ.SetEQGains(pGains, nBands, pFreqs, bReset, m_MixerSettings.gdwMixingFreq); } // 0=-12dB, 32=+12dB #endif // NO_EQ - // Float <-> Int conversion routines - forceinline void StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount) - { - ::StereoMixToFloat(pSrc, pOut1, pOut2, nCount, m_PlayConfig.getIntToFloat()); - } - forceinline void FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount) - { - ::FloatToStereoMix(pIn1, pIn2, pOut, nCount, m_PlayConfig.getFloatToInt()); - } - public: BOOL ReadNote(); BOOL ProcessRow(); Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-08-07 10:28:47 UTC (rev 2592) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-08-08 11:15:18 UTC (rev 2593) @@ -12,6 +12,7 @@ #include "stdafx.h" #include "Sndfile.h" +#include "MixerLoops.h" #include "MIDIEvents.h" #include "tuning.h" #include "Tables.h" @@ -27,11 +28,6 @@ #endif -void InterleaveFrontRear(int *pFrontBuf, int *pRearBuf, DWORD nFrames); -void StereoFill(int *pBuffer, UINT nSamples, LPLONG lpROfs, LPLONG lpLOfs); -void MonoFromStereo(int *pMixBuf, UINT nSamples); - - // Log tables for pre-amp // Pre-amp (or more precisely: Pre-attenuation) depends on the number of channels, // Which this table takes care of. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-08-09 22:33:32
|
Revision: 2594 http://sourceforge.net/p/modplug/code/2594 Author: saga-games Date: 2013-08-09 22:33:22 +0000 (Fri, 09 Aug 2013) Log Message: ----------- [Ref] Various small fixes for 64-bit compile Modified Paths: -------------- trunk/OpenMPT/mptrack/ACMConvert.cpp trunk/OpenMPT/mptrack/ACMConvert.h trunk/OpenMPT/mptrack/Autotune.cpp trunk/OpenMPT/mptrack/CreditStatic.cpp trunk/OpenMPT/mptrack/CreditStatic.h trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/Globals.cpp trunk/OpenMPT/mptrack/Globals.h trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/View_ins.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/View_smp.h trunk/OpenMPT/mptrack/mod2midi.cpp trunk/OpenMPT/mptrack/mod2wave.h trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/ITTools.cpp trunk/OpenMPT/soundlib/ITTools.h trunk/OpenMPT/soundlib/MIDIMacros.cpp Added Paths: ----------- trunk/OpenMPT/include/zlib/contrib/masmx64/gvmat64.lst trunk/OpenMPT/include/zlib/contrib/masmx64/gvmat64.obj trunk/OpenMPT/include/zlib/contrib/masmx64/inffasx64.lst trunk/OpenMPT/include/zlib/contrib/masmx64/inffasx64.obj Added: trunk/OpenMPT/include/zlib/contrib/masmx64/gvmat64.lst =================================================================== --- trunk/OpenMPT/include/zlib/contrib/masmx64/gvmat64.lst (rev 0) +++ trunk/OpenMPT/include/zlib/contrib/masmx64/gvmat64.lst 2013-08-09 22:33:22 UTC (rev 2594) @@ -0,0 +1,666 @@ +Microsoft (R) Macro Assembler (x64) Version 10.00.40219.01 08/10/13 00:27:06 +gvmat64.asm Page 1 - 1 + + + ;uInt longest_match_x64( + ; deflate_state *s, + ; IPos cur_match); /* current match */ + + ; gvmat64.asm -- Asm portion of the optimized longest_match for 32 bits x86_64 + ; (AMD64 on Athlon 64, Opteron, Phenom + ; and Intel EM64T on Pentium 4 with EM64T, Pentium D, Core 2 Duo, Core I5/I7) + ; Copyright (C) 1995-2010 Jean-loup Gailly, Brian Raiter and Gilles Vollant. + ; + ; File written by Gilles Vollant, by converting to assembly the longest_match + ; from Jean-loup Gailly in deflate.c of zLib and infoZip zip. + ; + ; and by taking inspiration on asm686 with masm, optimised assembly code + ; from Brian Raiter, written 1998 + ; + ; This software is provided 'as-is', without any express or implied + ; warranty. In no event will the authors be held liable for any damages + ; arising from the use of this software. + ; + ; Permission is granted to anyone to use this software for any purpose, + ; including commercial applications, and to alter it and redistribute it + ; freely, subject to the following restrictions: + ; + ; 1. The origin of this software must not be misrepresented; you must not + ; claim that you wrote the original software. If you use this software + ; in a product, an acknowledgment in the product documentation would be + ; appreciated but is not required. + ; 2. Altered source versions must be plainly marked as such, and must not be + ; misrepresented as being the original software + ; 3. This notice may not be removed or altered from any source distribution. + ; + ; + ; + ; http://www.zlib.net + ; http://www.winimage.com/zLibDll + ; http://www.muppetlabs.com/~breadbox/software/assembly.html + ; + ; to compile this file for infozip Zip, I use option: + ; ml64.exe /Flgvmat64 /c /Zi /DINFOZIP gvmat64.asm + ; + ; to compile this file for zLib, I use option: + ; ml64.exe /Flgvmat64 /c /Zi gvmat64.asm + ; Be carrefull to adapt zlib1222add below to your version of zLib + ; (if you use a version of zLib before 1.0.4 or after 1.2.2.2, change + ; value of zlib1222add later) + ; + ; This file compile with Microsoft Macro Assembler (x64) for AMD64 + ; + ; ml64.exe is given with Visual Studio 2005/2008/2010 and Windows WDK + ; + ; (you can get Windows WDK with ml64 for AMD64 from + ; http://www.microsoft.com/whdc/Devtools/wdk/default.mspx for low price) + ; + + + ;uInt longest_match(s, cur_match) + ; deflate_state *s; + ; IPos cur_match; /* current match */ + 00000000 .code + 00000000 longest_match PROC + + + ;LocalVarsSize equ 88 + = 00000048 LocalVarsSize equ 72 + + ; register used : rax,rbx,rcx,rdx,rsi,rdi,r8,r9,r10,r11,r12 + ; free register : r14,r15 + ; register can be saved : rsp + + = rsp + 8 - LocalVarsSize chainlenwmask equ rsp + 8 - LocalVarsSize ; high word: current chain len + ; low word: s->wmask + ;window equ rsp + xx - LocalVarsSize ; local copy of s->window ; stored in r10 + ;windowbestlen equ rsp + xx - LocalVarsSize ; s->window + bestlen , use r10+r11 + ;scanstart equ rsp + xx - LocalVarsSize ; first two bytes of string ; stored in r12w + ;scanend equ rsp + xx - LocalVarsSize ; last two bytes of string use ebx + ;scanalign equ rsp + xx - LocalVarsSize ; dword-misalignment of string r13 + ;bestlen equ rsp + xx - LocalVarsSize ; size of best match so far -> r11d + ;scan equ rsp + xx - LocalVarsSize ; ptr to string wanting match -> r9 + IFDEF INFOZIP + ELSE + = (rsp + 16 - LocalVarsSiz nicematch equ (rsp + 16 - LocalVarsSize) ; a good enough match size + e) + ENDIF + + = rsp + 24 - LocalVarsSize save_rdi equ rsp + 24 - LocalVarsSize + = rsp + 32 - LocalVarsSize save_rsi equ rsp + 32 - LocalVarsSize + = rsp + 40 - LocalVarsSize save_rbx equ rsp + 40 - LocalVarsSize + = rsp + 48 - LocalVarsSize save_rbp equ rsp + 48 - LocalVarsSize + = rsp + 56 - LocalVarsSize save_r12 equ rsp + 56 - LocalVarsSize + = rsp + 64 - LocalVarsSize save_r13 equ rsp + 64 - LocalVarsSize + ;save_r14 equ rsp + 72 - LocalVarsSize + ;save_r15 equ rsp + 80 - LocalVarsSize + + + ; summary of register usage + ; scanend ebx + ; scanendw bx + ; chainlenwmask edx + ; curmatch rsi + ; curmatchd esi + ; windowbestlen r8 + ; scanalign r9 + ; scanalignd r9d + ; window r10 + ; bestlen r11 + ; bestlend r11d + ; scanstart r12d + ; scanstartw r12w + ; scan r13 + ; nicematch r14d + ; limit r15 + ; limitd r15d + ; prev rcx + + ; all the +4 offsets are due to the addition of pending_buf_size (in zlib + ; in the deflate_state structure since the asm code was first written + ; (if you compile with zlib 1.0.4 or older, remove the +4). + ; Note : these value are good with a 8 bytes boundary pack structure + + + = 00000102 MAX_MATCH equ 258 + = 00000003 MIN_MATCH equ 3 + = 00000106 MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1) + + + ;;; Offsets for fields in the deflate_state structure. These numbers + ;;; are calculated from the definition of deflate_state, with the + ;;; assumption that the compiler will dword-align the fields. (Thus, + ;;; changing the definition of deflate_state could easily cause this + ;;; program to crash horribly, without so much as a warning at + ;;; compile time. Sigh.) + + ; all the +zlib1222add offsets are due to the addition of fields + ; in zlib in the deflate_state structure since the asm code was first written + ; (if you compile with zlib 1.0.4 or older, use "zlib1222add equ (-4)"). + ; (if you compile with zlib between 1.0.5 and 1.2.2.1, use "zlib1222add equ 0"). + ; if you compile with zlib 1.2.2.2 or later , use "zlib1222add equ 8"). + + + IFDEF INFOZIP + ELSE + + IFNDEF zlib1222add + = 00000008 zlib1222add equ 8 + ENDIF + = 00000044 dsWSize equ 56+zlib1222add+(zlib1222add/2) + = 0000004C dsWMask equ 64+zlib1222add+(zlib1222add/2) + = 00000050 dsWindow equ 72+zlib1222add + = 00000060 dsPrev equ 88+zlib1222add + = 00000088 dsMatchLen equ 128+zlib1222add + = 0000008C dsPrevMatch equ 132+zlib1222add + = 00000094 dsStrStart equ 140+zlib1222add + = 00000098 dsMatchStart equ 144+zlib1222add + = 0000009C dsLookahead equ 148+zlib1222add + = 000000A0 dsPrevLen equ 152+zlib1222add + = 000000A4 dsMaxChainLen equ 156+zlib1222add + = 000000B4 dsGoodMatch equ 172+zlib1222add + = 000000B8 dsNiceMatch equ 176+zlib1222add + + = [ rcx + dsWSize] window_size equ [ rcx + dsWSize] + = [ rcx + dsWMask] WMask equ [ rcx + dsWMask] + = [ rcx + dsWindow] window_ad equ [ rcx + dsWindow] + = [ rcx + dsPrev] prev_ad equ [ rcx + dsPrev] + = [ rcx + dsStrStart] strstart equ [ rcx + dsStrStart] + = [ rcx + dsMatchStart] match_start equ [ rcx + dsMatchStart] + = [ rcx + dsLookahead] Lookahead equ [ rcx + dsLookahead] ; 0ffffffffh on infozip + = [ rcx + dsPrevLen] prev_length equ [ rcx + dsPrevLen] + = [ rcx + dsMaxChainLen] max_chain_length equ [ rcx + dsMaxChainLen] + = [ rcx + dsGoodMatch] good_match equ [ rcx + dsGoodMatch] + = [ rcx + dsNiceMatch] nice_match equ [ rcx + dsNiceMatch] + ENDIF + + ; parameter 1 in r8(deflate state s), param 2 in rdx (cur match) + + ; see http://weblogs.asp.net/oldnewthing/archive/2004/01/14/58579.aspx and + ; http://msdn.microsoft.com/library/en-us/kmarch/hh/kmarch/64bitAMD_8e951dd2-ee77-4728-8702-55ce4b5dd24a.xml.asp + ; + ; All registers must be preserved across the call, except for + ; rax, rcx, rdx, r8, r9, r10, and r11, which are scratch. + + + + ;;; Save registers that the compiler may be using, and adjust esp to + ;;; make room for our stack frame. + + + ;;; Retrieve the function arguments. r8d will hold cur_match + ;;; throughout the entire function. edx will hold the pointer to the + ;;; deflate_state structure during the function's setup (before + ;;; entering the main loop. + + ; parameter 1 in rcx (deflate_state* s), param 2 in edx -> r8 (cur match) + + ; this clear high 32 bits of r8, which can be garbage in both r8 and rdx + + 00000000 48/ 89 7C 24 mov [save_rdi],rdi + D0 + 00000005 48/ 89 74 24 mov [save_rsi],rsi + D8 + 0000000A 48/ 89 5C 24 mov [save_rbx],rbx + E0 + 0000000F 48/ 89 6C 24 mov [save_rbp],rbp + E8 + IFDEF INFOZIP + ELSE + 00000014 44/ 8B C2 mov r8d,edx + ENDIF + 00000017 4C/ 89 64 24 mov [save_r12],r12 + F0 + 0000001C 4C/ 89 6C 24 mov [save_r13],r13 + F8 + ; mov [save_r14],r14 + ; mov [save_r15],r15 + + + ;;; uInt wmask = s->w_mask; + ;;; unsigned chain_length = s->max_chain_length; + ;;; if (s->prev_length >= s->good_match) { + ;;; chain_length >>= 2; + ;;; } + + 00000021 8B B9 000000A0 mov edi, prev_length + 00000027 8B B1 000000B4 mov esi, good_match + 0000002D 8B 41 4C mov eax, WMask + 00000030 8B 99 000000A4 mov ebx, max_chain_length + 00000036 3B FE cmp edi, esi + 00000038 7C 03 jl LastMatchGood + 0000003A C1 EB 02 shr ebx, 2 + 0000003D LastMatchGood: + + ;;; chainlen is decremented once beforehand so that the function can + ;;; use the sign flag instead of the zero flag for the exit test. + ;;; It is then shifted into the high word, to make room for the wmask + ;;; value, which it will always accompany. + + 0000003D FF CB dec ebx + 0000003F C1 E3 10 shl ebx, 16 + 00000042 0B D8 or ebx, eax + + ;;; on zlib only + ;;; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; + + IFDEF INFOZIP + ELSE + 00000044 8B 81 000000B8 mov eax, nice_match + 0000004A 89 5C 24 C0 mov [chainlenwmask], ebx + 0000004E 44/ 8B 91 mov r10d, Lookahead + 0000009C + 00000055 44/ 3B D0 cmp r10d, eax + 00000058 44/ 0F 4D D0 cmovnl r10d, eax + 0000005C 44/ 89 54 24 mov [nicematch],r10d + C8 + ENDIF + + ;;; register Bytef *scan = s->window + s->strstart; + 00000061 4C/ 8B 51 50 mov r10, window_ad + 00000065 8B A9 00000094 mov ebp, strstart + 0000006B 4E/ 8D 6C 15 lea r13, [r10 + rbp] + 00 + + ;;; Determine how many bytes the scan ptr is off from being + ;;; dword-aligned. + + 00000070 4D/ 8B CD mov r9,r13 + 00000073 49/ F7 DD neg r13 + 00000076 49/ 83 E5 03 and r13,3 + + ;;; IPos limit = s->strstart > (IPos)MAX_DIST(s) ? + ;;; s->strstart - (IPos)MAX_DIST(s) : NIL; + IFDEF INFOZIP + ELSE + 0000007A 8B 41 44 mov eax, window_size + 0000007D 2D 00000106 sub eax, MIN_LOOKAHEAD + ENDIF + 00000082 33 FF xor edi,edi + 00000084 2B E8 sub ebp, eax + + 00000086 44/ 8B 99 mov r11d, prev_length + 000000A0 + + 0000008D 0F 4E EF cmovng ebp,edi + + ;;; int best_len = s->prev_length; + + + ;;; Store the sum of s->window + best_len in esi locally, and in esi. + + 00000090 4B/ 8D 34 13 lea rsi,[r10+r11] + + ;;; register ush scan_start = *(ushf*)scan; + ;;; register ush scan_end = *(ushf*)(scan+best_len-1); + ;;; Posf *prev = s->prev; + + 00000094 45/ 0F B7 21 movzx r12d,word ptr [r9] + 00000098 43/ 0F B7 5C 0B movzx ebx, word ptr [r9 + r11 - 1] + FF + + 0000009E 48/ 8B 79 60 mov rdi, prev_ad + + ;;; Jump into the main loop. + + 000000A2 8B 54 24 C0 mov edx, [chainlenwmask] + + 000000A6 66| 41/ 3B 5C 30 cmp bx,word ptr [rsi + r8 - 1] + FF + 000000AC 0F 84 0000009A jz LookupLoopIsZero + + 000000B2 LookupLoop1: + 000000B2 44/ 23 C2 and r8d, edx + + 000000B5 46/ 0F B7 04 47 movzx r8d, word ptr [rdi + r8*2] + 000000BA 44/ 3B C5 cmp r8d, ebp + 000000BD 0F 86 00000170 jbe LeaveNow + 000000C3 81 EA 00010000 sub edx, 00010000h + 000000C9 0F 88 00000164 js LeaveNow + + 000000CF LoopEntry1: + 000000CF 66| 41/ 3B 5C 30 cmp bx,word ptr [rsi + r8 - 1] + FF + 000000D5 74 75 jz LookupLoopIsZero + + 000000D7 LookupLoop2: + 000000D7 44/ 23 C2 and r8d, edx + + 000000DA 46/ 0F B7 04 47 movzx r8d, word ptr [rdi + r8*2] + 000000DF 44/ 3B C5 cmp r8d, ebp + 000000E2 0F 86 0000014B jbe LeaveNow + 000000E8 81 EA 00010000 sub edx, 00010000h + 000000EE 0F 88 0000013F js LeaveNow + + 000000F4 LoopEntry2: + 000000F4 66| 41/ 3B 5C 30 cmp bx,word ptr [rsi + r8 - 1] + FF + 000000FA 74 50 jz LookupLoopIsZero + + 000000FC LookupLoop4: + 000000FC 44/ 23 C2 and r8d, edx + + 000000FF 46/ 0F B7 04 47 movzx r8d, word ptr [rdi + r8*2] + 00000104 44/ 3B C5 cmp r8d, ebp + 00000107 0F 86 00000126 jbe LeaveNow + 0000010D 81 EA 00010000 sub edx, 00010000h + 00000113 0F 88 0000011A js LeaveNow + + 00000119 LoopEntry4: + + 00000119 66| 41/ 3B 5C 30 cmp bx,word ptr [rsi + r8 - 1] + FF + 0000011F 75 91 jnz LookupLoop1 + 00000121 EB 29 jmp LookupLoopIsZero + + + ;;; do { + ;;; match = s->window + cur_match; + ;;; if (*(ushf*)(match+best_len-1) != scan_end || + ;;; *(ushf*)match != scan_start) continue; + ;;; [...] + ;;; } while ((cur_match = prev[cur_match & wmask]) > limit + ;;; && --chain_length != 0); + ;;; + ;;; Here is the inner loop of the function. The function will spend the + ;;; majority of its time in this loop, and majority of that time will + ;;; be spent in the first ten instructions. + ;;; + ;;; Within this loop: + ;;; ebx = scanend + ;;; r8d = curmatch + ;;; edx = chainlenwmask - i.e., ((chainlen << 16) | wmask) + ;;; esi = windowbestlen - i.e., (window + bestlen) + ;;; edi = prev + ;;; ebp = limit + + 00000123 LookupLoop: + 00000123 44/ 23 C2 and r8d, edx + + 00000126 46/ 0F B7 04 47 movzx r8d, word ptr [rdi + r8*2] + 0000012B 44/ 3B C5 cmp r8d, ebp + 0000012E 0F 86 000000FF jbe LeaveNow + 00000134 81 EA 00010000 sub edx, 00010000h + 0000013A 0F 88 000000F3 js LeaveNow + + 00000140 LoopEntry: + + 00000140 66| 41/ 3B 5C 30 cmp bx,word ptr [rsi + r8 - 1] + FF + 00000146 0F 85 FFFFFF66 jnz LookupLoop1 + 0000014C LookupLoopIsZero: + 0000014C 66| 47/ 3B 24 10 cmp r12w, word ptr [r10 + r8] + 00000151 0F 85 FFFFFF5B jnz LookupLoop1 + + + ;;; Store the current value of chainlen. + 00000157 89 54 24 C0 mov [chainlenwmask], edx + + ;;; Point edi to the string under scrutiny, and esi to the string we + ;;; are hoping to match it up with. In actuality, esi and edi are + ;;; both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and edx is + ;;; initialized to -(MAX_MATCH_8 - scanalign). + + 0000015B 4B/ 8D 34 02 lea rsi,[r8+r10] + 0000015F 48/ BA mov rdx, 0fffffffffffffef8h; -(MAX_MATCH_8) + FFFFFFFFFFFFFEF8 + 00000169 49/ 8D B4 35 lea rsi, [rsi + r13 + 0108h] ;MAX_MATCH_8] + 00000108 + 00000171 4B/ 8D BC 0D lea rdi, [r9 + r13 + 0108h] ;MAX_MATCH_8] + 00000108 + + 00000179 0F 18 14 32 prefetcht1 [rsi+rdx] + 0000017D 0F 18 14 3A prefetcht1 [rdi+rdx] + + + ;;; Test the strings for equality, 8 bytes at a time. At the end, + ;;; adjust rdx so that it is offset to the exact byte that mismatched. + ;;; + ;;; We already know at this point that the first three bytes of the + ;;; strings match each other, and they can be safely passed over before + ;;; starting the compare loop. So what this code does is skip over 0-3 + ;;; bytes, as much as necessary in order to dword-align the edi + ;;; pointer. (rsi will still be misaligned three times out of four.) + ;;; + ;;; It should be confessed that this loop usually does not represent + ;;; much of the total running time. Replacing it with a more + ;;; straightforward "rep cmpsb" would not drastically degrade + ;;; performance. + + + 00000181 LoopCmps: + 00000181 48/ 8B 04 32 mov rax, [rsi + rdx] + 00000185 48/ 33 04 3A xor rax, [rdi + rdx] + 00000189 75 28 jnz LeaveLoopCmps + + 0000018B 48/ 8B 44 32 mov rax, [rsi + rdx + 8] + 08 + 00000190 48/ 33 44 3A xor rax, [rdi + rdx + 8] + 08 + 00000195 75 18 jnz LeaveLoopCmps8 + + + 00000197 48/ 8B 44 32 mov rax, [rsi + rdx + 8+8] + 10 + 0000019C 48/ 33 44 3A xor rax, [rdi + rdx + 8+8] + 10 + 000001A1 75 08 jnz LeaveLoopCmps16 + + 000001A3 48/ 83 C2 18 add rdx,8+8+8 + + 000001A7 75 D8 jnz short LoopCmps + 000001A9 EB 7B jmp short LenMaximum + 000001AB 48/ 83 C2 08 LeaveLoopCmps16: add rdx,8 + 000001AF 48/ 83 C2 08 LeaveLoopCmps8: add rdx,8 + 000001B3 LeaveLoopCmps: + + 000001B3 A9 0000FFFF test eax, 0000FFFFh + 000001B8 75 1B jnz LenLower + + 000001BA A9 FFFFFFFF test eax,0ffffffffh + + 000001BF 75 0D jnz LenLower32 + + 000001C1 48/ 83 C2 04 add rdx,4 + 000001C5 48/ C1 E8 20 shr rax,32 + 000001C9 66| 0B C0 or ax,ax + 000001CC 75 07 jnz LenLower + + 000001CE LenLower32: + 000001CE C1 E8 10 shr eax,16 + 000001D1 48/ 83 C2 02 add rdx,2 + 000001D5 2C 01 LenLower: sub al, 1 + 000001D7 48/ 83 D2 00 adc rdx, 0 + ;;; Calculate the length of the match. If it is longer than MAX_MATCH, + ;;; then automatically accept it as the best possible match and leave. + + 000001DB 48/ 8D 04 3A lea rax, [rdi + rdx] + 000001DF 49/ 2B C1 sub rax, r9 + 000001E2 3D 00000102 cmp eax, MAX_MATCH + 000001E7 7D 3D jge LenMaximum + + ;;; If the length of the match is not longer than the best match we + ;;; have so far, then forget it and return to the lookup loop. + ;/////////////////////////////////// + + 000001E9 41/ 3B C3 cmp eax, r11d + 000001EC 7F 11 jg LongerMatch + + 000001EE 4B/ 8D 34 13 lea rsi,[r10+r11] + + 000001F2 48/ 8B 79 60 mov rdi, prev_ad + 000001F6 8B 54 24 C0 mov edx, [chainlenwmask] + 000001FA E9 FFFFFF24 jmp LookupLoop + + ;;; s->match_start = cur_match; + ;;; best_len = len; + ;;; if (len >= nice_match) break; + ;;; scan_end = *(ushf*)(scan+best_len-1); + + 000001FF LongerMatch: + 000001FF 44/ 8B D8 mov r11d, eax + 00000202 44/ 89 81 mov match_start, r8d + 00000098 + 00000209 3B 44 24 C8 cmp eax, [nicematch] + 0000020D 7D 24 jge LeaveNow + + 0000020F 4A/ 8D 34 10 lea rsi,[r10+rax] + + 00000213 42/ 0F B7 5C 08 movzx ebx, word ptr [r9 + rax - 1] + FF + 00000219 48/ 8B 79 60 mov rdi, prev_ad + 0000021D 8B 54 24 C0 mov edx, [chainlenwmask] + 00000221 E9 FFFFFEFD jmp LookupLoop + + ;;; Accept the current string, with the maximum possible length. + + 00000226 LenMaximum: + 00000226 41/ BB mov r11d,MAX_MATCH + 00000102 + 0000022C 44/ 89 81 mov match_start, r8d + 00000098 + + ;;; if ((uInt)best_len <= s->lookahead) return (uInt)best_len; + ;;; return s->lookahead; + + 00000233 LeaveNow: + IFDEF INFOZIP + ELSE + 00000233 8B 81 0000009C mov eax, Lookahead + 00000239 44/ 3B D8 cmp r11d, eax + 0000023C 41/ 0F 4E C3 cmovng eax, r11d + ENDIF + + ;;; Restore the stack and return from whence we came. + + + 00000240 48/ 8B 74 24 mov rsi,[save_rsi] + D8 + 00000245 48/ 8B 7C 24 mov rdi,[save_rdi] + D0 + 0000024A 48/ 8B 5C 24 mov rbx,[save_rbx] + E0 + 0000024F 48/ 8B 6C 24 mov rbp,[save_rbp] + E8 + 00000254 4C/ 8B 64 24 mov r12,[save_r12] + F0 + 00000259 4C/ 8B 6C 24 mov r13,[save_r13] + F8 + ; mov r14,[save_r14] + ; mov r15,[save_r15] + + + 0000025E C3 ret 0 + ; please don't remove this string ! + ; Your can freely use gvmat64 in any free or commercial app + ; but it is far better don't remove the string in the binary! + 0000025F 0D 0A 61 73 6D db 0dh,0ah,"asm686 with masm, optimised assembly code from Brian Raiter, written 1998, converted to amd 64 by Gilles Vollant 2005",0dh,0ah,0 + 36 38 36 20 77 + 69 74 68 20 6D + 61 73 6D 2C 20 + 6F 70 74 69 6D + 69 73 65 64 20 + 61 73 73 65 6D + 62 6C 79 20 63 + 6F 64 65 20 66 + 72 6F 6D 20 42 + 72 69 61 6E 20 + 52 61 69 74 65 + 72 2C 20 77 72 + 69 74 74 65 6E + 20 31 39 39 38 + 2C 20 63 6F 6E + 76 65 72 74 65 + 64 20 74 6F 20 + 61 6D 64 20 36 + 34 20 62 79 20 + 47 69 6C 6C 65 + 73 20 56 6F 6C + 6C 61 6E 74 20 + 32 30 30 35 0D + 0A 00 + 000002D9 longest_match ENDP + + 000002D9 match_init PROC + 000002D9 C3 ret 0 + 000002DA match_init ENDP + + + END +Microsoft (R) Macro Assembler (x64) Version 10.00.40219.01 08/10/13 00:27:06 +gvmat64.asm Symbols 2 - 1 + + + + +Procedures, parameters, and locals: + + N a m e Type Value Attr + +longest_match . . . . . . . . . P 00000000 _TEXT Length= 000002D9 Public + LastMatchGood . . . . . . . . L 0000003D _TEXT + LookupLoop1 . . . . . . . . . L 000000B2 _TEXT + LoopEntry1 . . . . . . . . . . L 000000CF _TEXT + LookupLoop2 . . . . . . . . . L 000000D7 _TEXT + LoopEntry2 . . . . . . . . . . L 000000F4 _TEXT + LookupLoop4 . . . . . . . . . L 000000FC _TEXT + LoopEntry4 . . . . . . . . . . L 00000119 _TEXT + LookupLoop . . . . . . . . . . L 00000123 _TEXT + LoopEntry . . . . . . . . . . L 00000140 _TEXT + LookupLoopIsZero . . . . . . . L 0000014C _TEXT + LoopCmps . . . . . . . . . . . L 00000181 _TEXT + LeaveLoopCmps16 . . . . . . . L 000001AB _TEXT + LeaveLoopCmps8 . . . . . . . . L 000001AF _TEXT + LeaveLoopCmps . . . . . . . . L 000001B3 _TEXT + LenLower32 . . . . . . . . . . L 000001CE _TEXT + LenLower . . . . . . . . . . . L 000001D5 _TEXT + LongerMatch . . . . . . . . . L 000001FF _TEXT + LenMaximum . . . . . . . . . . L 00000226 _TEXT + LeaveNow . . . . . . . . . . . L 00000233 _TEXT +match_init . . . . . . . . . . . P 000002D9 _TEXT Length= 00000001 Public + + +Symbols: + + N a m e Type Value Attr + +LocalVarsSize . . . . . . . . . Number 00000048h +Lookahead . . . . . . . . . . . Text [ rcx + dsLookahead] +MAX_MATCH . . . . . . . . . . . Number 00000102h +MIN_LOOKAHEAD . . . . . . . . . Number 00000106h +MIN_MATCH . . . . . . . . . . . Number 00000003h +WMask . . . . . . . . . . . . . Text [ rcx + dsWMask] +chainlenwmask . . . . . . . . . Text rsp + 8 - LocalVarsSize +dsGoodMatch . . . . . . . . . . Number 000000B4h +dsLookahead . . . . . . . . . . Number 0000009Ch +dsMatchLen . . . . . . . . . . . Number 00000088h +dsMatchStart . . . . . . . . . . Number 00000098h +dsMaxChainLen . . . . . . . . . Number 000000A4h +dsNiceMatch . . . . . . . . . . Number 000000B8h +dsPrevLen . . . . . . . . . . . Number 000000A0h +dsPrevMatch . . . . . . . . . . Number 0000008Ch +dsPrev . . . . . . . . . . . . . Number 00000060h +dsStrStart . . . . . . . . . . . Number 00000094h +dsWMask . . . . . . . . . . . . Number 0000004Ch +dsWSize . . . . . . . . . . . . Number 00000044h +dsWindow . . . . . . . . . . . . Number 00000050h +good_match . . . . . . . . . . . Text [ rcx + dsGoodMatch] +match_start . . . . . . . . . . Text [ rcx + dsMatchStart] +max_chain_length . . . . . . . . Text [ rcx + dsMaxChainLen] +nice_match . . . . . . . . . . . Text [ rcx + dsNiceMatch] +nicematch . . . . . . . . . . . Text (rsp + 16 - LocalVarsSize) +prev_ad . . . . . . . . . . . . Text [ rcx + dsPrev] +prev_length . . . . . . . . . . Text [ rcx + dsPrevLen] +save_r12 . . . . . . . . . . . . Text rsp + 56 - LocalVarsSize +save_r13 . . . . . . . . . . . . Text rsp + 64 - LocalVarsSize +save_rbp . . . . . . . . . . . . Text rsp + 48 - LocalVarsSize +save_rbx . . . . . . . . . . . . Text rsp + 40 - LocalVarsSize +save_rdi . . . . . . . . . . . . Text rsp + 24 - LocalVarsSize +save_rsi . . . . . . . . . . . . Text rsp + 32 - LocalVarsSize +strstart . . . . . . . . . . . . Text [ rcx + dsStrStart] +window_ad . . . . . . . . . . . Text [ rcx + dsWindow] +window_size . . . . . . . . . . Text [ rcx + dsWSize] +zlib1222add . . . . . . . . . . Number 00000008h + + 0 Warnings + 0 Errors Added: trunk/OpenMPT/include/zlib/contrib/masmx64/gvmat64.obj =================================================================== (Binary files differ) Index: trunk/OpenMPT/include/zlib/contrib/masmx64/gvmat64.obj =================================================================== --- trunk/OpenMPT/include/zlib/contrib/masmx64/gvmat64.obj 2013-08-08 11:15:18 UTC (rev 2593) +++ trunk/OpenMPT/include/zlib/contrib/masmx64/gvmat64.obj 2013-08-09 22:33:22 UTC (rev 2594) Property changes on: trunk/OpenMPT/include/zlib/contrib/masmx64/gvmat64.obj ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: trunk/OpenMPT/include/zlib/contrib/masmx64/inffasx64.lst =================================================================== --- trunk/OpenMPT/include/zlib/contrib/masmx64/inffasx64.lst (rev 0) +++ trunk/OpenMPT/include/zlib/contrib/masmx64/inffasx64.lst 2013-08-09 22:33:22 UTC (rev 2594) @@ -0,0 +1,488 @@ +Microsoft (R) Macro Assembler (x64) Version 10.00.40219.01 08/10/13 00:27:06 +inffasx64.asm Page 1 - 1 + + + ; inffasx64.asm is a hand tuned assembler version of inffast.c - fast decoding + ; version for AMD64 on Windows using Microsoft C compiler + ; + ; inffasx64.asm is automatically convert from AMD64 portion of inffas86.c + ; inffasx64.asm is called by inffas8664.c, which contain more info. + + + ; to compile this file, I use option + ; ml64.exe /Flinffasx64 /c /Zi inffasx64.asm + ; with Microsoft Macro Assembler (x64) for AMD64 + ; + + ; This file compile with Microsoft Macro Assembler (x64) for AMD64 + ; + ; ml64.exe is given with Visual Studio 2005/2008/2010 and Windows WDK + ; + ; (you can get Windows WDK with ml64 for AMD64 from + ; http://www.microsoft.com/whdc/Devtools/wdk/default.mspx for low price) + ; + + + 00000000 .code + 00000000 inffas8664fnc PROC + + ; see http://weblogs.asp.net/oldnewthing/archive/2004/01/14/58579.aspx and + ; http://msdn.microsoft.com/library/en-us/kmarch/hh/kmarch/64bitAMD_8e951dd2-ee77-4728-8702-55ce4b5dd24a.xml.asp + ; + ; All registers must be preserved across the call, except for + ; rax, rcx, rdx, r8, r-9, r10, and r11, which are scratch. + + + 00000000 48/ 89 74 24 mov [rsp-8],rsi + F8 + 00000005 48/ 89 7C 24 mov [rsp-16],rdi + F0 + 0000000A 4C/ 89 64 24 mov [rsp-24],r12 + E8 + 0000000F 4C/ 89 6C 24 mov [rsp-32],r13 + E0 + 00000014 4C/ 89 74 24 mov [rsp-40],r14 + D8 + 00000019 4C/ 89 7C 24 mov [rsp-48],r15 + D0 + 0000001E 48/ 89 5C 24 mov [rsp-56],rbx + C8 + + 00000023 48/ 8B C1 mov rax,rcx + + 00000026 48/ 89 68 08 mov [rax+8], rbp ; /* save regs rbp and rsp */ + 0000002A 48/ 89 20 mov [rax], rsp + + 0000002D 48/ 8B E0 mov rsp, rax ; /* make rsp point to &ar */ + + 00000030 48/ 8B 74 24 mov rsi, [rsp+16] ; /* rsi = in */ + 10 + 00000035 48/ 8B 7C 24 mov rdi, [rsp+32] ; /* rdi = out */ + 20 + 0000003A 4C/ 8B 4C 24 mov r9, [rsp+24] ; /* r9 = last */ + 18 + 0000003F 4C/ 8B 54 24 mov r10, [rsp+48] ; /* r10 = end */ + 30 + 00000044 48/ 8B 6C 24 mov rbp, [rsp+64] ; /* rbp = lcode */ + 40 + 00000049 4C/ 8B 5C 24 mov r11, [rsp+72] ; /* r11 = dcode */ + 48 + 0000004E 48/ 8B 54 24 mov rdx, [rsp+80] ; /* rdx = hold */ + 50 + 00000053 8B 5C 24 58 mov ebx, [rsp+88] ; /* ebx = bits */ + 00000057 44/ 8B 64 24 mov r12d, [rsp+100] ; /* r12d = lmask */ + 64 + 0000005C 44/ 8B 6C 24 mov r13d, [rsp+104] ; /* r13d = dmask */ + 68 + ; /* r14d = len */ + ; /* r15d = dist */ + + + 00000061 FC cld + 00000062 4C/ 3B D7 cmp r10, rdi + 00000065 74 05 je L_one_time ; /* if only one decode left */ + 00000067 4C/ 3B CE cmp r9, rsi + + 0000006A 75 2A jne L_do_loop + + + 0000006C L_one_time: + 0000006C 4D/ 8B C4 mov r8, r12 ; /* r8 = lmask */ + 0000006F 80 FB 20 cmp bl, 32 + 00000072 77 50 ja L_get_length_code_one_time + + 00000074 AD lodsd ; /* eax = *(uint *)in++ */ + 00000075 8A CB mov cl, bl ; /* cl = bits, needs it for shifting */ + 00000077 80 C3 20 add bl, 32 ; /* bits += 32 */ + 0000007A 48/ D3 E0 shl rax, cl + 0000007D 48/ 0B D0 or rdx, rax ; /* hold |= *((uint *)in)++ << bits */ + 00000080 EB 42 jmp L_get_length_code_one_time + + ALIGN 4 + 00000084 L_while_test: + 00000084 4C/ 3B D7 cmp r10, rdi + 00000087 0F 86 0000023F jbe L_break_loop + 0000008D 4C/ 3B CE cmp r9, rsi + 00000090 0F 86 00000236 jbe L_break_loop + + 00000096 L_do_loop: + 00000096 4D/ 8B C4 mov r8, r12 ; /* r8 = lmask */ + 00000099 80 FB 20 cmp bl, 32 + 0000009C 77 0C ja L_get_length_code ; /* if (32 < bits) */ + + 0000009E AD lodsd ; /* eax = *(uint *)in++ */ + 0000009F 8A CB mov cl, bl ; /* cl = bits, needs it for shifting */ + 000000A1 80 C3 20 add bl, 32 ; /* bits += 32 */ + 000000A4 48/ D3 E0 shl rax, cl + 000000A7 48/ 0B D0 or rdx, rax ; /* hold |= *((uint *)in)++ << bits */ + + 000000AA L_get_length_code: + 000000AA 4C/ 23 C2 and r8, rdx ; /* r8 &= hold */ + 000000AD 42/ 8B 44 85 mov eax, [rbp+r8*4] ; /* eax = lcode[hold & lmask] */ + 00 + + 000000B2 8A CC mov cl, ah ; /* cl = this.bits */ + 000000B4 2A DC sub bl, ah ; /* bits -= this.bits */ + 000000B6 48/ D3 EA shr rdx, cl ; /* hold >>= this.bits */ + + 000000B9 84 C0 test al, al + 000000BB 75 23 jnz L_test_for_length_base ; /* if (op != 0) 45.7% */ + + 000000BD 4D/ 8B C4 mov r8, r12 ; /* r8 = lmask */ + 000000C0 C1 E8 10 shr eax, 16 ; /* output this.val char */ + 000000C3 AA stosb + + 000000C4 L_get_length_code_one_time: + 000000C4 4C/ 23 C2 and r8, rdx ; /* r8 &= hold */ + 000000C7 42/ 8B 44 85 mov eax, [rbp+r8*4] ; /* eax = lcode[hold & lmask] */ + 00 + + 000000CC L_dolen: + 000000CC 8A CC mov cl, ah ; /* cl = this.bits */ + 000000CE 2A DC sub bl, ah ; /* bits -= this.bits */ + 000000D0 48/ D3 EA shr rdx, cl ; /* hold >>= this.bits */ + + 000000D3 84 C0 test al, al + 000000D5 75 09 jnz L_test_for_length_base ; /* if (op != 0) 45.7% */ + + 000000D7 C1 E8 10 shr eax, 16 ; /* output this.val char */ + 000000DA AA stosb + 000000DB EB A7 jmp L_while_test + + ALIGN 4 + 000000E0 L_test_for_length_base: + 000000E0 44/ 8B F0 mov r14d, eax ; /* len = this */ + 000000E3 41/ C1 EE 10 shr r14d, 16 ; /* len = this.val */ + 000000E7 8A C8 mov cl, al + + 000000E9 A8 10 test al, 16 + 000000EB 0F 84 000000C7 jz L_test_for_second_level_length ; /* if ((op & 16) == 0) 8% */ + 000000F1 80 E1 0F and cl, 15 ; /* op &= 15 */ + 000000F4 74 12 jz L_decode_distance ; /* if (!op) */ + + 000000F6 L_add_bits_to_len: + 000000F6 2A D9 sub bl, cl + 000000F8 33 C0 xor eax, eax + 000000FA FF C0 inc eax + 000000FC D3 E0 shl eax, cl + 000000FE FF C8 dec eax + 00000100 23 C2 and eax, edx ; /* eax &= hold */ + 00000102 48/ D3 EA shr rdx, cl + 00000105 44/ 03 F0 add r14d, eax ; /* len += hold & mask[op] */ + + 00000108 L_decode_distance: + 00000108 4D/ 8B C5 mov r8, r13 ; /* r8 = dmask */ + 0000010B 80 FB 20 cmp bl, 32 + 0000010E 77 0C ja L_get_distance_code ; /* if (32 < bits) */ + + 00000110 AD lodsd ; /* eax = *(uint *)in++ */ + 00000111 8A CB mov cl, bl ; /* cl = bits, needs it for shifting */ + 00000113 80 C3 20 add bl, 32 ; /* bits += 32 */ + 00000116 48/ D3 E0 shl rax, cl + 00000119 48/ 0B D0 or rdx, rax ; /* hold |= *((uint *)in)++ << bits */ + + 0000011C L_get_distance_code: + 0000011C 4C/ 23 C2 and r8, rdx ; /* r8 &= hold */ + 0000011F 43/ 8B 04 83 mov eax, [r11+r8*4] ; /* eax = dcode[hold & dmask] */ + + 00000123 L_dodist: + 00000123 44/ 8B F8 mov r15d, eax ; /* dist = this */ + 00000126 41/ C1 EF 10 shr r15d, 16 ; /* dist = this.val */ + 0000012A 8A CC mov cl, ah + 0000012C 2A DC sub bl, ah ; /* bits -= this.bits */ + 0000012E 48/ D3 EA shr rdx, cl ; /* hold >>= this.bits */ + 00000131 8A C8 mov cl, al ; /* cl = this.op */ + + 00000133 A8 10 test al, 16 ; /* if ((op & 16) == 0) */ + 00000135 0F 84 0000009D jz L_test_for_second_level_dist + 0000013B 80 E1 0F and cl, 15 ; /* op &= 15 */ + 0000013E 74 50 jz L_check_dist_one + + 00000140 L_add_bits_to_dist: + 00000140 2A D9 sub bl, cl + 00000142 33 C0 xor eax, eax + 00000144 FF C0 inc eax + 00000146 D3 E0 shl eax, cl + 00000148 FF C8 dec eax ; /* (1 << op) - 1 */ + 0000014A 23 C2 and eax, edx ; /* eax &= hold */ + 0000014C 48/ D3 EA shr rdx, cl + 0000014F 44/ 03 F8 add r15d, eax ; /* dist += hold & ((1 << op) - 1) */ + + 00000152 L_check_window: + 00000152 4C/ 8B C6 mov r8, rsi ; /* save in so from can use it's reg */ + 00000155 48/ 8B C7 mov rax, rdi + 00000158 48/ 2B 44 24 sub rax, [rsp+40] ; /* nbytes = out - beg */ + 28 + + 0000015D 41/ 3B C7 cmp eax, r15d + 00000160 0F 82 00000092 jb L_clip_window ; /* if (dist > nbytes) 4.2% */ + + 00000166 41/ 8B CE mov ecx, r14d ; /* ecx = len */ + 00000169 48/ 8B F7 mov rsi, rdi + 0000016C 49/ 2B F7 sub rsi, r15 ; /* from = out - dist */ + + 0000016F D1 F9 sar ecx, 1 + 00000171 73 12 jnc L_copy_two ; /* if len % 2 == 0 */ + + 00000173 F3/ 66| A5 rep movsw + 00000176 8A 06 mov al, [rsi] + 00000178 88 07 mov [rdi], al + 0000017A 48/ FF C7 inc rdi + + 0000017D 49/ 8B F0 mov rsi, r8 ; /* move in back to %rsi, toss from */ + 00000180 E9 FFFFFEFF jmp L_while_test + + 00000185 L_copy_two: + 00000185 F3/ 66| A5 rep movsw + 00000188 49/ 8B F0 mov rsi, r8 ; /* move in back to %rsi, toss from */ + 0000018B E9 FFFFFEF4 jmp L_while_test + + ALIGN 4 + 00000190 L_check_dist_one: + 00000190 41/ 83 FF 01 cmp r15d, 1 ; /* if dist 1, is a memset */ + 00000194 75 BC jne L_check_window + 00000196 48/ 39 7C 24 cmp [rsp+40], rdi ; /* if out == beg, outside window */ + 28 + 0000019B 74 B5 je L_check_window + + 0000019D 41/ 8B CE mov ecx, r14d ; /* ecx = len */ + 000001A0 8A 47 FF mov al, [rdi-1] + 000001A3 8A E0 mov ah, al + + 000001A5 D1 F9 sar ecx, 1 + 000001A7 73 05 jnc L_set_two + 000001A9 88 07 mov [rdi], al + 000001AB 48/ FF C7 inc rdi + + 000001AE L_set_two: + 000001AE F3/ 66| AB rep stosw + 000001B1 E9 FFFFFECE jmp L_while_test + + ALIGN 4 + 000001B8 L_test_for_second_level_length: + 000001B8 A8 40 test al, 64 + 000001BA 0F 85 000000E0 jnz L_test_for_end_of_block ; /* if ((op & 64) != 0) */ + + 000001C0 33 C0 xor eax, eax + 000001C2 FF C0 inc eax + 000001C4 D3 E0 shl eax, cl + 000001C6 FF C8 dec eax + 000001C8 23 C2 and eax, edx ; /* eax &= hold */ + 000001CA 41/ 03 C6 add eax, r14d ; /* eax += len */ + 000001CD 8B 44 85 00 mov eax, [rbp+rax*4] ; /* eax = lcode[val+(hold&mask[op])]*/ + 000001D1 E9 FFFFFEF6 jmp L_dolen + + ALIGN 4 + 000001D8 L_test_for_second_level_dist: + 000001D8 A8 40 test al, 64 + 000001DA 0F 85 000000D8 jnz L_invalid_distance_code ; /* if ((op & 64) != 0) */ + + 000001E0 33 C0 xor eax, eax + 000001E2 FF C0 inc eax + 000001E4 D3 E0 shl eax, cl + 000001E6 FF C8 dec eax + 000001E8 23 C2 and eax, edx ; /* eax &= hold */ + 000001EA 41/ 03 C7 add eax, r15d ; /* eax += dist */ + 000001ED 41/ 8B 04 83 mov eax, [r11+rax*4] ; /* eax = dcode[val+(hold&mask[op])]*/ + 000001F1 E9 FFFFFF2D jmp L_dodist + + ALIGN 4 + 000001F8 L_clip_window: + 000001F8 8B C8 mov ecx, eax ; /* ecx = nbytes */ + 000001FA 8B 44 24 5C mov eax, [rsp+92] ; /* eax = wsize, prepare for dist cmp */ + 000001FE F7 D9 neg ecx ; /* nbytes = -nbytes */ + + 00000200 41/ 3B C7 cmp eax, r15d + 00000203 0F 82 000000B9 jb L_invalid_distance_too_far ; /* if (dist > wsize) */ + + 00000209 41/ 03 CF add ecx, r15d ; /* nbytes = dist - nbytes */ + 0000020C 83 7C 24 60 00 cmp dword ptr [rsp+96], 0 + 00000211 75 21 jne L_wrap_around_window ; /* if (write != 0) */ + + 00000213 48/ 8B 74 24 mov rsi, [rsp+56] ; /* from = window */ + 38 + 00000218 2B C1 sub eax, ecx ; /* eax -= nbytes */ + 0000021A 48/ 03 F0 add rsi, rax ; /* from += wsize - nbytes */ + + 0000021D 41/ 8B C6 mov eax, r14d ; /* eax = len */ + 00000220 44/ 3B F1 cmp r14d, ecx + 00000223 76 6F jbe L_do_copy ; /* if (nbytes >= len) */ + + 00000225 2B C1 sub eax, ecx ; /* eax -= nbytes */ + 00000227 F3/ A4 rep movsb + 00000229 48/ 8B F7 mov rsi, rdi + 0000022C 49/ 2B F7 sub rsi, r15 ; /* from = &out[ -dist ] */ + 0000022F EB 63 jmp L_do_copy + + ALIGN 4 + 00000234 L_wrap_around_window: + 00000234 8B 44 24 60 mov eax, [rsp+96] ; /* eax = write */ + 00000238 3B C8 cmp ecx, eax + 0000023A 76 38 jbe L_contiguous_in_window ; /* if (write >= nbytes) */ + + 0000023C 8B 74 24 5C mov esi, [rsp+92] ; /* from = wsize */ + 00000240 48/ 03 74 24 add rsi, [rsp+56] ; /* from += window */ + 38 + 00000245 48/ 03 F0 add rsi, rax ; /* from += write */ + 00000248 48/ 2B F1 sub rsi, rcx ; /* from -= nbytes */ + 0000024B 2B C8 sub ecx, eax ; /* nbytes -= write */ + + 0000024D 41/ 8B C6 mov eax, r14d ; /* eax = len */ + 00000250 3B C1 cmp eax, ecx + 00000252 76 40 jbe L_do_copy ; /* if (nbytes >= len) */ + + 00000254 2B C1 sub eax, ecx ; /* len -= nbytes */ + 00000256 F3/ A4 rep movsb + 00000258 48/ 8B 74 24 mov rsi, [rsp+56] ; /* from = window */ + 38 + 0000025D 8B 4C 24 60 mov ecx, [rsp+96] ; /* nbytes = write */ + 00000261 3B C1 cmp eax, ecx + 00000263 76 2F jbe L_do_copy ; /* if (nbytes >= len) */ + + 00000265 2B C1 sub eax, ecx ; /* len -= nbytes */ + 00000267 F3/ A4 rep movsb + 00000269 48/ 8B F7 mov rsi, rdi + 0000026C 49/ 2B F7 sub rsi, r15 ; /* from = out - dist */ + 0000026F EB 23 jmp L_do_copy + + ALIGN 4 + 00000274 L_contiguous_in_window: + 00000274 48/ 8B 74 24 mov rsi, [rsp+56] ; /* rsi = window */ + 38 + 00000279 48/ 03 F0 add rsi, rax + 0000027C 48/ 2B F1 sub rsi, rcx ; /* from += write - nbytes */ + + 0000027F 41/ 8B C6 mov eax, r14d ; /* eax = len */ + 00000282 3B C1 cmp eax, ecx + 00000284 76 0E jbe L_do_copy ; /* if (nbytes >= len) */ + + 00000286 2B C1 sub eax, ecx ; /* len -= nbytes */ + 00000288 F3/ A4 rep movsb + 0000028A 48/ 8B F7 mov rsi, rdi + 0000028D 49/ 2B F7 sub rsi, r15 ; /* from = out - dist */ + 00000290 EB 02 jmp L_do_copy ; /* if (nbytes >= len) */ + + ALIGN 4 + 00000294 L_do_copy: + 00000294 8B C8 mov ecx, eax ; /* ecx = len */ + 00000296 F3/ A4 rep movsb + + 00000298 49/ 8B F0 mov rsi, r8 ; /* move in back to %esi, toss from */ + 0000029B E9 FFFFFDE4 jmp L_while_test + + 000002A0 L_test_for_end_of_block: + 000002A0 A8 20 test al, 32 + 000002A2 74 0A jz L_invalid_literal_length_code + 000002A4 C7 44 24 74 mov dword ptr [rsp+116], 1 + 00000001 + 000002AC EB 26 jmp L_break_loop_with_status + + 000002AE L_invalid_literal_length_code: + 000002AE C7 44 24 74 mov dword ptr [rsp+116], 2 + 00000002 + 000002B6 EB 1C jmp L_break_loop_with_status + + 000002B8 L_invalid_distance_code: + 000002B8 C7 44 24 74 mov dword ptr [rsp+116], 3 + 00000003 + 000002C0 EB 12 jmp L_break_loop_with_status + + 000002C2 L_invalid_distance_too_far: + 000002C2 C7 44 24 74 mov dword ptr [rsp+116], 4 + 00000004 + 000002CA EB 08 jmp L_break_loop_with_status + + 000002CC L_break_loop: + 000002CC C7 44 24 74 mov dword ptr [rsp+116], 0 + 00000000 + + 000002D4 L_break_loop_with_status: + ; /* put in, out, bits, and hold back into ar and pop esp */ + 000002D4 48/ 89 74 24 mov [rsp+16], rsi ; /* in */ + 10 + 000002D9 48/ 89 7C 24 mov [rsp+32], rdi ; /* out */ + 20 + 000002DE 89 5C 24 58 mov [rsp+88], ebx ; /* bits */ + 000002E2 48/ 89 54 24 mov [rsp+80], rdx ; /* hold */ + 50 + + 000002E7 48/ 8B 04 24 mov rax, [rsp] ; /* restore rbp and rsp */ + 000002EB 48/ 8B 6C 24 mov rbp, [rsp+8] + 08 + 000002F0 48/ 8B E0 mov rsp, rax + + + + 000002F3 48/ 8B 74 24 mov rsi,[rsp-8] + F8 + 000002F8 48/ 8B 7C 24 mov rdi,[rsp-16] + F0 + 000002FD 4C/ 8B 64 24 mov r12,[rsp-24] + E8 + 00000302 4C/ 8B 6C 24 mov r13,[rsp-32] + E0 + 00000307 4C/ 8B 74 24 mov r14,[rsp-40] + D8 + 0000030C 4C/ 8B 7C 24 mov r15,[rsp-48] + D0 + 00000311 48/ 8B 5C 24 mov rbx,[rsp-56] + C8 + + 00000316 C3 ret 0 + ; : + ; : "m" (ar) + ; : "memory", "%rax", "%rbx", "%rcx", "%rdx", "%rsi", "%rdi", + ; "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15" + ; ); + + 00000317 inffas8664fnc ENDP + ;_TEXT ENDS + END +Microsoft (R) Macro Assembler (x64) Version 10.00.40219.01 08/10/13 00:27:06 +inffasx64.asm Symbols 2 - 1 + + + + +Procedures, parameters, and locals: + + N a m e Type Value Attr + +inffas8664fnc . . . . . . . . . P 00000000 _TEXT Length= 00000317 Public + L_one_time . . . . . . . . . . L 0000006C _TEXT + L_while_test . . . . . . . . . L 00000084 _TEXT + L_do_loop . . . . . . . . . . L 00000096 _TEXT + L_get_length_code . . . . . . L 000000AA _TEXT + L_get_length_code_one_time . . L 000000C4 _TEXT + L_dolen . . . . . . . . . . . L 000000CC _TEXT + L_test_for_length_base . . . . L 000000E0 _TEXT + L_add_bits_to_len . . . . . . L 000000F6 _TEXT + L_decode_distance . . . . . . L 00000108 _TEXT + L_get_distance_code . . . . . L 0000011C _TEXT + L_dodist . . . . . . . . . . . L 00000123 _TEXT + L_add_bits_to_dist . . . . . . L 00000140 _TEXT + L_check_window . . . . . . . . L 00000152 _TEXT + L_copy_two . . . . . . . . . . L 00000185 _TEXT + L_check_dist_one . . . . . . . L 00000190 _TEXT + L_set_two . . . . . . . . . . L 000001AE _TEXT + L_test_for_second_level_length . L 000001B8 _TEXT + L_test_for_second_level_dist . L 000001D8 _TEXT + L_clip_window . . . . . . . . L 000001F8 _TEXT + L_wrap_around_window . . . . . L 00000234 _TEXT + L_contiguous_in_window . . . . L 00000274 _TEXT + L_do_copy . . . . . . . . . . L 00000294 _TEXT + L_test_for_end_of_block . . . L 000002A0 _TEXT + L_invalid_literal_length_code L 000002AE _TEXT + L_invalid_distance_code . . . L 000002B8 _TEXT + L_invalid_distance_too_far . . L 000002C2 _TEXT + L_break_loop . . . . . . . . . L 000002CC _TEXT + L_break_loop_with_status . . . L 000002D4 _TEXT + + +Symbols: + + N a m e Type Value Attr + + + 0 Warnings + 0 Errors Added: trunk/OpenMPT/include/zlib/contrib/masmx64/inffasx64.obj =================================================================== (Binary files differ) Index: trunk/OpenMPT/include/zlib/contrib/masmx64/inffasx64.obj =================================================================== --- trunk/OpenMPT/include/zlib/contrib/masmx64/inffasx64.obj 2013-08-08 11:15:18 UTC (rev 2593) +++ trunk/OpenMPT/include/zlib/contrib/masmx64/inffasx64.obj 2013-08-09 22:33:22 UTC (rev 2594) Property changes on: trunk/OpenMPT/include/zlib/contrib/masmx64/inffasx64.obj ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Modified: trunk/OpenMPT/mptrack/ACMConvert.cpp =================================================================== --- trunk/OpenMPT/mptrack/ACMConvert.cpp 2013-08-08 11:15:18 UTC (rev 2593) +++ trunk/OpenMPT/mptrack/ACMConvert.cpp 2013-08-09 22:33:22 UTC (rev 2594) @@ -150,8 +150,8 @@ } -MMRESULT ACMConvert::AcmFormatEnum(HACMDRIVER had, LPACMFORMATDETAILSA pafd, ACMFORMATENUMCBA fnCallback, DWORD dwInstance, DWORD fdwEnum) -//---------------------------------------------------------------------------------------------------------------------------------------- +MMRESULT ACMConvert::AcmFormatEnum(HACMDRIVER had, LPACMFORMATDETAILSA pafd, ACMFORMATENUMCBA fnCallback, DWORD_PTR dwInstance, DWORD fdwEnum) +//-------------------------------------------------------------------------------------------------------------------------------------------- { MMRESULT err = MMSYSERR_INVALPARAM; if ((m_hBladeEnc) || (m_hLameEnc)) @@ -218,8 +218,8 @@ } -BOOL ACMConvert::AcmFormatEnumCB(HACMDRIVERID, LPACMFORMATDETAILS pafd, DWORD, DWORD fdwSupport) -//---------------------------------------------------------------------------------------------- +BOOL ACMConvert::AcmFormatEnumCB(HACMDRIVERID, LPACMFORMATDETAILS pafd, DWORD_PTR, DWORD fdwSupport) +//-------------------------------------------------------------------------------------------------- { if ((pafd) && (fdwSupport & ACMDRIVERDETAILS_SUPPORTF_CODEC)) { @@ -311,8 +311,8 @@ LPWAVEFORMATEX pwfxSrc, // source format to convert LPWAVEFORMATEX pwfxDst, // required destination format LPWAVEFILTER pwfltr, // optional filter - DWORD dwCallback, // callback - DWORD dwInstance, // callback instance data + DWORD_PTR dwCallback, // callback + DWORD_PTR dwInstance, // callback instance data DWORD fdwOpen) // ACM_STREAMOPENF_* and CALLBACK_* //-------------------------------------------------------------------------- { Modified: trunk/OpenMPT/mptrack/ACMConvert.h =================================================================== --- trunk/OpenMPT/mptrack/ACMConvert.h 2013-08-08 11:15:18 UTC (rev 2593) +++ trunk/OpenMPT/mptrack/ACMConvert.h 2013-08-09 22:33:22 UTC (rev 2594) @@ -15,10 +15,10 @@ // ACM Functions (for dynamic linking) typedef VOID (ACMAPI *PFNACMMETRICS)(HACMOBJ, UINT, LPVOID); -typedef MMRESULT (ACMAPI *PFNACMFORMATENUM)(HACMDRIVER, LPACMFORMATDETAILSA, ACMFORMATENUMCBA, DWORD dwInstance, DWORD fdwEnum); +typedef MMRESULT (ACMAPI *PFNACMFORMATENUM)(HACMDRIVER, LPACMFORMATDETAILSA, ACMFORMATENUMCBA, DWORD_PTR dwInstance, DWORD fdwEnum); typedef MMRESULT (ACMAPI *PFNACMDRIVEROPEN)(LPHACMDRIVER, HACMDRIVERID, DWORD); typedef MMRESULT (ACMAPI *PFNACMDRIVERCLOSE)(HACMDRIVER, DWORD); -typedef MMRESULT (ACMAPI *PFNACMSTREAMOPEN)(LPHACMSTREAM, HACMDRIVER, LPWAVEFORMATEX, LPWAVEFORMATEX, LPWAVEFILTER, DWORD, DWORD, DWORD); +typedef MMRESULT (ACMAPI *PFNACMSTREAMOPEN)(LPHACMSTREAM, HACMDRIVER, LPWAVEFORMATEX, LPWAVEFORMATEX, LPWAVEFILTER, DWORD_PTR, DWORD_PTR, DWORD); typedef MMRESULT (ACMAPI *PFNACMSTREAMCLOSE)(HACMSTREAM, DWORD); typedef MMRESULT (ACMAPI *PFNACMSTREAMSIZE)(HACMSTREAM, DWORD, LPDWORD, DWORD); typedef MMRESULT (ACMAPI *PFNACMSTREAMCONVERT)(HACMSTREAM, LPACMSTREAMHEADER, DWORD); @@ -39,11 +39,11 @@ BOOL InitializeACM(BOOL bNoAcm = FALSE); BOOL UninitializeACM(); public: - MMRESULT AcmFormatEnum(HACMDRIVER had, LPACMFORMATDETAILSA pafd, ACMFORMATENUMCBA fnCallback, DWORD dwInstance, DWORD fdwEnum); + MMRESULT AcmFormatEnum(HACMDRIVER had, LPACMFORMATDETAILSA pafd, ACMFORMATENUMCBA fnCallback, DWORD_PTR dwInstance, DWORD fdwEnum); MMRESULT AcmDriverOpen(LPHACMDRIVER, HACMDRIVERID, DWORD); MMRESULT AcmDriverDetails(HACMDRIVERID hadid, LPACMDRIVERDETAILS padd, DWORD fdwDetails); MMRESULT AcmDriverClose(HACMDRIVER, DWORD); - MMRESULT AcmStreamOpen(LPHACMSTREAM, HACMDRIVER, LPWAVEFORMATEX, LPWAVEFORMATEX, LPWAVEFILTER pwfltr, DWORD dwCallback, DWORD dwInstance, DWORD fdwOpen); + MMRESULT AcmStreamOpen(LPHACMSTREAM, HACMDRIVER, LPWAVEFORMATEX, LPWAVEFORMATEX, LPWAVEFILTER pwfltr, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen); MMRESULT AcmStreamClose(HACMSTREAM, DWORD); MMRESULT AcmStreamSize(HACMSTREAM has, DWORD cbInput, LPDWORD pdwOutputBytes, DWORD fdwSize); MMRESULT AcmStreamPrepareHeader(HACMSTREAM has, LPACMSTREAMHEADER pash, DWORD fdwPrepare); @@ -66,6 +66,6 @@ } protected: - static BOOL CALLBACK AcmFormatEnumCB(HACMDRIVERID, LPACMFORMATDETAILS, DWORD, DWORD); + static BOOL CALLBACK AcmFormatEnumCB(HACMDRIVERID, LPACMFORMATDETAILS, DWORD_PTR, DWORD); }; Modified: trunk/OpenMPT/mptrack/Autotune.cpp =================================================================== --- trunk/OpenMPT/mptrack/Autotune.cpp 2013-08-08 11:15:18 UTC (rev 2593) +++ trunk/OpenMPT/mptrack/Autotune.cpp 2013-08-09 22:33:22 UTC (rev 2594) @@ -295,7 +295,7 @@ { CDialog::OnOK(); - targetNote = m_CbnNoteBox.GetItemData(m_CbnNoteBox.GetCurSel()); + targetNote = (int)m_CbnNoteBox.GetItemData(m_CbnNoteBox.GetCurSel()); pitchReference = GetDlgItemInt(IDC_EDIT1); } Modified: trunk/OpenMPT/mptrack/CreditStatic.cpp =================================================================== --- trunk/OpenMPT/mptrack/CreditStatic.cpp 2013-08-08 11:15:18 UTC (rev 2593) +++ trunk/OpenMPT/mptrack/CreditStatic.cpp 2013-08-09 22:33:22 UTC (rev 2594) @@ -246,7 +246,7 @@ // Invalidate and UpdateWindow to invoke the OnPaint which will paint // the contents of the newly updated work string. //************************************************************************ -void CCreditStatic::OnTimer(UINT nIDEvent) +void CCreditStatic::OnTimer(UINT_PTR nIDEvent) { if (nIDEvent != DISPLAY_TIMER_ID) { Modified: trunk/OpenMPT/mptrack/CreditStatic.h =================================================================== --- trunk/OpenMPT/mptrack/CreditStatic.h 2013-08-08 11:15:18 UTC (rev 2593) +++ trunk/OpenMPT/mptrack/CreditStatic.h 2013-08-09 22:33:22 UTC (rev 2594) @@ -107,7 +107,7 @@ //{{AFX_MSG(CCreditStatic) afx_msg void OnPaint(); afx_msg BOOL OnEraseBkgnd(CDC* pDC); - afx_msg void OnTimer(UINT nIDEvent); + afx_msg void OnTimer(UINT_PTR nIDEvent); afx_msg void OnDestroy(); //}}AFX_MSG Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-08-08 11:15:18 UTC (rev 2593) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-08-09 22:33:22 UTC (rev 2594) @@ -3081,8 +3081,8 @@ { const ModSample &sample = m_sndFile.GetSample(m_nSample); - Limit(nStart, 0u, sample.nLength); - Limit(nEnd, 0u, sample.nLength); + Limit(nStart, SmpLength(0), sample.nLength); + Limit(nEnd, SmpLength(0), sample.nLength); SAMPLEVIEWSTATE viewstate; MemsetZero(viewstate); Modified: trunk/OpenMPT/mptrack/Globals.cpp =================================================================== --- trunk/OpenMPT/mptrack/Globals.cpp 2013-08-08 11:15:18 UTC (rev 2593) +++ trunk/OpenMPT/mptrack/Globals.cpp 2013-08-09 22:33:22 UTC (rev 2594) @@ -114,10 +114,10 @@ } -int CModControlDlg::OnToolHitTest(CPoint point, TOOLINFO* pTI) const -//------------------------------------------------------------------ +INT_PTR CModControlDlg::OnToolHitTest(CPoint point, TOOLINFO* pTI) const +//---------------------------------------------------------------------- { - int nHit = CDialog::OnToolHitTest(point, pTI); + INT_PTR nHit = CDialog::OnToolHitTest(point, pTI); if ((nHit >= 0) && (pTI)) { if ((pTI->lpszText == LPSTR_TEXTCALLBACK) && (pTI->hwnd == m_hWnd)) Modified: trunk/OpenMPT/mptrack/Globals.h =================================================================== --- trunk/OpenMPT/mptrack/Globals.h 2013-08-08 11:15:18 UTC (rev 2593) +++ trunk/OpenMPT/mptrack/Globals.h 2013-08-09 22:33:22 UTC (rev 2594) @@ -94,7 +94,7 @@ virtual void OnActivatePage(LPARAM) {} virtual void OnDeactivatePage() {} virtual BOOL OnInitDialog(); - virtual int OnToolHitTest( CPoint point, TOOLINFO* pTI ) const; + virtual INT_PTR OnToolHitTest( CPoint point, TOOLINFO* pTI ) const; virtual BOOL GetToolTipText(UINT, LPSTR) { return FALSE; } //}}AFX_VIRTUAL //{{AFX_MSG(CModControlDlg) Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-08-08 11:15:18 UTC (rev 2593) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-08-09 22:33:22 UTC (rev 2594) @@ -1102,7 +1102,7 @@ for(CHANNELINDEX k = 0; k < MAX_CHANNELS; k++) { const ModChannel &chn = m_pSndFile->Chn[k]; - uint32 pos = Notification::PosInvalid; + SmpLength pos = Notification::PosInvalid; if(chn.pModInstrument == m_pSndFile->Instruments[ins] // Correct instrument is set up on this channel && (chn.nLength || chn.pModInstrument->HasValidMIDIChannel()) // And it's playing something (sample or instrument plugin) @@ -2082,8 +2082,8 @@ } -void CMainFrame::OnTimer(UINT) -//---------------------------- +void CMainFrame::OnTimer(UINT_PTR) +//-------------------------------- { // Display Time in status bar CSoundFile::samplecount_t time = 0; Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-08-08 11:15:18 UTC (rev 2593) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-08-09 22:33:22 UTC (rev 2594) @@ -485,7 +485,7 @@ afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void OnRButtonDown(UINT, CPoint); afx_msg void OnClose(); - afx_msg void OnTimer(UINT); + afx_msg void OnTimer(UINT_PTR); afx_msg void OnSongProperties(); // -> CODE#0002 Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-08-08 11:15:18 UTC (rev 2593) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-08-09 22:33:22 UTC (rev 2594) @@ -478,7 +478,7 @@ pwfx->wBitsPerSample = 16; pwfx->nBlockAlign = pwfx->nChannels * pwfx->wBitsPerSample / 8; pwfx->nAvgBytesPerSec = pwfx->nSamplesPerSec * pwfx->nBlockAlign; - acmConvert.AcmFormatEnum(NULL, &afd, AcmFormatEnumCB, (DWORD)this, ACM_FORMATENUMF_CONVERT); + acmConvert.AcmFormatEnum(NULL, &afd, AcmFormatEnumCB, (DWORD_PTR)this, ACM_FORMATENUMF_CONVERT); m_CbnFormat.SetCurSel(m_nFormatIndex); } @@ -491,8 +491,8 @@ } -BOOL CLayer3Convert::AcmFormatEnumCB(HACMDRIVERID hdid, LPACMFORMATDETAILS pafd, DWORD dwInstance, DWORD fdwSupport) -//------------------------------------------------------------------------------------------------------------------ +BOOL CLayer3Convert::AcmFormatEnumCB(HACMDRIVERID hdid, LPACMFORMATDETAILS pafd, DWORD_PTR dwInstance, DWORD fdwSupport) +//---------------------------------------------------------------------------------------------------------------------- { if (dwInstance) { Modified: trunk/OpenMPT/mptrack/View_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_ins.cpp 2013-08-08 11:15:18 UTC (rev 2593) +++ trunk/OpenMPT/mptrack/View_ins.cpp 2013-08-09 22:33:22 UTC (rev 2594) @@ -126,7 +126,7 @@ m_nBtnMouseOver = 0xFFFF; for(CHANNELINDEX i = 0; i < MAX_CHANNELS; i++) { - m_dwNotifyPos[i] = Notification::PosInvalid; + m_dwNotifyPos[i] = (uint32)Notification::PosInvalid; } MemsetZero(m_NcButtonState); m_bmpEnvBar.Create(IDB_ENVTOOLBAR, 20, 0, RGB(192,192,192)); @@ -1159,9 +1159,9 @@ bool invalidate = false; for(CHANNELINDEX i = 0; i < MAX_CHANNELS; i++) { - if(m_dwNotifyPos[i] != Notification::PosInvalid) + if(m_dwNotifyPos[i] != (uint32)Notification::PosInvalid) { - m_dwNotifyPos[i] = Notification::PosInvalid; + m_dwNotifyPos[i] = (uint32)Notification::PosInvalid; invalidate = true; } } @@ -1175,7 +1175,7 @@ BOOL bUpdate = FALSE; for (CHANNELINDEX i = 0; i < MAX_CHANNELS; i++) { - uint32 newpos = pnotify->pos[i]; + uint32 newpos = (uint32)pnotify->pos[i]; if (m_dwNotifyPos[i] != newpos) { bUpdate = TRUE; @@ -1189,7 +1189,7 @@ for (CHANNELINDEX j = 0; j < MAX_CHANNELS; j++) { //DWORD newpos = (pSndFile->m_SongFlags[SONG_PAUSED]) ? pnotify->dwPos[j] : 0; - DWORD newpos = pnotify->pos[j]; + uint32 newpos = (uint32)pnotify->pos[j]; m_dwNotifyPos[j] = newpos; } DrawPositionMarks(hdc); Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2013-08-08 11:15:18 UTC (rev 2593) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2013-08-09 22:33:22 UTC (rev 2594) @@ -1750,8 +1750,8 @@ // Update loop points after deleting a sample selection -void CViewSample::AdjustLoopPoints(UINT &loopStart, UINT &loopEnd, UINT length) const -//----------------------------------------------------------------------------------- +void CV... [truncated message content] |
From: <sag...@us...> - 2013-08-10 22:19:50
|
Revision: 2596 http://sourceforge.net/p/modplug/code/2596 Author: saga-games Date: 2013-08-10 22:19:41 +0000 (Sat, 10 Aug 2013) Log Message: ----------- [Mod] Don't try saving channel volume effects in XM files [Imp] Also show flac files when loading instruments in instrument view Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/soundlib/Load_mod.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2013-08-10 18:08:43 UTC (rev 2595) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2013-08-10 22:19:41 UTC (rev 2596) @@ -1682,7 +1682,7 @@ static int nLastIndex = 0; FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(true, "", "", - "All Instruments|*.xi;*.pat;*.iti;*.wav;*.aif;*.aiff|" + "All Instruments|*.xi;*.pat;*.iti;*.flac;*.wav;*.aif;*.aiff|" "FastTracker II Instruments (*.xi)|*.xi|" "GF1 Patches (*.pat)|*.pat|" "Impulse Tracker Instruments (*.iti)|*.iti|" Modified: trunk/OpenMPT/soundlib/Load_mod.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mod.cpp 2013-08-10 18:08:43 UTC (rev 2595) +++ trunk/OpenMPT/soundlib/Load_mod.cpp 2013-08-10 22:19:41 UTC (rev 2596) @@ -46,8 +46,8 @@ case 'H' - 55: m.command = CMD_GLOBALVOLSLIDE; break; case 'K' - 55: m.command = CMD_KEYOFF; break; case 'L' - 55: m.command = CMD_SETENVPOSITION; break; - case 'M' - 55: m.command = CMD_CHANNELVOLUME; break; - case 'N' - 55: m.command = CMD_CHANNELVOLSLIDE; break; + case 'M' - 55: m.command = CMD_CHANNELVOLUME; break; // Wat. Luckily, MPT never allowed this to be entered in patterns... + case 'N' - 55: m.command = CMD_CHANNELVOLSLIDE; break; // Ditto. case 'P' - 55: m.command = CMD_PANNINGSLIDE; break; case 'R' - 55: m.command = CMD_RETRIG; break; case 'T' - 55: m.command = CMD_TREMOR; break; @@ -124,8 +124,6 @@ case CMD_GLOBALVOLSLIDE: command = 'H' - 55; break; case CMD_KEYOFF: command = 'K' - 55; break; case CMD_SETENVPOSITION: command = 'L' - 55; break; - case CMD_CHANNELVOLUME: command = 'M' - 55; break; - case CMD_CHANNELVOLSLIDE: command = 'N' - 55; break; case CMD_PANNINGSLIDE: command = 'P' - 55; break; case CMD_RETRIG: command = 'R' - 55; break; case CMD_TREMOR: command = 'T' - 55; break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-08-11 00:18:35
|
Revision: 2598 http://sourceforge.net/p/modplug/code/2598 Author: saga-games Date: 2013-08-11 00:18:18 +0000 (Sun, 11 Aug 2013) Log Message: ----------- [Ref] More small changes to get rid of warnings in 64-bit compile Modified Paths: -------------- trunk/OpenMPT/common/serialization_utils.cpp trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/AutoSaver.cpp trunk/OpenMPT/mptrack/Childfrm.cpp trunk/OpenMPT/mptrack/CreditStatic.h trunk/OpenMPT/mptrack/Ctrl_com.cpp trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Ctrl_pat.cpp trunk/OpenMPT/mptrack/Ctrl_seq.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/Ctrl_smp.h trunk/OpenMPT/mptrack/DefaultVstEditor.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/mptrack/SampleEditorDialogs.h trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/VstPresets.cpp trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/ITTools.cpp trunk/OpenMPT/soundlib/ITTools.h trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/SampleIO.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/WAVTools.cpp trunk/OpenMPT/soundlib/modsmp_ctrl.cpp trunk/OpenMPT/soundlib/plugins/PluginEventQueue.h Modified: trunk/OpenMPT/common/serialization_utils.cpp =================================================================== --- trunk/OpenMPT/common/serialization_utils.cpp 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/common/serialization_utils.cpp 2013-08-11 00:18:18 UTC (rev 2598) @@ -172,7 +172,7 @@ void WriteItemString(std::ostream& oStrm, const char* const pStr, const size_t nSize) //-------------------------------------------------------------------------------- { - uint32 id = std::min<size_t>(nSize, (uint32_max >> 4)) << 4; + uint32 id = (uint32)std::min<size_t>(nSize, (uint32_max >> 4)) << 4; id |= 12; // 12 == 1100b Binarywrite<uint32>(oStrm, id); id >>= 4; @@ -206,7 +206,7 @@ for(size_t i = 0; i < str.size(); i++) iStrm.read(&str[i], 1); - id = (id >> 4) - str.size(); + id = (id >> 4) - (uint32)str.size(); if(id > 0) iStrm.ignore(id); } @@ -585,7 +585,7 @@ const Offtype nRawEntrySize = m_pOstrm->tellp() - posBeforeWrite; if (nRawEntrySize > std::numeric_limits<DataSize>::max()) - { AddWriteNote(SNW_INSUFFICIENT_DATASIZETYPE); return; } + { AddWriteNote(SNW_INSUFFICIENT_DATASIZETYPE); return; } if(GetFlag(RwfRMapHasSize) && nRawEntrySize > (std::numeric_limits<DataSize>::max() >> 2)) { AddWriteNote(SNW_DATASIZETYPE_OVERFLOW); return; } Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-08-11 00:18:18 UTC (rev 2598) @@ -104,7 +104,7 @@ { if(!CheckInstrument(m_nInstrument)) m_nInstrument = GetBestInstrumentCandidate(); - modDoc->ProcessMIDI(midiData, m_nInstrument, &m_VstPlugin, kCtxVSTGUI); + modDoc->ProcessMIDI((uint32)midiData, m_nInstrument, &m_VstPlugin, kCtxVSTGUI); return 1; } return 0; @@ -308,7 +308,7 @@ CInputHandler *ih = (CMainFrame::GetMainFrame())->GetInputHandler(); //Translate message manually - UINT nChar = pMsg->wParam; + UINT nChar = (UINT)pMsg->wParam; UINT nRepCnt = LOWORD(pMsg->lParam); UINT nFlags = HIWORD(pMsg->lParam); KeyEventType kT = ih->GetKeyEventType(nFlags); Modified: trunk/OpenMPT/mptrack/AutoSaver.cpp =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.cpp 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/mptrack/AutoSaver.cpp 2013-08-11 00:18:18 UTC (rev 2598) @@ -171,7 +171,7 @@ int CAutoSaver::GetHistoryDepth() -//_------------------------------ +//------------------------------- { return m_nBackupHistory; } Modified: trunk/OpenMPT/mptrack/Childfrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/Childfrm.cpp 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/mptrack/Childfrm.cpp 2013-08-11 00:18:18 UTC (rev 2598) @@ -361,12 +361,12 @@ ASSERT(pNMHDR->code == TTN_NEEDTEXTA || pNMHDR->code == TTN_NEEDTEXTW); szFullText[0] = 0; - UINT nID = pNMHDR->idFrom; + UINT_PTR nID = pNMHDR->idFrom; if (pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND) || pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND)) { // idFrom is actually the HWND of the tool - nID = (UINT)::GetDlgCtrlID((HWND)nID); + nID = (UINT_PTR)::GetDlgCtrlID((HWND)nID); } if ((nID >= 1000) && (nID < 10000) && (m_hWndCtrl) && (::SendMessage(m_hWndCtrl, WM_MOD_GETTOOLTIPTEXT, nID, (LPARAM)szFullText))) Modified: trunk/OpenMPT/mptrack/CreditStatic.h =================================================================== --- trunk/OpenMPT/mptrack/CreditStatic.h 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/mptrack/CreditStatic.h 2013-08-11 00:18:18 UTC (rev 2598) @@ -65,7 +65,7 @@ UINT m_Gradient; BOOL m_bTransparent; int n_MaxWidth; - UINT TimerOn; + UINT_PTR TimerOn; // Construction public: CCreditStatic(); Modified: trunk/OpenMPT/mptrack/Ctrl_com.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_com.cpp 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/mptrack/Ctrl_com.cpp 2013-08-11 00:18:18 UTC (rev 2598) @@ -195,8 +195,8 @@ } strcat(p, s); } - UINT len = strlen(p); - while ((len > 0) && ((p[len-1] == ' ') || (p[len-1] == SongMessage::InternalLineEnding))) + size_t len = strlen(p); + while ((len > 0) && ((p[len-1] == ' ') || (p[len - 1] == SongMessage::InternalLineEnding))) { len--; p[len] = 0; Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2013-08-11 00:18:18 UTC (rev 2598) @@ -1819,11 +1819,10 @@ CHAR s[64]; s[0] = 0; m_EditFileName.GetWindowText(s, sizeof(s)); - for (UINT i=strlen(s); i<=12; i++) s[i] = 0; ModInstrument *pIns = m_sndFile.Instruments[m_nInstrument]; if ((pIns) && (strncmp(s, pIns->filename, 12))) { - memcpy(pIns->filename, s, 12); + mpt::String::Copy(pIns->filename, s); SetInstrumentModified(true); } } @@ -2608,7 +2607,7 @@ { if(pIns->pTuning == &CSoundFile::GetBuiltInTunings().GetTuning(i)) { - m_ComboTuning.SetCurSel(i+1); + m_ComboTuning.SetCurSel((int)(i + 1)); return; } } @@ -2617,7 +2616,7 @@ { if(pIns->pTuning == &CSoundFile::GetLocalTunings().GetTuning(i)) { - m_ComboTuning.SetCurSel(i+CSoundFile::GetBuiltInTunings().GetNumTunings()+1); + m_ComboTuning.SetCurSel((int)(i + CSoundFile::GetBuiltInTunings().GetNumTunings() + 1)); return; } } @@ -2626,7 +2625,7 @@ { if(pIns->pTuning == &m_sndFile.GetTuneSpecificTunings().GetTuning(i)) { - m_ComboTuning.SetCurSel(i+CSoundFile::GetBuiltInTunings().GetNumTunings() + CSoundFile::GetLocalTunings().GetNumTunings()+1); + m_ComboTuning.SetCurSel((int)(i + CSoundFile::GetBuiltInTunings().GetNumTunings() + CSoundFile::GetLocalTunings().GetNumTunings() + 1)); return; } } Modified: trunk/OpenMPT/mptrack/Ctrl_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2013-08-11 00:18:18 UTC (rev 2598) @@ -379,7 +379,7 @@ return m_OrderList.GetCurrentPattern(); case CTRLMSG_PATTERNCHANGED: - UpdateView((lParam << HINT_SHIFT_PAT) | HINT_PATNAMES, NULL); + UpdateView((DWORD)(lParam << HINT_SHIFT_PAT) | HINT_PATNAMES, NULL); break; case CTRLMSG_PAT_PREVINSTRUMENT: @@ -1228,7 +1228,7 @@ //--------------------------------------------------------------------- { TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR; - UINT nID =pNMHDR->idFrom; + UINT_PTR nID = pNMHDR->idFrom; if (pTTT->uFlags & TTF_IDISHWND) { // idFrom is actually the HWND of the tool Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2013-08-11 00:18:18 UTC (rev 2598) @@ -380,7 +380,7 @@ CInputHandler* ih = (CMainFrame::GetMainFrame())->GetInputHandler(); //Translate message manually - UINT nChar = pMsg->wParam; + UINT nChar = (UINT)pMsg->wParam; UINT nRepCnt = LOWORD(pMsg->lParam); UINT nFlags = HIWORD(pMsg->lParam); KeyEventType kT = ih->GetKeyEventType(nFlags); Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-08-11 00:18:18 UTC (rev 2598) @@ -1133,62 +1133,62 @@ //------------------------------ { //Default case: Normalize current sample - SAMPLEINDEX iMinSample = m_nSample, iMaxSample = m_nSample; + SAMPLEINDEX minSample = m_nSample, maxSample = m_nSample; //If only one sample is selected, parts of it may be amplified - UINT iStart = 0, iEnd = 0; + SmpLength selStart = 0, selEnd = 0; //Shift -> Normalize all samples if(CMainFrame::GetInputHandler()->ShiftPressed()) { if(Reporting::Confirm(GetStrI18N(TEXT("This will normalize all samples independently. Continue?")), GetStrI18N(TEXT("Normalize"))) == cnfNo) return; - iMinSample = 1; - iMaxSample = m_sndFile.m_nSamples; + minSample = 1; + maxSample = m_sndFile.GetNumSamples(); } else { SampleSelectionPoints selection = GetSelectionPoints(); - iStart = selection.nStart; - iEnd = selection.nEnd; + selStart = selection.nStart; + selEnd = selection.nEnd; } BeginWaitCursor(); bool bModified = false; - for(SAMPLEINDEX iSmp = iMinSample; iSmp <= iMaxSample; iSmp++) + for(SAMPLEINDEX iSmp = minSample; iSmp <= maxSample; iSmp++) { if (m_sndFile.GetSample(iSmp).pSample) { bool bOk = false; ModSample &sample = m_sndFile.GetSample(iSmp); - if(iMinSample != iMaxSample) + if(minSample != maxSample) { //if more than one sample is selected, always amplify the whole sample. - iStart = 0; - iEnd = sample.nLength; + selStart = 0; + selEnd = sample.nLength; } else { //one sample: correct the boundaries, if needed - LimitMax(iEnd, sample.nLength); - LimitMax(iStart, iEnd); - if(iStart == iEnd) + LimitMax(selEnd, sample.nLength); + LimitMax(selStart, selEnd); + if(selStart == selEnd) { - iStart = 0; - iEnd = sample.nLength; + selStart = 0; + selEnd = sample.nLength; } } - m_modDoc.GetSampleUndo().PrepareUndo(iSmp, sundo_update, iStart, iEnd); + m_modDoc.GetSampleUndo().PrepareUndo(iSmp, sundo_update, selStart, selEnd); - if(sample.uFlags & CHN_STEREO) { iStart *= 2; iEnd *= 2; } + if(sample.uFlags & CHN_STEREO) { selStart *= 2; selEnd *= 2; } if(sample.uFlags & CHN_16BIT) { int16 *p = (int16 *)sample.pSample; int max = 1; - for (UINT i = iStart; i < iEnd; i++) + for (SmpLength i = selStart; i < selEnd; i++) { if (p[i] > max) max = p[i]; if (-p[i] > max) max = -p[i]; @@ -1196,7 +1196,7 @@ if (max < 32767) { max++; - for (UINT j = iStart; j < iEnd; j++) + for (SmpLength j = selStart; j < selEnd; j++) { int l = (((int)p[j]) << 15) / max; p[j] = (int16)l; @@ -1207,7 +1207,7 @@ { int8 *p = (int8 *)sample.pSample; int max = 1; - for (UINT i = iStart; i < iEnd; i++) + for (SmpLength i = selStart; i < selEnd; i++) { if (p[i] > max) max = p[i]; if (-p[i] > max) max = -p[i]; @@ -1215,7 +1215,7 @@ if (max < 127) { max++; - for (UINT j = iStart; j < iEnd; j++) + for (SmpLength j = selStart; j < selEnd; j++) { int l = (((int)p[j]) << 7) / max; p[j] = (int8)l; @@ -1254,13 +1254,13 @@ m_modDoc.GetSampleUndo().PrepareUndo(m_nSample, sundo_update, selection.nStart, selection.nEnd); if (sample.uFlags & CHN_STEREO) { selection.nStart *= 2; selection.nEnd *= 2; } - UINT len = selection.nEnd - selection.nStart; + SmpLength len = selection.nEnd - selection.nStart; if ((bFadeIn) && (bFadeOut)) lAmp *= 4; if (sample.uFlags & CHN_16BIT) { signed short *p = ((signed short *)sample.pSample) + selection.nStart; - for (UINT i=0; i<len; i++) + for (SmpLength i=0; i<len; i++) { LONG l = (p[i] * lAmp) / 100; if (bFadeIn) l = (LONG)((l * (LONGLONG)i) / len); @@ -1273,7 +1273,7 @@ { signed char *p = ((signed char *)sample.pSample) + selection.nStart; - for (UINT i=0; i<len; i++) + for (SmpLength i=0; i<len; i++) { LONG l = (p[i] * lAmp) / 100; if (bFadeIn) l = (LONG)((l * (LONGLONG)i) / len); @@ -1294,51 +1294,51 @@ void CCtrlSamples::OnRemoveDCOffset() //----------------------------------- { - SAMPLEINDEX iMinSample = m_nSample, iMaxSample = m_nSample; + SAMPLEINDEX minSample = m_nSample, maxSample = m_nSample; //Shift -> Process all samples if(CMainFrame::GetInputHandler()->ShiftPressed()) { if(Reporting::Confirm(GetStrI18N(TEXT("This will process all samples independently. Continue?")), GetStrI18N(TEXT("DC Offset Removal"))) == cnfNo) return; - iMinSample = 1; - iMaxSample = m_sndFile.m_nSamples; + minSample = 1; + maxSample = m_sndFile.GetNumSamples(); } BeginWaitCursor(); // for report / SetModified - UINT iModified = 0; + SAMPLEINDEX numModified = 0; float fReportOffset = 0; - for(SAMPLEINDEX iSmp = iMinSample; iSmp <= iMaxSample; iSmp++) + for(SAMPLEINDEX iSmp = minSample; iSmp <= maxSample; iSmp++) { - UINT iStart, iEnd; + SmpLength selStart, selEnd; if(m_sndFile.GetSample(iSmp).pSample == nullptr) continue; - if (iMinSample != iMaxSample) + if (minSample != maxSample) { - iStart = 0; - iEnd = m_sndFile.GetSample(iSmp).nLength; + selStart = 0; + selEnd = m_sndFile.GetSample(iSmp).nLength; } else { SampleSelectionPoints selection = GetSelectionPoints(); - iStart = selection.nStart; - iEnd = selection.nEnd; + selStart = selection.nStart; + selEnd = selection.nEnd; } - m_modDoc.GetSampleUndo().PrepareUndo(iSmp, sundo_update, iStart, iEnd); + m_modDoc.GetSampleUndo().PrepareUndo(iSmp, sundo_update, selStart, selEnd); - const float fOffset = ctrlSmp::RemoveDCOffset(m_sndFile.GetSample(iSmp), iStart, iEnd, m_sndFile.GetType(), m_sndFile); + const float fOffset = ctrlSmp::RemoveDCOffset(m_sndFile.GetSample(iSmp), selStart, selEnd, m_sndFile.GetType(), m_sndFile); if(fOffset == 0.0f) // No offset removed. continue; fReportOffset += fOffset; - iModified++; + numModified++; m_modDoc.UpdateAllViews(NULL, (iSmp << HINT_SHIFT_SMP) | HINT_SAMPLEDATA | HINT_SAMPLEINFO, NULL); } @@ -1348,16 +1348,16 @@ // fill the statusbar with some nice information CString dcInfo; - if(iModified) + if(numModified) { m_modDoc.SetModified(); - if(iModified == 1) + if(numModified == 1) { dcInfo.Format(GetStrI18N(TEXT("Removed DC offset (%.1f%%)")), fReportOffset * 100); } else { - dcInfo.Format(GetStrI18N(TEXT("Removed DC offset from %d samples (avg %0.1f%%)")), iModified, fReportOffset / iModified * 100); + dcInfo.Format(GetStrI18N(TEXT("Removed DC offset from %d samples (avg %0.1f%%)")), numModified, fReportOffset / numModified * 100); } } else @@ -1411,7 +1411,7 @@ void CCtrlSamples::OnUpsample() //----------------------------- { - DWORD dwStart, dwEnd, dwNewLen; + SmpLength dwStart, dwEnd, dwNewLen; UINT smplsize, newsmplsize; PVOID pOriginal, pNewSample; @@ -1443,13 +1443,13 @@ const UINT nCh = sample.GetNumChannels(); for (UINT iCh=0; iCh<nCh; iCh++) { - int len = dwEnd - dwStart; + SmpLength len = dwEnd - dwStart; int maxndx = sample.nLength; if (sample.uFlags & CHN_16BIT) { signed short *psrc = ((signed short *)pOriginal)+iCh; signed short *pdest = ((signed short *)pNewSample)+dwStart*nCh+iCh; - for (int i=0; i<len; i++) + for (SmpLength i=0; i<len; i++) { int accum = 0x80; for (int j=0; j<16; j++) @@ -1470,7 +1470,7 @@ { signed char *psrc = ((signed char *)pOriginal)+iCh; signed short *pdest = ((signed short *)pNewSample)+dwStart*nCh+iCh; - for (int i=0; i<len; i++) + for (SmpLength i=0; i<len; i++) { int accum = 0x40; for (int j=0; j<16; j++) @@ -1497,7 +1497,7 @@ { if (dwStart > 0) { - for (UINT i=0; i<dwStart*nCh; i++) + for (SmpLength i=0; i<dwStart*nCh; i++) { ((signed short *)pNewSample)[i] = (signed short)(((signed char *)pOriginal)[i] << 8); } @@ -1505,7 +1505,7 @@ if (dwEnd < sample.nLength) { signed short *pdest = ((signed short *)pNewSample) + (dwEnd-dwStart)*nCh; - for (UINT i=dwEnd*nCh; i<sample.nLength*nCh; i++) + for (SmpLength i=dwEnd*nCh; i<sample.nLength*nCh; i++) { pdest[i] = (signed short)(((signed char *)pOriginal)[i] << 8); } @@ -1903,8 +1903,8 @@ // Show wait mouse cursor BeginWaitCursor(); - UINT pos = 0; - UINT len = 0; //To contain length of processing step. + SmpLength pos = 0; + SmpLength len = 0; //To contain length of processing step. // Initialize soundtouch object. { @@ -2080,7 +2080,8 @@ // Process sample buffer using MAX_BUFFER_LENGTH (max) sized chunk steps (in order to allow // the processing of BIG samples...) - while(pos < sample.nLength){ + while(pos < sample.nLength) + { // Current chunk size limit test if(pos + len >= sample.nLength) len = sample.nLength - pos; @@ -2263,7 +2264,7 @@ ModSample &sample = m_sndFile.GetSample(m_nSample); m_modDoc.GetSampleUndo().PrepareUndo(m_nSample, sundo_update, selection.nStart, selection.nEnd); - int len = selection.nEnd - selection.nStart; + SmpLength len = selection.nEnd - selection.nStart; if (sample.uFlags & CHN_STEREO) { int smplsize = (sample.uFlags & CHN_16BIT) ? 4 : 2; @@ -2276,7 +2277,7 @@ int dest = (selection.nEnd < sample.nLength) ? p[len-1] : 0; int base = (selection.nStart) ? p[0] : 0; int delta = dest - base; - for (int i=0; i<len; i++) + for (SmpLength i=0; i<len; i++) { int n = base + (int)(((LONGLONG)delta * (LONGLONG)i) / (len-1)); p[i] = (signed short)n; @@ -2287,7 +2288,7 @@ int dest = (selection.nEnd < sample.nLength) ? p[len-1] : 0; int base = (selection.nStart) ? p[0] : 0; int delta = dest - base; - for (int i=0; i<len; i++) + for (SmpLength i=0; i<len; i++) { int n = base + (delta * i) / (len-1); p[i] = (signed char)n; @@ -2326,13 +2327,10 @@ void CCtrlSamples::OnNameChanged() //-------------------------------- { - CHAR s[64]; + char s[MAX_SAMPLENAME] = { '\0' }; if(IsLocked() || !m_nSample) return; - s[0] = 0; m_EditName.GetWindowText(s, sizeof(s)); - for (UINT i=strlen(s); i<32; i++) s[i] = 0; - s[31] = 0; if (strncmp(s, m_sndFile.m_szNames[m_nSample], MAX_SAMPLENAME)) { mpt::String::Copy(m_sndFile.m_szNames[m_nSample], s); @@ -2346,12 +2344,10 @@ void CCtrlSamples::OnFileNameChanged() //------------------------------------ { - CHAR s[MAX_SAMPLEFILENAME]; + char s[MAX_SAMPLEFILENAME] = { '\0' }; if(IsLocked()) return; - s[0] = 0; m_EditFileName.GetWindowText(s, sizeof(s)); - mpt::String::SetNullTerminator(s); if (strncmp(s, m_sndFile.GetSample(m_nSample).filename, MAX_SAMPLEFILENAME)) { @@ -2785,7 +2781,7 @@ // Find Next LoopStart Point if (pos > 0) { - for (UINT i=sample.nLoopStart+1; i+16<sample.nLoopEnd; i++) + for (SmpLength i=sample.nLoopStart+1; i+16<sample.nLoopEnd; i++) { p += pinc; bOk = (sample.uFlags & CHN_PINGPONGLOOP) ? MPT_BidiStartCheck(p[0], p[pinc], p[pinc*2]) : MPT_LoopCheck(find0, find1, p[0], p[pinc]); @@ -2798,7 +2794,7 @@ } else // Find Prev LoopStart Point { - for (UINT i=sample.nLoopStart; i; ) + for (SmpLength i=sample.nLoopStart; i; ) { i--; p -= pinc; @@ -2831,7 +2827,7 @@ // Find Next LoopEnd Point if (pos > 0) { - for (UINT i=sample.nLoopEnd+1; i<=sample.nLength; i++, p+=pinc) + for (SmpLength i=sample.nLoopEnd+1; i<=sample.nLength; i++, p+=pinc) { bOk = (sample.uFlags & CHN_PINGPONGLOOP) ? MPT_BidiEndCheck(p[0], p[pinc], p[pinc*2]) : MPT_LoopCheck(find0, find1, p[0], p[pinc]); if (bOk) @@ -2843,7 +2839,7 @@ } else // Find Prev LoopEnd Point { - for (UINT i=sample.nLoopEnd; i>sample.nLoopStart+16; ) + for (SmpLength i=sample.nLoopEnd; i>sample.nLoopStart+16; ) { i--; p -= pinc; @@ -2876,7 +2872,7 @@ // Find Next Sustain LoopStart Point if (pos > 0) { - for (UINT i=sample.nSustainStart+1; i+16<sample.nSustainEnd; i++) + for (SmpLength i=sample.nSustainStart+1; i+16<sample.nSustainEnd; i++) { p += pinc; bOk = (sample.uFlags & CHN_PINGPONGSUSTAIN) ? MPT_BidiStartCheck(p[0], p[pinc], p[pinc*2]) : MPT_LoopCheck(find0, find1, p[0], p[pinc]); @@ -2889,7 +2885,7 @@ } else // Find Prev Sustain LoopStart Point { - for (UINT i=sample.nSustainStart; i; ) + for (SmpLength i=sample.nSustainStart; i; ) { i--; p -= pinc; @@ -2921,7 +2917,7 @@ // Find Next LoopEnd Point if (pos > 0) { - for (UINT i=sample.nSustainEnd+1; i+1<sample.nLength; i++, p+=pinc) + for (SmpLength i=sample.nSustainEnd+1; i+1<sample.nLength; i++, p+=pinc) { bOk = (sample.uFlags & CHN_PINGPONGSUSTAIN) ? MPT_BidiEndCheck(p[0], p[pinc], p[pinc*2]) : MPT_LoopCheck(find0, find1, p[0], p[pinc]); if (bOk) @@ -2933,7 +2929,7 @@ } else // Find Prev LoopEnd Point { - for (UINT i=sample.nSustainEnd; i>sample.nSustainStart+16; ) + for (SmpLength i=sample.nSustainEnd; i>sample.nSustainStart+16; ) { i--; p -= pinc; @@ -2960,7 +2956,7 @@ { if (m_sndFile.m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT)) { - UINT d = sample.nC5Speed; + uint32 d = sample.nC5Speed; if (d < 1) d = 8363; if(d < m_nFinetuneStep) d = m_nFinetuneStep; d += (pos * m_nFinetuneStep); @@ -3015,7 +3011,7 @@ CInputHandler* ih = (CMainFrame::GetMainFrame())->GetInputHandler(); //Translate message manually - UINT nChar = pMsg->wParam; + UINT nChar = (UINT)pMsg->wParam; UINT nRepCnt = LOWORD(pMsg->lParam); UINT nFlags = HIWORD(pMsg->lParam); KeyEventType kT = ih->GetKeyEventType(nFlags); @@ -3076,8 +3072,8 @@ // Set the currently selected part of the sample. // To reset the selection, use nStart = nEnd = 0. -void CCtrlSamples::SetSelectionPoints(UINT nStart, UINT nEnd) -//----------------------------------------------------------- +void CCtrlSamples::SetSelectionPoints(SmpLength nStart, SmpLength nEnd) +//--------------------------------------------------------------------- { const ModSample &sample = m_sndFile.GetSample(m_nSample); Modified: trunk/OpenMPT/mptrack/Ctrl_smp.h =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.h 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/mptrack/Ctrl_smp.h 2013-08-11 00:18:18 UTC (rev 2598) @@ -58,7 +58,7 @@ void ApplyAmplify(LONG nAmp, bool bFadeIn = false, bool bFadeOut = false); SampleSelectionPoints GetSelectionPoints(); - void SetSelectionPoints(UINT nStart, UINT nEnd); + void SetSelectionPoints(SmpLength nStart, SmpLength nEnd); void PropagateAutoVibratoChanges() const; Modified: trunk/OpenMPT/mptrack/DefaultVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/DefaultVstEditor.cpp 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/mptrack/DefaultVstEditor.cpp 2013-08-11 00:18:18 UTC (rev 2598) @@ -204,7 +204,7 @@ rect.DeflateRect(edSpacing, edSpacing); rect.bottom = edTotalHeight; - for(size_t i = 0; i < NUM_PLUGINEDITOR_PARAMETERS; i++) + for(int i = 0; i < NUM_PLUGINEDITOR_PARAMETERS; i++) { try { Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-08-11 00:18:18 UTC (rev 2598) @@ -1036,7 +1036,8 @@ ModChannel *pChn = &m_SndFile.Chn[nChn]; // reset channel properties; in theory the chan is completely unused anyway. - pChn->nPos = pChn->nPosLo = pChn->nLength = 0; + pChn->nPos = pChn->nPosLo = 0; + pChn->nLength = 0; pChn->dwFlags &= CHN_SAMPLEFLAGS; pChn->dwFlags.reset(CHN_MUTE); pChn->nGlobalVol = 64; @@ -1065,7 +1066,8 @@ pChn->pSample = sample.pSample; pChn->nFineTune = sample.nFineTune; pChn->nC5Speed = sample.nC5Speed; - pChn->nPos = pChn->nPosLo = pChn->nLength = 0; + pChn->nPos = pChn->nPosLo = 0; + pChn->nLength = 0; pChn->nLoopStart = sample.nLoopStart; pChn->nLoopEnd = sample.nLoopEnd; pChn->dwFlags = static_cast<ChannelFlags>(sample.uFlags) & (CHN_SAMPLEFLAGS & ~CHN_MUTE); Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2013-08-11 00:18:18 UTC (rev 2598) @@ -288,7 +288,7 @@ std::vector<SAMPLEINDEX> newIndex(oldNumSamples + 1, 0); // One of the new indexes for the old sample std::vector<std::string> sampleNames(oldNumSamples + 1); - for(size_t i = 0; i < newOrder.size(); i++) + for(SAMPLEINDEX i = 0; i < newNumSamples; i++) { const SAMPLEINDEX origSlot = newOrder[i]; if(origSlot > 0 && origSlot <= oldNumSamples) @@ -397,7 +397,7 @@ std::vector<ModInstrument> instrumentHeaders(oldNumInstruments + 1); std::vector<INSTRUMENTINDEX> newIndex(oldNumInstruments + 1, 0); // One of the new indexes for the old instrument - for(size_t i = 0; i < newNumInstruments; i++) + for(INSTRUMENTINDEX i = 0; i < newNumInstruments; i++) { const INSTRUMENTINDEX origSlot = newOrder[i]; if(origSlot > 0 && origSlot <= oldNumInstruments) @@ -550,7 +550,7 @@ for (PLUGINDEX nPlug = 0; nPlug < maxPlug; nPlug++) { - SNDMIXPLUGIN* pPlug = &m_SndFile.m_MixPlugins[nPlug]; + SNDMIXPLUGIN* pPlug = &m_SndFile.m_MixPlugins[nPlug]; if (keepMask[nPlug] || !pPlug) { continue; Modified: trunk/OpenMPT/mptrack/SampleEditorDialogs.h =================================================================== --- trunk/OpenMPT/mptrack/SampleEditorDialogs.h 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/mptrack/SampleEditorDialogs.h 2013-08-11 00:18:18 UTC (rev 2598) @@ -144,7 +144,7 @@ CSpinButtonCtrl m_SpinSamples; public: - CSampleXFadeDlg(CWnd *parent, UINT nSamples, UINT nMaxSamples) : CDialog(IDD_SAMPLE_XFADE, parent) { m_nSamples = nSamples; m_nMaxSamples = nMaxSamples; }; + CSampleXFadeDlg(CWnd *parent, SmpLength nSamples, UINT nMaxSamples) : CDialog(IDD_SAMPLE_XFADE, parent), m_nSamples(nSamples), m_nMaxSamples(nMaxSamples) { }; protected: virtual void DoDataExchange(CDataExchange* pDX); Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2013-08-11 00:18:18 UTC (rev 2598) @@ -151,7 +151,7 @@ void CViewSample::UpdateScrollSize(const UINT nZoomOld) -//---------------------------------- +//----------------------------------------------------- { CModDoc *pModDoc = GetDocument(); @@ -161,7 +161,7 @@ CPoint pt; CSoundFile *pSndFile = pModDoc->GetSoundFile(); SIZE sizePage, sizeLine; - DWORD dwLen = 0; + SmpLength dwLen = 0; if ((m_nSample > 0) && (m_nSample <= pSndFile->GetNumSamples())) { @@ -348,7 +348,7 @@ if ((pModDoc) && (m_nSample <= pModDoc->GetNumSamples())) { CSoundFile *pSndFile = pModDoc->GetSoundFile(); - UINT nLen = pSndFile->GetSample(m_nSample).nLength; + SmpLength nLen = pSndFile->GetSample(m_nSample).nLength; if (!nLen) return 0; if (m_nZoom) { @@ -371,7 +371,7 @@ if ((pModDoc) && (m_nSample <= pModDoc->GetNumSamples())) { CSoundFile *pSndFile = pModDoc->GetSoundFile(); - UINT nLen = pSndFile->GetSample(m_nSample).nLength; + SmpLength nLen = pSndFile->GetSample(m_nSample).nLength; if (!nLen) return 0; if (m_nZoom) { Modified: trunk/OpenMPT/mptrack/VstPresets.cpp =================================================================== --- trunk/OpenMPT/mptrack/VstPresets.cpp 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/mptrack/VstPresets.cpp 2013-08-11 00:18:18 UTC (rev 2598) @@ -146,7 +146,7 @@ if(writeChunk) { char *chunk = nullptr; - uint32 chunkSize = plugin.Dispatch(effGetChunk, 0, 0, &chunk, 0); + uint32 chunkSize = mpt::saturate_cast<uint32>(plugin.Dispatch(effGetChunk, 0, 0, &chunk, 0)); if(chunkSize && chunk) { WriteBE(chunkSize, f); @@ -204,7 +204,7 @@ if(writeChunk) { char *chunk = nullptr; - uint32 chunkSize = plugin.Dispatch(effGetChunk, 1, 0, &chunk, 0); + uint32 chunkSize = mpt::saturate_cast<uint32>(plugin.Dispatch(effGetChunk, 1, 0, &chunk, 0)); if(chunkSize && chunk) { WriteBE(chunkSize, f); Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.cpp 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2013-08-11 00:18:18 UTC (rev 2598) @@ -1724,7 +1724,7 @@ if (pDlsIns->szName[0]) { sprintf(&s[strlen(s)], " (%s", pDlsIns->szName); - int n = strlen(s); + size_t n = strlen(s); while ((n) && (s[n-1] == ' ')) { n--; Modified: trunk/OpenMPT/soundlib/ITTools.cpp =================================================================== --- trunk/OpenMPT/soundlib/ITTools.cpp 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/soundlib/ITTools.cpp 2013-08-11 00:18:18 UTC (rev 2598) @@ -204,7 +204,7 @@ // Convert OpenMPT's internal instrument representation to an ITInstrument. -size_t ITInstrument::ConvertToIT(const ModInstrument &mptIns, bool compatExport, const CSoundFile &sndFile) +uint32 ITInstrument::ConvertToIT(const ModInstrument &mptIns, bool compatExport, const CSoundFile &sndFile) //--------------------------------------------------------------------------------------------------------- { MemsetZero(*this); @@ -255,7 +255,7 @@ // Sample Map nos = 0; std::vector<bool> smpCount(sndFile.GetNumSamples(), false); - for(size_t i = 0; i < 120; i++) + for(int i = 0; i < 120; i++) { keyboard[i * 2] = (mptIns.NoteMap[i] >= NOTE_MIN && mptIns.NoteMap[i] <= NOTE_MAX) ? (mptIns.NoteMap[i] - NOTE_MIN) : static_cast<uint8>(i); @@ -286,7 +286,7 @@ // Convert an ITInstrument to OpenMPT's internal instrument representation. Returns size of the instrument data that has been read. -size_t ITInstrument::ConvertToMPT(ModInstrument &mptIns, MODTYPE modFormat) const +uint32 ITInstrument::ConvertToMPT(ModInstrument &mptIns, MODTYPE modFormat) const //------------------------------------------------------------------------------- { if(id != ITInstrument::magic) @@ -351,7 +351,7 @@ mptIns.PitchEnv.dwFlags.set(ENV_FILTER, (pitchenv.flags & ITEnvelope::envFilter) != 0); // Sample Map - for(size_t i = 0; i < 120; i++) + for(int i = 0; i < 120; i++) { uint8 note = keyboard[i * 2]; SAMPLEINDEX ins = keyboard[i * 2 + 1]; @@ -381,10 +381,10 @@ // Convert OpenMPT's internal instrument representation to an ITInstrumentEx. Returns amount of bytes that need to be written to file. -size_t ITInstrumentEx::ConvertToIT(const ModInstrument &mptIns, bool compatExport, const CSoundFile &sndFile) +uint32 ITInstrumentEx::ConvertToIT(const ModInstrument &mptIns, bool compatExport, const CSoundFile &sndFile) //----------------------------------------------------------------------------------------------------------- { - size_t instSize = iti.ConvertToIT(mptIns, compatExport, sndFile); + uint32 instSize = iti.ConvertToIT(mptIns, compatExport, sndFile); if(compatExport) { @@ -395,7 +395,7 @@ bool usedExtension = false; iti.nos = 0; std::vector<bool> smpCount(sndFile.GetNumSamples(), false); - for(size_t i = 0; i < 120; i++) + for(int i = 0; i < 120; i++) { const SAMPLEINDEX smp = mptIns.Keyboard[i]; keyboardhi[i] = 0; @@ -430,10 +430,10 @@ // Convert an ITInstrumentEx to OpenMPT's internal instrument representation. Returns size of the instrument data that has been read. -size_t ITInstrumentEx::ConvertToMPT(ModInstrument &mptIns, MODTYPE fromType) const +uint32 ITInstrumentEx::ConvertToMPT(ModInstrument &mptIns, MODTYPE fromType) const //-------------------------------------------------------------------------------- { - size_t insSize = iti.ConvertToMPT(mptIns, fromType); + uint32 insSize = iti.ConvertToMPT(mptIns, fromType); // Is this actually an extended instrument? if(insSize == 0 || memcmp(iti.dummy, "MPTX", 4)) @@ -442,7 +442,7 @@ } // Olivier's MPT Instrument Extension - for(size_t i = 0; i < 120; i++) + for(int i = 0; i < 120; i++) { mptIns.Keyboard[i] |= ((SAMPLEINDEX)keyboardhi[i] << 8); } @@ -542,7 +542,7 @@ // Convert an ITSample to OpenMPT's internal sample representation. -size_t ITSample::ConvertToMPT(ModSample &mptSmp) const +uint32 ITSample::ConvertToMPT(ModSample &mptSmp) const //---------------------------------------------------- { if(id != ITSample::magic) Modified: trunk/OpenMPT/soundlib/ITTools.h =================================================================== --- trunk/OpenMPT/soundlib/ITTools.h 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/soundlib/ITTools.h 2013-08-11 00:18:18 UTC (rev 2598) @@ -206,9 +206,9 @@ void ConvertEndianness(); // Convert OpenMPT's internal instrument representation to an ITInstrument. Returns amount of bytes that need to be written. - size_t ConvertToIT(const ModInstrument &mptIns, bool compatExport, const CSoundFile &sndFile); + uint32 ConvertToIT(const ModInstrument &mptIns, bool compatExport, const CSoundFile &sndFile); // Convert an ITInstrument to OpenMPT's internal instrument representation. Returns size of the instrument data that has been read. - size_t ConvertToMPT(ModInstrument &mptIns, MODTYPE fromType) const; + uint32 ConvertToMPT(ModInstrument &mptIns, MODTYPE fromType) const; }; STATIC_ASSERT(sizeof(ITInstrument) == 554); @@ -229,9 +229,9 @@ void ConvertEndianness(); // Convert OpenMPT's internal instrument representation to an ITInstrumentEx. Returns amount of bytes that need to be written. - size_t ConvertToIT(const ModInstrument &mptIns, bool compatExport, const CSoundFile &sndFile); + uint32 ConvertToIT(const ModInstrument &mptIns, bool compatExport, const CSoundFile &sndFile); // Convert an ITInstrumentEx to OpenMPT's internal instrument representation. Returns size of the instrument data that has been read. - size_t ConvertToMPT(ModInstrument &mptIns, MODTYPE fromType) const; + uint32 ConvertToMPT(ModInstrument &mptIns, MODTYPE fromType) const; }; STATIC_ASSERT(sizeof(ITInstrumentEx) == sizeof(ITInstrument) + 120); @@ -294,7 +294,7 @@ // Convert OpenMPT's internal sample representation to an ITSample. void ConvertToIT(const ModSample &mptSmp, MODTYPE fromType, bool compress, bool compressIT215); // Convert an ITSample to OpenMPT's internal sample representation. - size_t ConvertToMPT(ModSample &mptSmp) const; + uint32 ConvertToMPT(ModSample &mptSmp) const; // Retrieve the internal sample format flags for this instrument. SampleIO GetSampleFormat(uint16 cwtv = 0x214) const; }; Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2013-08-11 00:18:18 UTC (rev 2598) @@ -1045,8 +1045,8 @@ #ifndef MODPLUG_NO_FILESAVE // Save edit history. Pass a null pointer for *f to retrieve the number of bytes that would be written. -DWORD SaveITEditHistory(const CSoundFile *pSndFile, FILE *f) -//---------------------------------------------------------- +uint32 SaveITEditHistory(const CSoundFile *pSndFile, FILE *f) +//----------------------------------------------------------- { #ifdef MODPLUG_TRACKER CModDoc *pModDoc = pSndFile->GetpModDoc(); @@ -1056,8 +1056,8 @@ UNREFERENCED_PARAMETER(pSndFile); #endif // MODPLUG_TRACKER - uint16 fnum = (uint16)MIN(num, uint16_max); // Number of entries that are actually going to be written - const size_t bytes_written = 2 + fnum * 8; // Number of bytes that are actually going to be written + uint16 fnum = std::min<uint16>(num, uint16_max); // Number of entries that are actually going to be written + const uint32 bytes_written = 2 + fnum * 8; // Number of bytes that are actually going to be written if(f == nullptr) return bytes_written; @@ -1333,7 +1333,7 @@ for(UINT nins = 1; nins <= itHeader.insnum; nins++) { ITInstrumentEx iti; - size_t instSize; + uint32 instSize; if(Instruments[nins]) { Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-08-11 00:18:18 UTC (rev 2598) @@ -1591,7 +1591,7 @@ iti.ConvertEndianness(); fwrite(&iti, 1, instSize, f); - filePos += smptable.size() * sizeof(ITSample); + filePos += mpt::saturate_cast<uint32>(smptable.size() * sizeof(ITSample)); // Writing sample headers + data std::vector<SampleIO> sampleFlags; @@ -1609,7 +1609,7 @@ // Write sample off_t curPos = ftell(f); fseek(f, filePos, SEEK_SET); - filePos += itss.GetSampleFormat(0x0214).WriteSample(f, Samples[*iter]); + filePos += mpt::saturate_cast<uint32>(itss.GetSampleFormat(0x0214).WriteSample(f, Samples[*iter])); fseek(f, curPos, SEEK_SET); } Modified: trunk/OpenMPT/soundlib/SampleIO.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleIO.cpp 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/soundlib/SampleIO.cpp 2013-08-11 00:18:18 UTC (rev 2598) @@ -490,7 +490,7 @@ uint32 sourceSize = file.ReadUint32LE(); int8 packCharacter = file.ReadUint8(); - LimitMax(sourceSize, file.BytesLeft()); + LimitMax(sourceSize, mpt::saturate_cast<uint32>(file.BytesLeft())); bytesRead = 9 + sourceSize; AMSUnpack(reinterpret_cast<const int8 *>(sourceBuf) + 9, sourceSize, sample.pSample, sample.GetSampleSizeInBytes(), packCharacter); Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-08-11 00:18:18 UTC (rev 2598) @@ -961,8 +961,8 @@ // Memory Allocation // Allocate sample memory. On sucess, a pointer to the silenced sample buffer is returned. On failure, nullptr is returned. -void *CSoundFile::AllocateSample(UINT nbytes) -//------------------------------------------- +void *CSoundFile::AllocateSample(size_t nbytes) +//--------------------------------------------- { if(nbytes > SIZE_MAX - 0x29u) return nullptr; @@ -1261,9 +1261,10 @@ { m_SongFlags.reset(SONG_FADINGSONG | SONG_ENDREACHED); m_nBufferCount = 0; - for (UINT i=0; i<MAX_CHANNELS; i++) + for(CHANNELINDEX i = 0; i < MAX_CHANNELS; i++) { - Chn[i].nROfs = Chn[i].nLOfs = Chn[i].nLength = 0; + Chn[i].nROfs = Chn[i].nLOfs = 0; + Chn[i].nLength = 0; } } @@ -1640,7 +1641,8 @@ { if(Chn[i].pSample == sample.pSample) { - Chn[i].nPos = Chn[i].nLength = 0; + Chn[i].nPos = 0; + Chn[i].nLength = 0; Chn[i].pSample = Chn[i].pCurrentSample = nullptr; } } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-08-11 00:18:18 UTC (rev 2598) @@ -774,7 +774,7 @@ // System-Dependant functions public: - static void *AllocateSample(UINT nbytes); + static void *AllocateSample(size_t nbytes); static void FreeSample(void *p); ModInstrument *AllocateInstrument(INSTRUMENTINDEX instr, SAMPLEINDEX assignedSample = 0); Modified: trunk/OpenMPT/soundlib/WAVTools.cpp =================================================================== --- trunk/OpenMPT/soundlib/WAVTools.cpp 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/soundlib/WAVTools.cpp 2013-08-11 00:18:18 UTC (rev 2598) @@ -231,14 +231,14 @@ { identifier = 0; loopType = bidi ? loopBidi : loopForward; - loopStart = start; + loopStart = mpt::saturate_cast<uint32>(start); // Loop ends are *inclusive* in the RIFF standard, while they're *exclusive* in OpenMPT. if(end > start) { - loopEnd = end - 1; + loopEnd = mpt::saturate_cast<uint32>(end - 1); } else { - loopEnd = start; + loopEnd = loopStart; } fraction = 0; playCount = 0; Modified: trunk/OpenMPT/soundlib/modsmp_ctrl.cpp =================================================================== --- trunk/OpenMPT/soundlib/modsmp_ctrl.cpp 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/soundlib/modsmp_ctrl.cpp 2013-08-11 00:18:18 UTC (rev 2598) @@ -147,7 +147,7 @@ //---------------------------------------- { ModSample* const pSmp = &smp; - const UINT len = pSmp->nLength; + const SmpLength len = pSmp->nLength; T *p = static_cast<T *>(pSmp->pSample); if (pSmp->uFlags & CHN_STEREO) { Modified: trunk/OpenMPT/soundlib/plugins/PluginEventQueue.h =================================================================== --- trunk/OpenMPT/soundlib/plugins/PluginEventQueue.h 2013-08-10 23:26:47 UTC (rev 2597) +++ trunk/OpenMPT/soundlib/plugins/PluginEventQueue.h 2013-08-11 00:18:18 UTC (rev 2598) @@ -102,7 +102,7 @@ VstInt32 Finalise() { Util::lock_guard<Util::mutex> lock(criticalSection); - numEvents = std::min(eventQueue.size(), N); + numEvents = std::min<VstInt32>(eventQueue.size(), N); for(VstInt32 i = 0; i < numEvents; i++) { events[i] = reinterpret_cast<VstEvent *>(&eventQueue[i]); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-08-11 17:33:18
|
Revision: 2599 http://sourceforge.net/p/modplug/code/2599 Author: manxorist Date: 2013-08-11 17:33:10 +0000 (Sun, 11 Aug 2013) Log Message: ----------- [Ref] Replace inline asm sample conversion functions in CASIODevice with c++ implementation from SampleFormatConverters.h . [Mod] CASIODevice used 16bit or 32bit sample input and converted it to the sample format requested by the ASIO driver. Remove 16bit integer support and add 32bit floating point support instead. This removes dithering for 16bit ASIO devices for now (which should be a really really rare configuration anyway). [Mod] Display sample format used for sending data to CASIODevice in soundcard options dialog and disable the combo box for ASIO devices because the user has no choice here anyway. [Ref] Make CASIODevice::FillAudioBuffer() more readable. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/sounddev/SoundDevice.h trunk/OpenMPT/sounddev/SoundDevices.h trunk/OpenMPT/soundlib/SampleFormatConverters.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-08-11 00:18:18 UTC (rev 2598) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-08-11 17:33:10 UTC (rev 2599) @@ -945,9 +945,9 @@ SampleFormat fixedBitsPerSample = SampleFormatInvalid; { Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); - fixedBitsPerSample = (gpSoundDevice) ? SampleFormat(gpSoundDevice->HasFixedBitsPerSample()) : SampleFormatInvalid; + fixedBitsPerSample = (gpSoundDevice) ? SampleFormat(gpSoundDevice->HasFixedSampleFormat()) : SampleFormatInvalid; } - if(err && (fixedBitsPerSample.IsValid() && (fixedBitsPerSample != TrackerSettings::Instance().m_SampleFormat))) + if(fixedBitsPerSample.IsValid() && (fixedBitsPerSample != TrackerSettings::Instance().m_SampleFormat)) { TrackerSettings::Instance().m_SampleFormat = fixedBitsPerSample; err = !audioTryOpeningDevice(TrackerSettings::Instance().m_MixerSettings.gnChannels, Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-08-11 00:18:18 UTC (rev 2598) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-08-11 17:33:10 UTC (rev 2599) @@ -287,37 +287,43 @@ void COptionsSoundcard::UpdateSampleFormat(int dev) //------------------------------------------------- { - CHAR s[128]; UINT n = 0; m_CbnSampleFormat.ResetContent(); - for(UINT bits = 32; bits >= 8; bits -= 8) + const bool asio = SNDDEV_GET_TYPE(dev) == SNDDEV_ASIO; + if(asio) { - if(bits > 16 && !theApp.IsWaveExEnabled() && SNDDEV_GET_TYPE(dev) != SNDDEV_ASIO) + m_SampleFormat = TrackerSettings::Instance().m_SampleFormat; + } + m_CbnSampleFormat.EnableWindow(asio ? FALSE : TRUE); + for(UINT bits = 40; bits >= 8; bits -= 8) + { + if(bits > 16 && !theApp.IsWaveExEnabled() && !asio) { continue; } - if(bits != 16 && bits != 32 && SNDDEV_GET_TYPE(dev) == SNDDEV_ASIO) + if(bits == 40) { - // CASIODevice only supports 16bit or 32bit input for now - continue; - } - if(bits == 32 && SNDDEV_GET_TYPE(dev) != SNDDEV_ASIO) + if(!asio || (asio && SampleFormatFloat32 == m_SampleFormat)) + { + UINT ndx = m_CbnSampleFormat.AddString("Floating Point"); + m_CbnSampleFormat.SetItemData(ndx, (32+128)); + if(SampleFormatFloat32 == m_SampleFormat) + { + n = ndx; + } + } + } else { - wsprintf(s, "Floating Point"); - UINT ndx = m_CbnSampleFormat.AddString(s); - m_CbnSampleFormat.SetItemData(ndx, (32+128)); - if(SampleFormatFloat32 == m_SampleFormat) + if(!asio || (asio && (SampleFormat)bits == m_SampleFormat)) { - n = ndx; + UINT ndx = m_CbnSampleFormat.AddString(mpt::String::Format("%d Bit", bits).c_str()); + m_CbnSampleFormat.SetItemData(ndx, bits); + if((SampleFormat)bits == m_SampleFormat) + { + n = ndx; + } } } - wsprintf(s, "%d Bit", bits); - UINT ndx = m_CbnSampleFormat.AddString(s); - m_CbnSampleFormat.SetItemData(ndx, bits); - if((SampleFormat)bits == m_SampleFormat) - { - n = ndx; - } } m_CbnSampleFormat.SetCurSel(n); } @@ -538,6 +544,7 @@ m_CbnUpdateIntervalMS.SetWindowText(s); } CMainFrame::GetMainFrame()->SetupSoundCard(m_SoundDeviceFlags, m_dwRate, m_SampleFormat, m_nChannels, m_LatencyMS, m_UpdateIntervalMS, m_nSoundDevice); + UpdateSampleFormat(m_nSoundDevice); UpdateStatistics(); CPropertyPage::OnOK(); } Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-08-11 00:18:18 UTC (rev 2598) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-08-11 17:33:10 UTC (rev 2599) @@ -18,6 +18,8 @@ #include "../mptrack/Reporting.h" #endif #include "../common/StringFixer.h" +struct ModSample; +#include "../soundlib/SampleFormatConverters.h" // DEBUG: #include "../common/AudioCriticalSection.h" @@ -1212,11 +1214,14 @@ //------------------------ { m_pAsioDrv = NULL; + m_nChannels = 0; + m_nAsioBufferLen = 0; + m_nAsioSampleSize = 0; + m_Float = false; m_Callbacks.bufferSwitch = BufferSwitch; m_Callbacks.sampleRateDidChange = SampleRateDidChange; m_Callbacks.asioMessage = AsioMessage; m_Callbacks.bufferSwitchTimeInfo = BufferSwitchTimeInfo; - m_nBitsPerSample = 0; // Unknown m_nCurrentDevice = (ULONG)-1; m_bMixRunning = FALSE; InterlockedExchange(&m_RenderSilence, 0); @@ -1245,7 +1250,6 @@ if (nDevice != m_nCurrentDevice) { m_nCurrentDevice = nDevice; - m_nBitsPerSample = 0; } #ifdef ASIO_LOG Log("CASIODevice::Open(%d:\"%s\"): %d-bit, %d channels, %dHz\n", @@ -1273,7 +1277,6 @@ #endif goto abort; } - m_nBitsPerSample = m_Settings.BitsPerSample; for (UINT ich=0; ich<m_Settings.Channels; ich++) { m_ChannelInfo[ich].channel = ich; @@ -1287,28 +1290,50 @@ m_BufferInfo[ich].channelNum = ich + CASIODevice::baseChannel; // map MPT channel i to ASIO channel i m_BufferInfo[ich].buffers[0] = NULL; m_BufferInfo[ich].buffers[1] = NULL; - if ((m_ChannelInfo[ich].type & 0x0f) == ASIOSTInt16MSB) + if(m_Settings.BitsPerSample != 32 && m_Settings.BitsPerSample != 32+128) { - if (m_nBitsPerSample < 16) - { - m_nBitsPerSample = 16; - goto abort; - } - } else + goto abort; + } + m_Float = false; + switch(m_ChannelInfo[ich].type) { - if (m_nBitsPerSample != 32) - { - m_nBitsPerSample = 32; + case ASIOSTInt16MSB: + case ASIOSTInt16LSB: + m_nAsioSampleSize = 2; + break; + case ASIOSTInt24MSB: + case ASIOSTInt24LSB: + m_nAsioSampleSize = 3; + break; + case ASIOSTInt32MSB: + case ASIOSTInt32LSB: + m_nAsioSampleSize = 4; + break; + case ASIOSTInt32MSB16: + case ASIOSTInt32MSB18: + case ASIOSTInt32MSB20: + case ASIOSTInt32MSB24: + case ASIOSTInt32LSB16: + case ASIOSTInt32LSB18: + case ASIOSTInt32LSB20: + case ASIOSTInt32LSB24: + m_nAsioSampleSize = 4; + break; + case ASIOSTFloat32MSB: + case ASIOSTFloat32LSB: + m_Float = true; + m_nAsioSampleSize = 4; + break; + case ASIOSTFloat64MSB: + case ASIOSTFloat64LSB: + m_Float = true; + m_nAsioSampleSize = 8; + break; + default: + m_nAsioSampleSize = 0; goto abort; - } + break; } - switch(m_ChannelInfo[ich].type & 0x0f) - { - case ASIOSTInt16MSB: m_nAsioSampleSize = 2; break; - case ASIOSTInt24MSB: m_nAsioSampleSize = 3; break; - case ASIOSTFloat64MSB: m_nAsioSampleSize = 8; break; - default: m_nAsioSampleSize = 4; - } } m_pAsioDrv->getBufferSize(&minSize, &maxSize, &preferredSize, &granularity); #ifdef ASIO_LOG @@ -1561,105 +1586,126 @@ } } + +static void SwapEndian(uint8 *buf, std::size_t itemCount, std::size_t itemSize) +//----------------------------------------------------------------------------- +{ + for(std::size_t i = 0; i < itemCount; ++i) + { + std::reverse(buf, buf + itemSize); + buf += itemSize; + } +} + + void CASIODevice::FillAudioBuffer() //--------------------------------- { bool rendersilence = (InterlockedExchangeAdd(&m_RenderSilence, 0) == 1); - DWORD dwSampleSize = m_nChannels*(m_nBitsPerSample>>3); - DWORD dwSamplesLeft = m_nAsioBufferLen; - DWORD dwFrameLen = (ASIO_BLOCK_LEN*sizeof(int)) / dwSampleSize; - DWORD dwBufferOffset = 0; + std::size_t sampleFrameSize = m_nChannels * sizeof(int32); + const std::size_t sampleFramesGoal = m_nAsioBufferLen; + std::size_t sampleFramesToRender = sampleFramesGoal; + std::size_t sampleFramesRendered = 0; + const std::size_t countChunkMax = (ASIO_BLOCK_LEN * sizeof(int32)) / sampleFrameSize; g_dwBuffer &= 1; - //Log("FillAudioBuffer(%d): dwSampleSize=%d dwSamplesLeft=%d dwFrameLen=%d\n", g_dwBuffer, dwSampleSize, dwSamplesLeft, dwFrameLen); - while ((LONG)dwSamplesLeft > 0) + //Log("FillAudioBuffer(%d): dwSampleSize=%d dwSamplesLeft=%d dwFrameLen=%d\n", g_dwBuffer, sampleFrameSize, dwSamplesLeft, dwFrameLen); + while(sampleFramesToRender > 0) { - UINT n = (dwSamplesLeft < dwFrameLen) ? dwSamplesLeft : dwFrameLen; + const std::size_t countChunk = std::min(sampleFramesToRender, countChunkMax); if(rendersilence) { - memset(m_FrameBuffer, 0, n*dwSampleSize); + memset(m_FrameBuffer, 0, countChunk * sampleFrameSize); } else { - SourceAudioRead(m_FrameBuffer, n); + SourceAudioRead(m_FrameBuffer, countChunk); } - dwSamplesLeft -= n; - for (UINT ich=0; ich<m_nChannels; ich++) + for(int channel = 0; channel < (int)m_nChannels; ++channel) { - char *psrc = (char *)m_FrameBuffer; - char *pbuffer = (char *)m_BufferInfo[ich].buffers[g_dwBuffer]; - switch(m_ChannelInfo[ich].type) + const int32 *src = m_FrameBuffer; + const float *srcFloat = reinterpret_cast<const float*>(m_FrameBuffer); + void *dst = (char*)m_BufferInfo[channel].buffers[g_dwBuffer] + m_nAsioSampleSize * sampleFramesRendered; + if(m_Float) switch(m_ChannelInfo[channel].type) { - case ASIOSTInt16MSB: - if (m_nBitsPerSample == 32) - Cvt32To16msb(pbuffer+dwBufferOffset*2, psrc+ich*4, m_nChannels*4, n); - else - Cvt16To16msb(pbuffer+dwBufferOffset*2, psrc+ich*2, m_nChannels*2, n); - break; - case ASIOSTInt16LSB: - if (m_nBitsPerSample == 32) - Cvt32To16(pbuffer+dwBufferOffset*2, psrc+ich*4, m_nChannels*4, n); - else - Cvt16To16(pbuffer+dwBufferOffset*2, psrc+ich*2, m_nChannels*2, n); - break; - case ASIOSTInt24MSB: - Cvt32To24msb(pbuffer+dwBufferOffset*3, psrc+ich*4, m_nChannels*4, n); - break; - case ASIOSTInt24LSB: - Cvt32To24(pbuffer+dwBufferOffset*3, psrc+ich*4, m_nChannels*4, n); - break; - case ASIOSTInt32MSB: - Cvt32To32msb(pbuffer+dwBufferOffset*4, psrc+ich*4, m_nChannels*4, n, 0); - break; - case ASIOSTInt32LSB: - Cvt32To32(pbuffer+dwBufferOffset*4, psrc+ich*4, m_nChannels*4, n, 0); - break; - case ASIOSTFloat32MSB: - Cvt32To32f(pbuffer+dwBufferOffset*4, psrc+ich*4, m_nChannels*4, n); - EndianSwap32(pbuffer+dwBufferOffset*4, n); - break; - case ASIOSTFloat32LSB: - Cvt32To32f(pbuffer+dwBufferOffset*4, psrc+ich*4, m_nChannels*4, n); - break; - case ASIOSTFloat64MSB: - Cvt32To64f(pbuffer+dwBufferOffset*8, psrc+ich*4, m_nChannels*4, n); - EndianSwap64(pbuffer+dwBufferOffset*4, n); - break; - case ASIOSTFloat64LSB: - Cvt32To64f(pbuffer+dwBufferOffset*8, psrc+ich*4, m_nChannels*4, n); - break; - case ASIOSTInt32MSB16: - Cvt32To32msb(pbuffer+dwBufferOffset*4, psrc+ich*4, m_nChannels*4, n, 16); - break; - case ASIOSTInt32LSB16: - Cvt32To32(pbuffer+dwBufferOffset*4, psrc+ich*4, m_nChannels*4, n, 16); - break; - case ASIOSTInt32MSB18: - Cvt32To32msb(pbuffer+dwBufferOffset*4, psrc+ich*4, m_nChannels*4, n, 14); - break; - case ASIOSTInt32LSB18: - Cvt32To32(pbuffer+dwBufferOffset*4, psrc+ich*4, m_nChannels*4, n, 14); - break; - case ASIOSTInt32MSB20: - Cvt32To32msb(pbuffer+dwBufferOffset*4, psrc+ich*4, m_nChannels*4, n, 12); - break; - case ASIOSTInt32LSB20: - Cvt32To32(pbuffer+dwBufferOffset*4, psrc+ich*4, m_nChannels*4, n, 12); - break; - case ASIOSTInt32MSB24: - Cvt32To32msb(pbuffer+dwBufferOffset*4, psrc+ich*4, m_nChannels*4, n, 8); - break; - case ASIOSTInt32LSB24: - Cvt32To32(pbuffer+dwBufferOffset*4, psrc+ich*4, m_nChannels*4, n, 8); - break; + case ASIOSTFloat32MSB: + case ASIOSTFloat32LSB: + CopyInterleavedToChannel<SC::Convert<float, float> >(reinterpret_cast<float*>(dst), srcFloat, m_nChannels, countChunk, channel); + break; + case ASIOSTFloat64MSB: + case ASIOSTFloat64LSB: + CopyInterleavedToChannel<SC::Convert<double, float> >(reinterpret_cast<double*>(dst), srcFloat, m_nChannels, countChunk, channel); + break; + default: + ASSERT(false); + break; + } else switch(m_ChannelInfo[channel].type) + { + case ASIOSTInt16MSB: + case ASIOSTInt16LSB: + CopyInterleavedToChannel<SC::Convert<int16, int32> >(reinterpret_cast<int16*>(dst), src, m_nChannels, countChunk, channel); + break; + case ASIOSTInt24MSB: + case ASIOSTInt24LSB: + CopyInterleavedToChannel<SC::Convert<int24, int32> >(reinterpret_cast<int24*>(dst), src, m_nChannels, countChunk, channel); + break; + case ASIOSTInt32MSB: + case ASIOSTInt32LSB: + CopyInterleavedToChannel<SC::Convert<int32, int32> >(reinterpret_cast<int32*>(dst), src, m_nChannels, countChunk, channel); + break; + case ASIOSTFloat32MSB: + case ASIOSTFloat32LSB: + CopyInterleavedToChannel<SC::Convert<float, int32> >(reinterpret_cast<float*>(dst), src, m_nChannels, countChunk, channel); + break; + case ASIOSTFloat64MSB: + case ASIOSTFloat64LSB: + CopyInterleavedToChannel<SC::Convert<double, int32> >(reinterpret_cast<double*>(dst), src, m_nChannels, countChunk, channel); + break; + case ASIOSTInt32MSB16: + case ASIOSTInt32LSB16: + CopyInterleavedToChannel<SC::ConvertShift<int32, int32, 16> >(reinterpret_cast<int32*>(dst), src, m_nChannels, countChunk, channel); + break; + case ASIOSTInt32MSB18: + case ASIOSTInt32LSB18: + CopyInterleavedToChannel<SC::ConvertShift<int32, int32, 14> >(reinterpret_cast<int32*>(dst), src, m_nChannels, countChunk, channel); + break; + case ASIOSTInt32MSB20: + case ASIOSTInt32LSB20: + CopyInterleavedToChannel<SC::ConvertShift<int32, int32, 12> >(reinterpret_cast<int32*>(dst), src, m_nChannels, countChunk, channel); + break; + case ASIOSTInt32MSB24: + case ASIOSTInt32LSB24: + CopyInterleavedToChannel<SC::ConvertShift<int32, int32, 8> >(reinterpret_cast<int32*>(dst), src, m_nChannels, countChunk, channel); + break; + default: + ASSERT(false); + break; } + switch(m_ChannelInfo[channel].type) + { + case ASIOSTInt16MSB: + case ASIOSTInt24MSB: + case ASIOSTInt32MSB: + case ASIOSTFloat32MSB: + case ASIOSTFloat64MSB: + case ASIOSTInt32MSB16: + case ASIOSTInt32MSB18: + case ASIOSTInt32MSB20: + case ASIOSTInt32MSB24: + SwapEndian(reinterpret_cast<uint8*>(dst), countChunk, m_nAsioSampleSize); + break; + } } - dwBufferOffset += n; + sampleFramesToRender -= countChunk; + sampleFramesRendered += countChunk; } - if (m_bPostOutput) m_pAsioDrv->outputReady(); + if(m_bPostOutput) + { + m_pAsioDrv->outputReady(); + } if(!rendersilence) { - SourceAudioDone(dwBufferOffset, m_nAsioBufferLen); + SourceAudioDone(sampleFramesRendered, m_nAsioBufferLen); } return; } @@ -1727,258 +1773,6 @@ } -void CASIODevice::EndianSwap64(void *pbuffer, UINT nSamples) -//---------------------------------------------------------- -{ - _asm { - mov edx, pbuffer - mov ecx, nSamples -swaploop: - mov eax, dword ptr [edx] - mov ebx, dword ptr [edx+4] - add edx, 8 - bswap eax - bswap ebx - dec ecx - mov dword ptr [edx-8], ebx - mov dword ptr [edx-4], eax - jnz swaploop - } -} - - -void CASIODevice::EndianSwap32(void *pbuffer, UINT nSamples) -//---------------------------------------------------------- -{ - _asm { - mov edx, pbuffer - mov ecx, nSamples -swaploop: - mov eax, dword ptr [edx] - add edx, 4 - bswap eax - dec ecx - mov dword ptr [edx-4], eax - jnz swaploop - } -} - - -void CASIODevice::Cvt16To16(void *pdst, void *psrc, UINT nSampleSize, UINT nSamples) -//---------------------------------------------------------------------------------- -{ - _asm { - mov ebx, psrc - mov edi, pdst - mov esi, nSampleSize - mov ecx, nSamples -cvtloop: - movsx eax, word ptr [ebx] - add ebx, esi - add edi, 2 - dec ecx - mov word ptr [edi-2], ax - jnz cvtloop - } -} - - -void CASIODevice::Cvt16To16msb(void *pdst, void *psrc, UINT nSampleSize, UINT nSamples) -//------------------------------------------------------------------------------------- -{ - _asm { - mov ebx, psrc - mov edi, pdst - mov esi, nSampleSize - mov ecx, nSamples -cvtloop: - movsx eax, word ptr [ebx] - add ebx, esi - add edi, 2 - dec ecx - mov byte ptr [edi-2], ah - mov byte ptr [edi-1], al - jnz cvtloop - } -} - - -void CASIODevice::Cvt32To24(void *pdst, void *psrc, UINT nSampleSize, UINT nSamples) -//---------------------------------------------------------------------------------- -{ - _asm { - mov ebx, psrc - mov edi, pdst - mov esi, nSampleSize - mov ecx, nSamples -cvtloop: - mov eax, dword ptr [ebx] - add ebx, esi - add edi, 3 - mov edx, eax - shr eax, 8 - shr edx, 24 - dec ecx - mov byte ptr [edi-3], al - mov byte ptr [edi-2], ah - mov byte ptr [edi-1], dl - jnz cvtloop - } -} - - -void CASIODevice::Cvt32To24msb(void *pdst, void *psrc, UINT nSampleSize, UINT nSamples) -//------------------------------------------------------------------------------------- -{ - _asm { - mov ebx, psrc - mov edi, pdst - mov esi, nSampleSize - mov ecx, nSamples -cvtloop: - mov eax, dword ptr [ebx] - add ebx, esi - add edi, 3 - mov edx, eax - shr eax, 8 - shr edx, 24 - dec ecx - mov byte ptr [edi-3], dl - mov byte ptr [edi-2], ah - mov byte ptr [edi-1], al - jnz cvtloop - } -} - - -void CASIODevice::Cvt32To32(void *pdst, void *psrc, UINT nSampleSize, UINT nSamples, UINT nShift) -//----------------------------------------------------------------------------------------------- -{ - _asm { - mov ebx, psrc - mov edi, pdst - mov esi, nSampleSize - mov edx, nSamples - mov ecx, nShift -cvtloop: - mov eax, dword ptr [ebx] - add ebx, esi - add edi, 4 - sar eax, cl - dec edx - mov dword ptr [edi-4], eax - jnz cvtloop - } -} - - -void CASIODevice::Cvt32To32msb(void *pdst, void *psrc, UINT nSampleSize, UINT nSamples, UINT nShift) -//-------------------------------------------------------------------------------------------------- -{ - _asm { - mov ebx, psrc - mov edi, pdst - mov esi, nSampleSize - mov edx, nSamples - mov ecx, nShift -cvtloop: - mov eax, dword ptr [ebx] - add ebx, esi - add edi, 4 - sar eax, cl - bswap eax - dec edx - mov dword ptr [edi-4], eax - jnz cvtloop - } -} - - -const float _pow2_31 = 1.0f / 2147483648.0f; - -void CASIODevice::Cvt32To32f(void *pdst, void *psrc, UINT nSampleSize, UINT nSamples) -//----------------------------------------------------------------------------------- -{ - _asm { - mov ebx, psrc - mov edi, pdst - mov esi, nSampleSize - mov edx, nSamples - fld _pow2_31 -cvtloop: - fild dword ptr [ebx] - add ebx, esi - add edi, 4 - fmul st(0), st(1) - dec edx - fstp dword ptr [edi-4] - jnz cvtloop - fstp st(1) - } -} - - -void CASIODevice::Cvt32To64f(void *pdst, void *psrc, UINT nSampleSize, UINT nSamples) -//----------------------------------------------------------------------------------- -{ - _asm { - mov ebx, psrc - mov edi, pdst - mov esi, nSampleSize - mov edx, nSamples - fld _pow2_31 -cvtloop: - fild dword ptr [ebx] - add ebx, esi - add edi, 8 - fmul st(0), st(1) - dec edx - fstp qword ptr [edi-8] - jnz cvtloop - fstp st(1) - } -} - - -void CASIODevice::Cvt32To16(void *pdst, void *psrc, UINT nSampleSize, UINT nSamples) -//---------------------------------------------------------------------------------- -{ - _asm { - mov ebx, psrc - mov edi, pdst - mov esi, nSampleSize - mov ecx, nSamples -cvtloop: - mov eax, dword ptr [ebx] - add ebx, esi - add edi, 2 - sar eax, 16 - dec ecx - mov word ptr [edi-2], ax - jnz cvtloop - } -} - - -void CASIODevice::Cvt32To16msb(void *pdst, void *psrc, UINT nSampleSize, UINT nSamples) -//------------------------------------------------------------------------------------- -{ - _asm { - mov ebx, psrc - mov edi, pdst - mov esi, nSampleSize - mov ecx, nSamples -cvtloop: - mov eax, dword ptr [ebx] - add ebx, esi - add edi, 2 - bswap eax - dec ecx - mov word ptr [edi-2], ax - jnz cvtloop - } -} - BOOL CASIODevice::ReportASIOException(LPCSTR format,...) //------------------------------------------------------ { Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2013-08-11 00:18:18 UTC (rev 2598) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2013-08-11 17:33:10 UTC (rev 2599) @@ -160,7 +160,7 @@ void Start(); void Stop(); void Reset(); - virtual UINT HasFixedBitsPerSample() { return 0; } + virtual int HasFixedSampleFormat() { return 0; } virtual bool IsOpen() const = 0; virtual UINT GetNumBuffers() { return 0; } virtual float GetCurrentRealLatencyMS() { return GetRealLatencyMS(); } Modified: trunk/OpenMPT/sounddev/SoundDevices.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevices.h 2013-08-11 00:18:18 UTC (rev 2598) +++ trunk/OpenMPT/sounddev/SoundDevices.h 2013-08-11 17:33:10 UTC (rev 2599) @@ -202,7 +202,8 @@ enum { ASIO_BLOCK_LEN=1024 }; protected: IASIO *m_pAsioDrv; - UINT m_nChannels, m_nBitsPerSample, m_nAsioBufferLen, m_nAsioSampleSize; + UINT m_nChannels, m_nAsioBufferLen, m_nAsioSampleSize; + bool m_Float; BOOL m_bMixRunning; BOOL m_bPostOutput; UINT m_nCurrentDevice; @@ -211,7 +212,7 @@ ASIOCallbacks m_Callbacks; ASIOChannelInfo m_ChannelInfo[ASIO_MAX_CHANNELS]; ASIOBufferInfo m_BufferInfo[ASIO_MAX_CHANNELS]; - int m_FrameBuffer[ASIO_BLOCK_LEN]; + int32 m_FrameBuffer[ASIO_BLOCK_LEN]; private: void SetRenderSilence(bool silence, bool wait=false); @@ -232,7 +233,7 @@ void InternalStart(); void InternalStop(); bool IsOpen() const { return (m_pAsioDrv != NULL); } - UINT HasFixedBitsPerSample() { return m_nBitsPerSample; } + int HasFixedSampleFormat() { return m_Float ? 32+128 : 32; } UINT GetNumBuffers() { return 2; } float GetCurrentRealLatencyMS() { return m_nAsioBufferLen * 2 * 1000.0f / m_Settings.Samplerate; } @@ -255,18 +256,6 @@ static void SampleRateDidChange(ASIOSampleRate sRate); static long AsioMessage(long selector, long value, void* message, double* opt); static ASIOTime* BufferSwitchTimeInfo(ASIOTime* params, long doubleBufferIndex, ASIOBool directProcess); - static void EndianSwap64(void *pbuffer, UINT nSamples); - static void EndianSwap32(void *pbuffer, UINT nSamples); - static void Cvt16To16(void *pdst, void *psrc, UINT nSampleSize, UINT nSamples); - static void Cvt16To16msb(void *pdst, void *psrc, UINT nSampleSize, UINT nSamples); - static void Cvt32To16(void *pdst, void *psrc, UINT nSampleSize, UINT nSamples); - static void Cvt32To16msb(void *pdst, void *psrc, UINT nSampleSize, UINT nSamples); - static void Cvt32To24(void *pdst, void *psrc, UINT nSampleSize, UINT nSamples); - static void Cvt32To24msb(void *pdst, void *psrc, UINT nSampleSize, UINT nSamples); - static void Cvt32To32(void *pdst, void *psrc, UINT nSampleSize, UINT nSamples, UINT nShift); - static void Cvt32To32msb(void *pdst, void *psrc, UINT nSampleSize, UINT nSamples, UINT nShift); - static void Cvt32To32f(void *pdst, void *psrc, UINT nSampleSize, UINT nSamples); - static void Cvt32To64f(void *pdst, void *psrc, UINT nSampleSize, UINT nSamples); static BOOL ReportASIOException(LPCSTR format,...); }; Modified: trunk/OpenMPT/soundlib/SampleFormatConverters.h =================================================================== --- trunk/OpenMPT/soundlib/SampleFormatConverters.h 2013-08-11 00:18:18 UTC (rev 2598) +++ trunk/OpenMPT/soundlib/SampleFormatConverters.h 2013-08-11 17:33:10 UTC (rev 2599) @@ -10,6 +10,9 @@ #pragma once +#include "../soundlib/Endianness.h" + + // Byte offsets, from lowest significant to highest significant byte (for various functor template parameters) #define littleEndian32 0, 1, 2, 3 #define littleEndian24 0, 1, 2 @@ -239,6 +242,17 @@ }; template <> +struct Convert<int8, int24> +{ + typedef int24 input_t; + typedef int8 output_t; + forceinline output_t operator() (input_t val) + { + return int8(val >> 16); + } +}; + +template <> struct Convert<int8, int32> { typedef int32 input_t; @@ -276,6 +290,17 @@ }; template <> +struct Convert<int16, int24> +{ + typedef int24 input_t; + typedef int16 output_t; + forceinline output_t operator() (input_t val) + { + return int16(val >> 8); + } +}; + +template <> struct Convert<int16, int32> { typedef int32 input_t; @@ -301,6 +326,84 @@ } }; +template <> +struct Convert<int24, int8> +{ + typedef int8 input_t; + typedef int24 output_t; + forceinline output_t operator() (input_t val) + { + return int24(val << 8); + } +}; + +template <> +struct Convert<int24, int16> +{ + typedef int16 input_t; + typedef int24 output_t; + forceinline output_t operator() (input_t val) + { + return int24(val << 8); + } +}; + +template <> +struct Convert<int24, int32> +{ + typedef int32 input_t; + typedef int24 output_t; + forceinline output_t operator() (input_t val) + { + return int24(val >> 8); + } +}; + +template <> +struct Convert<float32, int32> +{ + typedef int32 input_t; + typedef float32 output_t; + forceinline output_t operator() (input_t val) + { + return val * (1.0f / static_cast<float>((unsigned int)1<<31)); + } +}; + +template <> +struct Convert<double, int32> +{ + typedef int32 input_t; + typedef double output_t; + forceinline output_t operator() (input_t val) + { + return val * (1.0 / static_cast<double>((unsigned int)1<<31)); + } +}; + +template <> +struct Convert<double, float> +{ + typedef float input_t; + typedef double output_t; + forceinline output_t operator() (input_t val) + { + return val; + } +}; + +template <> +struct Convert<float, double> +{ + typedef double input_t; + typedef float output_t; + forceinline output_t operator() (input_t val) + { + return static_cast<float>(val); + } +}; + + template <typename Tdst, typename Tsrc, int fractionalBits> struct ConvertFixedPoint; @@ -741,3 +844,19 @@ } } } + + +// Copy from an interleaed buffer of #channels. +template <typename SampleConversion> +void CopyInterleavedToChannel(typename SampleConversion::output_t *dst, const typename SampleConversion::input_t *src, std::size_t channels, std::size_t countChunk, std::size_t channel, SampleConversion conv = SampleConversion()) +//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +{ + SampleConversion sampleConv(conv); + src += channel; + for(std::size_t i = 0; i < countChunk; ++i) + { + *dst = sampleConv(*src); + src += channels; + dst++; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-08-11 17:59:08
|
Revision: 2600 http://sourceforge.net/p/modplug/code/2600 Author: manxorist Date: 2013-08-11 17:58:59 +0000 (Sun, 11 Aug 2013) Log Message: ----------- [Ref] Move SampleFormat from MixerSettings.h into its own header SampleFormat.h . [Fix] Fix ASIO floating point output (broke in r2599 ). [Ref] Use SampleFormat.h in sounddev/ code. Revision Links: -------------- http://sourceforge.net/p/modplug/code/2599 Modified Paths: -------------- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/TrackerSettings.h trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/sounddev/SoundDevice.h trunk/OpenMPT/sounddev/SoundDevices.h trunk/OpenMPT/soundlib/AudioReadTarget.h trunk/OpenMPT/soundlib/MixerSettings.h Added Paths: ----------- trunk/OpenMPT/soundlib/SampleFormat.h Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2013-08-11 17:33:10 UTC (rev 2599) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2013-08-11 17:58:59 UTC (rev 2600) @@ -448,6 +448,7 @@ <ClInclude Include="..\soundlib\Resampler.h" /> <ClInclude Include="..\soundlib\RowVisitor.h" /> <ClInclude Include="..\soundlib\S3MTools.h" /> + <ClInclude Include="..\soundlib\SampleFormat.h" /> <ClInclude Include="..\soundlib\SampleFormatConverters.h" /> <ClInclude Include="..\soundlib\SampleIO.h" /> <ClInclude Include="..\soundlib\Sndfile.h" /> Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2013-08-11 17:33:10 UTC (rev 2599) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2013-08-11 17:58:59 UTC (rev 2600) @@ -242,6 +242,9 @@ <ClInclude Include="..\soundlib\MixerLoops.h"> <Filter>Header Files\soundlib</Filter> </ClInclude> + <ClInclude Include="..\soundlib\SampleFormat.h"> + <Filter>Header Files\soundlib</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="..\common\AudioCriticalSection.cpp"> Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-08-11 17:33:10 UTC (rev 2599) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-08-11 17:58:59 UTC (rev 2600) @@ -915,8 +915,7 @@ settings.fulCfgOptions = TrackerSettings::Instance().GetSoundDeviceFlags(); settings.Samplerate = samplespersec; settings.Channels = (uint8)channels; - settings.BitsPerSample = (uint8)sampleFormat.GetBitsPerSample(); - settings.FloatingPoint = sampleFormat.IsFloat(); + settings.sampleFormat = sampleFormat; return gpSoundDevice->Open(SNDDEV_GET_NUMBER(TrackerSettings::Instance().m_nWaveDevice), settings); } Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2013-08-11 17:33:10 UTC (rev 2599) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2013-08-11 17:58:59 UTC (rev 2600) @@ -13,6 +13,7 @@ #include "../soundlib/MixerSettings.h" #include "../soundlib/Resampler.h" +#include "../soundlib/SampleFormat.h" #include "../sounddsp/EQ.h" #include "../sounddsp/DSP.h" #include "../sounddsp/Reverb.h" Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-08-11 17:33:10 UTC (rev 2599) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-08-11 17:58:59 UTC (rev 2600) @@ -1085,6 +1085,10 @@ > </File> <File + RelativePath="..\soundlib\SampleFormat.h" + > + </File> + <File RelativePath="..\soundlib\SampleFormatConverters.h" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-08-11 17:33:10 UTC (rev 2599) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-08-11 17:58:59 UTC (rev 2600) @@ -511,6 +511,7 @@ <ClInclude Include="..\soundlib\Resampler.h" /> <ClInclude Include="..\soundlib\RowVisitor.h" /> <ClInclude Include="..\soundlib\S3MTools.h" /> + <ClInclude Include="..\soundlib\SampleFormat.h" /> <ClInclude Include="..\soundlib\SampleFormatConverters.h" /> <ClInclude Include="..\soundlib\SampleIO.h" /> <ClInclude Include="..\soundlib\Sndfile.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-08-11 17:33:10 UTC (rev 2599) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-08-11 17:58:59 UTC (rev 2600) @@ -894,6 +894,9 @@ <ClInclude Include="..\soundlib\MixerLoops.h"> <Filter>Header Files\soundlib</Filter> </ClInclude> + <ClInclude Include="..\soundlib\SampleFormat.h"> + <Filter>Header Files\soundlib</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-08-11 17:33:10 UTC (rev 2599) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-08-11 17:58:59 UTC (rev 2600) @@ -53,16 +53,16 @@ //--------------------------------------------------------------------------- { MemsetZero(WaveFormat); - UINT bytespersample = (m_Settings.BitsPerSample/8) * m_Settings.Channels; - if(m_Settings.FloatingPoint && m_Settings.BitsPerSample != 32) return false; - WaveFormat.Format.wFormatTag = m_Settings.FloatingPoint ? WAVE_FORMAT_IEEE_FLOAT : WAVE_FORMAT_PCM; + if(!m_Settings.sampleFormat.IsValid()) return false; + UINT bytespersample = (m_Settings.sampleFormat.GetBitsPerSample()/8) * m_Settings.Channels; + WaveFormat.Format.wFormatTag = m_Settings.sampleFormat.IsFloat() ? WAVE_FORMAT_IEEE_FLOAT : WAVE_FORMAT_PCM; WaveFormat.Format.nChannels = (WORD)m_Settings.Channels; WaveFormat.Format.nSamplesPerSec = m_Settings.Samplerate; WaveFormat.Format.nAvgBytesPerSec = m_Settings.Samplerate * bytespersample; WaveFormat.Format.nBlockAlign = (WORD)bytespersample; - WaveFormat.Format.wBitsPerSample = (WORD)m_Settings.BitsPerSample; + WaveFormat.Format.wBitsPerSample = (WORD)m_Settings.sampleFormat.GetBitsPerSample(); WaveFormat.Format.cbSize = 0; - if((WaveFormat.Format.wBitsPerSample > 16 && !m_Settings.FloatingPoint) || (WaveFormat.Format.nChannels > 2)) + if((WaveFormat.Format.wBitsPerSample > 16 && m_Settings.sampleFormat.IsInt()) || (WaveFormat.Format.nChannels > 2)) { WaveFormat.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; WaveFormat.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX); @@ -77,7 +77,7 @@ } const GUID guid_MEDIASUBTYPE_PCM = {0x00000001, 0x0000, 0x0010, 0x80, 0x00, 0x0, 0xAA, 0x0, 0x38, 0x9B, 0x71}; const GUID guid_MEDIASUBTYPE_IEEE_FLOAT = {0x00000003, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71}; - WaveFormat.SubFormat = m_Settings.FloatingPoint ? guid_MEDIASUBTYPE_IEEE_FLOAT : guid_MEDIASUBTYPE_PCM; + WaveFormat.SubFormat = m_Settings.sampleFormat.IsFloat() ? guid_MEDIASUBTYPE_IEEE_FLOAT : guid_MEDIASUBTYPE_PCM; } return true; } @@ -1242,8 +1242,6 @@ { bool bOk = false; - if(m_Settings.FloatingPoint) return false; // for now - if (IsOpen()) Close(); if (!gbAsioEnumerated) EnumerateDevices(nDevice, NULL, 0); if (nDevice >= gnNumAsioDrivers) return false; @@ -1253,7 +1251,7 @@ } #ifdef ASIO_LOG Log("CASIODevice::Open(%d:\"%s\"): %d-bit, %d channels, %dHz\n", - nDevice, gAsioDrivers[nDevice].name, m_Settings.BitsPerSample, m_Settings.Channels, m_Settings.Samplerate); + nDevice, gAsioDrivers[nDevice].name, (int)m_Settings.sampleFormat.GetBitsPerSample(), m_Settings.Channels, m_Settings.Samplerate); #endif OpenDevice(nDevice); @@ -1262,8 +1260,14 @@ long nInputChannels = 0, nOutputChannels = 0; long minSize = 0, maxSize = 0, preferredSize = 0, granularity = 0; - if ((m_Settings.Channels > ASIO_MAX_CHANNELS) - || ((m_Settings.BitsPerSample != 16) && (m_Settings.BitsPerSample != 32))) goto abort; + if(m_Settings.Channels > ASIO_MAX_CHANNELS) + { + goto abort; + } + if((m_Settings.sampleFormat != SampleFormatInt32) && (m_Settings.sampleFormat != SampleFormatFloat32)) + { + goto abort; + } m_nChannels = m_Settings.Channels; m_pAsioDrv->getChannels(&nInputChannels, &nOutputChannels); #ifdef ASIO_LOG @@ -1290,10 +1294,6 @@ m_BufferInfo[ich].channelNum = ich + CASIODevice::baseChannel; // map MPT channel i to ASIO channel i m_BufferInfo[ich].buffers[0] = NULL; m_BufferInfo[ich].buffers[1] = NULL; - if(m_Settings.BitsPerSample != 32 && m_Settings.BitsPerSample != 32+128) - { - goto abort; - } m_Float = false; switch(m_ChannelInfo[ich].type) { @@ -1888,13 +1888,13 @@ m_StreamParameters.device = HostApiOutputIndexToGlobalDeviceIndex(nDevice, m_HostApi); if(m_StreamParameters.device == -1) return false; m_StreamParameters.channelCount = m_Settings.Channels; - if(m_Settings.FloatingPoint) + if(m_Settings.sampleFormat.IsFloat()) { - if(m_Settings.BitsPerSample != 32) return false; + if(m_Settings.sampleFormat.GetBitsPerSample() != 32) return false; m_StreamParameters.sampleFormat = paFloat32; } else { - switch(m_Settings.BitsPerSample) + switch(m_Settings.sampleFormat.GetBitsPerSample()) { case 8: m_StreamParameters.sampleFormat = paUInt8; break; case 16: m_StreamParameters.sampleFormat = paInt16; break; Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2013-08-11 17:33:10 UTC (rev 2599) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2013-08-11 17:58:59 UTC (rev 2600) @@ -11,6 +11,8 @@ #pragma once +#include "../soundlib/SampleFormat.h" + #include <vector> @@ -93,8 +95,7 @@ ULONG fulCfgOptions; uint32 Samplerate; uint8 Channels; - uint8 BitsPerSample; - bool FloatingPoint; + SampleFormat sampleFormat; SoundDeviceSettings() : hWnd(NULL) , LatencyMS(SNDDEV_DEFAULT_LATENCY_MS) @@ -102,8 +103,7 @@ , fulCfgOptions(0) , Samplerate(48000) , Channels(2) - , BitsPerSample(16) - , FloatingPoint(false) + , sampleFormat(SampleFormatInt16) { return; } @@ -160,7 +160,7 @@ void Start(); void Stop(); void Reset(); - virtual int HasFixedSampleFormat() { return 0; } + virtual SampleFormat HasFixedSampleFormat() { return SampleFormatInvalid; } virtual bool IsOpen() const = 0; virtual UINT GetNumBuffers() { return 0; } virtual float GetCurrentRealLatencyMS() { return GetRealLatencyMS(); } Modified: trunk/OpenMPT/sounddev/SoundDevices.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevices.h 2013-08-11 17:33:10 UTC (rev 2599) +++ trunk/OpenMPT/sounddev/SoundDevices.h 2013-08-11 17:58:59 UTC (rev 2600) @@ -233,7 +233,7 @@ void InternalStart(); void InternalStop(); bool IsOpen() const { return (m_pAsioDrv != NULL); } - int HasFixedSampleFormat() { return m_Float ? 32+128 : 32; } + SampleFormat HasFixedSampleFormat() { return m_Float ? SampleFormatFloat32 : SampleFormatInt32; } UINT GetNumBuffers() { return 2; } float GetCurrentRealLatencyMS() { return m_nAsioBufferLen * 2 * 1000.0f / m_Settings.Samplerate; } Modified: trunk/OpenMPT/soundlib/AudioReadTarget.h =================================================================== --- trunk/OpenMPT/soundlib/AudioReadTarget.h 2013-08-11 17:33:10 UTC (rev 2599) +++ trunk/OpenMPT/soundlib/AudioReadTarget.h 2013-08-11 17:58:59 UTC (rev 2600) @@ -11,6 +11,7 @@ #include "Sndfile.h" #include "Dither.h" #include "SampleFormatConverters.h" +#include "SampleFormat.h" #include "MixerLoops.h" Modified: trunk/OpenMPT/soundlib/MixerSettings.h =================================================================== --- trunk/OpenMPT/soundlib/MixerSettings.h 2013-08-11 17:33:10 UTC (rev 2599) +++ trunk/OpenMPT/soundlib/MixerSettings.h 2013-08-11 17:58:59 UTC (rev 2600) @@ -10,108 +10,6 @@ #pragma once -enum SampleFormatEnum -{ - SampleFormatUnsigned8 = 8, // do not change value (for compatibility with old configuration settings) - SampleFormatInt16 = 16, // do not change value (for compatibility with old configuration settings) - SampleFormatInt24 = 24, // do not change value (for compatibility with old configuration settings) - SampleFormatInt32 = 32, // do not change value (for compatibility with old configuration settings) - SampleFormatFloat32 = 32 + 128, // Only supported as mixer output and ISoundDevice format, NOT supported by Mod2Wave settings dialog yet. Keep in mind to update all 3 cases at once. - SampleFormatFixed5p27 = 255, // mixbuffer format - SampleFormatInvalid = 0 -}; - -template<typename Tsample> struct SampleFormatTraits; -template<> struct SampleFormatTraits<uint8> { static const SampleFormatEnum sampleFormat = SampleFormatUnsigned8; }; -template<> struct SampleFormatTraits<int16> { static const SampleFormatEnum sampleFormat = SampleFormatInt16; }; -template<> struct SampleFormatTraits<int24> { static const SampleFormatEnum sampleFormat = SampleFormatInt24; }; -template<> struct SampleFormatTraits<int32> { static const SampleFormatEnum sampleFormat = SampleFormatInt32; }; -template<> struct SampleFormatTraits<float> { static const SampleFormatEnum sampleFormat = SampleFormatFloat32; }; -template<> struct SampleFormatTraits<fixed5p27> { static const SampleFormatEnum sampleFormat = SampleFormatFixed5p27; }; - -template<SampleFormatEnum sampleFormat> struct SampleFormatToType; -template<> struct SampleFormatToType<SampleFormatUnsigned8> { typedef uint8 type; }; -template<> struct SampleFormatToType<SampleFormatInt16> { typedef int16 type; }; -template<> struct SampleFormatToType<SampleFormatInt24> { typedef int24 type; }; -template<> struct SampleFormatToType<SampleFormatInt32> { typedef int32 type; }; -template<> struct SampleFormatToType<SampleFormatFloat32> { typedef float type; }; -template<> struct SampleFormatToType<SampleFormatFixed5p27> { typedef fixed5p27 type; }; - - -struct SampleFormat -{ - SampleFormatEnum value; - SampleFormat(SampleFormatEnum v = SampleFormatInvalid) : value(v) { } - bool operator == (SampleFormat other) const { return value == other.value; } - bool operator != (SampleFormat other) const { return value != other.value; } - operator SampleFormatEnum () const - { - return value; - } - bool IsValid() const - { - return value != SampleFormatInvalid; - } - bool IsUnsigned() const - { - if(!IsValid()) return false; - return value == SampleFormatUnsigned8; - } - bool IsFloat() const - { - if(!IsValid()) return false; - return value == SampleFormatFloat32; - } - bool IsInt() const - { - if(!IsValid()) return false; - return value != SampleFormatFloat32; - } - bool IsMixBuffer() const - { - if(!IsValid()) return false; - return value == SampleFormatFixed5p27; - } - uint8 GetBitsPerSample() const - { - if(!IsValid()) return 0; - switch(value) - { - case SampleFormatUnsigned8: - return 8; - break; - case SampleFormatInt16: - return 16; - break; - case SampleFormatInt24: - return 24; - break; - case SampleFormatInt32: - return 32; - break; - case SampleFormatFloat32: - return 32; - break; - case SampleFormatFixed5p27: - return 32; - break; - default: - return 0; - break; - } - } - - // backward compatibility, conversion to/from integers - operator int () const { return value; } - SampleFormat(int v) : value(SampleFormatEnum(v)) { } - operator long () const { return value; } - SampleFormat(long v) : value(SampleFormatEnum(v)) { } - operator unsigned int () const { return value; } - SampleFormat(unsigned int v) : value(SampleFormatEnum(v)) { } - operator unsigned long () const { return value; } - SampleFormat(unsigned long v) : value(SampleFormatEnum(v)) { } -}; - struct MixerSettings { Added: trunk/OpenMPT/soundlib/SampleFormat.h =================================================================== --- trunk/OpenMPT/soundlib/SampleFormat.h (rev 0) +++ trunk/OpenMPT/soundlib/SampleFormat.h 2013-08-11 17:58:59 UTC (rev 2600) @@ -0,0 +1,115 @@ +/* + * SampleFormat.h + * --------------- + * Purpose: Utility enum and funcion to describe sample formats. + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#pragma once + + +enum SampleFormatEnum +{ + SampleFormatUnsigned8 = 8, // do not change value (for compatibility with old configuration settings) + SampleFormatInt16 = 16, // do not change value (for compatibility with old configuration settings) + SampleFormatInt24 = 24, // do not change value (for compatibility with old configuration settings) + SampleFormatInt32 = 32, // do not change value (for compatibility with old configuration settings) + SampleFormatFloat32 = 32 + 128, // Only supported as mixer output and ISoundDevice format, NOT supported by Mod2Wave settings dialog yet. Keep in mind to update all 3 cases at once. + SampleFormatFixed5p27 = 255, // mixbuffer format + SampleFormatInvalid = 0 +}; + +template<typename Tsample> struct SampleFormatTraits; +template<> struct SampleFormatTraits<uint8> { static const SampleFormatEnum sampleFormat = SampleFormatUnsigned8; }; +template<> struct SampleFormatTraits<int16> { static const SampleFormatEnum sampleFormat = SampleFormatInt16; }; +template<> struct SampleFormatTraits<int24> { static const SampleFormatEnum sampleFormat = SampleFormatInt24; }; +template<> struct SampleFormatTraits<int32> { static const SampleFormatEnum sampleFormat = SampleFormatInt32; }; +template<> struct SampleFormatTraits<float> { static const SampleFormatEnum sampleFormat = SampleFormatFloat32; }; +template<> struct SampleFormatTraits<fixed5p27> { static const SampleFormatEnum sampleFormat = SampleFormatFixed5p27; }; + +template<SampleFormatEnum sampleFormat> struct SampleFormatToType; +template<> struct SampleFormatToType<SampleFormatUnsigned8> { typedef uint8 type; }; +template<> struct SampleFormatToType<SampleFormatInt16> { typedef int16 type; }; +template<> struct SampleFormatToType<SampleFormatInt24> { typedef int24 type; }; +template<> struct SampleFormatToType<SampleFormatInt32> { typedef int32 type; }; +template<> struct SampleFormatToType<SampleFormatFloat32> { typedef float type; }; +template<> struct SampleFormatToType<SampleFormatFixed5p27> { typedef fixed5p27 type; }; + + +struct SampleFormat +{ + SampleFormatEnum value; + SampleFormat(SampleFormatEnum v = SampleFormatInvalid) : value(v) { } + bool operator == (SampleFormat other) const { return value == other.value; } + bool operator != (SampleFormat other) const { return value != other.value; } + bool operator == (SampleFormatEnum other) const { return value == other; } + bool operator != (SampleFormatEnum other) const { return value != other; } + operator SampleFormatEnum () const + { + return value; + } + bool IsValid() const + { + return value != SampleFormatInvalid; + } + bool IsUnsigned() const + { + if(!IsValid()) return false; + return value == SampleFormatUnsigned8; + } + bool IsFloat() const + { + if(!IsValid()) return false; + return value == SampleFormatFloat32; + } + bool IsInt() const + { + if(!IsValid()) return false; + return value != SampleFormatFloat32; + } + bool IsMixBuffer() const + { + if(!IsValid()) return false; + return value == SampleFormatFixed5p27; + } + uint8 GetBitsPerSample() const + { + if(!IsValid()) return 0; + switch(value) + { + case SampleFormatUnsigned8: + return 8; + break; + case SampleFormatInt16: + return 16; + break; + case SampleFormatInt24: + return 24; + break; + case SampleFormatInt32: + return 32; + break; + case SampleFormatFloat32: + return 32; + break; + case SampleFormatFixed5p27: + return 32; + break; + default: + return 0; + break; + } + } + + // backward compatibility, conversion to/from integers + operator int () const { return value; } + SampleFormat(int v) : value(SampleFormatEnum(v)) { } + operator long () const { return value; } + SampleFormat(long v) : value(SampleFormatEnum(v)) { } + operator unsigned int () const { return value; } + SampleFormat(unsigned int v) : value(SampleFormatEnum(v)) { } + operator unsigned long () const { return value; } + SampleFormat(unsigned long v) : value(SampleFormatEnum(v)) { } +}; Property changes on: trunk/OpenMPT/soundlib/SampleFormat.h ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-chdr \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-08-11 21:28:10
|
Revision: 2601 http://sourceforge.net/p/modplug/code/2601 Author: saga-games Date: 2013-08-11 21:27:57 +0000 (Sun, 11 Aug 2013) Log Message: ----------- [Imp] Sample Editor: Don't limit size of loaded sample file to the size of physical memory. [Ref] Get rid of newly introduced warning in IT history code. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/soundlib/Load_it.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-08-11 17:58:59 UTC (rev 2600) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-08-11 21:27:57 UTC (rev 2601) @@ -735,9 +735,6 @@ //------------------------------------------------ { CMappedFile f; - CHAR szName[_MAX_FNAME], szExt[_MAX_EXT]; - LPBYTE lpFile; - DWORD len; bool bOk = false; BeginWaitCursor(); @@ -746,9 +743,8 @@ EndWaitCursor(); return false; } - len = f.GetLength(); - if (len > CTrackApp::gMemStatus.dwTotalPhys) len = CTrackApp::gMemStatus.dwTotalPhys; - lpFile = f.Lock(len); + const size_t len = f.GetLength(); + const void *lpFile = f.Lock(len); if (!lpFile) goto OpenError; { @@ -825,30 +821,18 @@ TrackerSettings::Instance().SetWorkingDirectory(lpszFileName, DIR_SAMPLES, true); if (!sample.filename[0]) { - CHAR szFullFilename[_MAX_PATH]; + CHAR szName[_MAX_PATH], szExt[_MAX_EXT]; _splitpath(lpszFileName, 0, 0, szName, szExt); - memset(szFullFilename, 0, 32); - strcpy(szFullFilename, szName); - if (m_sndFile.GetType() & (MOD_TYPE_MOD | MOD_TYPE_XM)) - { - // MOD/XM - strcat(szFullFilename, szExt); - szFullFilename[31] = 0; - memcpy(m_sndFile.m_szNames[m_nSample], szFullFilename, MAX_SAMPLENAME); - } else - { - // S3M/IT - szFullFilename[31] = 0; - if (!m_sndFile.m_szNames[m_nSample][0]) mpt::String::Copy(m_sndFile.m_szNames[m_nSample], szFullFilename); - if (strlen(szFullFilename) < 9) strcat(szFullFilename, szExt); - } - mpt::String::Copy(sample.filename, szFullFilename); + if(!m_sndFile.m_szNames[m_nSample][0]) mpt::String::Copy(m_sndFile.m_szNames[m_nSample], szName); + + if (strlen(szName) < 9) strcat(szName, szExt); + mpt::String::Copy(sample.filename, szName); } - if ((m_sndFile.GetType() & MOD_TYPE_XM) && (!(sample.uFlags & CHN_PANNING))) + if ((m_sndFile.GetType() & MOD_TYPE_XM) && !sample.uFlags[CHN_PANNING]) { sample.nPan = 128; - sample.uFlags |= CHN_PANNING; + sample.uFlags.set(CHN_PANNING); } m_modDoc.UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA | HINT_SAMPLEINFO | HINT_SMPNAMES, NULL); m_modDoc.SetModified(); @@ -1520,7 +1504,7 @@ if (sample.nSustainEnd >= dwEnd) sample.nSustainEnd += (dwEnd-dwStart); else if (sample.nSustainEnd > dwStart) sample.nSustainEnd += (sample.nSustainEnd - dwStart); - sample.uFlags |= CHN_16BIT; + sample.uFlags.set(CHN_16BIT); ctrlSmp::ReplaceSample(sample, (LPSTR)pNewSample, dwNewLen, m_sndFile); if(!selection.selectionActive) { Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2013-08-11 17:58:59 UTC (rev 2600) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2013-08-11 21:27:57 UTC (rev 2601) @@ -1056,8 +1056,8 @@ UNREFERENCED_PARAMETER(pSndFile); #endif // MODPLUG_TRACKER - uint16 fnum = std::min<uint16>(num, uint16_max); // Number of entries that are actually going to be written - const uint32 bytes_written = 2 + fnum * 8; // Number of bytes that are actually going to be written + uint16 fnum = (uint16)MIN(num, uint16_max); // Number of entries that are actually going to be written + const uint32 bytes_written = 2 + fnum * 8; // Number of bytes that are actually going to be written if(f == nullptr) return bytes_written; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-08-12 23:31:56
|
Revision: 2602 http://sourceforge.net/p/modplug/code/2602 Author: saga-games Date: 2013-08-12 23:31:49 +0000 (Mon, 12 Aug 2013) Log Message: ----------- [Ref] Unify usage of CMappedFile and move class implementation to its own files. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/Load_itp.cpp trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/Sndfile.h Added Paths: ----------- trunk/OpenMPT/mptrack/MemoryMappedFile.cpp trunk/OpenMPT/mptrack/MemoryMappedFile.h Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2013-08-11 21:27:57 UTC (rev 2601) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2013-08-12 23:31:49 UTC (rev 2602) @@ -22,6 +22,7 @@ #include "../common/misc_util.h" #include "../common/StringFixer.h" #include "SelectPluginDialog.h" +#include "MemoryMappedFile.h" #pragma warning(disable:4244) //conversion from 'type1' to 'type2', possible loss of data @@ -1395,8 +1396,6 @@ { CMappedFile f; BOOL bFirst, bOk; - DWORD len; - LPBYTE lpFile; BeginWaitCursor(); if ((!lpszFileName) || (!f.Open(lpszFileName))) @@ -1405,11 +1404,11 @@ return FALSE; } bFirst = FALSE; - len = f.GetLength(); - if (len > CTrackApp::gMemStatus.dwTotalPhys) len = CTrackApp::gMemStatus.dwTotalPhys; - lpFile = f.Lock(len); + + FileReader file = f.GetFile(); + bOk = FALSE; - if (lpFile) + if (file.IsValid()) { if (!m_sndFile.GetNumInstruments()) { @@ -1419,7 +1418,7 @@ m_modDoc.SetModified(); } if (!m_nInstrument) m_nInstrument = 1; - if (m_sndFile.ReadInstrumentFromFile(m_nInstrument, lpFile, len, TrackerSettings::Instance().m_MayNormalizeSamplesOnLoad)) + if (m_sndFile.ReadInstrumentFromFile(m_nInstrument, file, TrackerSettings::Instance().m_MayNormalizeSamplesOnLoad)) { m_modDoc.UpdateAllViews(NULL, HINT_SAMPLEINFO | HINT_MODTYPE, NULL); // -> CODE#0023 Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-08-11 21:27:57 UTC (rev 2601) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-08-12 23:31:49 UTC (rev 2602) @@ -27,6 +27,7 @@ #include "modsmp_ctrl.h" #include "Autotune.h" #include "../common/StringFixer.h" +#include "MemoryMappedFile.h" #include "../soundlib/FileReader.h" #include <Shlwapi.h> @@ -743,13 +744,12 @@ EndWaitCursor(); return false; } - const size_t len = f.GetLength(); - const void *lpFile = f.Lock(len); - if (!lpFile) goto OpenError; + + FileReader file = f.GetFile(); + if(file.IsValid()) goto OpenError; { m_modDoc.GetSampleUndo().PrepareUndo(m_nSample, sundo_replace); - FileReader file(lpFile, len); bOk = m_sndFile.ReadSampleFromFile(m_nSample, file, TrackerSettings::Instance().m_MayNormalizeSamplesOnLoad); } @@ -771,7 +771,7 @@ ModSample &sample = m_sndFile.GetSample(m_nSample); m_sndFile.DestroySampleThreadsafe(m_nSample); - sample.nLength = len; + sample.nLength = file.GetLength(); SampleIO sampleIO = dlg.GetSampleFormat(); @@ -791,8 +791,8 @@ sample.nLength /= 2; } - FileReader chunk(lpFile, len); - if(sampleIO.ReadSample(sample, chunk)) + file.Rewind(); + if(sampleIO.ReadSample(sample, file)) { bOk = true; Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-08-11 21:27:57 UTC (rev 2601) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-08-12 23:31:49 UTC (rev 2602) @@ -36,6 +36,7 @@ #include "SelectPluginDialog.h" #include "ExceptionHandler.h" #include "PatternClipboard.h" +#include "MemoryMappedFile.h" #include "soundlib/FileReader.h" #include "../common/Profiler.h" @@ -1617,26 +1618,21 @@ if(f.Open(lpszFileName)) { - DWORD dwLen = f.GetLength(); - if(dwLen) + FileReader file = f.GetFile(); + if(file.IsValid()) { - LPBYTE p = f.Lock(); - if(p) + InitPreview(); + m_WaveFile.m_SongFlags.set(SONG_PAUSED); + // Avoid hanging audio while reading file - we have removed all sample and instrument references before, + // so it's safe to replace the sample / instrument now. + cs.Leave(); + ok = m_WaveFile.ReadInstrumentFromFile(1, file, TrackerSettings::Instance().m_MayNormalizeSamplesOnLoad); + cs.Enter(); + if(!ok) { - InitPreview(); - m_WaveFile.m_SongFlags.set(SONG_PAUSED); - // Avoid hanging audio while reading file - we have removed all sample and instrument references before, - // so it's safe to replace the sample / instrument now. - cs.Leave(); - ok = m_WaveFile.ReadInstrumentFromFile(1, p, dwLen, TrackerSettings::Instance().m_MayNormalizeSamplesOnLoad); - cs.Enter(); - if(!ok) - { - // Try reading as sample if reading as instrument fails - FileReader file(p, dwLen); - ok = m_WaveFile.ReadSampleFromFile(1, file, TrackerSettings::Instance().m_MayNormalizeSamplesOnLoad); - m_WaveFile.AllocateInstrument(1, 1); - } + // Try reading as sample if reading as instrument fails + ok = m_WaveFile.ReadSampleFromFile(1, file, TrackerSettings::Instance().m_MayNormalizeSamplesOnLoad); + m_WaveFile.AllocateInstrument(1, 1); } } } Added: trunk/OpenMPT/mptrack/MemoryMappedFile.cpp =================================================================== --- trunk/OpenMPT/mptrack/MemoryMappedFile.cpp (rev 0) +++ trunk/OpenMPT/mptrack/MemoryMappedFile.cpp 2013-08-12 23:31:49 UTC (rev 2602) @@ -0,0 +1,109 @@ +/* + * MemoryMappedFile.cpp + * -------------------- + * Purpose: Wrapper class for memory-mapped files + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#include "stdafx.h" +#include "MemoryMappedFile.h" + + +CMappedFile::~CMappedFile() +//------------------------- +{ + Close(); +} + + +bool CMappedFile::Open(LPCSTR lpszFileName) +//----------------------------------------- +{ + return m_File.Open(lpszFileName, CFile::modeRead | CFile::typeBinary | CFile::shareDenyWrite) != FALSE; +} + + +void CMappedFile::Close() +//----------------------- +{ + if(m_pData) Unlock(); + m_File.Close(); +} + + +size_t CMappedFile::GetLength() +//----------------------------- +{ + return mpt::saturate_cast<size_t>(m_File.GetLength()); +} + + +const void *CMappedFile::Lock() +//----------------------------- +{ + size_t length = GetLength(); + if(!length) return nullptr; + + void *lpStream; + + HANDLE hmf = CreateFileMapping( + m_File.m_hFile, + NULL, + PAGE_READONLY, + 0, 0, + NULL); + + // Try memory-mapping first + if(hmf) + { + lpStream = MapViewOfFile( + hmf, + FILE_MAP_READ, + 0, 0, + 0); + if(lpStream) + { + m_hFMap = hmf; + m_pData = lpStream; + return lpStream; + } + CloseHandle(hmf); + hmf = nullptr; + } + + // Fallback if memory-mapping fails for some weird reason + if((lpStream = malloc(length)) == nullptr) return nullptr; + m_File.Read(lpStream, length); + m_pData = lpStream; + return lpStream; +} + + +FileReader CMappedFile::GetFile() +//------------------------------- +{ + return FileReader(Lock(), GetLength()); +} + + +void CMappedFile::Unlock() +//------------------------ +{ + if(m_hFMap) + { + if(m_pData) + { + UnmapViewOfFile(m_pData); + m_pData = nullptr; + } + CloseHandle(m_hFMap); + m_hFMap = nullptr; + } else if(m_pData) + { + free(m_pData); + m_pData = nullptr; + } +} \ No newline at end of file Added: trunk/OpenMPT/mptrack/MemoryMappedFile.h =================================================================== --- trunk/OpenMPT/mptrack/MemoryMappedFile.h (rev 0) +++ trunk/OpenMPT/mptrack/MemoryMappedFile.h 2013-08-12 23:31:49 UTC (rev 2602) @@ -0,0 +1,38 @@ +/* + * MemoryMappedFile.h + * ------------------ + * Purpose: Header file for memory-mapped file wrapper + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#pragma once + +#include "../soundlib/FileReader.h" + +////////////////////////////////////////////////////////////////// +// File Mapping Class + +//=============== +class CMappedFile +//=============== +{ +protected: + CFile m_File; + HANDLE m_hFMap; + void *m_pData; + +public: + CMappedFile() : m_hFMap(nullptr), m_pData(nullptr) { } + ~CMappedFile(); + +public: + bool Open(LPCSTR lpszFileName); + void Close(); + size_t GetLength(); + const void *Lock(); + FileReader GetFile(); + void Unlock(); +}; Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-08-11 21:27:57 UTC (rev 2601) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-08-12 23:31:49 UTC (rev 2602) @@ -24,8 +24,12 @@ #include "modsmp_ctrl.h" #include "CleanupSong.h" #include "../common/StringFixer.h" +#ifdef NO_FILEREADER_STD_ISTREAM +#include "MemoryMappedFile.h" +#else +#include <fstream> +#endif #include "soundlib/FileReader.h" -#include <fstream> #include <shlwapi.h> #ifdef _DEBUG @@ -215,15 +219,10 @@ CMappedFile f; if (f.Open(lpszPathName)) { - DWORD dwLen = f.GetLength(); - if (dwLen) + FileReader file = f.GetFile(); + if(file.IsValid()) { - LPBYTE lpStream = f.Lock(); - if (lpStream) - { - m_SndFile.Create(FileReader(lpStream, dwLen), CSoundFile::loadCompleteModule, this); - f.Unlock(); - } + m_SndFile.Create(file, CSoundFile::loadCompleteModule, this); } } } @@ -333,16 +332,14 @@ { // Load from Instrument or Sample file CHAR szName[_MAX_FNAME], szExt[_MAX_EXT]; - CFile f; + CMappedFile f; - if (f.Open(pszMidiMapName, CFile::modeRead)) + if(f.Open(pszMidiMapName)) { - DWORD len = static_cast<DWORD>(f.GetLength()); - LPBYTE lpFile; - if ((len) && ((lpFile = (LPBYTE)GlobalAllocPtr(GHND, len)) != NULL)) + FileReader file = f.GetFile(); + if(file.IsValid()) { - f.Read(lpFile, len); - m_SndFile.ReadInstrumentFromFile(nIns, lpFile, len, TrackerSettings::Instance().m_MayNormalizeSamplesOnLoad); + m_SndFile.ReadInstrumentFromFile(nIns, file, false); _splitpath(pszMidiMapName, NULL, NULL, szName, szExt); strncat(szName, szExt, sizeof(szName)); pIns = m_SndFile.Instruments[nIns]; @@ -360,7 +357,6 @@ } } } - f.Close(); } } } Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-08-11 21:27:57 UTC (rev 2601) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-08-12 23:31:49 UTC (rev 2602) @@ -1948,108 +1948,6 @@ } -///////////////////////////////////////////////////////////////////////////////////// -// CMappedFile - -CMappedFile::CMappedFile() -//------------------------ -{ - m_hFMap = NULL; - m_lpData = NULL; -} - - -CMappedFile::~CMappedFile() -//------------------------- -{ - Close(); -} - - -BOOL CMappedFile::Open(LPCSTR lpszFileName) -//----------------------------------------- -{ - return m_File.Open(lpszFileName, CFile::modeRead | CFile::typeBinary | CFile::shareDenyWrite); -} - - -void CMappedFile::Close() -//----------------------- -{ - if (m_lpData) Unlock(); - m_File.Close(); -} - - -DWORD CMappedFile::GetLength() -//---------------------------- -{ - return static_cast<DWORD>(m_File.GetLength()); -} - - -LPBYTE CMappedFile::Lock(DWORD dwMaxLen) -//-------------------------------------- -{ - DWORD dwLen = GetLength(); - LPBYTE lpStream; - - if (!dwLen) return NULL; - if ((dwMaxLen) && (dwLen > dwMaxLen)) dwLen = dwMaxLen; - HANDLE hmf = CreateFileMapping( - (HANDLE)m_File.m_hFile, - NULL, - PAGE_READONLY, - 0, 0, - NULL - ); - if (hmf) - { - lpStream = (LPBYTE)MapViewOfFile( - hmf, - FILE_MAP_READ, - 0, 0, - 0 - ); - if (lpStream) - { - m_hFMap = hmf; - m_lpData = lpStream; - return lpStream; - } - CloseHandle(hmf); - } - // Fallback - if (dwLen > CTrackApp::gMemStatus.dwTotalPhys) return NULL; - if ((lpStream = (LPBYTE)GlobalAllocPtr(GHND, dwLen)) == NULL) return NULL; - m_File.Read(lpStream, dwLen); - m_lpData = lpStream; - return lpStream; -} - - -BOOL CMappedFile::Unlock() -//------------------------ -{ - if (m_hFMap) - { - if (m_lpData) - { - UnmapViewOfFile(m_lpData); - m_lpData = NULL; - } - CloseHandle(m_hFMap); - m_hFMap = NULL; - } - if (m_lpData) - { - GlobalFreePtr(m_lpData); - m_lpData = NULL; - } - return TRUE; -} - - /////////////////////////////////////////////////////////////////////////////////// // // DirectX Plugins Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2013-08-11 21:27:57 UTC (rev 2601) +++ trunk/OpenMPT/mptrack/Mptrack.h 2013-08-12 23:31:49 UTC (rev 2602) @@ -239,31 +239,6 @@ ////////////////////////////////////////////////////////////////// -// File Mapping Class - -//=============== -class CMappedFile -//=============== -{ -protected: - CFile m_File; - HANDLE m_hFMap; - LPVOID m_lpData; - -public: - CMappedFile(); - virtual ~CMappedFile(); - -public: - BOOL Open(LPCSTR lpszFileName); - void Close(); - DWORD GetLength(); - LPBYTE Lock(DWORD dwMaxLen=0); - BOOL Unlock(); -}; - - -////////////////////////////////////////////////////////////////// // More Bitmap Helpers //#define FASTBMP_XSHIFT 12 // 4K pixels Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2013-08-11 21:27:57 UTC (rev 2601) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2013-08-12 23:31:49 UTC (rev 2602) @@ -17,6 +17,7 @@ #include "Dlsbank.h" #include "dlg_misc.h" #include "vstplug.h" +#include "MemoryMappedFile.h" #include "../soundlib/FileReader.h" @@ -267,28 +268,24 @@ SetCurrentDirectory(m_szInstrLibPath); if (f.Open(pszSongName)) { - DWORD dwLen = f.GetLength(); - if (dwLen) + FileReader file = f.GetFile(); + if (file.IsValid()) { - LPBYTE lpStream = f.Lock(); - if (lpStream) + if(m_SongFile != nullptr) { - if(m_SongFile != nullptr) - { - m_SongFile->Destroy(); - } else - { - m_SongFile = new (std::nothrow) CSoundFile; - } - if(m_SongFile != nullptr) - { - m_SongFile->Create(FileReader(lpStream, dwLen), CSoundFile::loadNoPatternData, nullptr); - // Destroy some stuff that we're not going to use anyway. - m_SongFile->Patterns.DestroyPatterns(); - m_SongFile->songMessage.clear(); - } - f.Unlock(); + m_SongFile->Destroy(); + } else + { + m_SongFile = new (std::nothrow) CSoundFile; } + if(m_SongFile != nullptr) + { + m_SongFile->Create(file, CSoundFile::loadNoPatternData, nullptr); + // Destroy some stuff that we're not going to use anyway. + m_SongFile->Patterns.DestroyPatterns(); + m_SongFile->songMessage.clear(); + } + f.Unlock(); } } } Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-08-11 21:27:57 UTC (rev 2601) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-08-12 23:31:49 UTC (rev 2602) @@ -25,6 +25,7 @@ #include "../common/version.h" #include "midimappingdialog.h" #include "../common/StringFixer.h" +#include "MemoryMappedFile.h" #include "../soundlib/FileReader.h" #include "../soundlib/plugins/JBridge.h" #include <fstream> @@ -1678,9 +1679,7 @@ const char *errorStr = nullptr; if(f.Open(files.first_file.c_str())) { - size_t len = f.GetLength(); - FileReader file(f.Lock(len), len); - + FileReader file = f.GetFile(); errorStr = VSTPresets::GetErrorMessage(VSTPresets::LoadFile(file, *this)); } else { Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-08-11 21:27:57 UTC (rev 2601) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-08-12 23:31:49 UTC (rev 2602) @@ -367,6 +367,10 @@ > </File> <File + RelativePath=".\MemoryMappedFile.cpp" + > + </File> + <File RelativePath="..\soundlib\Message.cpp" > </File> @@ -945,6 +949,10 @@ > </File> <File + RelativePath=".\MemoryMappedFile.h" + > + </File> + <File RelativePath="..\soundlib\MIDIEvents.h" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-08-11 21:27:57 UTC (rev 2601) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-08-12 23:31:49 UTC (rev 2602) @@ -379,6 +379,7 @@ <ClCompile Include="KeyConfigDlg.cpp" /> <ClCompile Include="Mainbar.cpp" /> <ClCompile Include="MainFrm.cpp" /> + <ClCompile Include="MemoryMappedFile.cpp" /> <ClCompile Include="MIDIMacroDialog.cpp" /> <ClCompile Include="MIDIMapping.cpp" /> <ClCompile Include="MIDIMappingDialog.cpp" /> @@ -554,6 +555,7 @@ <ClInclude Include="InputHandler.h" /> <ClInclude Include="Mainbar.h" /> <ClInclude Include="Mainfrm.h" /> + <ClInclude Include="MemoryMappedFile.h" /> <ClInclude Include="MIDIMacroDialog.h" /> <ClInclude Include="MIDIMapping.h" /> <ClInclude Include="mod2midi.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-08-11 21:27:57 UTC (rev 2601) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-08-12 23:31:49 UTC (rev 2602) @@ -481,6 +481,9 @@ <ClCompile Include="..\soundlib\MixerLoops.cpp"> <Filter>Source Files\soundlib</Filter> </ClCompile> + <ClCompile Include="MemoryMappedFile.cpp"> + <Filter>Source Files\mptrack</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\soundlib\Loaders.h"> @@ -897,6 +900,9 @@ <ClInclude Include="..\soundlib\SampleFormat.h"> <Filter>Header Files\soundlib</Filter> </ClInclude> + <ClInclude Include="MemoryMappedFile.h"> + <Filter>Header Files\mptrack</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.cpp 2013-08-11 21:27:57 UTC (rev 2601) +++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2013-08-12 23:31:49 UTC (rev 2602) @@ -13,6 +13,7 @@ #include "Sndfile.h" #ifdef MODPLUG_TRACKER #include "../mptrack/mptrack.h" +#include "../mptrack/MemoryMappedFile.h" #endif #include "Dlsbank.h" #include "Wav.h" @@ -25,10 +26,7 @@ //#define DLSBANK_LOG //#define DLSINSTR_LOG -//#define ASM_DLSUNITCONVERSION -#ifndef ASM_DLSUNITCONVERSION #include <math.h> -#endif #define F_RGN_OPTION_SELFNONEXCLUSIVE 0x0001 @@ -1156,7 +1154,7 @@ CMappedFile MapFile; if (!MapFile.Open(lpszFileName)) return FALSE; dwMemLength = MapFile.GetLength(); - if (dwMemLength >= 256) lpMemFile = MapFile.Lock(); + if (dwMemLength >= 256) lpMemFile = (const BYTE *)MapFile.Lock(); if (!lpMemFile) { return FALSE; Modified: trunk/OpenMPT/soundlib/Load_itp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_itp.cpp 2013-08-11 21:27:57 UTC (rev 2601) +++ trunk/OpenMPT/soundlib/Load_itp.cpp 2013-08-12 23:31:49 UTC (rev 2602) @@ -17,6 +17,7 @@ #ifdef MODPLUG_TRACKER #include "../mptrack/mptrack.h" #include "../mptrack/TrackerSettings.h" +#include "../mptrack/MemoryMappedFile.h" #endif #include "../common/version.h" #include "Loaders.h" @@ -220,16 +221,13 @@ // Load instruments CMappedFile f; - for(INSTRUMENTINDEX ins = 0; ins < GetNumInstruments(); ins++) { if(m_szInstrumentPath[ins].empty() || !f.Open(m_szInstrumentPath[ins].c_str())) continue; - size = f.GetLength(); - LPBYTE lpFile = f.Lock(size); - if(!lpFile) { f.Close(); continue; } - - ReadInstrumentFromFile(ins + 1, lpFile, size, TrackerSettings::Instance().m_MayNormalizeSamplesOnLoad); + FileReader file = f.GetFile(); + if(file.IsValid()) + ReadInstrumentFromFile(ins + 1, file, TrackerSettings::Instance().m_MayNormalizeSamplesOnLoad); f.Close(); } Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-08-11 21:27:57 UTC (rev 2601) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-08-12 23:31:49 UTC (rev 2602) @@ -88,16 +88,16 @@ } -bool CSoundFile::ReadInstrumentFromFile(INSTRUMENTINDEX nInstr, const LPBYTE lpMemFile, DWORD dwFileLength, bool mayNormalize) -//---------------------------------------------------------------------------------------------------------------------------- +bool CSoundFile::ReadInstrumentFromFile(INSTRUMENTINDEX nInstr, FileReader &file, bool mayNormalize) +//-------------------------------------------------------------------------------------------------- { - FileReader file(lpMemFile, dwFileLength); if ((!nInstr) || (nInstr >= MAX_INSTRUMENTS)) return false; - if ((!ReadXIInstrument(nInstr, file)) - && (!ReadPATInstrument(nInstr, lpMemFile, dwFileLength)) - && (!ReadITIInstrument(nInstr, file)) - // Generic read - && (!ReadSampleAsInstrument(nInstr, file, mayNormalize))) return false; + file.Rewind(); + if(!ReadPATInstrument(nInstr, (const LPBYTE)file.GetRawData(), file.GetLength()) + && !ReadXIInstrument(nInstr, file) + && !ReadITIInstrument(nInstr, file) + // Generic read + && !ReadSampleAsInstrument(nInstr, file, mayNormalize)) return false; if(nInstr > GetNumInstruments()) m_nInstruments = nInstr; return true; @@ -711,8 +711,8 @@ // PAT Instrument -bool CSoundFile::ReadPATInstrument(INSTRUMENTINDEX nInstr, LPBYTE lpStream, DWORD dwMemLength) -//-------------------------------------------------------------------------------------------- +bool CSoundFile::ReadPATInstrument(INSTRUMENTINDEX nInstr, const LPBYTE lpStream, DWORD dwMemLength) +//-------------------------------------------------------------------------------------------------- { GF1PATCHFILEHEADER *phdr = (GF1PATCHFILEHEADER *)lpStream; GF1INSTRUMENT *pih = (GF1INSTRUMENT *)(lpStream+sizeof(GF1PATCHFILEHEADER)); Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-08-11 21:27:57 UTC (rev 2601) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-08-12 23:31:49 UTC (rev 2602) @@ -740,7 +740,7 @@ #endif // Instrument file I/O - bool ReadInstrumentFromFile(INSTRUMENTINDEX nInstr, const LPBYTE lpMemFile, DWORD dwFileLength, bool mayNormalize=false); + bool ReadInstrumentFromFile(INSTRUMENTINDEX nInstr, FileReader &file, bool mayNormalize=false); bool ReadXIInstrument(INSTRUMENTINDEX nInstr, FileReader &file); bool ReadITIInstrument(INSTRUMENTINDEX nInstr, FileReader &file); bool ReadPATInstrument(INSTRUMENTINDEX nInstr, const LPBYTE lpMemFile, DWORD dwFileLength); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-08-28 18:33:53
|
Revision: 2617 http://sourceforge.net/p/modplug/code/2617 Author: saga-games Date: 2013-08-28 18:33:45 +0000 (Wed, 28 Aug 2013) Log Message: ----------- [Imp] General Tab: Effect parameters are now also updated while dragging the corresponding slider (tx madbrain). [Imp] Tree view: Releasing note keys now also stops sample / instrument previews (tx madbrain). [New] Tree view: Can now drag and drop samples / instruments between modules (tx madbrain). [Fix] Fine / extra fine portamento slides in IT/S3M with a parameter of 0 were broken since revision 2580 (http://bugs.openmpt.org/view.php?id=433). [Mod] OpenMPT: Version is now 1.22.04.02 Revision Links: -------------- http://sourceforge.net/p/modplug/code/2580 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/View_gen.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2013-08-26 13:47:33 UTC (rev 2616) +++ trunk/OpenMPT/common/versionNumber.h 2013-08-28 18:33:45 UTC (rev 2617) @@ -17,7 +17,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 22 #define VER_MINOR 04 -#define VER_MINORMINOR 01 +#define VER_MINORMINOR 02 //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/View_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_gen.cpp 2013-08-26 13:47:33 UTC (rev 2616) +++ trunk/OpenMPT/mptrack/View_gen.cpp 2013-08-28 18:33:45 UTC (rev 2617) @@ -766,7 +766,7 @@ float fValue = 0.01f * n; wsprintf(s, "%d.%02d", n/100, n%100); SetDlgItemText(IDC_EDIT14, s); - if ((nSBCode == SB_THUMBPOSITION) || (nSBCode == SB_ENDSCROLL)) + if (nSBCode == SB_THUMBPOSITION || nSBCode == SB_THUMBTRACK || nSBCode == SB_ENDSCROLL) { pVstPlugin->SetParameter(m_nCurrentParam, fValue); OnParamChanged(); @@ -1243,7 +1243,7 @@ } } -void CViewGlobals::OnMovePlugToSlot() +void CViewGlobals::OnMovePlugToSlot() //----------------------------------- { CMoveFXSlotDialog dlg((CWnd*)this); Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2013-08-26 13:47:33 UTC (rev 2616) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2013-08-28 18:33:45 UTC (rev 2617) @@ -1255,11 +1255,11 @@ { if (nParam & 0x80) { - pModDoc->NoteOff(nParam, true); + pModDoc->NoteOff(nParam & 0x7F, true); } else { pModDoc->NoteOff(0, true); - pModDoc->PlayNote(nParam, static_cast<INSTRUMENTINDEX>(modItemID), 0, false); + pModDoc->PlayNote(nParam & 0x7F, static_cast<INSTRUMENTINDEX>(modItemID), 0, false); } } return TRUE; @@ -2104,24 +2104,33 @@ break; case MODITEM_SAMPLE: - // Reorder samples in a module - if(m_itemDrag.type == MODITEM_SAMPLE && pInfoDrag != nullptr && sameModDoc) + if(m_itemDrag.type == MODITEM_SAMPLE && pInfoDrag != nullptr) { if(bDoDrop) { - const SAMPLEINDEX from = static_cast<SAMPLEINDEX>(modItemDragID - 1), to = static_cast<SAMPLEINDEX>(modItemDropID - 1); - - std::vector<SAMPLEINDEX> newOrder(pModDoc->GetNumSamples()); - for(SAMPLEINDEX smp = 0; smp < pModDoc->GetNumSamples(); smp++) + if(sameModDoc) { - newOrder[smp] = smp + 1; - } + // Reorder samples in a module + const SAMPLEINDEX from = static_cast<SAMPLEINDEX>(modItemDragID - 1), to = static_cast<SAMPLEINDEX>(modItemDropID - 1); - newOrder.erase(newOrder.begin() + from); - newOrder.insert(newOrder.begin() + to, from + 1); + std::vector<SAMPLEINDEX> newOrder(pModDoc->GetNumSamples()); + for(SAMPLEINDEX smp = 0; smp < pModDoc->GetNumSamples(); smp++) + { + newOrder[smp] = smp + 1; + } - pModDoc->ReArrangeSamples(newOrder); + newOrder.erase(newOrder.begin() + from); + newOrder.insert(newOrder.begin() + to, from + 1); + pModDoc->ReArrangeSamples(newOrder); + } else if(pInfoDrag->pModDoc != nullptr) + { + // Load sample into other module + pSndFile->ReadSampleFromSong(static_cast<SAMPLEINDEX>(modItemDropID), pInfoDrag->pModDoc->GetrSoundFile(), static_cast<SAMPLEINDEX>(modItemDragID)); + } else + { + return true; + } pModDoc->UpdateAllViews(NULL, HINT_SMPNAMES | HINT_SAMPLEINFO | HINT_SAMPLEDATA | HINT_PATTERNDATA, NULL); pModDoc->SetModified(); SelectItem(hItem); @@ -2131,24 +2140,33 @@ break; case MODITEM_INSTRUMENT: - // Reorder instruments in a module - if(m_itemDrag.type == MODITEM_INSTRUMENT && pInfoDrag != nullptr && sameModDoc) + if(m_itemDrag.type == MODITEM_INSTRUMENT && pInfoDrag != nullptr) { if(bDoDrop) { - const INSTRUMENTINDEX from = static_cast<INSTRUMENTINDEX>(modItemDragID - 1), to = static_cast<INSTRUMENTINDEX>(modItemDropID - 1); - - std::vector<INSTRUMENTINDEX> newOrder(pModDoc->GetNumInstruments()); - for(INSTRUMENTINDEX ins = 0; ins < pModDoc->GetNumInstruments(); ins++) + if(sameModDoc) { - newOrder[ins] = ins + 1; - } + // Reorder instruments in a module + const INSTRUMENTINDEX from = static_cast<INSTRUMENTINDEX>(modItemDragID - 1), to = static_cast<INSTRUMENTINDEX>(modItemDropID - 1); - newOrder.erase(newOrder.begin() + from); - newOrder.insert(newOrder.begin() + to, from + 1); + std::vector<INSTRUMENTINDEX> newOrder(pModDoc->GetNumInstruments()); + for(INSTRUMENTINDEX ins = 0; ins < pModDoc->GetNumInstruments(); ins++) + { + newOrder[ins] = ins + 1; + } - pModDoc->ReArrangeInstruments(newOrder); + newOrder.erase(newOrder.begin() + from); + newOrder.insert(newOrder.begin() + to, from + 1); + pModDoc->ReArrangeInstruments(newOrder); + } else if(pInfoDrag->pModDoc != nullptr) + { + // Load instrument into other module + pSndFile->ReadInstrumentFromSong(static_cast<INSTRUMENTINDEX>(modItemDropID), pInfoDrag->pModDoc->GetrSoundFile(), static_cast<INSTRUMENTINDEX>(modItemDragID)); + } else + { + return true; + } pModDoc->UpdateAllViews(NULL, HINT_INSNAMES | HINT_INSTRUMENT | HINT_ENVELOPE | HINT_PATTERNDATA, NULL); pModDoc->SetModified(); SelectItem(hItem); @@ -3294,17 +3312,18 @@ CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - if(wParam >= kcTreeViewStartNotes && wParam <= kcTreeViewEndNotes) + const bool start = wParam >= kcTreeViewStartNotes && wParam <= kcTreeViewEndNotes, + stop = wParam >= kcTreeViewStartNoteStops && wParam <= kcTreeViewEndNoteStops; + if(start || stop) { - if(PlayItem(GetSelectedItem(), static_cast<ModCommand::NOTE>(wParam - kcTreeViewStartNotes + 1 + pMainFrm->GetBaseOctave() * 12))) + ModCommand::NOTE note = static_cast<ModCommand::NOTE>(wParam - (start ? kcTreeViewStartNotes : kcTreeViewStartNoteStops) + 1 + pMainFrm->GetBaseOctave() * 12); + if(stop) note |= 0x80; + + if(PlayItem(GetSelectedItem(), note)) return wParam; else return NULL; } - if(wParam >= kcTreeViewStartNoteStops && wParam <= kcTreeViewEndNoteStops) - { - return wParam; - } return NULL; } Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-08-26 13:47:33 UTC (rev 2616) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-08-28 18:33:45 UTC (rev 2617) @@ -318,7 +318,9 @@ bool CSoundFile::ReadSampleFromSong(SAMPLEINDEX targetSample, const CSoundFile &srcSong, SAMPLEINDEX sourceSample) //---------------------------------------------------------------------------------------------------------------- { - if(!sourceSample || sourceSample > srcSong.GetNumSamples() || targetSample >= GetModSpecifications().samplesMax) + if(!sourceSample + || sourceSample > srcSong.GetNumSamples() + || (targetSample >= GetModSpecifications().samplesMax && targetSample > GetNumSamples())) { return false; } Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-08-26 13:47:33 UTC (rev 2616) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-08-28 18:33:45 UTC (rev 2617) @@ -2746,6 +2746,10 @@ return; } } + if(GetType() != MOD_TYPE_DBM) + { + return; + } } // Regular Slide if(!m_SongFlags[SONG_FIRSTTICK]) @@ -2794,6 +2798,10 @@ return; } } + if(GetType() != MOD_TYPE_DBM) + { + return; + } } if(!m_SongFlags[SONG_FIRSTTICK]) @@ -2990,7 +2998,7 @@ } // Implemented for IMF compatibility, can't actually save this in any formats -// sign should be 1 (up) or -1 (down) +// Slide up / down every x ticks by y semitones void CSoundFile::NoteSlide(ModChannel *pChn, UINT param, bool slideUp, bool retrig) //--------------------------------------------------------------------------------- { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-08-31 14:08:22
|
Revision: 2622 http://sourceforge.net/p/modplug/code/2622 Author: saga-games Date: 2013-08-31 14:08:15 +0000 (Sat, 31 Aug 2013) Log Message: ----------- [Mod] Updated release documents [Mod] OpenMPT: Version is now 1.22.05.00 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/packageTemplate/History.txt Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2013-08-31 09:43:02 UTC (rev 2621) +++ trunk/OpenMPT/common/versionNumber.h 2013-08-31 14:08:15 UTC (rev 2622) @@ -16,8 +16,8 @@ //Version definitions. The only thing that needs to be changed when changing version number. #define VER_MAJORMAJOR 1 #define VER_MAJOR 22 -#define VER_MINOR 04 -#define VER_MINORMINOR 02 +#define VER_MINOR 05 +#define VER_MINORMINOR 00 //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/packageTemplate/History.txt =================================================================== --- trunk/OpenMPT/packageTemplate/History.txt 2013-08-31 09:43:02 UTC (rev 2621) +++ trunk/OpenMPT/packageTemplate/History.txt 2013-08-31 14:08:15 UTC (rev 2622) @@ -25,6 +25,36 @@ <ks> coda / Ken Snyder +v1.22.05.00 (31 August 2013, revision 2622) +------------------------------------------- +General Tab + [Imp] <js> Effect parameters are now also updated while dragging the corresponding slider (tx madbrain). + +Sample Editor + [Imp] <js> Don't limit size of loaded sample file to the size of physical memory (old code relict). + +Instrument Editor + [Imp] <js> Also show FLAC files when loading instruments in instrument view. + +Tree view + [New] <js> Can now drag and drop samples / instruments between modules (tx madbrain). + [Imp] <js> Releasing note keys now also stops sample / instrument previews (tx madbrain). + [Fix] <js> Previewing sound font instruments in the treeview broke in OpenMPT 1.22.04.00. + [Fix] <js> Trying to rename items that are not part of a song folder crashed the application. + [Fix] <js> Adding and renaming sequences didn't update the tree view properly. + +Playback + [Fix] <js> Fine / extra fine portamento slides in IT / S3M with a parameter of 0 were broken in OpenMPT 1.22.04.00. + +Other formats + [Fix] <jh> DSM: Support files that start with a slightly different header than usual DSM files (http://forum.openmpt.org/index.php?topic=5091). + +Misc + [New] <jh> Added 32-bit floating point output for drivers that support it. + [Mod] <js> Updated zlib (1.2.8). + [Reg] <jh> Remove mpt_intl.ini and mpt_intl.dll support code which was solely usable to translate the options list in the general options tab. + + v1.22.04.00 (6 August 2013, revision 2581) ------------------------------------------ Pattern Editor This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-09-01 08:50:25
|
Revision: 2625 http://sourceforge.net/p/modplug/code/2625 Author: manxorist Date: 2013-09-01 08:50:08 +0000 (Sun, 01 Sep 2013) Log Message: ----------- [New] libopenmpt: Add heuristic to detect the used charset based on module type. [Mod] OpenMPT: Version is now 1.22.05.01 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Tables.cpp Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2013-09-01 08:32:23 UTC (rev 2624) +++ trunk/OpenMPT/common/versionNumber.h 2013-09-01 08:50:08 UTC (rev 2625) @@ -17,7 +17,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 22 #define VER_MINOR 05 -#define VER_MINORMINOR 00 +#define VER_MINORMINOR 01 //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/libopenmpt/libopenmpt_impl.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-09-01 08:32:23 UTC (rev 2624) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-09-01 08:50:08 UTC (rev 2625) @@ -786,17 +786,22 @@ std::vector<std::string> module_impl::get_ctls() const { std::vector<std::string> retval; + retval.push_back( "charset" ); return retval; } std::string module_impl::ctl_get( const std::string & ctl ) const { if ( ctl == "" ) { throw openmpt::exception("unknown ctl"); + } else if ( ctl == "charset" ) { + return m_sndFile->GetCharset().second; } throw openmpt::exception("unknown ctl"); } void module_impl::ctl_set( const std::string & ctl, const std::string & value ) { if ( ctl == "" ) { throw openmpt::exception("unknown ctl: " + ctl + " := " + value); + } else if ( ctl == "charset" ) { + throw openmpt::exception("ctl is read-only: " + ctl); } throw openmpt::exception("unknown ctl: " + ctl + " := " + value); } Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2013-09-01 08:32:23 UTC (rev 2624) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2013-09-01 08:50:08 UTC (rev 2625) @@ -113,6 +113,14 @@ DECLARE_FLAGSET(MODTYPE) +enum MOD_CHARSET_CERTAINTY +{ + MOD_CHARSET_UNKNOWN, + MOD_CHARSET_MAYBE, + MOD_CHARSET_IS, +}; + + // For compatibility mode #define TRK_IMPULSETRACKER (MOD_TYPE_IT | MOD_TYPE_MPT) #define TRK_FASTTRACKER2 (MOD_TYPE_XM) Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-09-01 08:32:23 UTC (rev 2624) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-09-01 08:50:08 UTC (rev 2625) @@ -447,6 +447,9 @@ bool TypeIsIT_MPT_XM() const { return (m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_XM)) != 0; } bool TypeIsS3M_IT_MPT() const { return (m_nType & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT)) != 0; } + // rough heuristic, could be improved + std::pair<MOD_CHARSET_CERTAINTY, std::string> GetCharset() const { return GetCharsetFromModType(GetType()); } + void SetPreAmp(UINT vol); UINT GetPreAmp() const { return m_MixerSettings.m_nPreAmp; } @@ -542,6 +545,7 @@ bool ReadMID(const LPCBYTE lpStream, DWORD dwMemLength, ModLoadingFlags loadFlags = loadCompleteModule); static std::vector<const char *> GetSupportedExtensions(bool otherFormats); + static std::pair<MOD_CHARSET_CERTAINTY, std::string> GetCharsetFromModType(MODTYPE modtype); static const char * ModTypeToString(MODTYPE modtype); static std::string ModTypeToTracker(MODTYPE modtype); Modified: trunk/OpenMPT/soundlib/Tables.cpp =================================================================== --- trunk/OpenMPT/soundlib/Tables.cpp 2013-09-01 08:32:23 UTC (rev 2624) +++ trunk/OpenMPT/soundlib/Tables.cpp 2013-09-01 08:50:08 UTC (rev 2625) @@ -121,6 +121,69 @@ #endif +struct ModCharsetInfo { + MODTYPE type; + MOD_CHARSET_CERTAINTY certainty; + const char *charset; +}; + +static const ModCharsetInfo ModCharsetInfos[] = +{ + // Amiga + { MOD_TYPE_OKT , MOD_CHARSET_IS , "Amiga-1251" }, + { MOD_TYPE_DBM , MOD_CHARSET_IS , "Amiga-1251" }, + { MOD_TYPE_DIGI, MOD_CHARSET_IS , "Amiga-1251" }, + // Amiga // DOS + { MOD_TYPE_MOD , MOD_CHARSET_MAYBE , "Amiga-1251" }, + { MOD_TYPE_MED , MOD_CHARSET_MAYBE , "Amiga-1251" }, + // DOS + { MOD_TYPE_S3M , MOD_CHARSET_IS , "cp437" }, + { MOD_TYPE_XM , MOD_CHARSET_IS , "cp437" }, + { MOD_TYPE_MTM , MOD_CHARSET_IS , "cp437" }, + { MOD_TYPE_IT , MOD_CHARSET_IS , "cp437" }, + { MOD_TYPE_669 , MOD_CHARSET_IS , "cp437" }, + { MOD_TYPE_STM , MOD_CHARSET_IS , "cp437" }, + { MOD_TYPE_FAR , MOD_CHARSET_IS , "cp437" }, + { MOD_TYPE_AMF , MOD_CHARSET_IS , "cp437" }, + { MOD_TYPE_AMF0, MOD_CHARSET_IS , "cp437" }, + { MOD_TYPE_MDL , MOD_CHARSET_IS , "cp437" }, + { MOD_TYPE_DMF , MOD_CHARSET_IS , "cp437" }, + { MOD_TYPE_PTM , MOD_CHARSET_IS , "cp437" }, + { MOD_TYPE_PSM , MOD_CHARSET_IS , "cp437" }, + { MOD_TYPE_J2B , MOD_CHARSET_IS , "cp437" }, + { MOD_TYPE_IMF , MOD_CHARSET_IS , "cp437" }, + { MOD_TYPE_ULT , MOD_CHARSET_IS , "cp437" }, + { MOD_TYPE_AMS , MOD_CHARSET_IS , "cp437" }, + { MOD_TYPE_AMS2, MOD_CHARSET_IS , "cp437" }, + { MOD_TYPE_DSM , MOD_CHARSET_IS , "cp437" }, + // Windows + { MOD_TYPE_MT2 , MOD_CHARSET_MAYBE , "Windows-1252"}, + { MOD_TYPE_MPT , MOD_CHARSET_MAYBE , "Windows-1252"}, + // random stuff + { MOD_TYPE_MID , MOD_CHARSET_IS , "US-ASCII" }, + { MOD_TYPE_WAV , MOD_CHARSET_MAYBE , "US-ASCII" }, + // end + { MOD_TYPE_NONE, MOD_CHARSET_UNKNOWN, "" } +}; + + +std::pair<MOD_CHARSET_CERTAINTY, std::string> CSoundFile::GetCharsetFromModType(MODTYPE modtype) +//---------------------------------------------------------------------------------------------- +{ + // This is just a rough heuristic. + // It could be improved by adjusting the charset according to the tracker that had been used to save the file. + for(const ModCharsetInfo *charsetInfoIt = ModCharsetInfos; charsetInfoIt->type != MOD_TYPE_NONE; ++charsetInfoIt) + { + if(charsetInfoIt->type == modtype) + { + return std::make_pair(charsetInfoIt->certainty, charsetInfoIt->charset); + } + } + // fallback + return std::make_pair(MOD_CHARSET_UNKNOWN, ""); +} + + std::vector<const char *> CSoundFile::GetSupportedExtensions(bool otherFormats) //----------------------------------------------------------------------------- { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-09-01 10:31:34
|
Revision: 2626 http://sourceforge.net/p/modplug/code/2626 Author: manxorist Date: 2013-09-01 10:31:18 +0000 (Sun, 01 Sep 2013) Log Message: ----------- [Ref] Split sound device code into one file per backend. Modified Paths: -------------- trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/sounddev/SoundDevices.h trunk/OpenMPT/soundlib/SampleFormatConverters.h Added Paths: ----------- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp trunk/OpenMPT/sounddev/SoundDeviceASIO.h trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp trunk/OpenMPT/sounddev/SoundDevicePortAudio.h trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp trunk/OpenMPT/sounddev/SoundDeviceWaveout.h Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-09-01 08:50:08 UTC (rev 2625) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-09-01 10:31:18 UTC (rev 2626) @@ -14,7 +14,7 @@ #include "Moddoc.h" #include "Mainfrm.h" #include "../sounddev/SoundDevice.h" -#include "../sounddev/SoundDevices.h" +#include "../sounddev/SoundDeviceASIO.h" #include "../common/version.h" #include "UpdateCheck.h" #include "Mpdlgs.h" Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-09-01 08:50:08 UTC (rev 2625) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-09-01 10:31:18 UTC (rev 2626) @@ -535,6 +535,22 @@ > </File> <File + RelativePath="..\sounddev\SoundDeviceASIO.cpp" + > + </File> + <File + RelativePath="..\sounddev\SoundDeviceDirectSound.cpp" + > + </File> + <File + RelativePath="..\sounddev\SoundDevicePortAudio.cpp" + > + </File> + <File + RelativePath="..\sounddev\SoundDeviceWaveout.cpp" + > + </File> + <File RelativePath="..\soundlib\SoundFilePlayConfig.cpp" > </File> @@ -1129,6 +1145,22 @@ > </File> <File + RelativePath="..\sounddev\SoundDeviceASIO.h" + > + </File> + <File + RelativePath="..\sounddev\SoundDeviceDirectSound.h" + > + </File> + <File + RelativePath="..\sounddev\SoundDevicePortAudio.h" + > + </File> + <File + RelativePath="..\sounddev\SoundDeviceWaveout.h" + > + </File> + <File RelativePath="..\soundlib\SoundFilePlayConfig.h" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-09-01 08:50:08 UTC (rev 2625) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-09-01 10:31:18 UTC (rev 2626) @@ -261,6 +261,10 @@ <ClCompile Include="..\common\typedefs.cpp" /> <ClCompile Include="..\common\version.cpp" /> <ClCompile Include="..\sounddev\SoundDevice.cpp" /> + <ClCompile Include="..\sounddev\SoundDeviceASIO.cpp" /> + <ClCompile Include="..\sounddev\SoundDeviceDirectSound.cpp" /> + <ClCompile Include="..\sounddev\SoundDevicePortAudio.cpp" /> + <ClCompile Include="..\sounddev\SoundDeviceWaveout.cpp" /> <ClCompile Include="..\sounddsp\AGC.cpp" /> <ClCompile Include="..\sounddsp\DSP.cpp" /> <ClCompile Include="..\sounddsp\EQ.cpp" /> @@ -478,7 +482,11 @@ <ClInclude Include="..\common\version.h" /> <ClInclude Include="..\common\versionNumber.h" /> <ClInclude Include="..\sounddev\SoundDevice.h" /> + <ClInclude Include="..\sounddev\SoundDeviceASIO.h" /> + <ClInclude Include="..\sounddev\SoundDeviceDirectSound.h" /> + <ClInclude Include="..\sounddev\SoundDevicePortAudio.h" /> <ClInclude Include="..\sounddev\SoundDevices.h" /> + <ClInclude Include="..\sounddev\SoundDeviceWaveout.h" /> <ClInclude Include="..\sounddsp\AGC.h" /> <ClInclude Include="..\sounddsp\DSP.h" /> <ClInclude Include="..\sounddsp\EQ.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-09-01 08:50:08 UTC (rev 2625) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-09-01 10:31:18 UTC (rev 2626) @@ -484,6 +484,18 @@ <ClCompile Include="MemoryMappedFile.cpp"> <Filter>Source Files\mptrack</Filter> </ClCompile> + <ClCompile Include="..\sounddev\SoundDeviceASIO.cpp"> + <Filter>Source Files\sounddev</Filter> + </ClCompile> + <ClCompile Include="..\sounddev\SoundDeviceDirectSound.cpp"> + <Filter>Source Files\sounddev</Filter> + </ClCompile> + <ClCompile Include="..\sounddev\SoundDevicePortAudio.cpp"> + <Filter>Source Files\sounddev</Filter> + </ClCompile> + <ClCompile Include="..\sounddev\SoundDeviceWaveout.cpp"> + <Filter>Source Files\sounddev</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\soundlib\Loaders.h"> @@ -903,6 +915,18 @@ <ClInclude Include="MemoryMappedFile.h"> <Filter>Header Files\mptrack</Filter> </ClInclude> + <ClInclude Include="..\sounddev\SoundDeviceASIO.h"> + <Filter>Header Files\sounddev</Filter> + </ClInclude> + <ClInclude Include="..\sounddev\SoundDeviceDirectSound.h"> + <Filter>Header Files\sounddev</Filter> + </ClInclude> + <ClInclude Include="..\sounddev\SoundDevicePortAudio.h"> + <Filter>Header Files\sounddev</Filter> + </ClInclude> + <ClInclude Include="..\sounddev\SoundDeviceWaveout.h"> + <Filter>Header Files\sounddev</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-09-01 08:50:08 UTC (rev 2625) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-09-01 10:31:18 UTC (rev 2626) @@ -13,20 +13,16 @@ #include "SoundDevice.h" #include "SoundDevices.h" + #include "../common/misc_util.h" -#ifdef MODPLUG_TRACKER -#include "../mptrack/Reporting.h" -#endif #include "../common/StringFixer.h" -struct ModSample; -#include "../soundlib/SampleFormatConverters.h" -// DEBUG: -#include "../common/AudioCriticalSection.h" +#include "SoundDeviceASIO.h" +#include "SoundDeviceDirectSound.h" +#include "SoundDevicePortAudio.h" +#include "SoundDeviceWaveout.h" -#include <algorithm> - /////////////////////////////////////////////////////////////////////////////////////// // // ISoundDevice base class @@ -561,1596 +557,13 @@ } -/////////////////////////////////////////////////////////////////////////////////////// -// -// MMSYSTEM WaveOut Device -// -static UINT gnNumWaveDevs = 0; - -CWaveDevice::CWaveDevice() -//------------------------ -{ - m_hWaveOut = NULL; - m_nWaveBufferSize = 0; - m_nPreparedHeaders = 0; - m_nBytesPerSec = 0; - m_BytesPerSample = 0; -} - - -CWaveDevice::~CWaveDevice() -//------------------------- -{ - Reset(); - Close(); -} - - -bool CWaveDevice::InternalOpen(UINT nDevice) -//------------------------------------------ -{ - WAVEFORMATEXTENSIBLE wfext; - if(!FillWaveFormatExtensible(wfext)) return false; - WAVEFORMATEX *pwfx = &wfext.Format; - - LONG nWaveDev; - - if (m_hWaveOut) Close(); - nWaveDev = (nDevice) ? nDevice-1 : WAVE_MAPPER; - if (waveOutOpen(&m_hWaveOut, nWaveDev, pwfx, (DWORD_PTR)WaveOutCallBack, (DWORD_PTR)this, CALLBACK_FUNCTION)) - { - sndPlaySound(NULL, 0); - LONG err = waveOutOpen(&m_hWaveOut, nWaveDev, pwfx, (DWORD_PTR)WaveOutCallBack, (DWORD_PTR)this, CALLBACK_FUNCTION); - if (err) return false; - } - m_nBytesPerSec = pwfx->nAvgBytesPerSec; - m_BytesPerSample = (pwfx->wBitsPerSample/8) * pwfx->nChannels; - m_nWaveBufferSize = (m_Settings.UpdateIntervalMS * pwfx->nAvgBytesPerSec) / 1000; - m_nWaveBufferSize = (m_nWaveBufferSize + 7) & ~7; - if (m_nWaveBufferSize < WAVEOUT_MINBUFFERSIZE) m_nWaveBufferSize = WAVEOUT_MINBUFFERSIZE; - if (m_nWaveBufferSize > WAVEOUT_MAXBUFFERSIZE) m_nWaveBufferSize = WAVEOUT_MAXBUFFERSIZE; - ULONG NumBuffers = m_Settings.LatencyMS * pwfx->nAvgBytesPerSec / ( m_nWaveBufferSize * 1000 ); - NumBuffers = CLAMP(NumBuffers, 3, WAVEOUT_MAXBUFFERS); - m_nPreparedHeaders = 0; - m_WaveBuffers.resize(NumBuffers); - m_WaveBuffersData.resize(NumBuffers); - for(UINT iBuf=0; iBuf<NumBuffers; iBuf++) - { - MemsetZero(m_WaveBuffers[iBuf]); - m_WaveBuffersData[iBuf].resize(m_nWaveBufferSize); - m_WaveBuffers[iBuf].dwFlags = WHDR_DONE; - m_WaveBuffers[iBuf].lpData = &m_WaveBuffersData[iBuf][0]; - m_WaveBuffers[iBuf].dwBufferLength = m_nWaveBufferSize; - if (waveOutPrepareHeader(m_hWaveOut, &m_WaveBuffers[iBuf], sizeof(WAVEHDR)) != 0) - { - break; - } - m_nPreparedHeaders++; - } - if (!m_nPreparedHeaders) - { - Close(); - return false; - } - m_RealLatencyMS = m_nWaveBufferSize * m_nPreparedHeaders * 1000.0f / m_nBytesPerSec; - m_RealUpdateIntervalMS = m_nWaveBufferSize * 1000.0f / m_nBytesPerSec; - m_nBuffersPending = 0; - m_nWriteBuffer = 0; - return true; -} - -bool CWaveDevice::InternalClose() -//------------------------------- -{ - Reset(); - if (m_hWaveOut) - { - ResetFromOutsideSoundThread(); // always reset so that waveOutClose does not fail if we did only P->Stop() (meaning waveOutPause()) before - while (m_nPreparedHeaders > 0) - { - m_nPreparedHeaders--; - waveOutUnprepareHeader(m_hWaveOut, &m_WaveBuffers[m_nPreparedHeaders], sizeof(WAVEHDR)); - } - MMRESULT err = waveOutClose(m_hWaveOut); - ALWAYS_ASSERT(err == MMSYSERR_NOERROR); - m_hWaveOut = NULL; - Sleep(1); // Linux WINE-friendly - } - return true; -} - - -void CWaveDevice::StartFromSoundThread() -//-------------------------------------- -{ - if(m_hWaveOut) - { - waveOutRestart(m_hWaveOut); - } -} - - -void CWaveDevice::StopFromSoundThread() -//------------------------------------- -{ - if(m_hWaveOut) - { - waveOutPause(m_hWaveOut); - } -} - - -void CWaveDevice::ResetFromOutsideSoundThread() -//--------------------------------------------- -{ - if(m_hWaveOut) - { - waveOutReset(m_hWaveOut); - } - InterlockedExchange(&m_nBuffersPending, 0); - m_nWriteBuffer = 0; -} - - -void CWaveDevice::FillAudioBuffer() -//--------------------------------- -{ - ULONG nBytesWritten; - ULONG nLatency; - LONG oldBuffersPending; - if (!m_hWaveOut) return; - nBytesWritten = 0; - oldBuffersPending = InterlockedExchangeAdd(&m_nBuffersPending, 0); // read - nLatency = oldBuffersPending * m_nWaveBufferSize; - - bool wasempty = false; - if(oldBuffersPending == 0) wasempty = true; - // When there were no pending buffers at all, pause the output, fill the buffers completely and then restart the output. - // This avoids buffer underruns which result in audible crackling on stream start with small buffers. - if(wasempty) waveOutPause(m_hWaveOut); - - while((ULONG)oldBuffersPending < m_nPreparedHeaders) - { - SourceAudioRead(m_WaveBuffers[m_nWriteBuffer].lpData, m_nWaveBufferSize/m_BytesPerSample); - nLatency += m_nWaveBufferSize; - nBytesWritten += m_nWaveBufferSize; - m_WaveBuffers[m_nWriteBuffer].dwBufferLength = m_nWaveBufferSize; - InterlockedIncrement(&m_nBuffersPending); - oldBuffersPending++; // increment separately to avoid looping without leaving at all when rendering takes more than 100% CPU - waveOutWrite(m_hWaveOut, &m_WaveBuffers[m_nWriteBuffer], sizeof(WAVEHDR)); - m_nWriteBuffer++; - m_nWriteBuffer %= m_nPreparedHeaders; - SourceAudioDone(m_nWaveBufferSize/m_BytesPerSample, nLatency/m_BytesPerSample); - } - - if(wasempty) waveOutRestart(m_hWaveOut); - -} - - -int64 CWaveDevice::GetStreamPositionSamples() const -//------------------------------------------------- -{ - if(!IsOpen()) return 0; - MMTIME mmtime; - MemsetZero(mmtime); - mmtime.wType = TIME_SAMPLES; - if(waveOutGetPosition(m_hWaveOut, &mmtime, sizeof(mmtime)) != MMSYSERR_NOERROR) return 0; - switch(mmtime.wType) - { - case TIME_BYTES: return mmtime.u.cb / m_BytesPerSample; break; - case TIME_MS: return mmtime.u.ms * m_nBytesPerSec / (1000 * m_BytesPerSample); break; - case TIME_SAMPLES: return mmtime.u.sample; break; - default: return 0; break; - } -} - - -void CWaveDevice::WaveOutCallBack(HWAVEOUT, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR, DWORD_PTR) -//-------------------------------------------------------------------------------------------- -{ - if ((uMsg == MM_WOM_DONE) && (dwUser)) - { - CWaveDevice *that = (CWaveDevice *)dwUser; - InterlockedDecrement(&that->m_nBuffersPending); - } -} - - -BOOL CWaveDevice::EnumerateDevices(UINT nIndex, LPSTR pszDescription, UINT cbSize) -//-------------------------------------------------------------------------------- -{ - WAVEOUTCAPS woc; - - if (!gnNumWaveDevs) - { - gnNumWaveDevs = waveOutGetNumDevs(); - } - if (nIndex > gnNumWaveDevs) return FALSE; - if (nIndex) - { - MemsetZero(woc); - waveOutGetDevCaps(nIndex-1, &woc, sizeof(woc)); - if (pszDescription) lstrcpyn(pszDescription, woc.szPname, cbSize); - } else - { - if (pszDescription) lstrcpyn(pszDescription, "Auto (Wave Mapper)", cbSize); - } - return TRUE; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// DirectSound device -// - -#ifndef NO_DSOUND - -#ifndef DSBCAPS_GLOBALFOCUS -#define DSBCAPS_GLOBALFOCUS 0x8000 -#endif - -#define MAX_DSOUND_DEVICES 16 - -typedef BOOL (WINAPI * LPDSOUNDENUMERATE)(LPDSENUMCALLBACK lpDSEnumCallback, LPVOID lpContext); -typedef HRESULT (WINAPI * LPDSOUNDCREATE)(GUID * lpGuid, LPDIRECTSOUND * ppDS, IUnknown * pUnkOuter); - -static HINSTANCE ghDSoundDLL = NULL; -static LPDSOUNDENUMERATE gpDSoundEnumerate = NULL; -static LPDSOUNDCREATE gpDSoundCreate = NULL; -static BOOL gbDSoundEnumerated = FALSE; -static UINT gnDSoundDevices = 0; -static GUID *glpDSoundGUID[MAX_DSOUND_DEVICES]; -static CHAR gszDSoundDrvNames[MAX_DSOUND_DEVICES][64]; - - -static BOOL WINAPI DSEnumCallback(GUID * lpGuid, LPCSTR lpstrDescription, LPCSTR, LPVOID) -//--------------------------------------------------------------------------------------- -{ - if (gnDSoundDevices >= MAX_DSOUND_DEVICES) return FALSE; - if ((lpstrDescription)) - { - if (lpGuid) - { - //if ((gnDSoundDevices) && (!glpDSoundGUID[gnDSoundDevices-1])) gnDSoundDevices--; - glpDSoundGUID[gnDSoundDevices] = new GUID; - *glpDSoundGUID[gnDSoundDevices] = *lpGuid; - } else glpDSoundGUID[gnDSoundDevices] = NULL; - lstrcpyn(gszDSoundDrvNames[gnDSoundDevices], lpstrDescription, 64); - gnDSoundDevices++; - gbDSoundEnumerated = TRUE; - } - return TRUE; -} - - -BOOL CDSoundDevice::EnumerateDevices(UINT nIndex, LPSTR pszDescription, UINT cbSize) -//---------------------------------------------------------------------------------- -{ - if (!gpDSoundEnumerate) return FALSE; - if (!gbDSoundEnumerated) - { - gpDSoundEnumerate((LPDSENUMCALLBACK)DSEnumCallback, NULL); - } - if (nIndex >= gnDSoundDevices) return FALSE; - lstrcpyn(pszDescription, gszDSoundDrvNames[nIndex], cbSize); - return TRUE; -} - - -CDSoundDevice::CDSoundDevice() -//---------------------------- -{ - m_piDS = NULL; - m_pPrimary = NULL; - m_pMixBuffer = NULL; - m_bMixRunning = FALSE; - m_nBytesPerSec = 0; - m_BytesPerSample = 0; -} - - -CDSoundDevice::~CDSoundDevice() -//----------------------------- -{ - Reset(); - Close(); -} - - -bool CDSoundDevice::InternalOpen(UINT nDevice) -//-------------------------------------------- -{ - WAVEFORMATEXTENSIBLE wfext; - if(!FillWaveFormatExtensible(wfext)) return false; - WAVEFORMATEX *pwfx = &wfext.Format; - - DSBUFFERDESC dsbd; - DSBCAPS dsc; - UINT nPriorityLevel = (m_Settings.fulCfgOptions & SNDDEV_OPTIONS_EXCLUSIVE) ? DSSCL_WRITEPRIMARY : DSSCL_PRIORITY; - - if (m_piDS) return true; - if (!gpDSoundEnumerate) return false; - if (!gbDSoundEnumerated) gpDSoundEnumerate((LPDSENUMCALLBACK)DSEnumCallback, NULL); - if ((nDevice >= gnDSoundDevices) || (!gpDSoundCreate)) return false; - if (gpDSoundCreate(glpDSoundGUID[nDevice], &m_piDS, NULL) != DS_OK) return false; - if (!m_piDS) return false; - m_piDS->SetCooperativeLevel(m_Settings.hWnd, nPriorityLevel); - m_bMixRunning = FALSE; - m_nDSoundBufferSize = (m_Settings.LatencyMS * pwfx->nAvgBytesPerSec) / 1000; - m_nDSoundBufferSize = (m_nDSoundBufferSize + 15) & ~15; - if(m_nDSoundBufferSize < DSOUND_MINBUFFERSIZE) m_nDSoundBufferSize = DSOUND_MINBUFFERSIZE; - if(m_nDSoundBufferSize > DSOUND_MAXBUFFERSIZE) m_nDSoundBufferSize = DSOUND_MAXBUFFERSIZE; - m_nBytesPerSec = pwfx->nAvgBytesPerSec; - m_BytesPerSample = (pwfx->wBitsPerSample/8) * pwfx->nChannels; - if(!(m_Settings.fulCfgOptions & SNDDEV_OPTIONS_EXCLUSIVE)) - { - // Set the format of the primary buffer - dsbd.dwSize = sizeof(dsbd); - dsbd.dwFlags = DSBCAPS_PRIMARYBUFFER; - dsbd.dwBufferBytes = 0; - dsbd.dwReserved = 0; - dsbd.lpwfxFormat = NULL; - if (m_piDS->CreateSoundBuffer(&dsbd, &m_pPrimary, NULL) != DS_OK) - { - Close(); - return false; - } - m_pPrimary->SetFormat(pwfx); - /////////////////////////////////////////////////// - // Create the secondary buffer - dsbd.dwSize = sizeof(dsbd); - dsbd.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_GETCURRENTPOSITION2; - dsbd.dwBufferBytes = m_nDSoundBufferSize; - dsbd.dwReserved = 0; - dsbd.lpwfxFormat = pwfx; - if (m_piDS->CreateSoundBuffer(&dsbd, &m_pMixBuffer, NULL) != DS_OK) - { - Close(); - return false; - } - } else - { - dsbd.dwSize = sizeof(dsbd); - dsbd.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_STICKYFOCUS | DSBCAPS_GETCURRENTPOSITION2; - dsbd.dwBufferBytes = 0; - dsbd.dwReserved = 0; - dsbd.lpwfxFormat = NULL; - if (m_piDS->CreateSoundBuffer(&dsbd, &m_pPrimary, NULL) != DS_OK) - { - Close(); - return false; - } - if (m_pPrimary->SetFormat(pwfx) != DS_OK) - { - Close(); - return false; - } - dsc.dwSize = sizeof(dsc); - if (m_pPrimary->GetCaps(&dsc) != DS_OK) - { - Close(); - return false; - } - m_nDSoundBufferSize = dsc.dwBufferBytes; - m_pMixBuffer = m_pPrimary; - m_pMixBuffer->AddRef(); - } - LPVOID lpBuf1, lpBuf2; - DWORD dwSize1, dwSize2; - if (m_pMixBuffer->Lock(0, m_nDSoundBufferSize, &lpBuf1, &dwSize1, &lpBuf2, &dwSize2, 0) == DS_OK) - { - UINT zero = (pwfx->wBitsPerSample == 8) ? 0x80 : 0x00; - if ((lpBuf1) && (dwSize1)) memset(lpBuf1, zero, dwSize1); - if ((lpBuf2) && (dwSize2)) memset(lpBuf2, zero, dwSize2); - m_pMixBuffer->Unlock(lpBuf1, dwSize1, lpBuf2, dwSize2); - } else - { - DWORD dwStat = 0; - m_pMixBuffer->GetStatus(&dwStat); - if (dwStat & DSBSTATUS_BUFFERLOST) m_pMixBuffer->Restore(); - } - m_RealLatencyMS = m_nDSoundBufferSize * 1000.0f / m_nBytesPerSec; - m_RealUpdateIntervalMS = CLAMP(static_cast<float>(m_Settings.UpdateIntervalMS), 1.0f, m_nDSoundBufferSize * 1000.0f / ( 2.0f * m_nBytesPerSec ) ); - m_dwWritePos = 0xFFFFFFFF; - return true; -} - - -bool CDSoundDevice::InternalClose() -//--------------------------------- -{ - if (m_pMixBuffer) - { - m_pMixBuffer->Release(); - m_pMixBuffer = NULL; - } - if (m_pPrimary) - { - m_pPrimary->Release(); - m_pPrimary = NULL; - } - if (m_piDS) - { - m_piDS->Release(); - m_piDS = NULL; - } - m_bMixRunning = FALSE; - return true; -} - - -void CDSoundDevice::StartFromSoundThread() -//---------------------------------------- -{ - if(!m_pMixBuffer) return; - // done in FillAudioBuffer for now -} - - -void CDSoundDevice::StopFromSoundThread() -//--------------------------------------- -{ - if(m_pMixBuffer) - { - m_pMixBuffer->Stop(); - } - m_bMixRunning = FALSE; -} - - -void CDSoundDevice::ResetFromOutsideSoundThread() -//----------------------------------------------- -{ - if(m_pMixBuffer) - { - m_pMixBuffer->Stop(); - } - m_bMixRunning = FALSE; -} - - -DWORD CDSoundDevice::LockBuffer(DWORD dwBytes, LPVOID *lpBuf1, LPDWORD lpSize1, LPVOID *lpBuf2, LPDWORD lpSize2) -//-------------------------------------------------------------------------------------------------------------- -{ - DWORD d, dwPlay = 0, dwWrite = 0; - - if ((!m_pMixBuffer) || (!m_nDSoundBufferSize)) return 0; - if (m_pMixBuffer->GetCurrentPosition(&dwPlay, &dwWrite) != DS_OK) return 0; - if ((m_dwWritePos >= m_nDSoundBufferSize) || (!m_bMixRunning)) - { - m_dwWritePos = dwWrite; - m_dwLatency = 0; - d = m_nDSoundBufferSize/2; - } else - { - dwWrite = m_dwWritePos; - m_dwLatency = (m_nDSoundBufferSize + dwWrite - dwPlay) % m_nDSoundBufferSize; - if (dwPlay >= dwWrite) - d = dwPlay - dwWrite; - else - d = m_nDSoundBufferSize + dwPlay - dwWrite; - } - if (d > m_nDSoundBufferSize) return FALSE; - if (d > m_nDSoundBufferSize/2) d = m_nDSoundBufferSize/2; - if (dwBytes) - { - if (m_dwLatency > dwBytes) return 0; - if (m_dwLatency+d > dwBytes) d = dwBytes - m_dwLatency; - } - d &= ~0x0f; - if (d <= 16) return 0; - HRESULT hr = m_pMixBuffer->Lock(m_dwWritePos, d, lpBuf1, lpSize1, lpBuf2, lpSize2, 0); - if(hr == DSERR_BUFFERLOST) - { - // buffer lost, restore buffer and try again, fail if it fails again - if(m_pMixBuffer->Restore() != DS_OK) return 0; - if(m_pMixBuffer->Lock(m_dwWritePos, d, lpBuf1, lpSize1, lpBuf2, lpSize2, 0) != DS_OK) return 0; - return d; - } else if(hr != DS_OK) - { - return 0; - } - return d; -} - - -BOOL CDSoundDevice::UnlockBuffer(LPVOID lpBuf1, DWORD dwSize1, LPVOID lpBuf2, DWORD dwSize2) -//------------------------------------------------------------------------------------------ -{ - if (!m_pMixBuffer) return FALSE; - if (m_pMixBuffer->Unlock(lpBuf1, dwSize1, lpBuf2, dwSize2) == DS_OK) - { - m_dwWritePos += dwSize1 + dwSize2; - if (m_dwWritePos >= m_nDSoundBufferSize) m_dwWritePos -= m_nDSoundBufferSize; - return TRUE; - } - return FALSE; -} - - -void CDSoundDevice::FillAudioBuffer() -//----------------------------------- -{ - LPVOID lpBuf1=NULL, lpBuf2=NULL; - DWORD dwSize1=0, dwSize2=0; - DWORD dwBytes; - - if (!m_pMixBuffer) return; - dwBytes = LockBuffer(m_nDSoundBufferSize, &lpBuf1, &dwSize1, &lpBuf2, &dwSize2); - if (dwBytes) - { - if ((lpBuf1) && (dwSize1)) SourceAudioRead(lpBuf1, dwSize1/m_BytesPerSample); - if ((lpBuf2) && (dwSize2)) SourceAudioRead(lpBuf2, dwSize2/m_BytesPerSample); - UnlockBuffer(lpBuf1, dwSize1, lpBuf2, dwSize2); - DWORD dwStatus = 0; - m_pMixBuffer->GetStatus(&dwStatus); - if(!m_bMixRunning || !(dwStatus & DSBSTATUS_PLAYING)) - { - HRESULT hr; - if(!(dwStatus & DSBSTATUS_BUFFERLOST)) - { - // start playing - hr = m_pMixBuffer->Play(0, 0, DSBPLAY_LOOPING); - } else - { - // buffer lost flag is set, do not try start playing, we know it will fail with DSERR_BUFFERLOST. - hr = DSERR_BUFFERLOST; - } - if(hr == DSERR_BUFFERLOST) - { - // buffer lost, restore buffer and try again, fail if it fails again - if(m_pMixBuffer->Restore() != DS_OK) return; - if(m_pMixBuffer->Play(0, 0, DSBPLAY_LOOPING) != DS_OK) return; - } else if(hr != DS_OK) - { - return; - } - m_bMixRunning = TRUE; - } - SourceAudioDone((dwSize1+dwSize2)/m_BytesPerSample, m_dwLatency/m_BytesPerSample); - } -} - -#endif // NO_DIRECTSOUND - - /////////////////////////////////////////////////////////////////////////////////////// // -// ASIO Device implementation -// - -#ifndef NO_ASIO - -#define ASIO_MAX_DRIVERS 8 -#define ASIO_MAXDRVNAMELEN 128 - -typedef struct _ASIODRIVERDESC -{ - CLSID clsid; - CHAR name[80]; -} ASIODRIVERDESC; - -CASIODevice *CASIODevice::gpCurrentAsio = NULL; -LONG CASIODevice::gnFillBuffers = 0; -int CASIODevice::baseChannel = 0; -static UINT gnNumAsioDrivers = 0; -static BOOL gbAsioEnumerated = FALSE; -static ASIODRIVERDESC gAsioDrivers[ASIO_MAX_DRIVERS]; - -static DWORD g_dwBuffer = 0; - -static int g_asio_startcount = 0; - - -BOOL CASIODevice::EnumerateDevices(UINT nIndex, LPSTR pszDescription, UINT cbSize) -//-------------------------------------------------------------------------------- -{ - if (!gbAsioEnumerated) - { - HKEY hkEnum = NULL; - CHAR keyname[ASIO_MAXDRVNAMELEN]; - CHAR s[256]; - WCHAR w[100]; - LONG cr; - DWORD index; - - cr = RegOpenKey(HKEY_LOCAL_MACHINE, "software\\asio", &hkEnum); - index = 0; - while ((cr == ERROR_SUCCESS) && (gnNumAsioDrivers < ASIO_MAX_DRIVERS)) - { - if ((cr = RegEnumKey(hkEnum, index, (LPTSTR)keyname, ASIO_MAXDRVNAMELEN)) == ERROR_SUCCESS) - { - #ifdef ASIO_LOG - Log("ASIO: Found \"%s\":\n", keyname); - #endif - HKEY hksub; - - if ((RegOpenKeyEx(hkEnum, (LPCTSTR)keyname, 0, KEY_READ, &hksub)) == ERROR_SUCCESS) - { - DWORD datatype = REG_SZ; - DWORD datasize = 64; - - if (ERROR_SUCCESS == RegQueryValueEx(hksub, "description", 0, &datatype, (LPBYTE)gAsioDrivers[gnNumAsioDrivers].name, &datasize)) - { - #ifdef ASIO_LOG - Log(" description =\"%s\":\n", gAsioDrivers[gnNumAsioDrivers].name); - #endif - } else - { - lstrcpyn(gAsioDrivers[gnNumAsioDrivers].name, keyname, 64); - } - datatype = REG_SZ; - datasize = sizeof(s); - if (ERROR_SUCCESS == RegQueryValueEx(hksub, "clsid", 0, &datatype, (LPBYTE)s, &datasize)) - { - MultiByteToWideChar(CP_ACP, 0, (LPCSTR)s,-1,(LPWSTR)w,100); - if (CLSIDFromString((LPOLESTR)w, (LPCLSID)&gAsioDrivers[gnNumAsioDrivers].clsid) == S_OK) - { - #ifdef ASIO_LOG - Log(" clsid=\"%s\"\n", s); - #endif - gnNumAsioDrivers++; - } - } - RegCloseKey(hksub); - } - } - index++; - } - if (hkEnum) RegCloseKey(hkEnum); - gbAsioEnumerated = TRUE; - } - if (nIndex < gnNumAsioDrivers) - { - if (pszDescription) lstrcpyn(pszDescription, gAsioDrivers[nIndex].name, cbSize); - return TRUE; - } - return FALSE; -} - - -CASIODevice::CASIODevice() -//------------------------ -{ - m_pAsioDrv = NULL; - m_nChannels = 0; - m_nAsioBufferLen = 0; - m_nAsioSampleSize = 0; - m_Float = false; - m_Callbacks.bufferSwitch = BufferSwitch; - m_Callbacks.sampleRateDidChange = SampleRateDidChange; - m_Callbacks.asioMessage = AsioMessage; - m_Callbacks.bufferSwitchTimeInfo = BufferSwitchTimeInfo; - m_nCurrentDevice = (ULONG)-1; - m_bMixRunning = FALSE; - InterlockedExchange(&m_RenderSilence, 0); - InterlockedExchange(&m_RenderingSilence, 0); -} - - -CASIODevice::~CASIODevice() -//------------------------- -{ - Reset(); - Close(); -} - - -bool CASIODevice::InternalOpen(UINT nDevice) -//------------------------------------------ -{ - bool bOk = false; - - if (IsOpen()) Close(); - if (!gbAsioEnumerated) EnumerateDevices(nDevice, NULL, 0); - if (nDevice >= gnNumAsioDrivers) return false; - if (nDevice != m_nCurrentDevice) - { - m_nCurrentDevice = nDevice; - } -#ifdef ASIO_LOG - Log("CASIODevice::Open(%d:\"%s\"): %d-bit, %d channels, %dHz\n", - nDevice, gAsioDrivers[nDevice].name, (int)m_Settings.sampleFormat.GetBitsPerSample(), m_Settings.Channels, m_Settings.Samplerate); -#endif - OpenDevice(nDevice); - - if (IsOpen()) - { - long nInputChannels = 0, nOutputChannels = 0; - long minSize = 0, maxSize = 0, preferredSize = 0, granularity = 0; - - if(m_Settings.Channels > ASIO_MAX_CHANNELS) - { - goto abort; - } - if((m_Settings.sampleFormat != SampleFormatInt32) && (m_Settings.sampleFormat != SampleFormatFloat32)) - { - goto abort; - } - m_nChannels = m_Settings.Channels; - m_pAsioDrv->getChannels(&nInputChannels, &nOutputChannels); - #ifdef ASIO_LOG - Log(" getChannels: %d inputs, %d outputs\n", nInputChannels, nOutputChannels); - #endif - if (m_Settings.Channels > nOutputChannels) goto abort; - if (m_pAsioDrv->setSampleRate(m_Settings.Samplerate) != ASE_OK) - { - #ifdef ASIO_LOG - Log(" setSampleRate(%d) failed (sample rate not supported)!\n", m_Settings.Samplerate); - #endif - goto abort; - } - for (UINT ich=0; ich<m_Settings.Channels; ich++) - { - m_ChannelInfo[ich].channel = ich; - m_ChannelInfo[ich].isInput = ASIOFalse; - m_pAsioDrv->getChannelInfo(&m_ChannelInfo[ich]); - #ifdef ASIO_LOG - Log(" getChannelInfo(%d): isActive=%d channelGroup=%d type=%d name=\"%s\"\n", - ich, m_ChannelInfo[ich].isActive, m_ChannelInfo[ich].channelGroup, m_ChannelInfo[ich].type, m_ChannelInfo[ich].name); - #endif - m_BufferInfo[ich].isInput = ASIOFalse; - m_BufferInfo[ich].channelNum = ich + CASIODevice::baseChannel; // map MPT channel i to ASIO channel i - m_BufferInfo[ich].buffers[0] = NULL; - m_BufferInfo[ich].buffers[1] = NULL; - m_Float = false; - switch(m_ChannelInfo[ich].type) - { - case ASIOSTInt16MSB: - case ASIOSTInt16LSB: - m_nAsioSampleSize = 2; - break; - case ASIOSTInt24MSB: - case ASIOSTInt24LSB: - m_nAsioSampleSize = 3; - break; - case ASIOSTInt32MSB: - case ASIOSTInt32LSB: - m_nAsioSampleSize = 4; - break; - case ASIOSTInt32MSB16: - case ASIOSTInt32MSB18: - case ASIOSTInt32MSB20: - case ASIOSTInt32MSB24: - case ASIOSTInt32LSB16: - case ASIOSTInt32LSB18: - case ASIOSTInt32LSB20: - case ASIOSTInt32LSB24: - m_nAsioSampleSize = 4; - break; - case ASIOSTFloat32MSB: - case ASIOSTFloat32LSB: - m_Float = true; - m_nAsioSampleSize = 4; - break; - case ASIOSTFloat64MSB: - case ASIOSTFloat64LSB: - m_Float = true; - m_nAsioSampleSize = 8; - break; - default: - m_nAsioSampleSize = 0; - goto abort; - break; - } - } - m_pAsioDrv->getBufferSize(&minSize, &maxSize, &preferredSize, &granularity); - #ifdef ASIO_LOG - Log(" getBufferSize(): minSize=%d maxSize=%d preferredSize=%d granularity=%d\n", - minSize, maxSize, preferredSize, granularity); - #endif - m_nAsioBufferLen = ((m_Settings.LatencyMS * m_Settings.Samplerate) / 2000); - if (m_nAsioBufferLen < (UINT)minSize) m_nAsioBufferLen = minSize; else - if (m_nAsioBufferLen > (UINT)maxSize) m_nAsioBufferLen = maxSize; else - if (granularity < 0) - { - //rewbs.ASIOfix: - /*UINT n = (minSize < 32) ? 32 : minSize; - if (n % granularity) n = (n + granularity - 1) - (n % granularity); - while ((n+(n>>1) < m_nAsioBufferLen) && (n*2 <= (UINT)maxSize)) - { - n *= 2; - } - m_nAsioBufferLen = n;*/ - //end rewbs.ASIOfix - m_nAsioBufferLen = preferredSize; - - } else - if (granularity > 0) - { - int n = (minSize < 32) ? 32 : minSize; - n = (n + granularity-1); - n -= (n % granularity); - while ((n+(granularity>>1) < (int)m_nAsioBufferLen) && (n+granularity <= maxSize)) - { - n += granularity; - } - m_nAsioBufferLen = n; - } - m_RealLatencyMS = m_nAsioBufferLen * 2 * 1000.0f / m_Settings.Samplerate; - m_RealUpdateIntervalMS = m_nAsioBufferLen * 1000.0f / m_Settings.Samplerate; - #ifdef ASIO_LOG - Log(" Using buffersize=%d samples\n", m_nAsioBufferLen); - #endif - if (m_pAsioDrv->createBuffers(m_BufferInfo, m_nChannels, m_nAsioBufferLen, &m_Callbacks) == ASE_OK) - { - for (UINT iInit=0; iInit<m_nChannels; iInit++) - { - if (m_BufferInfo[iInit].buffers[0]) - { - memset(m_BufferInfo[iInit].buffers[0], 0, m_nAsioBufferLen * m_nAsioSampleSize); - } - if (m_BufferInfo[iInit].buffers[1]) - { - memset(m_BufferInfo[iInit].buffers[1], 0, m_nAsioBufferLen * m_nAsioSampleSize); - } - } - m_bPostOutput = (m_pAsioDrv->outputReady() == ASE_OK) ? TRUE : FALSE; - bOk = true; - } - #ifdef ASIO_LOG - else Log(" createBuffers failed!\n"); - #endif - } -abort: - if (bOk) - { - gpCurrentAsio = this; - gnFillBuffers = 2; - } else - { - #ifdef ASIO_LOG - Log("Error opening ASIO device!\n"); - #endif - CloseDevice(); - } - return bOk; -} - - -void CASIODevice::SetRenderSilence(bool silence, bool wait) -//--------------------------------------------------------- -{ - InterlockedExchange(&m_RenderSilence, silence?1:0); - if(!wait) - { - return; - } - DWORD pollingstart = GetTickCount(); - while(InterlockedExchangeAdd(&m_RenderingSilence, 0) != (silence?1:0)) - { - if(GetTickCount() - pollingstart > 250) - { - if(silence) - { - if(CriticalSection::IsLocked()) - { - ASSERT_WARN_MESSAGE(false, "AudioCriticalSection locked while stopping ASIO"); - } else - { - ASSERT_WARN_MESSAGE(false, "waiting for asio failed in Stop()"); - } - } else - { - if(CriticalSection::IsLocked()) - { - ASSERT_WARN_MESSAGE(false, "AudioCriticalSection locked while starting ASIO"); - } else - { - ASSERT_WARN_MESSAGE(false, "waiting for asio failed in Start()"); - } - } - break; - } - Sleep(1); - } -} - - -void CASIODevice::InternalStart() -//------------------------------- -{ - ALWAYS_ASSERT_WARN_MESSAGE(!CriticalSection::IsLocked(), "AudioCriticalSection locked while starting ASIO"); - - ALWAYS_ASSERT(g_asio_startcount==0); - g_asio_startcount++; - - if(!m_bMixRunning) - { - SetRenderSilence(false); - m_bMixRunning = TRUE; - try - { - m_pAsioDrv->start(); - } catch(...) - { - CASIODevice::ReportASIOException("ASIO crash in start()\n"); - m_bMixRunning = FALSE; - } - } else - { - SetRenderSilence(false, true); - } -} - - -void CASIODevice::InternalStop() -//------------------------------ -{ - ALWAYS_ASSERT(g_asio_startcount==1); - ALWAYS_ASSERT_WARN_MESSAGE(!CriticalSection::IsLocked(), "AudioCriticalSection locked while stopping ASIO"); - - SetRenderSilence(true, true); - g_asio_startcount--; - ALWAYS_ASSERT(g_asio_startcount==0); -} - - -bool CASIODevice::InternalClose() -//------------------------------- -{ - if (IsOpen()) - { - Stop(); - if (m_bMixRunning) - { - m_bMixRunning = FALSE; - ALWAYS_ASSERT(g_asio_startcount==0); - try - { - m_pAsioDrv->stop(); - } catch(...) - { - CASIODevice::ReportASIOException("ASIO crash in stop()\n"); - } - } - g_asio_startcount = 0; - SetRenderSilence(false); - try - { - m_pAsioDrv->disposeBuffers(); - } catch(...) - { - CASIODevice::ReportASIOException("ASIO crash in disposeBuffers()\n"); - } - CloseDevice(); - } - if (gpCurrentAsio == this) - { - gpCurrentAsio = NULL; - } - return true; -} - - -void CASIODevice::InternalReset() -//------------------------------- -{ - if(IsOpen()) - { - Stop(); - if(m_bMixRunning) - { - m_bMixRunning = FALSE; - ALWAYS_ASSERT(g_asio_startcount==0); - try - { - m_pAsioDrv->stop(); - } catch(...) - { - CASIODevice::ReportASIOException("ASIO crash in stop()\n"); - } - g_asio_startcount = 0; - SetRenderSilence(false); - } - } -} - - -void CASIODevice::OpenDevice(UINT nDevice) -//---------------------------------------- -{ - if (IsOpen()) - { - return; - } - - CLSID clsid = gAsioDrivers[nDevice].clsid; - if (CoCreateInstance(clsid,0,CLSCTX_INPROC_SERVER, clsid, (void **)&m_pAsioDrv) == S_OK) - { - m_pAsioDrv->init((void *)m_Settings.hWnd); - } else - { -#ifdef ASIO_LOG - Log(" CoCreateInstance failed!\n"); -#endif - m_pAsioDrv = NULL; - } -} - - -void CASIODevice::CloseDevice() -//----------------------------- -{ - if (IsOpen()) - { - try - { - m_pAsioDrv->Release(); - } catch(...) - { - CASIODevice::ReportASIOException("ASIO crash in Release()\n"); - } - m_pAsioDrv = NULL; - } -} - - -static void SwapEndian(uint8 *buf, std::size_t itemCount, std::size_t itemSize) -//----------------------------------------------------------------------------- -{ - for(std::size_t i = 0; i < itemCount; ++i) - { - std::reverse(buf, buf + itemSize); - buf += itemSize; - } -} - - -void CASIODevice::FillAudioBuffer() -//--------------------------------- -{ - bool rendersilence = (InterlockedExchangeAdd(&m_RenderSilence, 0) == 1); - - std::size_t sampleFrameSize = m_nChannels * sizeof(int32); - const std::size_t sampleFramesGoal = m_nAsioBufferLen; - std::size_t sampleFramesToRender = sampleFramesGoal; - std::size_t sampleFramesRendered = 0; - const std::size_t countChunkMax = (ASIO_BLOCK_LEN * sizeof(int32)) / sampleFrameSize; - - g_dwBuffer &= 1; - //Log("FillAudioBuffer(%d): dwSampleSize=%d dwSamplesLeft=%d dwFrameLen=%d\n", g_dwBuffer, sampleFrameSize, dwSamplesLeft, dwFrameLen); - while(sampleFramesToRender > 0) - { - const std::size_t countChunk = std::min(sampleFramesToRender, countChunkMax); - if(rendersilence) - { - memset(m_FrameBuffer, 0, countChunk * sampleFrameSize); - } else - { - SourceAudioRead(m_FrameBuffer, countChunk); - } - for(int channel = 0; channel < (int)m_nChannels; ++channel) - { - const int32 *src = m_FrameBuffer; - const float *srcFloat = reinterpret_cast<const float*>(m_FrameBuffer); - void *dst = (char*)m_BufferInfo[channel].buffers[g_dwBuffer] + m_nAsioSampleSize * sampleFramesRendered; - if(m_Float) switch(m_ChannelInfo[channel].type) - { - case ASIOSTFloat32MSB: - case ASIOSTFloat32LSB: - CopyInterleavedToChannel<SC::Convert<float, float> >(reinterpret_cast<float*>(dst), srcFloat, m_nChannels, countChunk, channel); - break; - case ASIOSTFloat64MSB: - case ASIOSTFloat64LSB: - CopyInterleavedToChannel<SC::Convert<double, float> >(reinterpret_cast<double*>(dst), srcFloat, m_nChannels, countChunk, channel); - break; - default: - ASSERT(false); - break; - } else switch(m_ChannelInfo[channel].type) - { - case ASIOSTInt16MSB: - case ASIOSTInt16LSB: - CopyInterleavedToChannel<SC::Convert<int16, int32> >(reinterpret_cast<int16*>(dst), src, m_nChannels, countChunk, channel); - break; - case ASIOSTInt24MSB: - case ASIOSTInt24LSB: - CopyInterleavedToChannel<SC::Convert<int24, int32> >(reinterpret_cast<int24*>(dst), src, m_nChannels, countChunk, channel); - break; - case ASIOSTInt32MSB: - case ASIOSTInt32LSB: - CopyInterleavedToChannel<SC::Convert<int32, int32> >(reinterpret_cast<int32*>(dst), src, m_nChannels, countChunk, channel); - break; - case ASIOSTFloat32MSB: - case ASIOSTFloat32LSB: - CopyInterleavedToChannel<SC::Convert<float, int32> >(reinterpret_cast<float*>(dst), src, m_nChannels, countChunk, channel); - break; - case ASIOSTFloat64MSB: - case ASIOSTFloat64LSB: - CopyInterleavedToChannel<SC::Convert<double, int32> >(reinterpret_cast<double*>(dst), src, m_nChannels, countChunk, channel); - break; - case ASIOSTInt32MSB16: - case ASIOSTInt32LSB16: - CopyInterleavedToChannel<SC::ConvertShift<int32, int32, 16> >(reinterpret_cast<int32*>(dst), src, m_nChannels, countChunk, channel); - break; - case ASIOSTInt32MSB18: - case ASIOSTInt32LSB18: - CopyInterleavedToChannel<SC::ConvertShift<int32, int32, 14> >(reinterpret_cast<int32*>(dst), src, m_nChannels, countChunk, channel); - break; - case ASIOSTInt32MSB20: - case ASIOSTInt32LSB20: - CopyInterleavedToChannel<SC::ConvertShift<int32, int32, 12> >(reinterpret_cast<int32*>(dst), src, m_nChannels, countChunk, channel); - break; - case ASIOSTInt32MSB24: - case ASIOSTInt32LSB24: - CopyInterleavedToChannel<SC::ConvertShift<int32, int32, 8> >(reinterpret_cast<int32*>(dst), src, m_nChannels, countChunk, channel); - break; - default: - ASSERT(false); - break; - } - switch(m_ChannelInfo[channel].type) - { - case ASIOSTInt16MSB: - case ASIOSTInt24MSB: - case ASIOSTInt32MSB: - case ASIOSTFloat32MSB: - case ASIOSTFloat64MSB: - case ASIOSTInt32MSB16: - case ASIOSTInt32MSB18: - case ASIOSTInt32MSB20: - case ASIOSTInt32MSB24: - SwapEndian(reinterpret_cast<uint8*>(dst), countChunk, m_nAsioSampleSize); - break; - } - } - sampleFramesToRender -= countChunk; - sampleFramesRendered += countChunk; - } - if(m_bPostOutput) - { - m_pAsioDrv->outputReady(); - } - if(!rendersilence) - { - SourceAudioDone(sampleFramesRendered, m_nAsioBufferLen); - } - return; -} - - -void CASIODevice::BufferSwitch(long doubleBufferIndex) -//---------------------------------------------------- -{ - g_dwBuffer = doubleBufferIndex; - bool rendersilence = (InterlockedExchangeAdd(&m_RenderSilence, 0) == 1); - InterlockedExchange(&m_RenderingSilence, rendersilence ? 1 : 0 ); - if(rendersilence) - { - FillAudioBuffer(); - } else - { - SourceFillAudioBufferLocked(); - } -} - - -void CASIODevice::BufferSwitch(long doubleBufferIndex, ASIOBool directProcess) -//---------------------------------------------------------------------------- -{ - UNREFERENCED_PARAMETER(directProcess); - if(gpCurrentAsio) - { - gpCurrentAsio->BufferSwitch(doubleBufferIndex); - } else - { - ALWAYS_ASSERT(false && "gpCurrentAsio"); - } -} - - -void CASIODevice::SampleRateDidChange(ASIOSampleRate sRate) -//--------------------------------------------------------- -{ - UNREFERENCED_PARAMETER(sRate); -} - - -long CASIODevice::AsioMessage(long selector, long value, void* message, double* opt) -//---------------------------------------------------------------------------------- -{ - UNREFERENCED_PARAMETER(value); - UNREFERENCED_PARAMETER(message); - UNREFERENCED_PARAMETER(opt); -#ifdef ASIO_LOG - // Log("AsioMessage(%d, %d)\n", selector, value); -#endif - switch(selector) - { - case kAsioEngineVersion: return 2; - } - return 0; -} - - -ASIOTime* CASIODevice::BufferSwitchTimeInfo(ASIOTime* params, long doubleBufferIndex, ASIOBool directProcess) -//----------------------------------------------------------------------------------------------------------- -{ - BufferSwitch(doubleBufferIndex, directProcess); - return params; -} - - -BOOL CASIODevice::ReportASIOException(LPCSTR format,...) -//------------------------------------------------------ -{ - CHAR cBuf[1024]; - va_list va; - va_start(va, format); - wvsprintf(cBuf, format, va); - Reporting::Notification(cBuf); - Log(cBuf); - va_end(va); - - return TRUE; -} - - -bool CASIODevice::CanSampleRate(UINT nDevice, std::vector<UINT> &samplerates, std::vector<bool> &result) -//------------------------------------------------------------------------------------------------------ -{ - const bool wasOpen = (m_pAsioDrv != NULL); - if(!wasOpen) - { - OpenDevice(nDevice); - if(m_pAsioDrv == NULL) - { - return false; - } - } - - bool foundSomething = false; // is at least one sample rate supported by the device? - result.clear(); - for(size_t i = 0; i < samplerates.size(); i++) - { - result.push_back((m_pAsioDrv->canSampleRate((ASIOSampleRate)samplerates[i]) == ASE_OK)); - if(result.back()) - { - foundSomething = true; - } - } - - if(!wasOpen) - { - CloseDevice(); - } - - return foundSomething; -} - - -// If the device is open, this returns the current sample rate. If it's not open, it returns some sample rate supported by the device. -UINT CASIODevice::GetCurrentSampleRate(UINT nDevice) -//-------------------------------------------------- -{ - const bool wasOpen = (m_pAsioDrv != NULL); - if(!wasOpen) - { - OpenDevice(nDevice); - if(m_pAsioDrv == NULL) - { - return 0; - } - } - - ASIOSampleRate samplerate; - if(m_pAsioDrv->getSampleRate(&samplerate) != ASE_OK) - { - samplerate = 0; - } - - if(!wasOpen) - { - CloseDevice(); - } - - return (UINT)samplerate; -} - -#endif // NO_ASIO - - -/////////////////////////////////////////////////////////////////////////////////////// -// -// Portaudio Device implementation -// - -#ifndef NO_PORTAUDIO - -CPortaudioDevice::CPortaudioDevice(PaHostApiIndex hostapi) -//-------------------------------------------------------- -{ - m_HostApi = hostapi; - MemsetZero(m_StreamParameters); - m_Stream = 0; - m_CurrentFrameCount = 0; - m_CurrentRealLatencyMS = 0.0f; -} - - -CPortaudioDevice::~CPortaudioDevice() -//----------------------------------- -{ - Reset(); - Close(); -} - - -bool CPortaudioDevice::InternalOpen(UINT nDevice) -//----------------------------------------------- -{ - MemsetZero(m_StreamParameters); - m_Stream = 0; - m_CurrentFrameBuffer = 0; - m_CurrentFrameCount = 0; - m_StreamParameters.device = HostApiOutputIndexToGlobalDeviceIndex(nDevice, m_HostApi); - if(m_StreamParameters.device == -1) return false; - m_StreamParameters.channelCount = m_Settings.Channels; - if(m_Settings.sampleFormat.IsFloat()) - { - if(m_Settings.sampleFormat.GetBitsPerSample() != 32) return false; - m_StreamParameters.sampleFormat = paFloat32; - } else - { - switch(m_Settings.sampleFormat.GetBitsPerSample()) - { - case 8: m_StreamParameters.sampleFormat = paUInt8; break; - case 16: m_StreamParameters.sampleFormat = paInt16; break; - case 24: m_StreamParameters.sampleFormat = paInt24; break; - case 32: m_StreamParameters.sampleFormat = paInt32; break; - default: return false; break; - } - } - m_StreamParameters.suggestedLatency = m_Settings.LatencyMS / 1000.0; - m_StreamParameters.hostApiSpecificStreamInfo = NULL; - if((m_HostApi == Pa_HostApiTypeIdToHostApiIndex(paWASAPI)) && (m_Settings.fulCfgOptions & SNDDEV_OPTIONS_EXCLUSIVE)) - { - MemsetZero(m_WasapiStreamInfo); - m_WasapiStreamInfo.size = sizeof(PaWasapiStreamInfo); - m_WasapiStreamInfo.hostApiType = paWASAPI; - m_WasapiStreamInfo.version = 1; - m_WasapiStreamInfo.flags = paWinWasapiExclusive; - m_StreamParameters.hostApiSpecificStreamInfo = &m_WasapiStreamInfo; - } - if(Pa_IsFormatSupported(NULL, &m_StreamParameters, m_Settings.Samplerate) != paFormatIsSupported) return false; - if(Pa_OpenStream(&m_Stream, NULL, &m_StreamParameters, m_Settings.Samplerate, /*static_cast<long>(m_UpdateIntervalMS * pwfx->nSamplesPerSec / 1000.0f)*/ paFramesPerBufferUnspecified, paNoFlag, StreamCallbackWrapper, (void*)this) != paNoError) return false; - if(!Pa_GetStreamInfo(m_Stream)) - { - Pa_CloseStream(m_Stream); - m_Stream = 0; - return false; - } - m_RealLatencyMS = static_cast<float>(Pa_GetStreamInfo(m_Stream)->outputLatency) * 1000.0f; - m_RealUpdateIntervalMS = static_cast<float>(m_Settings.UpdateIntervalMS); - return true; -} - - -bool CPortaudioDevice::InternalClose() -//------------------------------------ -{ - if(m_Stream) - { - Pa_AbortStream(m_Stream); - Pa_CloseStream(m_Stream); - if(Pa_GetDeviceInfo(m_StreamParameters.device)->hostApi == Pa_HostApiTypeIdToHostApiIndex(paWDMKS)) Pa_Sleep((long)(m_RealLatencyMS*2)); // wait for broken wdm drivers not closing the stream immediatly - MemsetZero(m_StreamParameters); - m_Stream = 0; - m_CurrentFrameCount = 0; - m_CurrentFrameBuffer = 0; - } - return true; -} - - -void CPortaudioDevice::InternalReset() -//------------------------------------ -{ - Pa_AbortStream(m_Stream); -} - - -void CPortaudioDevice::InternalStart() -//------------------------------------ -{ - Pa_StartStream(m_Stream); -} - - -void CPortaudioDevice::InternalStop() -//----------------------------------- -{ - Pa_StopStream(m_Stream); -} - - -void CPortaudioDevice::FillAudioBuffer() -//-------------------------------------- -{ - if(m_CurrentFrameCount == 0) return; - SourceAudioRead(m_CurrentFrameBuffer, m_CurrentFrameCount); - SourceAudioDone(m_CurrentFrameCount, static_cast<ULONG>(m_CurrentRealLatencyMS * Pa_GetStreamInfo(m_Stream)->sampleRate / 1000.0f)); -} - - -int64 CPortaudioDevice::GetStreamPositionSamples() const -//------------------------------------------------------ -{ - if(!IsOpen()) return 0; - if(Pa_IsStreamActive(m_Stream) != 1) return 0; - return static_cast<int64>(Pa_GetStreamTime(m_Stream) * Pa_GetStreamInfo(m_Stream)->sampleRate); -} - - -float CPortaudioDevice::GetCurrentRealLatencyMS() -//----------------------------------------------- -{ - if(!IsOpen()) return 0.0f; - return m_CurrentRealLatencyMS; -} - - -bool CPortaudioDevice::CanSampleRate(UINT nDevice, std::vector<UINT> &samplerates, std::vector<bool> &result) -//----------------------------------------------------------------------------------------------------------- -{ - result.clear(); - for(UINT n=0; n<samplerates.size(); n++) - { - PaStreamParameters StreamParameters; - MemsetZero(StreamParameters); - StreamParameters.device = HostApiOutputIndexToGlobalDeviceIndex(nDevice, m_HostApi); - if(StreamParameters.device == -1) - { - result.assign(samplerates.size(), false); - return false; - } - StreamParameters.channelCount = 2; - StreamParameters.sampleFormat = paInt16; - StreamParameters.suggestedLatency = 0.0; - StreamParameters.hostApiSpecificStreamInfo = NULL; - if((m_HostApi == Pa_HostApiTypeIdToHostApiIndex(paWASAPI)) && (m_Settings.fulCfgOptions & SNDDEV_OPTIONS_EXCLUSIVE)) - { - MemsetZero(m_WasapiStreamInfo); - m_WasapiStreamInfo.size = sizeof(PaWasapiStreamInfo); - m_WasapiStreamInfo.hostApiType = paWASAPI; - m_WasapiStreamInfo.version = 1; - m_WasapiStreamInfo.flags = paWinWasapiExclusive; - m_StreamParameters.hostApiSpecificStreamInfo = &m_WasapiStreamInfo; - } - result.push_back(Pa_IsFormatSupported(NULL, &StreamParameters, samplerates[n]) == paFormatIsSupported); - } - return true; -} - - -int CPortaudioDevice::StreamCallback( - const void *input, void *output, - unsigned long frameCount, - const PaStreamCallbackTimeInfo* timeInfo, - PaStreamCallbackFlags statusFlags - ) -//----------------------------------------- -{ - UNREFERENCED_PARAMETER(input); - UNREFERENCED_PARAMETER(statusFlags); - if(!output) return paAbort; - m_CurrentRealLatencyMS = static_cast<float>( timeInfo->outputBufferDacTime - timeInfo->currentTime ) * 1000.0f; - m_CurrentFrameBuffer = output; - m_CurrentFrameCount = frameCount; - SourceFillAudioBufferLocked(); - m_CurrentFrameCount = 0; - m_CurrentFrameBuffer = 0; - return paContinue; -} - - -int CPortaudioDevice::StreamCallbackWrapper( - const void *input, void *output, - unsigned long frameCount, - const PaStreamCallbackTimeInfo* timeInfo, - PaStreamCallbackFlags statusFlags, - void *userData - ) -//------------------------------------------ -{ - return ((CPortaudioDevice*)userData)->StreamCallback(input, output, frameCount, timeInfo, statusFlags); -} - - -PaDeviceIndex CPortaudioDevice::HostApiOutputIndexToGlobalDeviceIndex(int hostapioutputdeviceindex, PaHostApiIndex hostapi) -//------------------------------------------------------------------------------------------------------------------- -{ - if(hostapi < 0) - return -1; - if(hostapi >= Pa_GetHostApiCount()) - return -1; - if(!Pa_GetHostApiInfo(hostapi)) - return -1; - if(hostapioutputdeviceindex < 0) - return -1; - if(hostapioutputdeviceindex >= Pa_GetHostApiInfo(hostapi)->deviceCount) - return -1; - int dev = hostapioutputdeviceindex; - for(int hostapideviceindex=0; hostapideviceindex<Pa_GetHostApiInfo(hostapi)->deviceCount; hostapideviceindex++) - { - if(!Pa_GetDeviceInfo(Pa_HostApiDeviceIndexToDeviceIndex(hostapi, hostapideviceindex))) - { - dev++; // skip this device - continue; - } - if(Pa_GetDeviceInfo(Pa_HostApiDeviceIndexToDeviceIndex(hostapi, hostapideviceindex))->maxOutputChannels == 0) - { - dev++; // skip this device - continue; - } - if(dev == hostapideviceindex) - { - break; - } - } - if(dev >= Pa_GetHostApiInfo(hostapi)->deviceCount) - return -1; - return Pa_HostApiDeviceIndexToDeviceIndex(hostapi, dev); -} - - -int CPortaudioDevice::HostApiToSndDevType(PaHostApiIndex hostapi) -//--------------------------------------------------------------- -{ - if(hostapi == Pa_HostApiTypeIdToHostApiIndex(paWASAPI)) return SNDDEV_PORTAUDIO_WASAPI; - if(hostapi == Pa_HostApiTypeIdToHostApiIndex(paWDMKS)) return SNDDEV_PORTAUDIO_WDMKS; - if(hostapi == Pa_HostApiTypeIdToHostApiIndex(paMME)) return SNDDEV_PORTAUDIO_WMME; - if(hostapi == Pa_HostApiTypeIdToHostApiIndex(paDirectSound)) return SNDDEV_PORTAUDIO_DS; - if(hostapi == Pa_HostApiTypeIdToHostApiIndex(paASIO)) return SNDDEV_PORTAUDIO_ASIO; - return -1; -} - - -PaHostApiIndex CPortaudioDevice::SndDevTypeToHostApi(int snddevtype) -//------------------------------------------------------------------ -{ - if(snddevtype == SNDDEV_PORTAUDIO_WASAPI) return Pa_HostApiTypeIdToHostApiIndex(paWASAPI); - if(snddevtype == SNDDEV_PORTAUDIO_WDMKS) return Pa_HostApiTypeIdToHostApiIndex(paWDMKS); - if(snddevtype == SNDDEV_PORTAUDIO_WMME) return Pa_HostApiTypeIdToHostApiIndex(paMME); - if(snddevtype == SNDDEV_PORTAUDIO_DS) return Pa_HostApiTypeIdToHostApiIndex(paDirectSound); - if(snddevtype == SNDDEV_PORTAUDIO_ASIO) return Pa_HostApiTypeIdToHostApiIndex(paASIO); - return paInDevelopment; -} - - -BOOL CPortaudioDevice::EnumerateDevices(UINT nIndex, LPSTR pszDescription, UINT cbSize, PaHostApiIndex hostapi) -//------------------------------------------------------------------------------------------------------------- -{ - memset(pszDescription, 0, cbSize); - PaDeviceIndex dev = HostApiOutputIndexToGlobalDeviceIndex(nIndex, hostapi); - if(dev == -1) - return false; - if(!Pa_GetDeviceInfo(dev)) - return false; - _snprintf(pszDescription, cbSize, "%s - %s%s (portaudio)", - Pa_GetHostApiInfo(Pa_GetDeviceInfo(dev)->hostApi)->name, - Pa_GetDeviceInfo(dev)->name, - Pa_GetHostApiInfo(Pa_GetDeviceInfo(dev)->hostApi)->defaultOutputDevice == (PaDeviceIndex)dev ? " (Default)" : "" - ); - return true; -} - -#endif - - -/////////////////////////////////////////////////////////////////////////////////////// -// // Global Functions // -static bool g_PortaudioInitialized = false; - - BOOL EnumerateSoundDevices(UINT nType, UINT nIndex, LPSTR pszDesc, UINT cbSize) //----------------------------------------------------------------------------- { @@ -2169,7 +582,7 @@ case SNDDEV_PORTAUDIO_WMME: case SNDDEV_PORTAUDIO_DS: case SNDDEV_PORTAUDIO_ASIO: - return g_PortaudioInitialized ? CPortaudioDevice::EnumerateDevices(nIndex, pszDesc, cbSize, CPortaudioDevice::SndDevTypeToHostApi(nType)) : FALSE; + return SndDevPortaudioIsInitialized() ? CPortaudioDevice::EnumerateDevices(nIndex, pszDesc, cbSize, CPortaudioDevice::SndDevTypeToHostApi(nType)) : FALSE; break; #endif } @@ -2195,7 +608,7 @@ case SNDDEV_PORTAUDIO_WMME: case SNDDEV_PORTAUDIO_DS: case SNDDEV_PORTAUDIO_ASIO: - return g_PortaudioInitialized ? new CPortaudioDevice(CPortaudioDevice::SndDevTypeToHostApi(nType)) : nullptr; + return SndDevPortaudioIsInitialized() ? new CPortaudioDevice(CPortaudioDevice::SndDevTypeToHostApi(nType)) : nullptr; break; #endif } @@ -2203,69 +616,6 @@ } -#ifndef NO_PORTAUDIO - -static void SndDevPortaudioInitialize() -//------------------------------------- -{ - // try loading delay-loaded dll, if it fails, portaudio gets disabled automatically - if(Pa_Initialize() != paNoError) return; - g_PortaudioInitialized = true; -} - - -static void SndDevPortaudioUnnitialize() -//-------------------------------------- -{ - if(!g_PortaudioInitialized) return; - Pa_Terminate(); - g_PortaudioInitialized = false; -} - -#endif // NO_PORTAUDIO - - -#ifndef NO_DSOUND - -static BOOL SndDevDSoundInitialize() -//---------------------------------- -{ - if (ghDSoundDLL) return TRUE; - if ((ghDSoundDLL = LoadLibrary("dsound.dll")) == NULL) return FALSE; - static_assert(sizeof(TCHAR) == 1, "Check DirectSoundEnumerateA below"); - if ((gpDSoundEnumerate = (LPDSOUNDENUMERATE)GetProcAddress(ghDSoundDLL, "DirectSoundEnumerateA")) == NULL) return FALSE; - if ((gpDSoundCreate = (LPDSOUNDCREATE)GetProcAddress(ghDSoundDLL, "DirectSoundCreate")) == NULL) return FALSE; - MemsetZero(glpDSoundGUID); - return TRUE; -} - - -static BOOL SndDevDSoundUninitialize() -//------------------------------------ -{ - gpDSoundEnumerate = NULL; - gpDSoundCreate = NULL; - if (ghDSoundDLL) - { - FreeLibrary(ghDSoundDLL); - ghDSoundDLL = NULL; - } - for (UINT i=0; i<MAX_DSOUND_DEVICES; i++) - { - if (glpDSoundGUID[i]) - { - delete glpDSoundGUID[i]; - glpDSoundGUID[i] = NULL; - } - } - gbDSoundEnumerated = FALSE; - gnDSoundDevices = 0; - return TRUE; -} - -#endif // NO_DSOUND - - BOOL SndDevInitialize() //--------------------- { Copied: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp (from rev 2625, trunk/OpenMPT/sounddev/SoundDevice.cpp) =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp (rev 0) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2013-09-01 10:31:18 UTC (rev 2626) @@ -0,0 +1,766 @@ +/* + * SoundDeviceASIO.cpp + * ------------------- + * Purpose: ASIO sound device driver class. + * Notes : (currently none) + * Authors: Olivier Lapicque + * OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#include "stdafx.h" + +#include "SoundDevice.h" +#include "SoundDevices.h" + +#include "SoundDeviceASIO.h" + +#include "../common/misc_util.h" +#ifdef MODPLUG_TRACKER +#include "../mptrack/Reporting.h" +#endif +#include "../common/StringFixer.h" +#include "../soundlib/SampleFormatConverters.h" + +// DEBUG: +#include "../common/AudioCriticalSection.h" + +#include <algorithm> + + +/////////////////////////////////////////////////////////////////////////////////////// +// +// ASIO Device implementation +// + +#ifndef NO_ASIO + +#define ASIO_MAX_DRIVERS 8 +#define ASIO_MAXDRVNAMELEN 128 + +typedef struct _ASIODRIVERDESC +{ + CLSID clsid; + CHAR name[80]; +} ASIODRIVERDESC; + +CASIODevice *CASIODevice::gpCurrentAsio = NULL; +LONG CASIODevice::gnFillBuffers = 0; +int CASIODevice::baseChannel = 0; +static UINT gnNumAsioDrivers = 0; +static BOOL gbAsioEnumerated = FALSE; +static ASIODRIVERDESC gAsioDrivers[ASIO_MAX_DRIVERS]; + +static DWORD g_dwBuffer = 0; + +static int g_asio_startcount = 0; + + +BOOL CASIODevice::EnumerateDevices(UINT nIndex, LPSTR pszDescription, UINT cbSize) +//-------------------------------------------------------------------------------- +{ + if (!gbAsioEnumerated) + { + HKEY hkEnum = NULL; + CHAR keyname[ASIO_MAXDRVNAMELEN]; + CHAR s[256]; + WCHAR w[100]; + LONG cr; + DWORD index; + + cr = RegOpenKey(HKEY_LOCAL_MACHINE, "software\\asio", &hkEnum); + index = 0; + while ((cr == ERROR_SUCCESS) && (gnNumAsioDrivers < ASIO_MAX_DRIVERS)) + { + if ((cr = RegEnumKey(hkEnum, index, (LPTSTR)keyname, ASIO_MAXDRVNAMELEN)) == ERROR_SUCCESS) + { + #ifdef ASIO_LOG + Log("ASIO: Found \"%s\":\n", keyname); + #endif + HKEY hksub; + + if ((RegOpenKeyEx(hkEnum, (LPCTSTR)keyname, 0, KEY_READ, &hksub)) == ERROR_SUCCESS) + { + DWORD datatype = REG_SZ; + DWORD datasize = 64; + + if (ERROR_SUCCESS == RegQueryValueEx(hksub, "description", 0, &datatype, (LPBYTE)gAsioDrivers[gnNumAsioDrivers].name, &datasize)) + { + #ifdef ASIO_LOG + Log(" description =\"%s\":\n", gAsioDrivers[gnNumAsioDrivers].name); + #endif + } else + { + lstrcpyn(gAsioDrivers[gnNumAsioDrivers].name, keyname, 64); + } + datatype = REG_SZ; + datasize = sizeof(s); + if (ERROR_SUCCESS == RegQueryValueEx(hksub, "clsid", 0, &datatype, (LPBYTE)s, &datasize)) + { + MultiByteToWideChar(CP_ACP, 0, (LPCSTR)s,-1,(LPWSTR)w,100); + if (CLSIDFromString((LPOLESTR)w, (LPCLSID)&gAsioDrivers[gnNumAsioDrivers].clsid) == S_OK) + { + #ifdef ASIO_LOG + Log(" clsid=\"%s\"\n", s); + #endif + gnNumAsioDrivers++; + } + } + RegCloseKey(hksub); + } + } + index++; + } + if (hkEnum) RegCloseKey(hkEnum); + gbAsioEnumerated = TRUE; + } + if (nIndex < gnNumAsioDrivers) + { + if (pszDescription) lstrcpyn(pszDescription, gAsioDrivers[nIndex].name, cbSize); + return TRUE; + } + return FALSE; +} + + +CASIODevice::CASIODevice() +//------------------------ +{ + m_pAsioDrv = NULL; + m_nChannels = 0; + m_nAsioBufferLen = 0; + m_nAsioSampleSize = 0; + m_Float = false; + m_Callbacks.bufferSwitch = BufferSwitch; + m_Callbacks.sampleRateDidChange = SampleRateDidChange; + m_Callbacks.asioMessage = AsioMessage; + m_Callbacks.bufferSwitchTimeInfo = BufferSwitchTimeInfo; + m_nCurrentDevice = (ULONG)-1; + m_bMixRunning = FALSE; + InterlockedExchange(&m_RenderSilence, 0); + InterlockedExchange(&m_RenderingSilence, 0); +} + + +CASIODevice::~CASIODevice() +//------------------------- +{ + Reset(); + Close(); +} + + +bool CASIODevice::InternalOpen(UINT nDevice) +//------------------------------------------ +{ + bool bOk = false; + + if (IsOpen()) Close(); + if (!gbAsioEnumerated) EnumerateDevices(nDevice, NULL, 0); + if (nDevice >= gnNumAsioDrivers) return false; + if (nDevice != m_nCurrentDevice) + { + m_nCurrentDevice = nDevice; + } +#ifdef ASIO_LOG + Log("CASIODevice::Open(%d:\"%s\"): %d-bit, %d channels, %dHz\n", + nDevice, gAsioDrivers[nDevice].name, (int)m_Settings.sampleFormat.GetBitsPerSample(), m_Settings.Channels, m_Settings.Samplerate); +#endif + OpenDevice(nDevice); + + if (IsOpen()) + { + long nInputChannels = 0, nOutputChannels = 0; + long minSize = 0, maxSize = 0, preferredSize = 0, granularity = 0; + + if(m_Settings.Channels > ASIO_MAX_CHANNELS) + { + goto abort; + } + if((m_Settings.sampleFormat != SampleFormatInt32) && (m_Settings.sampleFormat != SampleFormatFloat32)) + { + goto abort; + } + m_nChannels = m_Settings.Channels; + m_pAsioDrv->getChannels(&nInputChannels, &nOutputChannels); + #ifdef ASIO_LOG + Log(" getChannels: %d inputs, %d outputs\n", nInputChannels, nOutputChannels); + #e... [truncated message content] |