From: <rel...@us...> - 2010-01-07 17:10:27
|
Revision: 456 http://modplug.svn.sourceforge.net/modplug/?rev=456&view=rev Author: relabsoluness Date: 2010-01-07 17:10:05 +0000 (Thu, 07 Jan 2010) Log Message: ----------- [New] Tuning: Can import scl-files. Upper limit for note count is 64. [Imp] SoundTouch: Update to version 1.5.0. [Mod] XM/MOD: Allow extended XM/MOD files to use '+++'-items again. [Fix] Orderlist: Deleting orders didn't set document modified (appeared in rev. 406). [Fix] GUI: Fixes to handling of 32 chars long instrument name. [Ref/Fix/Mod] Minor tweaks and fixes (changed some "modplug tracker" strings to "OpenMPT", added a couple of utility functions, added tuning directory to existing default/working directory system...). Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/Ctrl_seq.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/TuningDialog.cpp trunk/OpenMPT/mptrack/TuningDialog.h trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/mptrack/misc_util.cpp trunk/OpenMPT/mptrack/misc_util.h trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/resource.h trunk/OpenMPT/mptrack/test/test.cpp trunk/OpenMPT/packageTemplate/SoundTouch/README.html trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/mod_specifications.h trunk/OpenMPT/soundlib/tuningCollection.cpp trunk/OpenMPT/soundlib/tuningbase.cpp trunk/OpenMPT/soundlib/tuningbase.h trunk/OpenMPT/soundlib/tuningcollection.h trunk/OpenMPT/soundtouch/3dnow_win.cpp trunk/OpenMPT/soundtouch/BPMDetect.cpp trunk/OpenMPT/soundtouch/BPMDetect.h trunk/OpenMPT/soundtouch/FIFOSampleBuffer.cpp trunk/OpenMPT/soundtouch/FIFOSampleBuffer.h trunk/OpenMPT/soundtouch/FIFOSamplePipe.h trunk/OpenMPT/soundtouch/FIRFilter.cpp trunk/OpenMPT/soundtouch/FIRFilter.h trunk/OpenMPT/soundtouch/PeakFinder.cpp trunk/OpenMPT/soundtouch/PeakFinder.h trunk/OpenMPT/soundtouch/README.html trunk/OpenMPT/soundtouch/RateTransposer.cpp trunk/OpenMPT/soundtouch/RateTransposer.h trunk/OpenMPT/soundtouch/STTypes.h trunk/OpenMPT/soundtouch/SoundTouch.cpp trunk/OpenMPT/soundtouch/SoundTouch.h trunk/OpenMPT/soundtouch/TDStretch.cpp trunk/OpenMPT/soundtouch/TDStretch.h trunk/OpenMPT/soundtouch/cpu_detect_x86_win.cpp trunk/OpenMPT/soundtouch/mmx_optimized.cpp trunk/OpenMPT/soundtouch/sse_optimized.cpp Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2010-01-07 17:10:05 UTC (rev 456) @@ -469,7 +469,7 @@ if (nIns==0 && (inputPlugs.GetSize() || inputChannels.GetSize())) { m_pInputMenu->AppendMenu(MF_SEPARATOR); } - name.Format("Ins%02d: %s", inputInstruments[nIns], pSndFile->Instruments[inputInstruments[nIns]]->name); + name.Format("Ins%02d: %s", inputInstruments[nIns], (LPCTSTR)pSndFile->GetInstrumentName(inputInstruments[nIns])); if (inputInstruments[nIns] == (UINT)m_nInstrument) checked=true; m_pInputMenu->AppendMenu(MF_STRING|(checked?MF_CHECKED:0), ID_SELECTINST+inputInstruments[nIns], name); } Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2010-01-07 17:10:05 UTC (rev 456) @@ -1192,6 +1192,7 @@ pSndFile->Order.Remove(selection.nOrdLo, selection.nOrdHi); + m_pModDoc->SetModified(); InvalidateRect(NULL, FALSE); m_pModDoc->UpdateAllViews(NULL, HINT_MODSEQUENCE, this); Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2010-01-07 17:10:05 UTC (rev 456) @@ -310,6 +310,8 @@ for(UINT i = 0; i < NUM_DIRS; i++) { + if (i == DIR_TUNING) // Hack: Tuning folder is set already so don't reset it. + continue; m_szDefaultDirectory[i][0] = 0; m_szWorkingDirectory[i][0] = 0; } Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2010-01-07 17:10:05 UTC (rev 456) @@ -372,6 +372,7 @@ DIR_PLUGINS, DIR_PLUGINPRESETS, DIR_EXPORT, + DIR_TUNING, NUM_DIRS }; Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2010-01-07 17:10:05 UTC (rev 456) @@ -3486,7 +3486,7 @@ { const SAMPLEINDEX nSmp = m_SndFile.Instruments[nInstr]->Keyboard[60]; if (nSmp < ARRAYELEMCOUNT(m_SndFile.Samples) && m_SndFile.Samples[nSmp].pSample) - instrumentName.Format(TEXT("s: %s"), (LPCTSTR)m_SndFile.GetSampleName(nSmp)); //60 is C-5 + instrumentName.Format(TEXT("s: %s"), m_SndFile.GetSampleName(nSmp)); //60 is C-5 } // Get plugin name. Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2010-01-07 17:10:05 UTC (rev 456) @@ -790,12 +790,13 @@ } // Create tunings dir - strcpy(m_szTuningsDirectory, m_szConfigDirectory); - strcat(m_szTuningsDirectory, "tunings\\"); + CString sTuningPath; + sTuningPath.Format(TEXT("%stunings\\"), m_szConfigDirectory); + CMainFrame::SetDefaultDirectory(sTuningPath, DIR_TUNING); - if(PathIsDirectory(m_szTuningsDirectory) == 0) + if(PathIsDirectory(CMainFrame::GetDefaultDirectory(DIR_TUNING)) == 0) { - CreateDirectory(m_szTuningsDirectory, 0); + CreateDirectory(CMainFrame::GetDefaultDirectory(DIR_TUNING), 0); } if(!bIsAppDir) Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/mptrack/Mptrack.h 2010-01-07 17:10:05 UTC (rev 456) @@ -155,7 +155,6 @@ MODMIDICFG m_MidiCfg; TCHAR m_szExePath[_MAX_PATH]; TCHAR m_szConfigDirectory[_MAX_PATH]; - TCHAR m_szTuningsDirectory[_MAX_PATH]; TCHAR m_szConfigFileName[_MAX_PATH]; TCHAR m_szPluginCacheFileName[_MAX_PATH]; TCHAR m_szStringsFileName[_MAX_PATH]; @@ -202,7 +201,6 @@ BOOL IsDebug() const { return m_bDebugMode; } LPCSTR GetConfigFileName() const { return m_szConfigFileName; } LPCSTR GetPluginCacheFileName() const { return m_szPluginCacheFileName; } - LPCSTR GetTuningsPath() const { return m_szTuningsDirectory; } LPCSTR GetConfigPath() const { return m_szConfigDirectory; } void SetupPaths(); @@ -439,6 +437,7 @@ const LPCSTR gszModCommands = " 0123456789ABCDRFFTE???GHK?YXPLZ\\:#??"; //rewbs.smoothVST: added last \ (written as \\); rewbs.velocity: added last : const LPCSTR gszS3mCommands = " JFEGHLKRXODB?CQATI?SMNVW?UY?P?Z\\:#??"; //rewbs.smoothVST: added last \ (written as \\); rewbs.velocity: added last : const LPCSTR gszVolCommands = " vpcdabuhlrgfe:o"; //rewbs.velocity: added last : ; rewbs.volOff added last o +const TCHAR gszEmpty[] = TEXT(""); // Defined in load_mid.cpp extern const LPCSTR szMidiProgramNames[128]; Modified: trunk/OpenMPT/mptrack/TuningDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/TuningDialog.cpp 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/mptrack/TuningDialog.cpp 2010-01-07 17:10:05 UTC (rev 456) @@ -1,6 +1,7 @@ #include "stdafx.h" #include "mptrack.h" #include "TuningDialog.h" +#include "MainFrm.h" #include <algorithm> #include "misc_util.h" #include ".\tuningdialog.h" @@ -627,7 +628,7 @@ FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(false, CTuning::s_FileExtension, "", filter, - theApp.GetTuningsPath()); + CMainFrame::GetWorkingDirectory(DIR_TUNING)); if(files.abort) return; BeginWaitCursor(); @@ -655,67 +656,141 @@ ErrorBox(IDS_ERR_EXPORT_TUNING, this); } + void CTuningDialog::OnBnClickedButtonImport() //------------------------------------------- { - //TODO: Ability to import ratios from text file. - string filter = string("Tuning files (*") + CTuning::s_FileExtension + string(", *") + CTuningCollection::s_FileExtension + string(")|*") + - CTuning::s_FileExtension + string(";*") + CTuningCollection::s_FileExtension + string("|"); + CString sFilter; + sFilter.Format(TEXT("Tuning files (*%s, *%s, *.scl)|*%s;*%s;*.scl|"), + CTuning::s_FileExtension, + CTuningCollection::s_FileExtension, + CTuning::s_FileExtension, + CTuningCollection::s_FileExtension); - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(true, "", "", - filter, - theApp.GetTuningsPath()); - if(files.abort) return; + FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(true, TEXT(""), TEXT(""), + (LPCTSTR)sFilter, + CMainFrame::GetWorkingDirectory(DIR_TUNING), + true); + if(files.abort) + return; - const string ext = string(".") + files.extension; + CMainFrame::SetWorkingDirectory(files.workingDirectory.c_str(), DIR_TUNING, true); - bool failure = true; + CString sLoadReport; - if(ext == CTuning::s_FileExtension) + const size_t nFiles = files.filenames.size(); + for(size_t counter = 0; counter < nFiles; counter++) { - ifstream fin(files.first_file.c_str(), ios::binary); - CTuning* pT = CTuningRTI::DeserializeOLD(fin); - if(pT == 0) {fin.clear(); fin.seekg(0); pT = CTuningRTI::Deserialize(fin);} - fin.close(); - if(pT) + TCHAR szFileName[_MAX_FNAME], szExt[_MAX_EXT]; + _tsplitpath(files.filenames[counter].c_str(), nullptr, nullptr, szFileName, szExt); + + _tcslwr(szExt); // Convert extension to lower case. + + const bool bIsTun = (_tcscmp(szExt, CTuning::s_FileExtension) == 0); + const bool bIsScl = (_tcscmp(szExt, TEXT(".scl")) == 0); + + if (bIsTun || bIsScl) { - failure = false; - m_TempTunings.AddTuning(pT); - m_pActiveTuning = pT; + CTuning* pT = nullptr; - AddTreeItem(m_pActiveTuning, m_TreeItemTuningItemMap.GetMapping_21(TUNINGTREEITEM(&m_TempTunings)), NULL); - UpdateView(); + if (bIsTun) + { + std::ifstream fin(files.filenames[counter].c_str(), ios::binary); + pT = CTuningRTI::DeserializeOLD(fin); + if(pT == 0) + {fin.clear(); fin.seekg(0); pT = CTuningRTI::Deserialize(fin);} + fin.close(); + if (pT) + { + if (m_TempTunings.AddTuning(pT) == true) + { + delete pT; pT = nullptr; + if (m_TempTunings.GetNumTunings() >= CTuningCollection::s_nMaxTuningCount) + { + CString sFormat, sMsg; + sFormat.LoadString(IDS_TUNING_IMPORT_LIMIT); + sMsg.FormatMessage(sFormat, szFileName, szExt, CTuningCollection::s_nMaxTuningCount); + sLoadReport += sMsg; + } + else // Case: Can't add tuning to tuning collection for unknown reason. + { + CString sMsg; + AfxFormatString2(sMsg, IDS_TUNING_IMPORT_UNKNOWN_FAILURE, szFileName, szExt); + sLoadReport += sMsg; + } + } + } + else // pT == nullptr + { + CString sMsg; + AfxFormatString2(sMsg, IDS_TUNING_IMPORT_UNRECOGNIZED_FILE, szFileName, szExt); + sLoadReport += sMsg; + } + } + else // scl import. + { + EnSclImport a = ImportScl(files.filenames[counter].c_str(), szFileName); + if (a != enSclImportOk) + { + if (a == enSclImportAddTuningFailure && m_TempTunings.GetNumTunings() >= CTuningCollection::s_nMaxTuningCount) + { + CString sFormat, sMsg; + sFormat.LoadString(IDS_TUNING_IMPORT_LIMIT); + sMsg.FormatMessage(sFormat, szFileName, szExt, CTuningCollection::s_nMaxTuningCount); + sLoadReport += sMsg; + } + else + { + CString sFormat, sMsg; + sFormat.LoadString(IDS_TUNING_IMPORT_SCL_FAILURE); + sMsg.FormatMessage(sFormat, szFileName, szExt, (LPCTSTR)GetSclImportFailureMsg(a)); + sLoadReport += sMsg; + } + } + else // scl import successful. + pT = &m_TempTunings.GetTuning(m_TempTunings.GetNumTunings() - 1); + } + + if (pT) + { + m_pActiveTuning = pT; + AddTreeItem(m_pActiveTuning, m_TreeItemTuningItemMap.GetMapping_21(TUNINGTREEITEM(&m_TempTunings)), NULL); + } } - } - else - { - if(ext == CTuningCollection::s_FileExtension) + else if (_tcscmp(szExt, CTuningCollection::s_FileExtension) == 0) { - //For now only loading tuning collection as - //a separate collection - no possibility to - //directly replace some collection. + // For now only loading tuning collection as + // a separate collection - no possibility to + // directly replace some collection. CTuningCollection* pNewTCol = new CTuningCollection; - pNewTCol->SetSavefilePath(static_cast<LPCTSTR>(files.first_file.c_str())); - failure = pNewTCol->Deserialize(); - if(failure) + pNewTCol->SetSavefilePath(files.filenames[counter].c_str()); + if (pNewTCol->Deserialize()) { delete pNewTCol; pNewTCol = 0; + CString sMsg; + AfxFormatString2(sMsg, IDS_TUNING_IMPORT_UNKNOWN_TC_FAILURE, szFileName, szExt); + sLoadReport += sMsg; } else { m_TuningCollections.push_back(pNewTCol); m_DeletableTuningCollections.push_back(pNewTCol); AddTreeItem(pNewTCol, NULL, NULL); - UpdateView(); } - - } + else // Case: Unknown extension (should not happen). + { + CString sMsg; + AfxFormatString2(sMsg, IDS_TUNING_IMPORT_UNRECOGNIZED_FILE_EXT, szFileName, szExt); + sLoadReport += sMsg; + } } - if(failure) - ErrorBox(IDS_OPERATION_FAIL, this); + if (sLoadReport.GetLength() > 0) + AfxMessageBox(sLoadReport, MB_ICONINFORMATION); + UpdateView(); } + void CTuningDialog::OnEnChangeEditFinetunesteps() //----------------------------------------------- { @@ -1325,3 +1400,187 @@ } +//////////////////////////////////////////////////////// +// +// scl import +// +//////////////////////////////////////////////////////// + +typedef double SclFloat; + +CString CTuningDialog::GetSclImportFailureMsg(EnSclImport id) +//---------------------------------------------------------- +{ + CString sMsg; + switch(id) + { + case enSclImportFailTooManyNotes: + AfxFormatString1(sMsg, IDS_SCL_IMPORT_FAIL_8, Stringify(s_nSclImportMaxNoteCount).c_str()); + return sMsg; + + case enSclImportFailTooLargeNumDenomIntegers: + sMsg.LoadString(IDS_SCL_IMPORT_FAIL_1); return sMsg; + + case enSclImportFailZeroDenominator: + sMsg.LoadString(IDS_SCL_IMPORT_FAIL_2); return sMsg; + + case enSclImportFailNegativeRatio: + sMsg.LoadString(IDS_SCL_IMPORT_FAIL_3); return sMsg; + + case enSclImportFailUnableToOpenFile: + sMsg.LoadString(IDS_SCL_IMPORT_FAIL_4); return sMsg; + + case enSclImportLineCountMismatch: + sMsg.LoadString(IDS_SCL_IMPORT_FAIL_5); return sMsg; + + case enSclImportTuningCreationFailure: + sMsg.LoadString(IDS_SCL_IMPORT_FAIL_6); return sMsg; + + case enSclImportAddTuningFailure: + sMsg.LoadString(IDS_SCL_IMPORT_FAIL_7); return sMsg; + + default: + return sMsg; + } +} + + +static void SkipCommentLines(std::istream& iStrm, std::string& str) +//----------------------------------------------------------------- +{ + while(std::getline(iStrm, str)) + { + LPCSTR psz = str.c_str(); + for(; *psz != 0; psz++) + { + if (*psz == ' ' || *psz == '\t') + continue; + else + { + if (*psz != '!') + return; + else // Found comment line: break for loop and get another line. + break; + } + } + } +} + + +static inline SclFloat CentToRatio(const SclFloat& val) +//----------------------------------------------------- +{ + return pow(2.0, val / 1200.0); +} + + +CTuningDialog::EnSclImport CTuningDialog::ImportScl(LPCTSTR pszPath, LPCTSTR pszName) +//----------------------------------------------------------------------------------- +{ + CFile file; + if (file.Open(pszPath, CFile::modeRead) == 0) + return enSclImportFailUnableToOpenFile; + + size_t nSize = static_cast<size_t>(file.GetLength()); + + std::vector<char> data(nSize + 1, 0); + nSize = file.Read(&data[0], nSize); + file.Close(); + + std::istrstream iStrm(&data[0], nSize); + return ImportScl(iStrm, pszName); +} + + +CTuningDialog::EnSclImport CTuningDialog::ImportScl(std::istream& iStrm, LPCTSTR pszName) +//--------------------------------------------------------------------------------------- +{ + std::string str; + SkipCommentLines(iStrm, str); + // str should now contain comment line. + SkipCommentLines(iStrm, str); + // str should now contain number of notes. + const size_t nNotes = 1 + ConvertStrTo<size_t>(str.c_str()); + if (nNotes > s_nSclImportMaxNoteCount) + return enSclImportFailTooManyNotes; + + std::vector<CTuningRTI::RATIOTYPE> fRatios; + fRatios.reserve(nNotes); + fRatios.push_back(1); + + char buffer[128]; + MemsetZero(buffer); + + while (iStrm.getline(buffer, sizeof(buffer))) + { + LPSTR psz = buffer; + LPSTR const pEnd = psz + strlen(buffer); + + // Skip tabs and spaces. + while(psz != pEnd && (*psz == ' ' || *psz == '\t')) + psz++; + + // Skip empty lines, comment lines and non-text. + if (*psz == 0 || *psz == '!' || *psz < 32) + continue; + + char* pNonDigit = pEnd; + + // Check type of first non digit. This tells whether to read cent, ratio or plain number. + for (pNonDigit = psz; pNonDigit != pEnd; pNonDigit++) + { + if (isdigit(*pNonDigit) == 0) + break; + } + + if (*pNonDigit == '.') // Reading cents + { + SclFloat fCent = ConvertStrTo<SclFloat>(psz); + fRatios.push_back(static_cast<CTuningRTI::RATIOTYPE>(CentToRatio(fCent))); + } + else if (*pNonDigit == '/') // Reading ratios + { + *pNonDigit = 0; // Replace '/' with null. + int64 nNum = ConvertStrTo<int64>(psz); + psz = pNonDigit + 1; + int64 nDenom = ConvertStrTo<int64>(psz); + + if (nNum > int32_max || nDenom > int32_max) + return enSclImportFailTooLargeNumDenomIntegers; + if (nDenom == 0) + return enSclImportFailZeroDenominator; + + fRatios.push_back(static_cast<CTuningRTI::RATIOTYPE>((SclFloat)nNum / (SclFloat)nDenom)); + } + else // Plain numbers. + fRatios.push_back(static_cast<CTuningRTI::RATIOTYPE>(ConvertStrTo<int32>(psz))); + } + + if (nNotes != fRatios.size()) + return enSclImportLineCountMismatch; + + for(size_t i = 0; i < fRatios.size(); i++) + { + if (fRatios[i] < 0) + return enSclImportFailNegativeRatio; + } + + CTuning* pT = new CTuningRTI; + if (pT->CreateGroupGeometric(fRatios, 1, pT->GetValidityRange(), 0) != false) + { + delete pT; + return enSclImportTuningCreationFailure; + } + + if (m_TempTunings.AddTuning(pT) != false) + { + delete pT; + return enSclImportAddTuningFailure; + } + + pT->SetName(pszName); + + return enSclImportOk; +} + + Modified: trunk/OpenMPT/mptrack/TuningDialog.h =================================================================== --- trunk/OpenMPT/mptrack/TuningDialog.h 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/mptrack/TuningDialog.h 2010-01-07 17:10:05 UTC (rev 456) @@ -187,6 +187,19 @@ friend class CTuningTreeCtrl; + enum EnSclImport + { + enSclImportOk, + enSclImportFailTooLargeNumDenomIntegers, + enSclImportFailZeroDenominator, + enSclImportFailNegativeRatio, + enSclImportFailUnableToOpenFile, + enSclImportLineCountMismatch, + enSclImportTuningCreationFailure, + enSclImportAddTuningFailure, + enSclImportFailTooManyNotes + }; + public: typedef vector<CTuningCollection*> TUNINGVECTOR; @@ -233,6 +246,10 @@ //Checks whether tuning collection can be deleted. bool IsDeletable(const CTuningCollection* const pTC) const; + + // Scl-file import. + EnSclImport ImportScl(LPCTSTR pszPath, LPCTSTR pszName); + EnSclImport ImportScl(std::istream& iStrm, LPCTSTR pszName); private: @@ -297,6 +314,8 @@ TT_TUNING }; + static CString GetSclImportFailureMsg(EnSclImport); + static const size_t s_nSclImportMaxNoteCount = 64; //To indicate whether to apply changes made to //those edit boxes(they are modified by certain activities Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2010-01-07 17:10:05 UTC (rev 456) @@ -965,10 +965,10 @@ // path info for ITP instruments BOOL pathOk = pSndFile->m_szInstrumentPath[nIns-1][0] != '\0'; BOOL instOk = pSndFile->instrumentModified[nIns-1] == FALSE; - wsprintf(s, pathOk ? (instOk ? "%3d: %s" : "%3d: * %s") : "%3d: ? %s", nIns, pSndFile->Instruments[nIns]->name); + wsprintf(s, pathOk ? (instOk ? "%3d: %s" : "%3d: * %s") : "%3d: ? %s", nIns, (LPCTSTR)pSndFile->GetInstrumentName(nIns)); } else { - wsprintf(s, "%3d: %s", nIns, pSndFile->Instruments[nIns]->name); + wsprintf(s, "%3d: %s", nIns, (LPCTSTR)pSndFile->GetInstrumentName(nIns)); } int nImage = IMAGE_INSTRUMENTS; Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2010-01-07 17:10:05 UTC (rev 456) @@ -746,7 +746,7 @@ { if (pSndFile->m_nInstruments) { - wsprintf(s, "%03d:%s", n, (pSndFile->Instruments[n]) ? pSndFile->Instruments[n]->name : ""); + wsprintf(s, "%03d:%s", n, (pSndFile->Instruments[n]) ? (LPCTSTR)pSndFile->GetInstrumentName(n) : ""); } else { wsprintf(s, "%03d:%s", n, pSndFile->m_szNames[n]); @@ -2876,7 +2876,7 @@ } if (bUsed) { CString sampleName; - sampleName.Format("%d: %s", i, (LPCTSTR)m_pSndFile->GetSampleName(i)); + sampleName.Format("%d: %s", i, m_pSndFile->GetSampleName(i)); nInsertPos = m_CbnSample.AddString(sampleName); m_CbnSample.SetItemData(nInsertPos, i); Modified: trunk/OpenMPT/mptrack/misc_util.cpp =================================================================== --- trunk/OpenMPT/mptrack/misc_util.cpp 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/mptrack/misc_util.cpp 2010-01-07 17:10:05 UTC (rev 456) @@ -29,3 +29,25 @@ return pData; } + +// Returns error message corresponding to error code returned by GetLastError(). +CString GetErrorMessage(DWORD nErrorCode) +//--------------------------------------- +{ + const size_t nBufferSize = 256; + CString sMsg; + LPTSTR pszBuf = sMsg.GetBuffer(nBufferSize); + + FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + nErrorCode, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + pszBuf, + nBufferSize, + NULL ); + + sMsg.ReleaseBuffer(); + + return sMsg; +} + Modified: trunk/OpenMPT/mptrack/misc_util.h =================================================================== --- trunk/OpenMPT/mptrack/misc_util.h 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/mptrack/misc_util.h 2010-01-07 17:10:05 UTC (rev 456) @@ -17,23 +17,19 @@ //Convert string to number. template<class T> -inline T ConvertStrTo(const char* str) -//---------------------------------- +inline T ConvertStrTo(LPCSTR psz) +//------------------------------- { - //Is implemented like this because the commented code below caused link errors. if(std::numeric_limits<T>::is_integer) - return static_cast<T>(atoi(str)); + return static_cast<T>(atoi(psz)); else - return static_cast<T>(atof(str)); - - /* - std::istringstream i(str); - T t; - i >> t; - return t; - */ + return static_cast<T>(atof(psz)); } +template<> inline uint32 ConvertStrTo(LPCSTR psz) {return strtoul(psz, nullptr, 10);} +template<> inline int64 ConvertStrTo(LPCSTR psz) {return _strtoi64(psz, nullptr, 10);} +template<> inline uint64 ConvertStrTo(LPCSTR psz) {return _strtoui64(psz, nullptr, 10);} + // Sets last character to null in given char array. // Size of the array must be known at compile time. template <size_t size> @@ -45,6 +41,11 @@ } +// Memset given object to zero. +template <class T> +inline void MemsetZero(T& a) {memset(&a, 0, sizeof(T));} + + // Limits 'val' to given range. If 'val' is less than 'lowerLimit', 'val' is set to value 'lowerLimit'. // Similarly if 'val' is greater than 'upperLimit', 'val' is set to value 'upperLimit'. // If 'lowerLimit' > 'upperLimit', 'val' won't be modified. @@ -75,6 +76,7 @@ LPCCH LoadResource(LPCTSTR lpName, LPCTSTR lpType, LPCCH& pData, size_t& nSize, HGLOBAL& hglob); +CString GetErrorMessage(DWORD nErrorCode); namespace utilImpl { Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/mptrack/mptrack.rc 2010-01-07 17:10:05 UTC (rev 456) @@ -13,7 +13,7 @@ #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// -// Deutsch (Deutschland) resources +// German (Germany) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) #ifdef _WIN32 @@ -142,12 +142,12 @@ END #endif // APSTUDIO_INVOKED -#endif // Deutsch (Deutschland) resources +#endif // German (Germany) resources ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// -// Englisch (USA) resources +// English (U.S.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 @@ -162,7 +162,7 @@ IDD_ABOUTBOX DIALOGEX 0, 0, 267, 254 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "About ModPlug Tracker" +CAPTION "About OpenMPT" FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN CONTROL "",IDC_BITMAP1,"Static",SS_BLACKRECT | SS_NOTIFY | SS_CENTERIMAGE,5,3,256,81,WS_EX_CLIENTEDGE @@ -1966,7 +1966,7 @@ STRINGTABLE BEGIN - AFX_IDS_APP_TITLE "Modplug Tracker" + AFX_IDS_APP_TITLE "OpenMPT" AFX_IDS_IDLEMESSAGE "Ready" END @@ -2012,8 +2012,8 @@ STRINGTABLE BEGIN - ID_APP_ABOUT "About ModPlug Tracker\nAbout" - ID_APP_EXIT "Exit ModPlug Tracker\nExit" + ID_APP_ABOUT "About OpenMPT\nAbout" + ID_APP_EXIT "Exit OpenMPT\nExit" ID_HELP_INDEX "Opens Help\nHelp Topics" ID_HELP_FINDER "List Help topics\nHelp Topics" ID_HELP_USING "Display instructions about how to use help\nHelp" @@ -2286,14 +2286,36 @@ IDS_CONFIRM_SEQUENCE_DELETE "Delete sequence %1?" IDS_PATTERN_CLEANUP_UNAVAILABLE "Removing unused patterns is not available when using multiple sequences." + IDS_SCL_IMPORT_FAIL_1 "Invalid numerator or denominator" + IDS_SCL_IMPORT_FAIL_2 "Zero denominator" + IDS_SCL_IMPORT_FAIL_3 "Negative ratio" + IDS_SCL_IMPORT_FAIL_4 "Unable to open file" + IDS_SCL_IMPORT_FAIL_5 "Note count error" + IDS_SCL_IMPORT_FAIL_6 "Unknown tuning creation error" + IDS_SCL_IMPORT_FAIL_7 "Can't add tuning to tuning collection" + IDS_SCL_IMPORT_FAIL_8 "OpenMPT supports importing scl-files with at most %1 notes" END -#endif // Englisch (USA) resources +STRINGTABLE +BEGIN + IDS_TUNING_IMPORT_LIMIT "-Failed to load file %1%2: maximum number(=%3!u!) of temporary tunings is already open.\n" + IDS_TUNING_IMPORT_UNKNOWN_FAILURE + "-Unable to import file ""%1%2"": unknown reason.\n" + IDS_TUNING_IMPORT_UNRECOGNIZED_FILE_EXT + "-Unable to load ""%1%2"": unrecognized file extension.\n" + IDS_TUNING_IMPORT_UNKNOWN_TC_FAILURE + "-Unable to import tuning collection ""%1%2"": unrecognized file.\n" + IDS_TUNING_IMPORT_SCL_FAILURE "-Unable to import ""%1%2"": %3.\n" + IDS_TUNING_IMPORT_UNRECOGNIZED_FILE + "-Unable to import file ""%1%2"": unrecognized file.\n" +END + +#endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// -// Englisch (GB) resources +// English (U.K.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG) #ifdef _WIN32 @@ -2662,7 +2684,7 @@ // IDR_BUILTIN_TUNINGS TUNING "res\\built-inTunings.tc" -#endif // Englisch (GB) resources +#endif // English (U.K.) resources ///////////////////////////////////////////////////////////////////////////// Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/mptrack/resource.h 2010-01-07 17:10:05 UTC (rev 456) @@ -52,6 +52,20 @@ #define IDS_CANT_OPEN_FILE_FOR_WRITING 213 #define IDS_CONFIRM_SEQUENCE_DELETE 214 #define IDS_PATTERN_CLEANUP_UNAVAILABLE 215 +#define IDS_SCL_IMPORT_FAIL_1 216 +#define IDS_SCL_IMPORT_FAIL_2 217 +#define IDS_SCL_IMPORT_FAIL_3 218 +#define IDS_SCL_IMPORT_FAIL_4 219 +#define IDS_SCL_IMPORT_FAIL_5 220 +#define IDS_SCL_IMPORT_FAIL_6 221 +#define IDS_SCL_IMPORT_FAIL_7 222 +#define IDS_SCL_IMPORT_FAIL_8 223 +#define IDS_TUNING_IMPORT_LIMIT 224 +#define IDS_TUNING_IMPORT_UNKNOWN_FAILURE 225 +#define IDS_TUNING_IMPORT_UNRECOGNIZED_FILE_EXT 226 +#define IDS_TUNING_IMPORT_UNKNOWN_TC_FAILURE 227 +#define IDS_TUNING_IMPORT_SCL_FAILURE 228 +#define IDS_TUNING_IMPORT_UNRECOGNIZED_FILE 229 #define IDB_MAINBAR 300 #define IDB_IMAGELIST 301 #define IDB_PATTERNS 302 @@ -579,9 +593,7 @@ #define IDC_SPIN_SPACING 2032 #define IDC_EDIT_SPACING 2033 #define IDC_SAMPLE_NAME 2034 -#define IDC_EDIT_SEQNUM 2034 #define IDC_SAMPLE_FILENAME 2035 -#define IDC_SPIN_SEQNUM 2035 #define IDC_SAMPLE_NEW 2036 #define IDC_SAMPLE_OPEN 2037 #define IDC_SAMPLE_SAVEAS 2038 @@ -604,6 +616,8 @@ #define IDC_SAMPLE_SILENCE 2054 #define IDC_SAMPLE_INVERT 2055 #define IDC_SAMPLE_SIGN_UNSIGN 2056 +#define IDC_EDIT_SEQNUM 2057 +#define IDC_SPIN_SEQNUM 2058 #define IDC_INSTRUMENT_NEW 2060 #define IDC_INSTRUMENT_OPEN 2061 #define IDC_INSTRUMENT_SAVEAS 2062 Modified: trunk/OpenMPT/mptrack/test/test.cpp =================================================================== --- trunk/OpenMPT/mptrack/test/test.cpp 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/mptrack/test/test.cpp 2010-01-07 17:10:05 UTC (rev 456) @@ -65,6 +65,7 @@ void TestVersion(); void TestTypes(); void TestPCnoteSerialization(); +void TestMisc(); @@ -75,6 +76,7 @@ DO_TEST(TestVersion); DO_TEST(TestTypes); //DO_TEST(TestPCnoteSerialization); + DO_TEST(TestMisc); Log(TEXT("Tests were run\n")); } @@ -169,6 +171,27 @@ } +void TestMisc() +//------------- +{ + VERIFY_EQUAL(ConvertStrTo<uint32>("586"), 586); + VERIFY_EQUAL(ConvertStrTo<uint32>("2147483647"), int32_max); + VERIFY_EQUAL(ConvertStrTo<uint32>("4294967295"), uint32_max); + + VERIFY_EQUAL(ConvertStrTo<int64>("-9223372036854775808"), int64_min); + VERIFY_EQUAL(ConvertStrTo<int64>("-159"), -159); + VERIFY_EQUAL(ConvertStrTo<int64>("9223372036854775807"), int64_max); + + VERIFY_EQUAL(ConvertStrTo<uint64>("85059"), 85059); + VERIFY_EQUAL(ConvertStrTo<uint64>("9223372036854775807"), int64_max); + VERIFY_EQUAL(ConvertStrTo<uint64>("18446744073709551615"), uint64_max); + + VERIFY_EQUAL(ConvertStrTo<float>("-87.0"), -87.0); + VERIFY_EQUAL(ConvertStrTo<double>("-0.5e-6"), -0.5e-6); + VERIFY_EQUAL(ConvertStrTo<double>("58.65403492763"), 58.65403492763); +} + + template<class T> T Round(double a) {return static_cast<T>(floor(a + 0.5));} Modified: trunk/OpenMPT/packageTemplate/SoundTouch/README.html =================================================================== --- trunk/OpenMPT/packageTemplate/SoundTouch/README.html 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/packageTemplate/SoundTouch/README.html 2010-01-07 17:10:05 UTC (rev 456) @@ -12,9 +12,9 @@ <hr> <font color=red><h5>Note: This readme is shortened version of the original SoundTouch readme providing documentation for the time stretching feature.<br> -SoundTouch WWW page: http://www.surina.net/soundtouch +SoundTouch WWW page: <a href="http://www.surina.net/soundtouch">www.surina.net/soundtouch</a> </h5></font> -<h1>SoundTouch audio processing library v1.4.0 +<h1>SoundTouch audio processing library v1.5.0 </h1> <p class="normal">SoundTouch library Copyright (c) Olli Parviainen 2002-2009 </p> @@ -40,11 +40,11 @@ sound the default parameter set may result into a sub-optimal result.</p> <p>The time-stretch algorithm default -parameter values are set by these #defines in file "TDStretch.h":</p> +parameter values are set by the following #defines in file "TDStretch.h":</p> <blockquote> <pre>#define DEFAULT_SEQUENCE_MS AUTOMATIC #define DEFAULT_SEEKWINDOW_MS AUTOMATIC -#define DEFAULT_OVERLAP_MS 12</pre> +#define DEFAULT_OVERLAP_MS 8</pre> </blockquote> <p>These parameters affect to the time-stretch algorithm as follows:</p> @@ -148,6 +148,37 @@ <h2>5. Change History</h2> <h3>5.1. SoundTouch library Change History </h3> +<p><strong>1.5.0:</strong></p> +<ul> +<li>Added normalization to correlation calculation and improvement automatic seek/sequence parameter calculation to improve sound quality</li> + +<li>Bugfixes: + <ul> + <li>Fixed negative array indexing in quick seek algorithm</li> + <li>FIR autoalias filter running too far in processing buffer</li> + <li>Check against zero sample count in rate transposing</li> + <li>Fix for x86-64 support: Removed pop/push instructions from the cpu detection algorithm. </li> + <li>Check against empty buffers in FIFOSampleBuffer</li> + <li>Other minor fixes & code cleanup</li> + </ul> +</li> + +<li>Fixes in compilation scripts for non-Intel platforms</li> +<li>Added Dynamic-Link-Library (DLL) version of SoundTouch library build, + provided with Delphi/Pascal wrapper for calling the dll routines</li> +<li>Added #define PREVENT_CLICK_AT_RATE_CROSSOVER that prevents a click artifact + when crossing the nominal pitch from either positive to negative side or vice + versa</li> + +</ul> + +<p><strong>1.4.1:</strong></p> +<ul> +<li>Fixed a buffer overflow bug in BPM detect algorithm routines if processing + more than 2048 samples at one call </li> + +</ul> + <p><strong>1.4.0:</strong></p> <ul> <li>Improved sound quality by automatic calculation of time stretch algorithm @@ -237,25 +268,32 @@ <p> </p> <hr> <h2 >6. Acknowledgements </h2> -<p >Kudos for these people who have submitted bugfixed since +<p >Kudos for these people who have contributed to development or submitted +bugfixes since SoundTouch v1.3.1: </p> <ul> <li>Arthur A</li> <li>Richard Ash</li> <li>Stanislav Brabec</li> + <li>Christian Budde</li> <li>Brian Cameron</li> + <li>Jason Champion</li> + <li>Patrick Colis</li> <li>Justin Frankel</li> <li>Jason Garland</li> <li>Takashi Iwai</li> + <li>Paulo Pizarro</li> + <li>RJ Ryan</li> + <li>John Sheehy</li> </ul> -<p >Moral greetings to all other contributors as well!</p> +<p >Moral greetings to all other contributors and users also!</p> <hr> <h2 >7. LICENSE </h2> <p>SoundTouch audio processing library<br> Copyright (c) Olli Parviainen</p> <p>This library is free software; you can redistribute it and/or modify it under the terms of the GNU -Lesser General Public License vesrion 2.1 as published by the Free Software +Lesser General Public License version 2.1 as published by the Free Software Foundation.</p> <p>This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2010-01-07 17:10:05 UTC (rev 456) @@ -1404,13 +1404,13 @@ } -CString CSoundFile::GetSampleName(UINT nSample) const -//-------------------------------------------------------- +LPCTSTR CSoundFile::GetSampleName(UINT nSample) const +//--------------------------------------------------- { if (nSample<MAX_SAMPLES) { return m_szNames[nSample]; } else { - return ""; + return gszEmpty; } } @@ -2875,7 +2875,9 @@ } // Load local tunings. - s_pTuningsSharedLocal->SetSavefilePath(std::string(std::string(theApp.GetTuningsPath()) + "local_tunings" + CTuningCollection::s_FileExtension.c_str())); + CString sPath; + sPath.Format(TEXT("%slocal_tunings%s"), CMainFrame::GetDefaultDirectory(DIR_TUNING), CTuningCollection::s_FileExtension); + s_pTuningsSharedLocal->SetSavefilePath(sPath); s_pTuningsSharedLocal->Deserialize(); // Enabling adding/removing of tunings for standard collection Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/soundlib/Sndfile.h 2010-01-07 17:10:05 UTC (rev 456) @@ -116,7 +116,7 @@ signed char nPPS; //Pitch to Pan Separator? unsigned char nPPC; //Pitch Centre? - CHAR name[32]; + CHAR name[32]; // Note: not guaranteed to be null-terminated. CHAR filename[32]; BYTE nMixPlug; //rewbs.instroVSTi @@ -651,7 +651,7 @@ void SetCurrentOrder(ORDERINDEX nOrder); void GetTitle(LPSTR s) const { lstrcpyn(s,m_szNames[0],32); } LPCSTR GetTitle() const { return m_szNames[0]; } - CString GetSampleName(UINT nSample) const; + LPCTSTR GetSampleName(UINT nSample) const; CString GetInstrumentName(UINT nInstr) const; UINT GetMusicSpeed() const { return m_nMusicSpeed; } UINT GetMusicTempo() const { return m_nMusicTempo; } Modified: trunk/OpenMPT/soundlib/mod_specifications.h =================================================================== --- trunk/OpenMPT/soundlib/mod_specifications.h 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/soundlib/mod_specifications.h 2010-01-07 17:10:05 UTC (rev 456) @@ -146,7 +146,7 @@ 0, //No instrument envelopes " 0123456789ABCD?FF?E???????????????", // Supported Effects " ???????????????", // Supported Volume Column commands - false, // Doesn't have "+++" pattern + true, // Has "+++" pattern }; const CModSpecifications xm = @@ -209,7 +209,7 @@ 12, //Envelope point count " 0123456789ABCDRFFTE???GHK?YXPLZ\\:#", // Supported Effects " vpcdabuhlrgfe:o", // Supported Volume Column commands - false, // Doesn't have "+++" pattern + true, // Has "+++" pattern }; const CModSpecifications s3m = Modified: trunk/OpenMPT/soundlib/tuningCollection.cpp =================================================================== --- trunk/OpenMPT/soundlib/tuningCollection.cpp 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/soundlib/tuningCollection.cpp 2010-01-07 17:10:05 UTC (rev 456) @@ -18,7 +18,7 @@ using namespace std; -const string CTuningCollection::s_FileExtension = ".tc"; +const TCHAR CTuningCollection::s_FileExtension[4] = TEXT(".tc"); namespace CTuningS11n { @@ -277,7 +277,7 @@ bool CTuningCollection::AddTuning(CTuning* const pT) //-------------------------------------------------- { - if((m_EditMask & EM_ADD) == 0 || m_Tunings.size() >= 255) + if((m_EditMask & EM_ADD) == 0 || m_Tunings.size() >= s_nMaxTuningCount) return true; if(pT == NULL) @@ -292,7 +292,7 @@ bool CTuningCollection::AddTuning(istream& inStrm, const bool ignoreEditmask) //------------------------------------------------- { - if(!ignoreEditmask && (m_EditMask & EM_ADD) == 0 || m_Tunings.size() >= 255) + if(!ignoreEditmask && (m_EditMask & EM_ADD) == 0 || m_Tunings.size() >= s_nMaxTuningCount) return true; if(!inStrm.good()) return true; Modified: trunk/OpenMPT/soundlib/tuningbase.cpp =================================================================== --- trunk/OpenMPT/soundlib/tuningbase.cpp 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/soundlib/tuningbase.cpp 2010-01-07 17:10:05 UTC (rev 456) @@ -44,7 +44,7 @@ const TYPENAME CTUNINGBASE::SERIALIZATION_RETURN_TYPE CTUNINGBASE::SERIALIZATION_FAILURE = true; TEMPLATEDEC -const string CTUNINGBASE::s_FileExtension = ".tun"; +const TCHAR CTUNINGBASE::s_FileExtension[5] = TEXT(".tun"); TEMPLATEDEC const TYPENAME CTUNINGBASE::EDITMASK CTUNINGBASE::EM_RATIOS = 1; //1b @@ -290,8 +290,8 @@ if(MayEdit(EM_RATIOS) && (MayEdit(EM_TYPE) || GetType() == TT_GROUPGEOMETRIC)) { - if(vr.first > vr.second) return true; - if(ratiostartpos < vr.first || vr.second < ratiostartpos || static_cast<UNOTEINDEXTYPE>(vr.second - ratiostartpos) < static_cast<UNOTEINDEXTYPE>(v.size())) return true; + if(vr.first > vr.second || v.size() == 0) return true; + if(ratiostartpos < vr.first || vr.second < ratiostartpos || static_cast<UNOTEINDEXTYPE>(vr.second - ratiostartpos) < static_cast<UNOTEINDEXTYPE>(v.size() - 1)) return true; if(!IsStepCountRangeSufficient(GetFineStepCount(), vr)) return true; for(size_t i = 0; i<v.size(); i++) {if(v[i] < 0) return true;} if(ProCreateGroupGeometric(v,r, vr, ratiostartpos)) Modified: trunk/OpenMPT/soundlib/tuningbase.h =================================================================== --- trunk/OpenMPT/soundlib/tuningbase.h 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/soundlib/tuningbase.h 2010-01-07 17:10:05 UTC (rev 456) @@ -95,7 +95,7 @@ static const SERIALIZATION_RETURN_TYPE SERIALIZATION_SUCCESS; static const SERIALIZATION_RETURN_TYPE SERIALIZATION_FAILURE; - static const string s_FileExtension; + static const TCHAR s_FileExtension[5]; static const EDITMASK EM_RATIOS; static const EDITMASK EM_NOTENAME; Modified: trunk/OpenMPT/soundlib/tuningcollection.h =================================================================== --- trunk/OpenMPT/soundlib/tuningcollection.h 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/soundlib/tuningcollection.h 2010-01-07 17:10:05 UTC (rev 456) @@ -50,7 +50,8 @@ SERIALIZATION_FAILURE = true }; - static const string s_FileExtension; + static const TCHAR s_FileExtension[4]; + static const size_t s_nMaxTuningCount = 255; //END PUBLIC STATIC CONSTS @@ -84,7 +85,7 @@ const string& GetName() const {return m_Name;} - void SetSavefilePath(const string& str) {m_SavefilePath = str;} + void SetSavefilePath(LPCTSTR psz) {m_SavefilePath = psz;} const string& GetSaveFilePath() const {return m_SavefilePath;} string GetVersionString() const {return Stringify(s_SerializationVersion);} Modified: trunk/OpenMPT/soundtouch/3dnow_win.cpp =================================================================== --- trunk/OpenMPT/soundtouch/3dnow_win.cpp 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/soundtouch/3dnow_win.cpp 2010-01-07 17:10:05 UTC (rev 456) @@ -35,10 +35,10 @@ /// //////////////////////////////////////////////////////////////////////////////// // -// Last changed : $Date: 2009-01-25 16:13:39 +0200 (Sun, 25 Jan 2009) $ +// Last changed : $Date: 2009-02-21 18:00:14 +0200 (Sat, 21 Feb 2009) $ // File revision : $Revision: 4 $ // -// $Id: 3dnow_win.cpp 51 2009-01-25 14:13:39Z oparviai $ +// $Id: 3dnow_win.cpp 63 2009-02-21 16:00:14Z oparviai $ // //////////////////////////////////////////////////////////////////////////////// // @@ -82,17 +82,13 @@ ////////////////////////////////////////////////////////////////////////////// #include "TDStretch.h" -//#include <limits.h> -// these are declared in 'TDStretch.cpp' -// extern int scanOffsets[4][24]; - // Calculates cross correlation of two buffers double TDStretch3DNow::calcCrossCorrStereo(const float *pV1, const float *pV2) const { - uint overlapLengthLocal = overlapLength; - float corr; + int overlapLengthLocal = overlapLength; + float corr = 0; // Calculates the cross-correlation value between 'pV1' and 'pV2' vectors /* Modified: trunk/OpenMPT/soundtouch/BPMDetect.cpp =================================================================== --- trunk/OpenMPT/soundtouch/BPMDetect.cpp 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/soundtouch/BPMDetect.cpp 2010-01-07 17:10:05 UTC (rev 456) @@ -26,10 +26,10 @@ /// //////////////////////////////////////////////////////////////////////////////// // -// Last changed : $Date: 2008-12-25 19:54:41 +0200 (Thu, 25 Dec 2008) $ +// Last changed : $Date: 2009-02-21 18:00:14 +0200 (Sat, 21 Feb 2009) $ // File revision : $Revision: 4 $ // -// $Id: BPMDetect.cpp 43 2008-12-25 17:54:41Z oparviai $ +// $Id: BPMDetect.cpp 63 2009-02-21 16:00:14Z oparviai $ // //////////////////////////////////////////////////////////////////////////////// // @@ -66,8 +66,6 @@ #define INPUT_BLOCK_SAMPLES 2048 #define DECIMATED_BLOCK_SAMPLES 256 -typedef unsigned short ushort; - /// decay constant for calculating RMS volume sliding average approximation /// (time constant is about 10 sec) const float avgdecay = 0.99986f; @@ -77,19 +75,14 @@ -BPMDetect::BPMDetect(int numChannels, int sampleRate) +BPMDetect::BPMDetect(int numChannels, int aSampleRate) { - xcorr = NULL; + this->sampleRate = aSampleRate; + this->channels = numChannels; - buffer = new FIFOSampleBuffer(); - decimateSum = 0; decimateCount = 0; - decimateBy = 0; - this->sampleRate = sampleRate; - this->channels = numChannels; - envelopeAccu = 0; // Initialize RMS volume accumulator to RMS level of 3000 (out of 32768) that's @@ -103,7 +96,26 @@ RMSVolumeAccu = (0.092f * 0.092f) / avgnorm; #endif - init(numChannels, sampleRate); + // choose decimation factor so that result is approx. 500 Hz + decimateBy = sampleRate / 500; + assert(decimateBy > 0); + assert(INPUT_BLOCK_SAMPLES < decimateBy * DECIMATED_BLOCK_SAMPLES); + + // Calculate window length & starting item according to desired min & max bpms + windowLen = (60 * sampleRate) / (decimateBy * MIN_BPM); + windowStart = (60 * sampleRate) / (decimateBy * MAX_BPM); + + assert(windowLen > windowStart); + + // allocate new working objects + xcorr = new float[windowLen]; + memset(xcorr, 0, windowLen * sizeof(float)); + + // allocate processing buffer + buffer = new FIFOSampleBuffer(); + // we do processing in mono mode + buffer->setChannels(1); + buffer->clear(); } @@ -115,7 +127,9 @@ } -/// low-pass filter & decimate to about 500 Hz. return number of outputted samples. + +/// convert to mono, low-pass filter & decimate to about 500 Hz. +/// return number of outputted samples. /// /// Decimation is used to remove the unnecessary frequencies and thus to reduce /// the amount of data needed to be processed as calculating autocorrelation @@ -130,17 +144,25 @@ int count, outcount; LONG_SAMPLETYPE out; - assert(decimateBy != 0); + assert(channels > 0); + assert(decimateBy > 0); outcount = 0; for (count = 0; count < numsamples; count ++) { - decimateSum += src[count]; + int j; + // convert to mono and accumulate + for (j = 0; j < channels; j ++) + { + decimateSum += src[j]; + } + src += j; + decimateCount ++; if (decimateCount >= decimateBy) { // Store every Nth sample only - out = (LONG_SAMPLETYPE)(decimateSum / decimateBy); + out = (LONG_SAMPLETYPE)(decimateSum / (decimateBy * channels)); decimateSum = 0; decimateCount = 0; #ifdef INTEGER_SAMPLES @@ -231,35 +253,35 @@ -void BPMDetect::inputSamples(SAMPLETYPE *samples, int numSamples) +void BPMDetect::inputSamples(const SAMPLETYPE *samples, int numSamples) { SAMPLETYPE decimated[DECIMATED_BLOCK_SAMPLES]; - // convert from stereo to mono if necessary - if (channels == 2) + // iterate so that max INPUT_BLOCK_SAMPLES processed per iteration + while (numSamples > 0) { - int i; + int block; + int decSamples; - for (i = 0; i < numSamples; i ++) - { - samples[i] = (samples[i * 2] + samples[i * 2 + 1]) / 2; - } - } - - // decimate - numSamples = decimate(decimated, samples, numSamples); + block = (numSamples > INPUT_BLOCK_SAMPLES) ? INPUT_BLOCK_SAMPLES : numSamples; - // envelope new samples and add them to buffer - calcEnvelope(decimated, numSamples); - buffer->putSamples(decimated, numSamples); + // decimate. note that converts to mono at the same time + decSamples = decimate(decimated, samples, block); + samples += block * channels; + numSamples -= block; + // envelope new samples and add them to buffer + calcEnvelope(decimated, decSamples); + buffer->putSamples(decimated, decSamples); + } + // when the buffer has enought samples for processing... if ((int)buffer->numSamples() > windowLen) { int processLength; // how many samples are processed - processLength = buffer->numSamples() - windowLen; + processLength = (int)buffer->numSamples() - windowLen; // ... calculate autocorrelations for oldest samples... updateXCorr(processLength); @@ -269,32 +291,7 @@ } -void BPMDetect::init(int numChannels, int sampleRate) -{ - this->sampleRate = sampleRate; - // choose decimation factor so that result is approx. 500 Hz - decimateBy = sampleRate / 500; - assert(decimateBy > 0); - assert(INPUT_BLOCK_SAMPLES < decimateBy * DECIMATED_BLOCK_SAMPLES); - - // Calculate window length & starting item according to desired min & max bpms - windowLen = (60 * sampleRate) / (decimateBy * MIN_BPM); - windowStart = (60 * sampleRate) / (decimateBy * MAX_BPM); - - assert(windowLen > windowStart); - - // allocate new working objects - xcorr = new float[windowLen]; - memset(xcorr, 0, windowLen * sizeof(float)); - - // we do processing in mono mode - buffer->setChannels(1); - buffer->clear(); -} - - - float BPMDetect::getBpm() { double peakPos; Modified: trunk/OpenMPT/soundtouch/BPMDetect.h =================================================================== --- trunk/OpenMPT/soundtouch/BPMDetect.h 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/soundtouch/BPMDetect.h 2010-01-07 17:10:05 UTC (rev 456) @@ -26,10 +26,10 @@ /// //////////////////////////////////////////////////////////////////////////////// // -// Last changed : $Date: 2008-12-25 14:20:01 +0200 (Thu, 25 Dec 2008) $ +// Last changed : $Date: 2009-02-21 18:00:14 +0200 (Sat, 21 Feb 2009) $ // File revision : $Revision: 4 $ // -// $Id: BPMDetect.h 33 2008-12-25 12:20:01Z oparviai $ +// $Id: BPMDetect.h 63 2009-02-21 16:00:14Z oparviai $ // //////////////////////////////////////////////////////////////////////////////// // @@ -108,9 +108,6 @@ /// FIFO-buffer for decimated processing samples. soundtouch::FIFOSampleBuffer *buffer; - /// Initialize the class for processing. - void init(int numChannels, int sampleRate); - /// Updates auto-correlation function for given number of decimated samples that /// are read from the internal 'buffer' pipe (samples aren't removed from the pipe /// though). @@ -146,8 +143,8 @@ /// function. /// /// Notice that data in 'samples' array can be disrupted in processing. - void inputSamples(soundtouch::SAMPLETYPE *samples, ///< Pointer to input/working data buffer - int numSamples ///< Number of samples in buffer + void inputSamples(const soundtouch::SAMPLETYPE *samples, ///< Pointer to input/working data buffer + int numSamples ///< Number of samples in buffer ); Modified: trunk/OpenMPT/soundtouch/FIFOSampleBuffer.cpp =================================================================== --- trunk/OpenMPT/soundtouch/FIFOSampleBuffer.cpp 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/soundtouch/FIFOSampleBuffer.cpp 2010-01-07 17:10:05 UTC (rev 456) @@ -15,10 +15,10 @@ /// //////////////////////////////////////////////////////////////////////////////// // -// Last changed : $Date: 2008-02-10 18:26:55 +0200 (Sun, 10 Feb 2008) $ +// Last changed : $Date: 2009-02-27 19:24:42 +0200 (Fri, 27 Feb 2009) $ // File revision : $Revision: 4 $ // -// $Id: FIFOSampleBuffer.cpp 11 2008-02-10 16:26:55Z oparviai $ +// $Id: FIFOSampleBuffer.cpp 68 2009-02-27 17:24:42Z oparviai $ // //////////////////////////////////////////////////////////////////////////////// // @@ -63,6 +63,7 @@ samplesInBuffer = 0; bufferPos = 0; channels = (uint)numChannels; + ensureCapacity(32); // allocate initial capacity } @@ -151,8 +152,9 @@ // When using this function to output samples, also remember to 'remove' the // outputted samples from the buffer by calling the // 'receiveSamples(numSamples)' function -SAMPLETYPE *FIFOSampleBuffer::ptrBegin() const +SAMPLETYPE *FIFOSampleBuffer::ptrBegin() { + assert(buffer); return buffer + bufferPos * channels; } @@ -175,8 +177,12 @@ { throw std::runtime_error("Couldn't allocate memory!\n"); } + // Align the buffer to begin at 16byte cache line boundary for optimal performance temp = (SAMPLETYPE *)(((ulong)tempUnaligned + 15) & (ulong)-16); - memcpy(temp, ptrBegin(), samplesInBuffer * channels * sizeof(SAMPLETYPE)); + if (samplesInBuffer) + { + memcpy(temp, ptrBegin(), samplesInBuffer * channels * sizeof(SAMPLETYPE)); + } delete[] bufferUnaligned; buffer = temp; bufferUnaligned = tempUnaligned; Modified: trunk/OpenMPT/soundtouch/FIFOSampleBuffer.h =================================================================== --- trunk/OpenMPT/soundtouch/FIFOSampleBuffer.h 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/soundtouch/FIFOSampleBuffer.h 2010-01-07 17:10:05 UTC (rev 456) @@ -15,10 +15,10 @@ /// //////////////////////////////////////////////////////////////////////////////// // -// Last changed : $Date: 2008-02-10 18:26:55 +0200 (Sun, 10 Feb 2008) $ +// Last changed : $Date: 2009-02-21 18:00:14 +0200 (Sat, 21 Feb 2009) $ // File revision : $Revision: 4 $ // -// $Id: FIFOSampleBuffer.h 11 2008-02-10 16:26:55Z oparviai $ +// $Id: FIFOSampleBuffer.h 63 2009-02-21 16:00:14Z oparviai $ // //////////////////////////////////////////////////////////////////////////////// // @@ -107,7 +107,7 @@ /// When using this function to output samples, also remember to 'remove' the /// output samples from the buffer by calling the /// 'receiveSamples(numSamples)' function - virtual SAMPLETYPE *ptrBegin() const; + virtual SAMPLETYPE *ptrBegin(); /// Returns a pointer to the end of the used part of the sample buffer (i.e. /// where the new samples are to be inserted). This function may be used for Modified: trunk/OpenMPT/soundtouch/FIFOSamplePipe.h =================================================================== --- trunk/OpenMPT/soundtouch/FIFOSamplePipe.h 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/soundtouch/FIFOSamplePipe.h 2010-01-07 17:10:05 UTC (rev 456) @@ -65,6 +65,10 @@ class SOUNDTOUCH_DLLEXPORT FIFOSamplePipe { public: + // virtual default destructor + virtual ~FIFOSamplePipe() {} + + /// Returns a pointer to the beginning of the output samples. /// This function is provided for accessing the output samples directly. /// Please be careful for not to corrupt the book-keeping! @@ -72,7 +76,7 @@ /// When using this function to output samples, also remember to 'remove' the /// output samples from the buffer by calling the /// 'receiveSamples(numSamples)' function - virtual SAMPLETYPE *ptrBegin() const = 0; + virtual SAMPLETYPE *ptrBegin() = 0; /// Adds 'numSamples' pcs of samples from the 'samples' memory position to /// the sample buffer. @@ -173,7 +177,7 @@ /// When using this function to output samples, also remember to 'remove' the /// output samples from the buffer by calling the /// 'receiveSamples(numSamples)' function - virtual SAMPLETYPE *ptrBegin() const + virtual SAMPLETYPE *ptrBegin() { return output->ptrBegin(); } Modified: trunk/OpenMPT/soundtouch/FIRFilter.cpp =================================================================== --- trunk/OpenMPT/soundtouch/FIRFilter.cpp 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/soundtouch/FIRFilter.cpp 2010-01-07 17:10:05 UTC (rev 456) @@ -1,12 +1,3 @@ -/*********************************************** - * - * ------------- NOTE ------------- - * - * This file is modified version of the original SoundTouch file. - * Search for "OpenMPT_change" to see the modifications. - * -*/ - //////////////////////////////////////////////////////////////////////////////// /// /// General FIR digital filter routines with MMX optimization. @@ -20,7 +11,11 @@ /// //////////////////////////////////////////////////////////////////////////////// // +// Last changed : $Date: 2009-02-25 19:13:51 +0200 (Wed, 25 Feb 2009) $ +// File revision : $Revision: 4 $ // +// $Id: FIRFilter.cpp 67 2009-02-25 17:13:51Z oparviai $ +// //////////////////////////////////////////////////////////////////////////////// // // License : @@ -186,10 +181,7 @@ assert(length == newLength); resultDivFactor = uResultDivFactor; - //OpenMPT_change--> - //resultDivider = (SAMPLETYPE)::pow(2, resultDivFactor); - resultDivider = (1 << resultDivFactor); // == 2^resultDivFactor - //<-- + resultDivider = (SAMPLETYPE)::pow(2.0, (int)resultDivFactor); delete[] filterCoeffs; filterCoeffs = new SAMPLETYPE[length]; Modified: trunk/OpenMPT/soundtouch/FIRFilter.h =================================================================== --- trunk/OpenMPT/soundtouch/FIRFilter.h 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/soundtouch/FIRFilter.h 2010-01-07 17:10:05 UTC (rev 456) @@ -11,10 +11,10 @@ /// //////////////////////////////////////////////////////////////////////////////// // -// Last changed : $Date: 2008-02-10 18:26:55 +0200 (Sun, 10 Feb 2008) $ +// Last changed : $Date: 2009-02-21 18:00:14 +0200 (Sat, 21 Feb 2009) $ // File revision : $Revision: 4 $ // -// $Id: FIRFilter.h 11 2008-02-10 16:26:55Z oparviai $ +// $Id: FIRFilter.h 63 2009-02-21 16:00:14Z oparviai $ // //////////////////////////////////////////////////////////////////////////////// // @@ -42,6 +42,7 @@ #ifndef FIRFilter_H #define FIRFilter_H +#include <stddef.h> #include "STTypes.h" namespace soundtouch @@ -103,7 +104,7 @@ #ifdef ALLOW_MMX - /// Class that implements MMX optimized functions exclusive for 16bit integer samples type. +/// Class that implements MMX optimized functions exclusive for 16bit integer samples type. class FIRFilterMMX : public FIRFilter { protected: Modified: trunk/OpenMPT/soundtouch/PeakFinder.cpp =================================================================== --- trunk/OpenMPT/soundtouch/PeakFinder.cpp 2010-01-04 20:01:28 UTC (rev 455) +++ trunk/OpenMPT/soundtouch/PeakFinder.cpp 2010-01-07 17:10:05 UTC (r... [truncated message content] |