From: <sag...@us...> - 2015-06-12 15:15:12
|
Revision: 5293 http://sourceforge.net/p/modplug/code/5293 Author: saga-games Date: 2015-06-12 15:15:05 +0000 (Fri, 12 Jun 2015) Log Message: ----------- [New] Export: It is now possible to export to a sample slot rather than a file (http://bugs.openmpt.org/view.php?id=561). [Mod] OpenMPT: Version is now 1.25.00.13 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/mod2wave.h trunk/OpenMPT/mptrack/mptrack.rc Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2015-06-11 20:16:08 UTC (rev 5292) +++ trunk/OpenMPT/common/versionNumber.h 2015-06-12 15:15:05 UTC (rev 5293) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 25 #define VER_MINOR 00 -#define VER_MINORMINOR 12 +#define VER_MINORMINOR 13 //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/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2015-06-11 20:16:08 UTC (rev 5292) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2015-06-12 15:15:05 UTC (rev 5293) @@ -40,17 +40,6 @@ } -static mpt::ustring GetDefaultArtist() -//------------------------------------ -{ - if(std::getenv("USERNAME")) - { - return mpt::ToUnicode(mpt::CharsetLocale, std::getenv("USERNAME")); - } - return mpt::ustring(); -} - - static mpt::ustring GetDefaultYear() //---------------------------------- { @@ -60,7 +49,7 @@ StoredTags::StoredTags(SettingsContainer &conf) //--------------------------------------------- - : artist(conf, "Export", "TagArtist", GetDefaultArtist()) + : artist(conf, "Export", "TagArtist", TrackerSettings::Instance().defaultArtist) , album(conf, "Export", "TagAlbum", MPT_USTRING("")) , trackno(conf, "Export", "TagTrackNo", MPT_USTRING("")) , year(conf, "Export", "TagYear", GetDefaultYear()) @@ -81,6 +70,8 @@ ON_COMMAND(IDC_CHECK6, OnCheckInstrMode) ON_COMMAND(IDC_RADIO1, UpdateDialog) ON_COMMAND(IDC_RADIO2, UpdateDialog) + ON_COMMAND(IDC_RADIO3, UpdateDialog) + ON_COMMAND(IDC_RADIO4, UpdateDialog) ON_COMMAND(IDC_PLAYEROPTIONS, OnPlayerOptions) ON_COMMAND(IDC_BUTTON1, OnShowEncoderInfo) ON_CBN_SELCHANGE(IDC_COMBO5, OnFileTypeChanged) @@ -193,6 +184,8 @@ } } + CheckRadioButton(IDC_RADIO3, IDC_RADIO4, m_Settings.outputToSample ? IDC_RADIO4 : IDC_RADIO3); + UpdateDialog(); return TRUE; } @@ -536,7 +529,6 @@ //-------------------------------------- { SaveEncoderSettings(); - //DWORD dwSamplerate = m_CbnSampleRate.GetItemData(m_CbnSampleRate.GetCurSel()); FillFormats(); FillDither(); } @@ -546,7 +538,6 @@ //------------------------------------ { SaveEncoderSettings(); - //UINT nChannels = m_CbnChannels.GetItemData(m_CbnChannels.GetCurSel()); FillFormats(); FillDither(); } @@ -563,7 +554,6 @@ //---------------------------------- { SaveEncoderSettings(); - //DWORD dwFormat = m_CbnSampleFormat.GetItemData(m_CbnSampleFormat.GetCurSel()); FillDither(); FillTags(); } @@ -578,14 +568,23 @@ ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT2), (m_dwSongLimit) ? TRUE : FALSE); // Repeat / selection play - BOOL bSel = IsDlgButtonChecked(IDC_RADIO2) ? TRUE : FALSE; - /*m_SpinMinOrder.EnableWindow(bSel); - m_SpinMaxOrder.EnableWindow(bSel);*/ + BOOL bSel = (IsDlgButtonChecked(IDC_RADIO2) != BST_UNCHECKED) ? TRUE : FALSE; GetDlgItem(IDC_EDIT3)->EnableWindow(bSel); GetDlgItem(IDC_EDIT4)->EnableWindow(bSel); GetDlgItem(IDC_EDIT5)->EnableWindow(!bSel); + m_SpinLoopCount.EnableWindow(!bSel); - m_SpinLoopCount.EnableWindow(!bSel); + bSel = (IsDlgButtonChecked(IDC_RADIO4) != BST_UNCHECKED) ? FALSE : TRUE; + m_CbnFileType.EnableWindow(bSel); + if(!bSel) + { + // Render to sample: Always use WAV + if(m_CbnFileType.GetCurSel() != 0) + { + m_CbnFileType.SetCurSel(0); + OnFileTypeChanged(); + } + } } @@ -670,8 +669,9 @@ } m_Settings.repeatCount = static_cast<uint16>(GetDlgItemInt(IDC_EDIT5, NULL, FALSE)); - m_Settings.Normalize = IsDlgButtonChecked(IDC_CHECK5) != BST_UNCHECKED; - m_Settings.SilencePlugBuffers = IsDlgButtonChecked(IDC_RENDERSILENCE) != BST_UNCHECKED; + m_Settings.normalize = IsDlgButtonChecked(IDC_CHECK5) != BST_UNCHECKED; + m_Settings.silencePlugBuffers = IsDlgButtonChecked(IDC_RENDERSILENCE) != BST_UNCHECKED; + m_Settings.outputToSample = IsDlgButtonChecked(IDC_RADIO4) != BST_UNCHECKED; m_bGivePlugsIdleTime = IsDlgButtonChecked(IDC_GIVEPLUGSIDLETIME) != BST_UNCHECKED; if (m_bGivePlugsIdleTime) { @@ -845,8 +845,9 @@ , storedTags(conf) , repeatCount(0) , minOrder(ORDERINDEX_INVALID), maxOrder(ORDERINDEX_INVALID) - , Normalize(false) - , SilencePlugBuffers(false) + , normalize(false) + , silencePlugBuffers(false) + , outputToSample(false) { for(std::size_t i = 0; i < EncoderFactories.size(); ++i) { @@ -912,7 +913,7 @@ float normalizePeak = 0.0f; const mpt::PathString normalizeFileName = Util::CreateTempFileName(MPT_PATHSTRING("OpenMPT")); mpt::fstream normalizeFile; - if(m_Settings.Normalize) + if(m_Settings.normalize) { normalizeFile.open(normalizeFileName, std::ios::binary | std::ios::in | std::ios::out | std::ios::trunc); } @@ -934,7 +935,7 @@ IAudioStreamEncoder *fileEnc = m_Settings.GetEncoderFactory()->ConstructStreamEncoder(fileStream); // Silence mix buffer of plugins, for plugins that don't clear their reverb buffers and similar stuff when they are reset - if(m_Settings.SilencePlugBuffers) + if(m_Settings.silencePlugBuffers) { SetDlgItemText(IDC_TEXT1, _T("Clearing plugin buffers")); for(PLUGINDEX i = 0; i < MAX_MIXPLUGINS; i++) @@ -971,7 +972,7 @@ mixersettings.gdwMixingFreq = samplerate; mixersettings.gnChannels = channels; m_SndFile.m_SongFlags.reset(SONG_PAUSED | SONG_STEP); - if(m_Settings.Normalize) + if(m_Settings.normalize) { #ifndef NO_AGC mixersettings.DSPMask &= ~SNDDSP_AGC; @@ -1057,7 +1058,7 @@ for (UINT n = 0; ; n++) { UINT lRead = 0; - if(m_Settings.Normalize || m_Settings.FinalSampleFormat == SampleFormatFloat32) + if(m_Settings.normalize || m_Settings.FinalSampleFormat == SampleFormatFloat32) { lRead = ReadInterleaved(m_SndFile, floatbuffer, MIXBUFFERSIZE, SampleFormatFloat32, dither); } else @@ -1087,7 +1088,7 @@ break; ullSamples += lRead; - if(m_Settings.Normalize) + if(m_Settings.normalize) { std::size_t countSamples = lRead * m_SndFile.m_MixerSettings.gnChannels; @@ -1140,7 +1141,7 @@ timeRemaining = static_cast<uint32>(((dwCurrentTime - dwStartTime) * (max - ullSamples) / ullSamples) / 1000); } - if(m_Settings.Normalize) + if(m_Settings.normalize) { _stprintf(s, _T("Rendering file... (%umn%02us, %umn%02us remaining)"), l / 60, l % 60, timeRemaining / 60, timeRemaining % 60u); } else @@ -1178,7 +1179,7 @@ CMainFrame::GetMainFrame()->StopRenderer(&m_SndFile); - if(m_Settings.Normalize) + if(m_Settings.normalize) { ::SendMessage(progress, PBM_SETRANGE, 0, MAKELPARAM(0, 100)); Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2015-06-11 20:16:08 UTC (rev 5292) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2015-06-12 15:15:05 UTC (rev 5293) @@ -1684,7 +1684,7 @@ .DefaultFilename(GetPathNameMpt().GetFileName() + MPT_PATHSTRING(".") + extension) .ExtensionFilter(encFactory->GetTraits().fileDescription + MPT_USTRING(" (*.") + extension.ToUnicode() + MPT_USTRING(")|*.") + extension.ToUnicode() + MPT_USTRING("||")) .WorkingDirectory(TrackerSettings::Instance().PathExport.GetWorkingDir()); - if(!dlg.Show()) return; + if(!wsdlg.m_Settings.outputToSample && !dlg.Show()) return; // will set default dir here because there's no setup option for export dir yet (feel free to add one...) TrackerSettings::Instance().PathExport.SetDefaultDir(dlg.GetWorkingDirectory(), true); @@ -1810,6 +1810,10 @@ thisName += mpt::PathString::FromUnicode(mpt::ToUnicode(mpt::CharsetLocale, fileNameAdd)); } thisName += fileExt; + if(wsdlg.m_Settings.outputToSample) + { + thisName = Util::CreateTempFileName(MPT_PATHSTRING("OpenMPT")); + } // Render song (or current channel, or current sample/instrument) CDoWaveConvert dwcdlg(m_SndFile, thisName, wsdlg.m_Settings, pMainFrm); @@ -1817,7 +1821,48 @@ dwcdlg.m_bGivePlugsIdleTime = wsdlg.m_bGivePlugsIdleTime; dwcdlg.m_dwSongLimit = wsdlg.m_dwSongLimit; - if(dwcdlg.DoModal() != IDOK) break; + bool cancel = dwcdlg.DoModal() != IDOK; + + if(wsdlg.m_Settings.outputToSample) + { + if(!cancel) + { + InputFile f(thisName); + if(f.IsValid()) + { + FileReader file = GetFileReader(f); + SAMPLEINDEX smp = m_SndFile.GetNextFreeSample(); + if(smp == SAMPLEINDEX_INVALID) + { + Reporting::Error(_T("Too many samples!")); + break; + } + if(m_SndFile.ReadSampleFromFile(smp, file, false)) + { + UpdateAllViews(nullptr, SampleHint().Info().Data().Names()); + if(m_SndFile.GetNumInstruments()) + { + InsertInstrument(smp); + UpdateAllViews(nullptr, InstrumentHint().Info().Names()); + } + SetModified(); + } + } + } + + // Always clean up after ourselves + for(int retry = 0; retry < 10; retry++) + { + // stupid virus scanners + if(DeleteFileW(thisName.AsNative().c_str()) != EACCES) + { + break; + } + Sleep(10); + } + } + + if(cancel) break; } // Restore channels' flags Modified: trunk/OpenMPT/mptrack/mod2wave.h =================================================================== --- trunk/OpenMPT/mptrack/mod2wave.h 2015-06-11 20:16:08 UTC (rev 5292) +++ trunk/OpenMPT/mptrack/mod2wave.h 2015-06-12 15:15:05 UTC (rev 5293) @@ -52,8 +52,9 @@ int repeatCount; ORDERINDEX minOrder, maxOrder; - bool Normalize; - bool SilencePlugBuffers; + bool normalize : 1; + bool silencePlugBuffers : 1; + bool outputToSample : 1; std::size_t FindEncoder(const mpt::ustring &name) const; void SelectEncoder(std::size_t index); @@ -129,7 +130,7 @@ public: const CWaveConvertSettings &m_Settings; CSoundFile &m_SndFile; - mpt::PathString m_lpszFileName; + const mpt::PathString &m_lpszFileName; uint64 m_dwFileLimit, m_dwSongLimit; bool m_bAbort, m_bGivePlugsIdleTime; Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2015-06-11 20:16:08 UTC (rev 5292) +++ trunk/OpenMPT/mptrack/mptrack.rc 2015-06-12 15:15:05 UTC (rev 5293) @@ -635,7 +635,7 @@ BEGIN DEFPUSHBUTTON "OK",IDOK,270,216,50,14 PUSHBUTTON "Cancel",IDCANCEL,330,216,50,14 - GROUPBOX "Format",IDC_STATIC,6,6,186,66 + GROUPBOX "For&mat",IDC_STATIC,6,6,186,66 COMBOBOX IDC_COMBO5,12,18,90,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Encoder Information",IDC_BUTTON1,108,18,78,12 COMBOBOX IDC_COMBO1,12,36,54,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP @@ -660,7 +660,7 @@ EDITTEXT IDC_EDIT1,324,18,50,12,ES_AUTOHSCROLL CONTROL "Limit song &length to: (seconds)",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,204,37,114,10 EDITTEXT IDC_EDIT2,324,36,50,12,ES_AUTOHSCROLL - CONTROL "Play &entire song",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON,204,54,72,12 + CONTROL "Play &entire song",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON | WS_GROUP,204,54,72,12 CONTROL "From &position",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,204,73,72,12 EDITTEXT IDC_EDIT5,276,54,36,12,ES_AUTOHSCROLL | ES_NUMBER CONTROL "",IDC_SPIN5,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_NOTHOUSANDS,300,60,11,11 @@ -685,6 +685,9 @@ COMBOBOX IDC_COMBO3,240,192,78,64,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP RTEXT "Year:",IDC_STATIC,324,194,18,8 EDITTEXT IDC_EDIT9,348,192,30,12,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "Export To:",IDC_STATIC,6,219,48,8 + CONTROL "&File",IDC_RADIO3,"Button",BS_AUTORADIOBUTTON | WS_GROUP,54,219,48,8 + CONTROL "S&le Slot",IDC_RADIO4,"Button",BS_AUTORADIOBUTTON,96,219,90,8 END IDD_PROGRESS DIALOG 0, 0, 186, 55 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |