From: <sag...@us...> - 2011-08-01 22:47:51
|
Revision: 954 http://modplug.svn.sourceforge.net/modplug/?rev=954&view=rev Author: saga-games Date: 2011-08-01 22:47:44 +0000 (Mon, 01 Aug 2011) Log Message: ----------- [Imp] Macros are now sanitized and cleared after first null char before saving them to a module file. [Imp] When saving a file loaded from a template for the first time, the extension of the proposed filename is not duplicated anymore. [Ref] Some more related save code refactoring. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/soundlib/Sndfile.cpp Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2011-08-01 16:21:19 UTC (rev 953) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2011-08-01 22:47:44 UTC (rev 954) @@ -481,6 +481,9 @@ void CMainFrame::OnClose() //------------------------ { + // TODO: Here we could add a custom dialog that lists all modified files, and the user could select which should be saved. + // How do we get all files? Does the document manager help here? + CChildFrame *pMDIActive = (CChildFrame *)MDIGetActive(); BeginWaitCursor(); @@ -2177,6 +2180,14 @@ ASSERT(pDoc->IsKindOf(RUNTIME_CLASS(CModDoc)) == TRUE); CModDoc* pModDoc = static_cast<CModDoc*>(pDoc); pModDoc->ClearFilePath(); // Clear path so that saving will not take place in templates/examples folder. + // Remove extension from title, so that saving the file will not suggest a filename like f.e. "template.mptm.mptm". + const CString title = pModDoc->GetTitle(); + const int dotPos = title.ReverseFind('.'); + if(dotPos >= 0) + { + pModDoc->SetTitle(title.Left(dotPos)); + } + if (bTemplateFile) { pModDoc->GetFileHistory()->clear(); // Reset edit history for template files @@ -2362,7 +2373,7 @@ { case kcViewTree: OnBarCheck(IDD_TREEVIEW); break; case kcViewOptions: OnViewOptions(); break; - case kcViewMain: OnBarCheck(59392); break; + case kcViewMain: OnBarCheck(59392 /* MAINVIEW */); break; case kcFileImportMidiLib: OnImportMidiLib(); break; case kcFileAddSoundBank: OnAddDlsBank(); break; case kcPauseSong: OnPlayerPause(); break; Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2011-08-01 16:21:19 UTC (rev 953) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2011-08-01 22:47:44 UTC (rev 954) @@ -436,13 +436,11 @@ //-------------------------------------------------------------------------- { static int greccount = 0; - TCHAR fext[_MAX_EXT] = _T(""); UINT dwPacking = 0; BOOL bOk = FALSE; m_SndFile.m_dwLastSavedWithVersion = MptVersion::num; if (!lpszPathName) return FALSE; - _tsplitpath(lpszPathName, NULL, NULL, NULL, fext); MODTYPE type = m_SndFile.GetType(); // CModSpecifications::ExtensionToType(fext); if (type == MOD_TYPE_NONE && !greccount) @@ -460,17 +458,21 @@ case MOD_TYPE_MOD: bOk = m_SndFile.SaveMod(lpszPathName, dwPacking); break; case MOD_TYPE_S3M: bOk = m_SndFile.SaveS3M(lpszPathName, dwPacking); break; case MOD_TYPE_XM: bOk = m_SndFile.SaveXM(lpszPathName, dwPacking); break; - case MOD_TYPE_IT: bOk = (m_SndFile.m_dwSongFlags & SONG_ITPROJECT || !lstrcmpi(fext, _T(".itp"))) ? m_SndFile.SaveITProject(lpszPathName) : m_SndFile.SaveIT(lpszPathName, dwPacking); break; + case MOD_TYPE_IT: bOk = (m_SndFile.m_dwSongFlags & SONG_ITPROJECT) ? m_SndFile.SaveITProject(lpszPathName) : m_SndFile.SaveIT(lpszPathName, dwPacking); break; case MOD_TYPE_MPT: bOk = m_SndFile.SaveIT(lpszPathName, dwPacking); break; } EndWaitCursor(); if (bOk) { - if (type == m_SndFile.GetType() && !bTemplateFile) + if (!bTemplateFile) + { + // Set new path for this file, unless we are saving a template, in which case we want to keep the old file path. SetPathName(lpszPathName); + } ShowLog(); if (bTemplateFile) { + // Update template menu. CMainFrame* const pMainFrame = CMainFrame::GetMainFrame(); if (pMainFrame) pMainFrame->CreateTemplateModulesMenu(); @@ -491,7 +493,8 @@ BOOL CModDoc::SaveModified() //-------------------------- { - if((m_SndFile.m_nType & MOD_TYPE_IT) && m_SndFile.m_dwSongFlags & SONG_ITPROJECT && !(m_SndFile.m_dwSongFlags & SONG_ITPEMBEDIH)){ + if((m_SndFile.m_nType & MOD_TYPE_IT) && m_SndFile.m_dwSongFlags & SONG_ITPROJECT && !(m_SndFile.m_dwSongFlags & SONG_ITPEMBEDIH)) + { bool unsavedInstrument = false; @@ -506,8 +509,10 @@ if(unsavedInstrument && ::MessageBox(NULL,"Do you want to save modified instruments?",NULL,MB_ICONQUESTION | MB_YESNO | MB_APPLMODAL) == IDYES){ - for(INSTRUMENTINDEX i = 0 ; i < m_SndFile.m_nInstruments ; i++){ - if(m_SndFile.m_szInstrumentPath[i][0] != '\0'){ + for(INSTRUMENTINDEX i = 0 ; i < m_SndFile.m_nInstruments ; i++) + { + if(m_SndFile.m_szInstrumentPath[i][0] != '\0') + { int size = strlen(m_SndFile.m_szInstrumentPath[i]); bool iti = _stricmp(&m_SndFile.m_szInstrumentPath[i][size-3],"iti") == 0; bool xi = _stricmp(&m_SndFile.m_szInstrumentPath[i][size-2],"xi") == 0; @@ -596,7 +601,7 @@ if ((!lpszPathName) || (!lpszPathName[0]) || m_ShowSavedialog) { _splitpath(m_strPathName, drive, path, fname, NULL); - if (!fname[0]) strcpy(fname, m_strTitle); + if (!fname[0]) strcpy(fname, GetTitle()); strcpy(s, drive); strcat(s, path); strcat(s, fname); @@ -1787,15 +1792,10 @@ if ((!pMainFrm) || (!m_SndFile.GetType())) return; switch (type) { - /*case MOD_TYPE_XM: - ext = "xm"; - pattern = "Fast Tracker Files (*.xm)|*.xm||"; - break;*/ case MOD_TYPE_MOD: - ext = ModSpecs::mod.fileExtension; pattern = FileFilterMOD; if( AfxMessageBox(GetStrI18N(TEXT( - "Compared to regular MOD save, compatibility export adjust the beginning of oneshot samples " + "Compared to regular MOD save, compatibility export adjusts the beginning of oneshot samples " "in order to make the file compatible with ProTracker and other Amiga-based trackers. " "Note that this feature does not remove effects \"invented\" by other PC-based trackers (f.e. panning commands)." "\n\n Proceed?")), MB_ICONINFORMATION|MB_YESNO) != IDYES @@ -1803,12 +1803,10 @@ return; break; case MOD_TYPE_IT: - ext = ModSpecs::it.fileExtension; pattern = FileFilterIT; ::MessageBox(NULL,"Warning: the exported file will not contain any of MPT's file-format hacks.", "Compatibility export warning.",MB_ICONINFORMATION | MB_OK); break; case MOD_TYPE_XM: - ext = ModSpecs::xm.fileExtension; pattern = FileFilterXM; ::MessageBox(NULL,"Warning: the exported file will not contain any of MPT's file-format hacks.", "Compatibility export warning.",MB_ICONINFORMATION | MB_OK); break; @@ -1816,6 +1814,7 @@ ::MessageBox(NULL,"Compatibility export is currently only available for MOD, XM and IT modules.", "Can't do compatibility export.",MB_ICONINFORMATION | MB_OK); return; } + ext = m_SndFile.GetModSpecifications().fileExtension; _splitpath(GetPathName(), drive, path, fname, NULL); filename = drive; @@ -3951,11 +3950,14 @@ FixNullString(m_SndFile.ChnSettings[nChn].szName); } + // Macros + m_SndFile.SanitizeMacros(); + // Pattern names - // Halp, this is currently not possible. Is it even needed? + // Those are CStrings and don't need to be fixed. // Sequence names. - // Not needed? + // Those are CStrings and don't need to be fixed. } Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2011-08-01 16:21:19 UTC (rev 953) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2011-08-01 22:47:44 UTC (rev 954) @@ -940,15 +940,15 @@ { for(size_t i = 0; i < CountOf(m_MidiCfg.szMidiGlb); i++) { - SetNullTerminator(m_MidiCfg.szMidiGlb[i]); + FixNullString(m_MidiCfg.szMidiGlb[i]); } for(size_t i = 0; i < CountOf(m_MidiCfg.szMidiSFXExt); i++) { - SetNullTerminator(m_MidiCfg.szMidiSFXExt[i]); + FixNullString(m_MidiCfg.szMidiSFXExt[i]); } for(size_t i = 0; i < CountOf(m_MidiCfg.szMidiZXXExt); i++) { - SetNullTerminator(m_MidiCfg.szMidiZXXExt[i]); + FixNullString(m_MidiCfg.szMidiZXXExt[i]); } } @@ -2662,9 +2662,9 @@ MemsetZero(m_defaultInstrument); m_defaultInstrument.nResampling = SRCMODE_DEFAULT; m_defaultInstrument.nFilterMode = FLTMODE_UNCHANGED; - m_defaultInstrument.nPPC = 5*12; - m_defaultInstrument.nGlobalVol=64; - m_defaultInstrument.nPan = 0x20 << 2; + m_defaultInstrument.nPPC = 5 * 12; + m_defaultInstrument.nGlobalVol = 64; + m_defaultInstrument.nPan = 32 * 4; //m_defaultInstrument.nIFC = 0xFF; m_defaultInstrument.PanEnv.nReleaseNode=ENV_RELEASE_NODE_UNSET; m_defaultInstrument.PitchEnv.nReleaseNode=ENV_RELEASE_NODE_UNSET; @@ -2942,4 +2942,3 @@ FixMIDIConfigString(midiCfg.szMidiZXXExt[i]); } } - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-08-08 12:54:49
|
Revision: 964 http://modplug.svn.sourceforge.net/modplug/?rev=964&view=rev Author: saga-games Date: 2011-08-08 12:54:40 +0000 (Mon, 08 Aug 2011) Log Message: ----------- [Ref] Moved string fixing functions to separate namespace and file. Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Ctrl_pat.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/View_gen.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/mptrack/misc_util.h trunk/OpenMPT/mptrack/mptrack.vcproj trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/view_com.cpp trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/LOAD_AMF.CPP trunk/OpenMPT/soundlib/LOAD_DBM.CPP trunk/OpenMPT/soundlib/LOAD_DMF.CPP trunk/OpenMPT/soundlib/LOAD_DSM.CPP trunk/OpenMPT/soundlib/Load_669.cpp trunk/OpenMPT/soundlib/Load_ams.cpp trunk/OpenMPT/soundlib/Load_far.cpp trunk/OpenMPT/soundlib/Load_gdm.cpp trunk/OpenMPT/soundlib/Load_imf.cpp trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_itp.cpp trunk/OpenMPT/soundlib/Load_mdl.cpp trunk/OpenMPT/soundlib/Load_med.cpp trunk/OpenMPT/soundlib/Load_mod.cpp trunk/OpenMPT/soundlib/Load_mt2.cpp trunk/OpenMPT/soundlib/Load_mtm.cpp trunk/OpenMPT/soundlib/Load_okt.cpp trunk/OpenMPT/soundlib/Load_psm.cpp trunk/OpenMPT/soundlib/Load_ptm.cpp trunk/OpenMPT/soundlib/Load_s3m.cpp trunk/OpenMPT/soundlib/Load_stm.cpp trunk/OpenMPT/soundlib/Load_ult.cpp trunk/OpenMPT/soundlib/Load_xm.cpp trunk/OpenMPT/soundlib/Loaders.h trunk/OpenMPT/soundlib/Sampleio.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/load_j2b.cpp Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -9,6 +9,7 @@ #include "fxp.h" #include "dlg_misc.h" #include "AbstractVstEditor.h" +#include "../soundlib/StringFixer.h" #ifndef NO_VST @@ -201,7 +202,7 @@ strcpy(rawname, ""); } } - SetNullTerminator(rawname); + StringFixer::SetNullTerminator(rawname); CreateVerifiedProgramName(rawname, CountOf(rawname), name, CountOf(name), index); m_pMenu->ModifyMenu(8, MF_BYPOSITION, 0, name); @@ -440,7 +441,7 @@ { strcpy(sname, ""); } - SetNullTerminator(sname); + StringFixer::SetNullTerminator(sname); CreateVerifiedProgramName(sname, sizeof(sname), s, sizeof(s), p); Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -9,6 +9,7 @@ #include "dlg_misc.h" #include "tuningDialog.h" #include "misc_util.h" +#include "../soundlib/StringFixer.h" #include "Vstplug.h" #pragma warning(disable:4244) //conversion from 'type1' to 'type2', possible loss of data @@ -1717,7 +1718,7 @@ { strncpy(szFileName, pIns->name, min(CountOf(pIns->name), CountOf(szFileName) - 1)); } - SetNullTerminator(szFileName); + StringFixer::SetNullTerminator(szFileName); SanitizeFilename(szFileName); FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(false, (m_pSndFile->GetType() == MOD_TYPE_XM) ? "xi" : "iti", szFileName, Modified: trunk/OpenMPT/mptrack/Ctrl_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -8,7 +8,9 @@ #include "ctrl_pat.h" #include "view_pat.h" #include "ChannelManagerDlg.h" +#include "../soundlib/StringFixer.h" + ////////////////////////////////////////////////////////////// // CCtrlPatterns @@ -1071,7 +1073,7 @@ CHAR s[MAX_PATTERNNAME]; m_EditPatName.GetWindowText(s, CountOf(s)); - SetNullTerminator(s); + StringFixer::SetNullTerminator(s); if (m_pSndFile->Patterns[nPat].GetName().Compare(s)) { Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -16,6 +16,7 @@ #include "smbPitchShift.cpp" #pragma warning(default:4244) //"conversion from 'type1' to 'type2', possible loss of data" #include "modsmp_ctrl.h" +#include "../soundlib/StringFixer.h" #include <Shlwapi.h> #ifdef _DEBUG @@ -1019,7 +1020,7 @@ sPath += ".wav"; _splitpath(sPath, NULL, NULL, szFileName, NULL); } - SetNullTerminator(szFileName); + StringFixer::SetNullTerminator(szFileName); SanitizeFilename(szFileName); FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(false, "wav", szFileName, Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -8,6 +8,7 @@ #include "EffectVis.h" //rewbs.fxvis #include "ChannelManagerDlg.h" #include "../soundlib/tuningbase.h" +#include "../soundlib/StringFixer.h" #include <string> using std::string; @@ -1515,7 +1516,7 @@ if(m->instr <= MAX_MIXPLUGINS) { strncpy(sztmp, pSndFile->m_MixPlugins[m->instr - 1].GetName(), sizeof(sztmp)); - SetNullTerminator(sztmp); + StringFixer::SetNullTerminator(sztmp); } } else { @@ -1564,7 +1565,7 @@ { CHAR sztmp[128] = ""; strncpy(sztmp, pSndFile->m_MixPlugins[m->instr - 1].GetParamName(m->GetValueVolCol()), sizeof(sztmp)); - SetNullTerminator(sztmp); + StringFixer::SetNullTerminator(sztmp); if (sztmp[0]) wsprintf(s, "%d: %s", m->GetValueVolCol(), sztmp); } } else Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -15,6 +15,7 @@ #include "version.h" #include "modsmp_ctrl.h" #include "CleanupSong.h" +#include "../soundlib/StringFixer.h" #include <shlwapi.h> extern WORD S3MFineTuneTable[16]; @@ -3926,13 +3927,13 @@ //---------------------------- { // Song title - FixNullString(m_SndFile.m_szNames[0]); + StringFixer::FixNullString(m_SndFile.m_szNames[0]); // Sample names + filenames for(SAMPLEINDEX nSmp = 1; nSmp < m_SndFile.GetNumSamples(); nSmp++) { - FixNullString(m_SndFile.m_szNames[nSmp]); - FixNullString(m_SndFile.Samples[nSmp].filename); + StringFixer::FixNullString(m_SndFile.m_szNames[nSmp]); + StringFixer::FixNullString(m_SndFile.Samples[nSmp].filename); } // Instrument names @@ -3940,15 +3941,15 @@ { if(m_SndFile.Instruments[nIns] != nullptr) { - FixNullString(m_SndFile.Instruments[nIns]->name); - FixNullString(m_SndFile.Instruments[nIns]->filename); + StringFixer::FixNullString(m_SndFile.Instruments[nIns]->name); + StringFixer::FixNullString(m_SndFile.Instruments[nIns]->filename); } } // Channel names for(CHANNELINDEX nChn = 0; nChn < m_SndFile.GetNumChannels(); nChn++) { - FixNullString(m_SndFile.ChnSettings[nChn].szName); + StringFixer::FixNullString(m_SndFile.ChnSettings[nChn].szName); } // Macros Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -19,6 +19,7 @@ #include <shlwapi.h> #include <afxadv.h> #include "UpdateCheck.h" +#include "../soundlib/StringFixer.h" // rewbs.memLeak #define _CRTDBG_MAP_ALLOC @@ -3106,7 +3107,7 @@ const size_t nStrLength = nLength - 1; // "usable" length, i.e. not including the null char. TCHAR szExePath[nLength], szTempPath[nLength]; _tcsncpy(szExePath, GetAppDirPath(), nStrLength); - SetNullTerminator(szExePath); + StringFixer::SetNullTerminator(szExePath); if(!_tcsncicmp(szExePath, szPath, _tcslen(szExePath))) { @@ -3120,7 +3121,7 @@ _tcsncpy(szTempPath, &szPath[2], nStrLength); // "\Somepath" _tcscpy(szPath, szTempPath); } - SetNullTerminator(szPath); + StringFixer::SetNullTerminator(szPath); } @@ -3140,7 +3141,7 @@ const size_t nStrLength = nLength - 1; // "usable" length, i.e. not including the null char. TCHAR szExePath[nLength], szTempPath[nLength] = _T(""); _tcsncpy(szExePath, GetAppDirPath(), nStrLength); - SetNullTerminator(szExePath); + StringFixer::SetNullTerminator(szExePath); if(!_tcsncicmp(szPath, _T("\\"), 1)) { @@ -3158,7 +3159,7 @@ } _tcscpy(szPath, szTempPath); } - SetNullTerminator(szPath); + StringFixer::SetNullTerminator(szPath); } void CTrackApp::RemoveMruItem(const int nItem) Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -19,6 +19,7 @@ #include "UpdateCheck.h" #include "Mpdlgs.h" #include "AutoSaver.h" +#include "../soundlib/StringFixer.h" #include "TrackerSettings.h" @@ -202,14 +203,14 @@ CHAR snam[8]; wsprintf(snam, "SF%X", isfx); GetPrivateProfileString("Zxx Macros", snam, macros.szMidiSFXExt[isfx], macros.szMidiSFXExt[isfx], CountOf(macros.szMidiSFXExt[isfx]), iniFile); - SetNullTerminator(macros.szMidiSFXExt[isfx]); + StringFixer::SetNullTerminator(macros.szMidiSFXExt[isfx]); } for(int izxx = 0; izxx < 128; izxx++) { CHAR snam[8]; wsprintf(snam, "Z%02X", izxx | 0x80); GetPrivateProfileString("Zxx Macros", snam, macros.szMidiZXXExt[izxx], macros.szMidiZXXExt[izxx], CountOf(macros.szMidiZXXExt[izxx]), iniFile); - SetNullTerminator(macros.szMidiZXXExt[izxx]); + StringFixer::SetNullTerminator(macros.szMidiZXXExt[izxx]); } // Fix old nasty broken (non-standard) MIDI configs in INI file. if(storedVersion >= "1.17" && storedVersion < "1.20") Modified: trunk/OpenMPT/mptrack/View_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_gen.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/mptrack/View_gen.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -10,6 +10,7 @@ #include "EffectVis.h" #include "movefxslotdialog.h" #include "ChannelManagerDlg.h" +#include "../soundlib/StringFixer.h" #include ".\view_gen.h" #define ID_FXCOMMANDS_BASE 41000 @@ -1531,7 +1532,7 @@ { strcpy(sname, ""); } - SetNullTerminator(sname); + StringFixer::SetNullTerminator(sname); if(sname[0] < ' ') { Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -14,6 +14,7 @@ #include "midi.h" #include "version.h" #include "midimappingdialog.h" +#include "../soundlib/StringFixer.h" #ifdef VST_USE_ALTERNATIVE_MAGIC //Pelya's plugin ID fix. Breaks fx presets, so let's avoid it for now. #define ZLIB_WINAPI #include "../zlib/zlib.h" //For CRC32 calculation (to detect plugins with same UID) @@ -219,7 +220,7 @@ { // Get path from cache file GetPrivateProfileString(cacheSection, IDs, "", szPath, CountOf(szPath), cacheFile); - SetNullTerminator(szPath); + StringFixer::SetNullTerminator(szPath); theApp.RelativePathToAbsolute(szPath); if ((szPath[0]) && (!lstrcmpi(szPath, pszDllPath))) @@ -367,7 +368,7 @@ { theApp.AbsolutePathToRelative(szPath); } - SetNullTerminator(szPath); + StringFixer::SetNullTerminator(szPath); WritePrivateProfileString(cacheSection, IDs, szPath, cacheFile); CMainFrame::WritePrivateProfileCString(cacheSection, IDs, pszDllPath, cacheFile); Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -9,6 +9,7 @@ #include "ChannelManagerDlg.h" #include "midi.h" #include "version.h" +#include "../soundlib/StringFixer.h" #pragma warning(disable:4244) //"conversion from 'type1' to 'type2', possible loss of data" @@ -800,7 +801,7 @@ for (UINT plug=0; plug<MAX_MIXPLUGINS; plug++) { PSNDMIXPLUGIN p = &(m_pSndFile->m_MixPlugins[plug]); - SetNullTerminator(p->Info.szLibraryName); + StringFixer::SetNullTerminator(p->Info.szLibraryName); if (p->Info.szLibraryName[0]) { wsprintf(s, "FX%d: %s", plug+1, p->Info.szName); @@ -886,7 +887,7 @@ { ToggleBoxes(sfx_preset, sfx); memcpy(s, m_MidiCfg.szMidiSFXExt[sfx], MACRO_LENGTH); - SetNullTerminator(s); + StringFixer::SetNullTerminator(s); m_EditSFx.SetWindowText(s); } @@ -894,7 +895,7 @@ if (zxx < 0x80) { memcpy(s, m_MidiCfg.szMidiZXXExt[zxx], MACRO_LENGTH); - SetNullTerminator(s); + StringFixer::SetNullTerminator(s); m_EditZxx.SetWindowText(s); } UpdateMacroList(); @@ -1008,7 +1009,7 @@ { MemsetZero(s); m_EditSFx.GetWindowText(s, MACRO_LENGTH); - SetNullTerminator(s); + StringFixer::SetNullTerminator(s); memcpy(m_MidiCfg.szMidiSFXExt[sfx], s, MACRO_LENGTH); int sfx_preset = m_pModDoc->GetMacroType(m_MidiCfg.szMidiSFXExt[sfx]); @@ -1033,7 +1034,7 @@ { MemsetZero(s); m_EditZxx.GetWindowText(s, MACRO_LENGTH); - SetNullTerminator(s); + StringFixer::SetNullTerminator(s); memcpy(m_MidiCfg.szMidiZXXExt[zxx], s, MACRO_LENGTH); } } Modified: trunk/OpenMPT/mptrack/misc_util.h =================================================================== --- trunk/OpenMPT/mptrack/misc_util.h 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/mptrack/misc_util.h 2011-08-08 12:54:40 UTC (rev 964) @@ -13,7 +13,7 @@ //Convert object(typically number) to string template<class T> inline std::string Stringify(const T& x) -//-------------------------- +//-------------------------------------- { std::ostringstream o; if(!(o << x)) return "FAILURE"; @@ -38,20 +38,11 @@ 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> -inline void SetNullTerminator(char (&buffer)[size]) -//------------------------------------------------- -{ - STATIC_ASSERT(size > 0); - buffer[size-1] = 0; -} - // Memset given object to zero. template <class T> inline void MemsetZero(T& a) +//_------------------------- { #if _HAS_TR1 static_assert(std::tr1::is_pointer<T>::value == false, "Won't memset pointers."); @@ -151,98 +142,6 @@ } -// Convert a 0-terminated string to a space-padded string -template <size_t size> -void NullToSpaceString(char (&buffer)[size]) -//------------------------------------------ -{ - STATIC_ASSERT(size > 0); - size_t pos = size; - while (pos-- > 0) - if (buffer[pos] == 0) - buffer[pos] = 32; - buffer[size - 1] = 0; -} - - -// Convert a space-padded string to a 0-terminated string -template <size_t size> -void SpaceToNullString(char (&buffer)[size]) -//------------------------------------------ -{ - STATIC_ASSERT(size > 0); - // First, remove any Nulls - NullToSpaceString(buffer); - size_t pos = size; - while (pos-- > 0) - { - if (buffer[pos] == 32) - buffer[pos] = 0; - else if(buffer[pos] != 0) - break; - } - buffer[size - 1] = 0; -} - - -// Remove any chars after the first null char -template <size_t size> -void FixNullString(char (&buffer)[size]) -//-------------------------------------- -{ - STATIC_ASSERT(size > 0); - SetNullTerminator(buffer); - size_t pos = 0; - // Find the first null char. - while(buffer[pos] != '\0' && pos < size) - { - pos++; - } - // Remove everything after the null char. - while(pos < size) - { - buffer[pos++] = '\0'; - } -} - - -// Convert a space-padded string to a 0-terminated string. STATIC VERSION! (use this if the maximum string length is known) -// Additional template parameter to specifify the max length of the final string, -// not including null char (useful for e.g. mod loaders) -template <size_t length, size_t size> -void SpaceToNullStringFixed(char (&buffer)[size]) -//------------------------------------------------ -{ - STATIC_ASSERT(size > 0); - STATIC_ASSERT(length < size); - // Remove Nulls in string - SpaceToNullString(buffer); - // Overwrite trailing chars - for(size_t pos = length; pos < size; pos++) - { - buffer[pos] = 0; - } -} - - -// Convert a space-padded string to a 0-terminated string. DYNAMIC VERSION! -// Additional function parameter to specifify the max length of the final string, -// not including null char (useful for e.g. mod loaders) -template <size_t size> -void SpaceToNullStringFixed(char (&buffer)[size], size_t length) -//-------------------------------------------------------------- -{ - STATIC_ASSERT(size > 0); - ASSERT(length < size); - // Remove Nulls in string - SpaceToNullString(buffer); - // Overwrite trailing chars - for(size_t pos = length; pos < size; pos++) - { - buffer[pos] = 0; - } -} - namespace Util { // Like std::max, but avoids conflict with max-macro. Modified: trunk/OpenMPT/mptrack/mptrack.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack.vcproj 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/mptrack/mptrack.vcproj 2011-08-08 12:54:40 UTC (rev 964) @@ -843,6 +843,9 @@ RelativePath=".\StdAfx.h"> </File> <File + RelativePath="..\Soundlib\StringFixer.h"> + </File> + <File RelativePath=".\tagging.h"> </File> <File Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2011-08-08 12:54:40 UTC (rev 964) @@ -1123,6 +1123,10 @@ > </File> <File + RelativePath="..\soundlib\StringFixer.h" + > + </File> + <File RelativePath=".\tagging.h" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2011-08-08 12:54:40 UTC (rev 964) @@ -393,6 +393,7 @@ <ClInclude Include="..\Soundlib\Sndfile.h" /> <ClInclude Include="SoundFilePlayConfig.h" /> <ClInclude Include="StdAfx.h" /> + <ClInclude Include="..\Soundlib\StringFixer.h" /> <ClInclude Include="tagging.h" /> <ClInclude Include="TrackerSettings.h" /> <ClInclude Include="typedefs.h" /> Modified: trunk/OpenMPT/mptrack/view_com.cpp =================================================================== --- trunk/OpenMPT/mptrack/view_com.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/mptrack/view_com.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -5,8 +5,9 @@ #include "moddoc.h" #include "globals.h" #include "ctrl_com.h" +#include "ChannelManagerDlg.h" +#include "../soundlib/StringFixer.h" #include "view_com.h" -#include "ChannelManagerDlg.h" #define DETAILS_TOOLBAR_CY 28 @@ -505,7 +506,7 @@ if (iItem < pSndFile->m_nSamples) { memcpy(pSndFile->m_szNames[iItem + 1], s, sizeof(pSndFile->m_szNames[iItem + 1])); - SetNullTerminator(pSndFile->m_szNames[iItem + 1]); + StringFixer::SetNullTerminator(pSndFile->m_szNames[iItem + 1]); // 05/01/05 : ericus replaced "<< 24" by "<< 20" : 4000 samples -> 12bits [see Moddoc.h] pModDoc->UpdateAllViews(this, ((iItem + 1) << HINT_SHIFT_SMP) | (HINT_SMPNAMES|HINT_SAMPLEINFO), this); pModDoc->SetModified(); @@ -517,7 +518,7 @@ { MODINSTRUMENT *pIns = pSndFile->Instruments[iItem+1]; memcpy(pIns->name, s, sizeof(pIns->name)); - SetNullTerminator(pIns->name); + StringFixer::SetNullTerminator(pIns->name); pModDoc->UpdateAllViews(this, ((iItem + 1) << HINT_SHIFT_INS) | (HINT_INSNAMES|HINT_INSTRUMENT), this); pModDoc->SetModified(); } Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -17,6 +17,7 @@ #include "../mptrack/mptrack.h" #include "dlsbank.h" #include "Wav.h" +#include "StringFixer.h" //#define DLSBANK_LOG @@ -1675,7 +1676,7 @@ } else { memcpy(pIns->name, pDlsIns->szName, 32); - SetNullTerminator(pIns->name); + StringFixer::SetNullTerminator(pIns->name); } int nTranspose = 0; for (UINT iNoteMap=0; iNoteMap<NOTE_MAX; iNoteMap++) Modified: trunk/OpenMPT/soundlib/LOAD_AMF.CPP =================================================================== --- trunk/OpenMPT/soundlib/LOAD_AMF.CPP 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/LOAD_AMF.CPP 2011-08-08 12:54:40 UTC (rev 964) @@ -201,7 +201,7 @@ { MODSAMPLE *psmp = &Samples[iSmp+1]; memcpy(m_szNames[iSmp + 1], lpStream+dwMemPos, 22); - SpaceToNullStringFixed<22>(m_szNames[iSmp + 1]); + StringFixer::SpaceToNullStringFixed<22>(m_szNames[iSmp + 1]); psmp->nFineTune = MOD2XMFineTune(lpStream[dwMemPos+22]); psmp->nVolume = lpStream[dwMemPos+23]; psmp->nGlobalVol = 64; @@ -274,7 +274,7 @@ || (pfh->numchannels < 1) || (pfh->numchannels > 32)) return false; memcpy(m_szNames[0], pfh->title, 31); - SpaceToNullStringFixed<31>(m_szNames[0]); + StringFixer::SpaceToNullStringFixed<31>(m_szNames[0]); dwMemPos = sizeof(AMFFILEHEADER); m_nType = MOD_TYPE_AMF; m_nChannels = pfh->numchannels; @@ -335,8 +335,8 @@ dwMemPos += sizeof(AMFSAMPLE); memcpy(m_szNames[iIns+1], psh->samplename, 31); memcpy(pSmp->filename, psh->filename, 13); - SpaceToNullStringFixed<31>(m_szNames[iIns + 1]); - SpaceToNullStringFixed<13>(pSmp->filename); + StringFixer::SpaceToNullStringFixed<31>(m_szNames[iIns + 1]); + StringFixer::SpaceToNullStringFixed<13>(pSmp->filename); pSmp->nLength = LittleEndian(psh->length); pSmp->nC5Speed = LittleEndianW(psh->c2spd); pSmp->nGlobalVol = 64; Modified: trunk/OpenMPT/soundlib/LOAD_DBM.CPP =================================================================== --- trunk/OpenMPT/soundlib/LOAD_DBM.CPP 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/LOAD_DBM.CPP 2011-08-08 12:54:40 UTC (rev 964) @@ -201,7 +201,7 @@ m_nType = MOD_TYPE_DBM; m_nChannels = CLAMP(BigEndianW(pfh->channels), 1, MAX_BASECHANNELS); // note: MAX_BASECHANNELS is currently 127, but DBM supports up to 128 channels. memcpy(m_szNames[0], (pfh->songname[0]) ? pfh->songname : pfh->songname2, 32); - SpaceToNullStringFixed<31>(m_szNames[0]); + StringFixer::SpaceToNullStringFixed<31>(m_szNames[0]); Order.resize(nOrders, Order.GetInvalidPatIndex()); for (UINT iOrd=0; iOrd < nOrders; iOrd++) { @@ -240,11 +240,11 @@ nsmp = BigEndianW(pih->sampleno); psmp = ((nsmp) && (nsmp < MAX_SAMPLES)) ? &Samples[nsmp] : nullptr; memcpy(pIns->name, pih->name, 30); - SpaceToNullStringFixed<30>(pIns->name); + StringFixer::SpaceToNullStringFixed<30>(pIns->name); if (psmp) { memcpy(m_szNames[nsmp], pih->name, 30); - SpaceToNullStringFixed<30>(m_szNames[nsmp]); + StringFixer::SpaceToNullStringFixed<30>(m_szNames[nsmp]); } pIns->nFadeOut = 1024; // ??? Modified: trunk/OpenMPT/soundlib/LOAD_DMF.CPP =================================================================== --- trunk/OpenMPT/soundlib/LOAD_DMF.CPP 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/LOAD_DMF.CPP 2011-08-08 12:54:40 UTC (rev 964) @@ -753,7 +753,7 @@ const size_t lenNameImport = min(30, lenName); ASSERT_CAN_READ_SAMPLE(lenName); memcpy(pSndFile->m_szNames[nSmp], lpStream + dwMemPos, lenNameImport); - SpaceToNullStringFixed(pSndFile->m_szNames[nSmp], lenNameImport); + StringFixer::SpaceToNullStringFixed(pSndFile->m_szNames[nSmp], lenNameImport); dwMemPos += lenName; ASSERT_CAN_READ_SAMPLE(sizeof(DMFCHUNK_SAMPLEHEADER)); @@ -798,7 +798,7 @@ // Read library name in version 8 files ASSERT_CAN_READ_SAMPLE(8); memcpy(pSmp->filename, lpStream + dwMemPos, 8); - SpaceToNullStringFixed<8>(pSmp->filename); + StringFixer::SpaceToNullStringFixed<8>(pSmp->filename); dwMemPos += 8; } @@ -829,7 +829,7 @@ dwMemPos += sizeof(DMFHEADER); memcpy(m_szNames[0], pHeader->songname, 30); - SpaceToNullStringFixed<30>(m_szNames[0]); + StringFixer::SpaceToNullStringFixed<30>(m_szNames[0]); m_nChannels = 0; #ifdef MODPLUG_TRACKER Modified: trunk/OpenMPT/soundlib/LOAD_DSM.CPP =================================================================== --- trunk/OpenMPT/soundlib/LOAD_DSM.CPP 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/LOAD_DSM.CPP 2011-08-08 12:54:40 UTC (rev 964) @@ -122,7 +122,7 @@ } } memcpy(m_szNames[0], psong->songname, 28); - SpaceToNullStringFixed<28>(m_szNames[0]); + StringFixer::SpaceToNullStringFixed<28>(m_szNames[0]); nPat = 0; nSmp = 1; while (dwMemPos < dwMemLength - 8) @@ -216,10 +216,10 @@ DWORD dwPos = dwMemPos + sizeof(DSMSAMPLE); dwMemPos += 8 + pSmp->inst_len; memcpy(m_szNames[nSmp], pSmp->samplename, 28); - SpaceToNullStringFixed<28>(m_szNames[nSmp]); + StringFixer::SpaceToNullStringFixed<28>(m_szNames[nSmp]); MODSAMPLE *psmp = &Samples[nSmp]; memcpy(psmp->filename, pSmp->filename, 13); - SpaceToNullStringFixed<13>(psmp->filename); + StringFixer::SpaceToNullStringFixed<13>(psmp->filename); psmp->nGlobalVol = 64; psmp->nC5Speed = pSmp->c2spd; psmp->uFlags = (WORD)((pSmp->flags & 1) ? CHN_LOOP : 0); Modified: trunk/OpenMPT/soundlib/Load_669.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_669.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/Load_669.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -70,7 +70,7 @@ m_nChannels = 8; memcpy(m_szNames[0], pfh->songmessage, min(MAX_SAMPLENAME - 1, 36)); - SpaceToNullStringFixed<min(MAX_SAMPLENAME - 1, 36)>(m_szNames[0]); + StringFixer::SpaceToNullStringFixed<min(MAX_SAMPLENAME - 1, 36)>(m_szNames[0]); m_nSamples = pfh->samples; for (SAMPLEINDEX nSmp = 1; nSmp <= m_nSamples; nSmp++, psmp++) @@ -87,7 +87,7 @@ Samples[nSmp].nLoopEnd = loopend; if (loopend) Samples[nSmp].uFlags |= CHN_LOOP; memcpy(m_szNames[nSmp], psmp->filename, 13); - SpaceToNullStringFixed<13>(m_szNames[nSmp]); + StringFixer::SpaceToNullStringFixed<13>(m_szNames[nSmp]); Samples[nSmp].nVolume = 256; Samples[nSmp].nGlobalVol = 64; Samples[nSmp].nPan = 128; Modified: trunk/OpenMPT/soundlib/Load_ams.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ams.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/Load_ams.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -117,7 +117,7 @@ if (dwMemPos + tmp + 1 >= dwMemLength) return true; tmp2 = (tmp < 32) ? tmp : 31; if (tmp2) memcpy(m_szNames[0], lpStream + dwMemPos, tmp2); - SpaceToNullStringFixed(m_szNames[0], tmp2); + StringFixer::SpaceToNullStringFixed(m_szNames[0], tmp2); m_szNames[0][tmp2] = 0; dwMemPos += tmp; @@ -128,7 +128,7 @@ tmp = lpStream[dwMemPos++]; tmp2 = (tmp < 32) ? tmp : 31; if (tmp2) memcpy(m_szNames[sNam], lpStream+dwMemPos, tmp2); - SpaceToNullStringFixed(m_szNames[sNam], tmp2); + StringFixer::SpaceToNullStringFixed(m_szNames[sNam], tmp2); dwMemPos += tmp; } @@ -140,7 +140,7 @@ if ((chnnamlen) && (chnnamlen < MAX_CHANNELNAME)) { memcpy(ChnSettings[cNam].szName, lpStream + dwMemPos, chnnamlen); - SpaceToNullStringFixed(ChnSettings[cNam].szName, chnnamlen); + StringFixer::SpaceToNullStringFixed(ChnSettings[cNam].szName, chnnamlen); } dwMemPos += chnnamlen; } @@ -371,7 +371,7 @@ if (pfh->titlelen) { memcpy(m_szNames[0], pfh->szTitle, pfh->titlelen); - SpaceToNullStringFixed(m_szNames[0], pfh->titlelen); + StringFixer::SpaceToNullStringFixed(m_szNames[0], pfh->titlelen); } m_nType = MOD_TYPE_AMS; m_nChannels = 32; @@ -449,7 +449,7 @@ if ((psmp) && (smpnamelen) && (smpnamelen <= 22)) { memcpy(m_szNames[smpmap[ismp]], lpStream+dwMemPos+1, smpnamelen); - SpaceToNullStringFixed(m_szNames[smpmap[ismp]], smpnamelen); + StringFixer::SpaceToNullStringFixed(m_szNames[smpmap[ismp]], smpnamelen); } dwMemPos += smpnamelen + 1; if (psmp) @@ -487,7 +487,7 @@ if ((chnnamlen) && (chnnamlen < MAX_CHANNELNAME)) { memcpy(ChnSettings[i].szName, lpStream+dwMemPos+1, chnnamlen); - SpaceToNullStringFixed(ChnSettings[i].szName, chnnamlen); + StringFixer::SpaceToNullStringFixed(ChnSettings[i].szName, chnnamlen); } dwMemPos += chnnamlen + 1; if (dwMemPos + chnnamlen + 256 >= dwMemLength) return true; @@ -523,7 +523,7 @@ { char s[MAX_PATTERNNAME]; memcpy(s, lpStream+dwMemPos+3, patnamlen); - SpaceToNullStringFixed(s, patnamlen); + StringFixer::SpaceToNullStringFixed(s, patnamlen); SetPatternName(ipat, s); } if(Patterns.Insert(ipat, numrows)) return true; Modified: trunk/OpenMPT/soundlib/Load_far.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_far.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/Load_far.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -88,7 +88,7 @@ m_nDefaultGlobalVolume = MAX_GLOBAL_VOLUME; memcpy(m_szNames[0], pmh1->songname, 31); - SpaceToNullStringFixed<31>(m_szNames[0]); + StringFixer::SpaceToNullStringFixed<31>(m_szNames[0]); // Channel Setting for (UINT nchpan=0; nchpan<16; nchpan++) @@ -246,7 +246,7 @@ dwMemPos += sizeof(FARSAMPLE); m_nSamples = ismp + 1; memcpy(m_szNames[ismp+1], pfs->samplename, 31); - SpaceToNullStringFixed<31>(m_szNames[ismp + 1]); + StringFixer::SpaceToNullStringFixed<31>(m_szNames[ismp + 1]); const DWORD length = LittleEndian( pfs->length ); pSmp->nLength = length; pSmp->nLoopStart = LittleEndian(pfs->reppos) ; Modified: trunk/OpenMPT/soundlib/Load_gdm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_gdm.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/Load_gdm.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -100,9 +100,9 @@ // interesting question: Is TrackID, TrackMajorVer, TrackMinorVer relevant? The only TrackID should be 0 - 2GDM.exe, so the answer would be no. // song name - memset(m_szNames, 0, sizeof(m_szNames)); + MemsetZero(m_szNames); memcpy(m_szNames[0], pHeader->SongTitle, 32); - SpaceToNullStringFixed<31>(m_szNames[0]); + StringFixer::SpaceToNullStringFixed<31>(m_szNames[0]); // read channel pan map... 0...15 = channel panning, 16 = surround channel, 255 = channel does not exist m_nChannels = 32; @@ -163,9 +163,9 @@ // sample header memcpy(m_szNames[iSmp], pSample->SamName, 32); - SpaceToNullStringFixed<31>(m_szNames[iSmp]); + StringFixer::SpaceToNullStringFixed<31>(m_szNames[iSmp]); memcpy(Samples[iSmp].filename, pSample->FileName, 12); - SpaceToNullStringFixed<12>(Samples[iSmp].filename); + StringFixer::SpaceToNullStringFixed<12>(Samples[iSmp].filename); Samples[iSmp].nC5Speed = LittleEndianW(pSample->C4Hertz); Samples[iSmp].nGlobalVol = 256; // not supported in this format @@ -196,7 +196,7 @@ if(pSample->Flags & 0x04) { - Samples[iSmp].nVolume = min(pSample->Volume << 2, 256); // 0...64, 255 = no default volume + Samples[iSmp].nVolume = min(pSample->Volume, 64) * 4; // 0...64, 255 = no default volume } else { @@ -206,7 +206,7 @@ if(pSample->Flags & 0x08) // default panning is used { Samples[iSmp].uFlags |= CHN_PANNING; - Samples[iSmp].nPan = (pSample->Pan > 15) ? 128 : min((pSample->Pan << 4) + 8, 256); // 0...15, 16 = surround (not supported), 255 = no default panning + Samples[iSmp].nPan = (pSample->Pan > 15) ? 128 : min((pSample->Pan * 16) + 8, 256); // 0...15, 16 = surround (not supported), 255 = no default panning } else { Modified: trunk/OpenMPT/soundlib/Load_imf.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_imf.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/Load_imf.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -294,7 +294,7 @@ // song name memset(m_szNames, 0, sizeof(m_szNames)); memcpy(m_szNames[0], hdr.title, 31); - SpaceToNullStringFixed<31>(m_szNames[0]); + StringFixer::SpaceToNullStringFixed<31>(m_szNames[0]); if (hdr.flags & 1) m_dwSongFlags |= SONG_LINEARSLIDES; @@ -313,7 +313,7 @@ ChnSettings[nChn].nPan *= 4; memcpy(ChnSettings[nChn].szName, hdr.channels[nChn].name, 12); - SpaceToNullStringFixed<12>(ChnSettings[nChn].szName); + StringFixer::SpaceToNullStringFixed<12>(ChnSettings[nChn].szName); // TODO: reverb/chorus? switch(hdr.channels[nChn].status) @@ -506,7 +506,7 @@ SetDefaultInstrumentValues(pIns); memcpy(pIns->name, imfins.name, 31); - SpaceToNullStringFixed<31>(pIns->name); + StringFixer::SpaceToNullStringFixed<31>(pIns->name); if(imfins.smpnum) { @@ -545,7 +545,7 @@ return false; memcpy(pSample->filename, imfsmp.filename, 12); - SpaceToNullStringFixed<12>(pSample->filename); + StringFixer::SpaceToNullStringFixed<12>(pSample->filename); strcpy(m_szNames[m_nSamples], pSample->filename); blen = pSample->nLength = LittleEndian(imfsmp.length); Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -311,8 +311,8 @@ const ITOLDINSTRUMENT *pis = (const ITOLDINSTRUMENT *)p; memcpy(pIns->name, pis->name, 26); memcpy(pIns->filename, pis->filename, 12); - SpaceToNullStringFixed<26>(pIns->name); - SpaceToNullStringFixed<12>(pIns->filename); + StringFixer::SpaceToNullStringFixed<26>(pIns->name); + StringFixer::SpaceToNullStringFixed<12>(pIns->filename); pIns->nFadeOut = pis->fadeout << 6; pIns->nGlobalVol = 64; for (UINT j = 0; j < 120; j++) @@ -353,8 +353,8 @@ const ITINSTRUMENT *pis = (const ITINSTRUMENT *)p; memcpy(pIns->name, pis->name, 26); memcpy(pIns->filename, pis->filename, 12); - SpaceToNullStringFixed<26>(pIns->name); - SpaceToNullStringFixed<12>(pIns->filename); + StringFixer::SpaceToNullStringFixed<26>(pIns->name); + StringFixer::SpaceToNullStringFixed<12>(pIns->filename); if (pis->mpr<=128) pIns->nMidiProgram = pis->mpr; pIns->nMidiChannel = pis->mch; @@ -604,7 +604,7 @@ if (pifh->flags & 0x1000) m_dwSongFlags |= SONG_EXFILTERRANGE; memcpy(m_szNames[0], pifh->songname, 26); - SpaceToNullStringFixed<26>(m_szNames[0]); + StringFixer::SpaceToNullStringFixed<26>(m_szNames[0]); // Global Volume m_nDefaultGlobalVolume = pifh->globalvol << 1; @@ -971,7 +971,7 @@ { MODSAMPLE *pSmp = &Samples[nsmp+1]; memcpy(pSmp->filename, pis->filename, 12); - SpaceToNullStringFixed<12>(pSmp->filename); + StringFixer::SpaceToNullStringFixed<12>(pSmp->filename); pSmp->uFlags = 0; pSmp->nLength = 0; pSmp->nLoopStart = pis->loopbegin; @@ -1030,7 +1030,7 @@ } } memcpy(m_szNames[nsmp + 1], pis->name, 26); - SpaceToNullStringFixed<26>(m_szNames[nsmp + 1]); + StringFixer::SpaceToNullStringFixed<26>(m_szNames[nsmp + 1]); } m_nSamples = max(1, m_nSamples); @@ -2167,7 +2167,7 @@ MODINSTRUMENT *pIns = Instruments[nins]; memcpy(iti.filename, pIns->filename, 12); memcpy(iti.name, pIns->name, 26); - SetNullTerminator(iti.name); + StringFixer::SetNullTerminator(iti.name); iti.mbank = pIns->wMidiBank; iti.mpr = pIns->nMidiProgram; iti.mch = pIns->nMidiChannel; @@ -2433,7 +2433,7 @@ memset(&itss, 0, sizeof(itss)); memcpy(itss.filename, psmp->filename, 12); memcpy(itss.name, m_szNames[nsmp], 26); - SetNullTerminator(itss.name); + StringFixer::SetNullTerminator(itss.name); itss.id = LittleEndian(IT_IMPS); itss.gvl = (BYTE)psmp->nGlobalVol; Modified: trunk/OpenMPT/soundlib/Load_itp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_itp.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/Load_itp.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -64,7 +64,7 @@ { memcpy(m_szNames[0],lpStream+dwMemPos,len); dwMemPos += len; - SetNullTerminator(m_szNames[0]); + StringFixer::SetNullTerminator(m_szNames[0]); } else return false; @@ -150,7 +150,7 @@ // ChnSettings[i].szName memcpy(&ChnSettings[i].szName[0],lpStream+dwMemPos,len); - SetNullTerminator(ChnSettings[i].szName); + StringFixer::SetNullTerminator(ChnSettings[i].szName); dwMemPos += len; } @@ -200,7 +200,7 @@ for(i=0; i<m_nInstruments; i++){ ASSERT_CAN_READ(len); memcpy(&m_szInstrumentPath[i][0],lpStream+dwMemPos,len); - SetNullTerminator(m_szInstrumentPath[i]); + StringFixer::SetNullTerminator(m_szInstrumentPath[i]); dwMemPos += len; } Modified: trunk/OpenMPT/soundlib/Load_mdl.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mdl.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/Load_mdl.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -276,7 +276,7 @@ #endif pmib = (MDLINFOBLOCK *)(lpStream+dwMemPos); memcpy(m_szNames[0], pmib->songname, 31); - SpaceToNullStringFixed<31>(m_szNames[0]); + StringFixer::SpaceToNullStringFixed<31>(m_szNames[0]); norders = pmib->norders; if (norders > MAX_ORDERS) norders = MAX_ORDERS; @@ -374,7 +374,7 @@ MODINSTRUMENT *pIns = Instruments[nins]; memset(pIns, 0, sizeof(MODINSTRUMENT)); memcpy(pIns->name, lpStream+dwPos+2, 32); - SpaceToNullStringFixed<31>(pIns->name); + StringFixer::SpaceToNullStringFixed<31>(pIns->name); pIns->nGlobalVol = 64; pIns->nPPC = 5*12; @@ -465,8 +465,8 @@ MODSAMPLE *pSmp = &Samples[nins]; memcpy(m_szNames[nins], lpStream+dwPos+1, 31); memcpy(pSmp->filename, lpStream+dwPos+33, 8); - SpaceToNullStringFixed<31>(m_szNames[nins]); - SpaceToNullStringFixed<8>(pSmp->filename); + StringFixer::SpaceToNullStringFixed<31>(m_szNames[nins]); + StringFixer::SpaceToNullStringFixed<8>(pSmp->filename); const BYTE *p = lpStream+dwPos+41; if (pmsh->version > 0) { Modified: trunk/OpenMPT/soundlib/Load_med.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_med.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/Load_med.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -713,7 +713,7 @@ { if (songnamelen > 31) songnamelen = 31; memcpy(m_szNames[0], lpStream+songname, songnamelen); - SpaceToNullStringFixed(m_szNames[0], songnamelen); + StringFixer::SpaceToNullStringFixed(m_szNames[0], songnamelen); } // Sample Names DWORD smpinfoex = BigEndian(pmex->iinfo); @@ -731,7 +731,7 @@ for (UINT i=0; i<ientries; i++) if (i < m_nSamples) { memcpy(m_szNames[i+1], psznames + i*ientrysz, maxnamelen); - SpaceToNullStringFixed(m_szNames[i + 1], maxnamelen); + StringFixer::SpaceToNullStringFixed(m_szNames[i + 1], maxnamelen); } } } @@ -762,7 +762,7 @@ if ((trknameofs) && (trknameofs < dwMemLength - trknamelen)) { memcpy(ChnSettings[i].szName, (LPCSTR)(lpStream+trknameofs), trknamelen); - SpaceToNullStringFixed(ChnSettings[i].szName, trknamelen); + StringFixer::SpaceToNullStringFixed(ChnSettings[i].szName, trknamelen); } } } Modified: trunk/OpenMPT/soundlib/Load_mod.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mod.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/Load_mod.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -300,7 +300,7 @@ UINT loopstart, looplen; memcpy(m_szNames[i], pms->name, 22); - SpaceToNullStringFixed<22>(m_szNames[i]); + StringFixer::SpaceToNullStringFixed<22>(m_szNames[i]); psmp->uFlags = 0; psmp->nLength = BigEndianW(pms->length)*2; dwTotalSampleLen += psmp->nLength; @@ -417,7 +417,7 @@ m_nMinPeriod = 14 << 2; m_nMaxPeriod = 3424 << 2; memcpy(m_szNames[0], lpStream, 20); - SpaceToNullStringFixed<20>(m_szNames[0]); + StringFixer::SpaceToNullStringFixed<20>(m_szNames[0]); // Setup channel pan positions and volume SetupMODPanning(); Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mt2.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -214,7 +214,7 @@ Order[iOrd] = (PATTERNINDEX)pfh->Orders[iOrd]; } memcpy(m_szNames[0], pfh->szSongName, 32); - SpaceToNullStringFixed<31>(m_szNames[0]); + StringFixer::SpaceToNullStringFixed<31>(m_szNames[0]); dwMemPos = sizeof(MT2FILEHEADER); nDrumDataLen = *(WORD *)(lpStream + dwMemPos); @@ -407,7 +407,7 @@ { memcpy(Instruments[iIns], &m_defaultInstrument, sizeof(MODINSTRUMENT)); memcpy(pIns->name, pmi->szName, 32); - SpaceToNullStringFixed<31>(pIns->name); + StringFixer::SpaceToNullStringFixed<31>(pIns->name); pIns->nGlobalVol = 64; pIns->nPan = 128; for (BYTE i = 0; i < NOTE_MAX; i++) @@ -520,7 +520,7 @@ if (iSmp < MAX_SAMPLES) { memcpy(m_szNames[iSmp], pms->szName, 31); - SpaceToNullStringFixed<31>(m_szNames[iSmp]); + StringFixer::SpaceToNullStringFixed<31>(m_szNames[iSmp]); } if (pms->dwDataLen > 0) { Modified: trunk/OpenMPT/soundlib/Load_mtm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mtm.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/Load_mtm.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -61,7 +61,7 @@ || (!pmh->numtracks) || (!pmh->numchannels) || (!pmh->lastpattern) || (pmh->lastpattern > MAX_PATTERNS)) return false; memcpy(m_szNames[0], pmh->songname, 20); - SpaceToNullStringFixed<20>(m_szNames[0]); + StringFixer::SpaceToNullStringFixed<20>(m_szNames[0]); if (dwMemPos + 37 * pmh->numsamples + 128 + 192 * pmh->numtracks + 64 * (pmh->lastpattern+1) + pmh->commentsize >= dwMemLength) return false; @@ -73,7 +73,7 @@ { MTMSAMPLE *pms = (MTMSAMPLE *)(lpStream + dwMemPos); memcpy(m_szNames[i], pms->samplename, 22); - SpaceToNullStringFixed<22>(m_szNames[i]); + StringFixer::SpaceToNullStringFixed<22>(m_szNames[i]); Samples[i].nVolume = pms->volume << 2; Samples[i].nGlobalVol = 64; UINT len = pms->length; Modified: trunk/OpenMPT/soundlib/Load_okt.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_okt.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/Load_okt.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -74,7 +74,7 @@ MemsetZero(*pSmp); strncpy(pSndFile->m_szNames[nSmp], oktsmp.name, 20); - SpaceToNullStringFixed<20>(pSndFile->m_szNames[nSmp]); + StringFixer::SpaceToNullStringFixed<20>(pSndFile->m_szNames[nSmp]); pSmp->nC5Speed = 8287; pSmp->nGlobalVol = 64; Modified: trunk/OpenMPT/soundlib/Load_psm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_psm.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/Load_psm.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -186,7 +186,7 @@ { case PSMCHUNKID_TITL: // "TITL" - Song Title memcpy(m_szNames[0], lpStream + dwMemPos, (chunkSize < 31) ? chunkSize : 31); - SpaceToNullStringFixed<31>(m_szNames[0]); + StringFixer::SpaceToNullStringFixed<31>(m_szNames[0]); break; case PSMCHUNKID_SDFT: // "SDFT" - Format info (song data starts here) @@ -220,7 +220,7 @@ PSMSUBSONG subsong; subsong.restartPos = (ORDERINDEX)Order.size(); // restart order "offset": current orderlist length memcpy(subsong.songName, &pSong->songType, 9); // subsong name - SpaceToNullStringFixed<9>(subsong.songName); + StringFixer::SpaceToNullStringFixed<9>(subsong.songName); DWORD dwChunkPos = dwMemPos + sizeof(PSMSONGHEADER); @@ -445,9 +445,9 @@ SAMPLEINDEX smp = (SAMPLEINDEX)(LittleEndianW(pSample->sampleNumber) + 1); m_nSamples = max(m_nSamples, smp); memcpy(m_szNames[smp], pSample->sampleName, 31); - SpaceToNullStringFixed<31>(m_szNames[smp]); + StringFixer::SpaceToNullStringFixed<31>(m_szNames[smp]); memcpy(Samples[smp].filename, pSample->fileName, 8); - SpaceToNullStringFixed<8>(Samples[smp].filename); + StringFixer::SpaceToNullStringFixed<8>(Samples[smp].filename); Samples[smp].nGlobalVol = 0x40; Samples[smp].nC5Speed = LittleEndianW(pSample->C5Freq); @@ -469,9 +469,9 @@ SAMPLEINDEX smp = (SAMPLEINDEX)(LittleEndianW(pSample->sampleNumber) + 1); m_nSamples = max(m_nSamples, smp); memcpy(m_szNames[smp], pSample->sampleName, 31); - SpaceToNullStringFixed<31>(m_szNames[smp]); + StringFixer::SpaceToNullStringFixed<31>(m_szNames[smp]); memcpy(Samples[smp].filename, pSample->fileName, 8); - SpaceToNullStringFixed<8>(Samples[smp].filename); + StringFixer::SpaceToNullStringFixed<8>(Samples[smp].filename); Samples[smp].nGlobalVol = 0x40; Samples[smp].nC5Speed = LittleEndianW(pSample->C5Freq); @@ -895,7 +895,7 @@ memset(m_szNames, 0, sizeof(m_szNames)); memcpy(m_szNames[0], shdr->songName, 31); - SpaceToNullStringFixed<31>(m_szNames[0]); + StringFixer::SpaceToNullStringFixed<31>(m_szNames[0]); // Read orders dwMemPos = LittleEndian(shdr->orderOffset); @@ -935,9 +935,9 @@ m_nSamples = max(m_nSamples, iSmp); memcpy(m_szNames[iSmp], smphdr->name, 24); - SpaceToNullStringFixed<24>(m_szNames[iSmp]); + StringFixer::SpaceToNullStringFixed<24>(m_szNames[iSmp]); memcpy(Samples[iSmp].filename, smphdr->filename, 13); - SpaceToNullStringFixed<13>(Samples[iSmp].filename); + StringFixer::SpaceToNullStringFixed<13>(Samples[iSmp].filename); Samples[iSmp].nLength = LittleEndian(smphdr->length); Samples[iSmp].nLoopStart = LittleEndian(smphdr->loopStart); Modified: trunk/OpenMPT/soundlib/Load_ptm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ptm.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/Load_ptm.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -91,7 +91,7 @@ || (!pfh.npatterns) || (pfh.npatterns > 128) || (SIZEOF_PTMFILEHEADER+pfh.nsamples*SIZEOF_PTMSAMPLE >= (int)dwMemLength)) return false; memcpy(m_szNames[0], pfh.songname, 28); - SpaceToNullStringFixed<28>(m_szNames[0]); + StringFixer::SpaceToNullStringFixed<28>(m_szNames[0]); m_nType = MOD_TYPE_PTM; m_nChannels = pfh.nchannels; @@ -112,8 +112,8 @@ lstrcpyn(m_szNames[ismp+1], psmp->samplename, 28); memcpy(pSmp->filename, psmp->filename, 12); - SpaceToNullStringFixed<28>(m_szNames[ismp + 1]); - SpaceToNullStringFixed<12>(pSmp->filename); + StringFixer::SpaceToNullStringFixed<28>(m_szNames[ismp + 1]); + StringFixer::SpaceToNullStringFixed<12>(pSmp->filename); pSmp->nGlobalVol = 64; pSmp->nPan = 128; Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_s3m.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/Load_s3m.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -272,7 +272,7 @@ m_nType = MOD_TYPE_S3M; memset(m_szNames, 0, sizeof(m_szNames)); memcpy(m_szNames[0], psfh.name, 28); - SpaceToNullStringFixed<28>(m_szNames[0]); + StringFixer::SpaceToNullStringFixed<28>(m_szNames[0]); // Speed m_nDefaultSpeed = psfh.speed; if (!m_nDefaultSpeed || m_nDefaultSpeed == 255) m_nDefaultSpeed = 6; @@ -362,13 +362,13 @@ memcpy(s, lpStream + nInd, 0x50); memcpy(Samples[iSmp].filename, s+1, 12); - SpaceToNullStringFixed<12>(Samples[iSmp].filename); + StringFixer::SpaceToNullStringFixed<12>(Samples[iSmp].filename); insflags[iSmp - 1] = s[0x1F]; inspack[iSmp - 1] = s[0x1E]; s[0x4C] = 0; lstrcpy(m_szNames[iSmp], (LPCSTR)&s[0x30]); - SpaceToNullStringFixed<28>(m_szNames[iSmp]); + StringFixer::SpaceToNullStringFixed<28>(m_szNames[iSmp]); if ((s[0] == S3I_TYPE_PCM) && (s[0x4E] == 'R') && (s[0x4F] == 'S')) { Modified: trunk/OpenMPT/soundlib/Load_stm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_stm.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/Load_stm.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -70,7 +70,7 @@ || ((_strnicmp(phdr->trackername, "!SCREAM!", 8)) && (_strnicmp(phdr->trackername, "BMOD2STM", 8)))) return false; memcpy(m_szNames[0], phdr->songname, 20); - SpaceToNullStringFixed<20>(m_szNames[0]); + StringFixer::SpaceToNullStringFixed<20>(m_szNames[0]); // Read STM header m_nType = MOD_TYPE_STM; m_nSamples = 31; @@ -98,8 +98,8 @@ STMSAMPLE *pStm = &phdr->sample[nIns]; // STM sample data memcpy(pIns->filename, pStm->filename, 13); memcpy(m_szNames[nIns+1], pStm->filename, 12); - SpaceToNullStringFixed<12>(pIns->filename); - SpaceToNullStringFixed<12>(m_szNames[nIns + 1]); + StringFixer::SpaceToNullStringFixed<12>(pIns->filename); + StringFixer::SpaceToNullStringFixed<12>(m_szNames[nIns + 1]); pIns->nC5Speed = LittleEndianW(pStm->c2spd); pIns->nGlobalVol = 64; pIns->nVolume = pStm->volume << 2; Modified: trunk/OpenMPT/soundlib/Load_ult.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ult.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/Load_ult.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -322,7 +322,7 @@ ASSERT_CAN_READ(32); memcpy(m_szNames[0], lpStream + dwMemPos, 32); - SetNullTerminator(m_szNames[0]); + StringFixer::SetNullTerminator(m_szNames[0]); dwMemPos += 32; m_nType = MOD_TYPE_ULT; @@ -369,9 +369,9 @@ ultSmp.size_end = LittleEndian(ultSmp.size_end); memcpy(m_szNames[nSmp + 1], ultSmp.name, 32); - SetNullTerminator(m_szNames[nSmp + 1]); + StringFixer::SetNullTerminator(m_szNames[nSmp + 1]); memcpy(pSmp->filename, ultSmp.filename, 12); - SpaceToNullStringFixed<12>(pSmp->filename); + StringFixer::SpaceToNullStringFixed<12>(pSmp->filename); if(ultSmp.size_end <= ultSmp.size_start) continue; Modified: trunk/OpenMPT/soundlib/Load_xm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_xm.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/Load_xm.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -252,7 +252,7 @@ // look for null-terminated song name - that's most likely a tune made with modplug for(int i = 0; i < 20; i++) if(lpStream[17 + i] == 0) bProbablyMadeWithModPlug = true; - SpaceToNullStringFixed<20>(m_szNames[0]); + StringFixer::SpaceToNullStringFixed<20>(m_szNames[0]); // load and convert header memcpy(&xmheader, lpStream + 58, sizeof(XMFILEHEADER)); @@ -323,7 +323,7 @@ Instruments[iIns]->nPluginVolumeHandling = PLUGIN_VOLUMEHANDLING_IGNORE; memcpy(Instruments[iIns]->name, pih.name, 22); - SpaceToNullStringFixed<22>(Instruments[iIns]->name); + StringFixer::SpaceToNullStringFixed<22>(Instruments[iIns]->name); memset(&xmsh, 0, sizeof(XMSAMPLEHEADER)); @@ -527,7 +527,7 @@ if (!xmss.looplen) xmss.type &= ~3; UINT imapsmp = samplemap[ins]; memcpy(m_szNames[imapsmp], xmss.name, 22); - SpaceToNullStringFixed<22>(m_szNames[imapsmp]); + StringFixer::SpaceToNullStringFixed<22>(m_szNames[imapsmp]); MODSAMPLE *pSmp = &Samples[imapsmp]; pSmp->nLength = (xmss.samplen > MAX_SAMPLE_LENGTH) ? MAX_SAMPLE_LENGTH : xmss.samplen; pSmp->nLoopStart = xmss.loopstart; @@ -556,7 +556,7 @@ pSmp->nVibDepth = xmsh.vibdepth; pSmp->nVibRate = xmsh.vibrate; memcpy(pSmp->filename, xmss.name, 22); - SpaceToNullStringFixed<21>(pSmp->filename); + StringFixer::SpaceToNullStringFixed<21>(pSmp->filename); if ((xmss.type & 3) == 3) // MPT 1.09 and maybe newer / older versions set both flags for bidi loops bProbablyMPT109 = true; Modified: trunk/OpenMPT/soundlib/Loaders.h =================================================================== --- trunk/OpenMPT/soundlib/Loaders.h 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/Loaders.h 2011-08-08 12:54:40 UTC (rev 964) @@ -8,6 +8,7 @@ */ #include "Sndfile.h" +#include "StringFixer.h" // Execute "action" if "request_bytes" bytes cannot be read from stream at position "position" #define ASSERT_CAN_READ_PROTOTYPE(position, length, request_bytes, action) \ Modified: trunk/OpenMPT/soundlib/Sampleio.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sampleio.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/Sampleio.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -15,6 +15,7 @@ #include "../mptrack/Moddoc.h" #endif //MODPLUG_TRACKER #include "Wav.h" +#include "StringFixer.h" #pragma warning(disable:4244) @@ -1798,7 +1799,7 @@ iti->id = LittleEndian(IT_IMPI); // "IMPI" memcpy(iti->filename, pIns->filename, 12); memcpy(iti->name, pIns->name, 26); - SetNullTerminator(iti->name); + StringFixer::SetNullTerminator(iti->name); iti->mpr = pIns->nMidiProgram; iti->mch = pIns->nMidiChannel; iti->mbank = pIns->wMidiBank; //rewbs.MidiBank Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -16,6 +16,7 @@ #include "sndfile.h" #include "wavConverter.h" #include "tuningcollection.h" +#include "StringFixer.h" #include <vector> #include <list> #include <algorithm> @@ -940,15 +941,15 @@ { for(size_t i = 0; i < CountOf(m_MidiCfg.szMidiGlb); i++) { - FixNullString(m_MidiCfg.szMidiGlb[i]); + StringFixer::FixNullString(m_MidiCfg.szMidiGlb[i]); } for(size_t i = 0; i < CountOf(m_MidiCfg.szMidiSFXExt); i++) { - FixNullString(m_MidiCfg.szMidiSFXExt[i]); + StringFixer::FixNullString(m_MidiCfg.szMidiSFXExt[i]); } for(size_t i = 0; i < CountOf(m_MidiCfg.szMidiZXXExt); i++) { - FixNullString(m_MidiCfg.szMidiZXXExt[i]); + StringFixer::FixNullString(m_MidiCfg.szMidiZXXExt[i]); } } Modified: trunk/OpenMPT/soundlib/load_j2b.cpp =================================================================== --- trunk/OpenMPT/soundlib/load_j2b.cpp 2011-08-08 00:01:23 UTC (rev 963) +++ trunk/OpenMPT/soundlib/load_j2b.cpp 2011-08-08 12:54:40 UTC (rev 964) @@ -490,7 +490,7 @@ ASSERT_CAN_READ_CHUNK(mainchunk->channels); memcpy(m_szNames[0], mainchunk->songname, 32); - SpaceToNullStringFixed<31>(m_szNames[0]); + StringFixer::SpaceToNullStringFixed<31>(m_szNames[0]); m_dwSongFlags = SONG_ITOLDEFFECTS | SONG_ITCOMPATGXX; if(!(mainchunk->flags & AMHEAD_LINEAR)) m_dwSongFlags |= SONG_LINEARSLIDES; if(mainchunk->channels < 1) return false; @@ -561,7 +561,7 @@ m_nInstruments = max(m_nInstruments, nIns); memcpy(pIns->name, instheader->name, 28); - SpaceToNullStringFixed<28>(pIns->name); + StringFixer::SpaceToNullStringFixed<28>(pIns->name); for(BYTE i = 0; i < 128; i++) { @@ -602,7 +602,7 @@ if(smpchunk->signature != AMCHUNKID_SAMP) break; // SAMP memcpy(m_szNames[nSmp], smpchunk->name, 28); - SpaceToNullStringFixed<28>(m_szNames[nSmp]); + StringFixer::SpaceToNullStringFixed<28>(m_szNames[nSmp]); Samples[nSmp].nPan = smpchunk->pan << 2; Samples[nSmp].nVolume = smpchunk->volume << 2; @@ -672,7 +672,7 @@ m_nInstruments = max(m_nInstruments, nIns); memcpy(pIns->name, instheader->name, 32); - SpaceToNullStringFixed<31>(pIns->name); + StringFixer::SpaceToNullStringFixed<31>(pIns->name); for(BYTE i = 0; i < 128; i++) { @@ -726,7 +726,7 @@ MemsetZero(Samples[nSmp]); memcpy(m_szNames[nSmp], smpchunk->name, 32); - SpaceToNullStringFixed<31>(m_szNames[nSmp]); + StringFixer::SpaceToNullStringFixed<31>(m_szNames[nSmp]); if(LittleEndianW(smpchunk->pan) > 0x7FFF || LittleEndianW(smpchunk->volume) > 0x7FFF) break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-08-08 16:00:51
|
Revision: 970 http://modplug.svn.sourceforge.net/modplug/?rev=970&view=rev Author: saga-games Date: 2011-08-08 16:00:45 +0000 (Mon, 08 Aug 2011) Log Message: ----------- [Imp] Macros are now evaluated on every tick (both smooth and normal MIDI macros), so that volume / pan changes are taken into account immediately. [Mod] OpenMPT: Version is now 1.20.00.05 Modified Paths: -------------- trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-08-08 15:00:31 UTC (rev 969) +++ trunk/OpenMPT/mptrack/version.h 2011-08-08 16:00:45 UTC (rev 970) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 04 +#define VER_MINORMINOR 05 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-08-08 15:00:31 UTC (rev 969) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-08-08 16:00:45 UTC (rev 970) @@ -1342,7 +1342,7 @@ // the need for parameter control. The condition cmd == 0 // is to make sure that m_nPlugParamValueStep != 0 because // of NOTE_PCS, not because of macro. - if(pChn->nRowNote == NOTE_PCS || (cmd == 0 && pChn->m_nPlugParamValueStep != 0)) + if(pChn->nRowNote == NOTE_PCS || (cmd == 0 && pChn->m_plugParamValueStep != 0)) { const bool isFirstTick = (m_dwSongFlags & SONG_FIRSTTICK) != 0; if(isFirstTick) @@ -1358,17 +1358,17 @@ { PlugParamValue targetvalue = MODCOMMAND::GetValueEffectCol(pChn->nRowCommand, pChn->nRowParam) / PlugParamValue(MODCOMMAND::maxColumnValue); // Hack: Use m_nPlugInitialParamValue to store the target value, not initial. - pChn->m_nPlugInitialParamValue = targetvalue; - pChn->m_nPlugParamValueStep = (targetvalue - m_MixPlugins[nPlug-1].pMixPlugin->GetParameter(plugparam)) / float(m_nMusicSpeed); + pChn->m_plugInitialParamValue = targetvalue; + pChn->m_plugParamValueStep = (targetvalue - m_MixPlugins[nPlug-1].pMixPlugin->GetParameter(plugparam)) / float(m_nMusicSpeed); } - if(m_nTickCount + 1 == m_nMusicSpeed) + if(m_nTickCount + 1 == GetNumTicksOnCurrentRow()) { // On last tick, set parameter exactly to target value. // Note: m_nPlugInitialParamValue is used to store the target value, // not the initial value as the name suggests. - m_MixPlugins[nPlug-1].pMixPlugin->SetParameter(plugparam, pChn->m_nPlugInitialParamValue); + m_MixPlugins[nPlug-1].pMixPlugin->SetParameter(plugparam, pChn->m_plugInitialParamValue); } else - m_MixPlugins[nPlug-1].pMixPlugin->ModifyParameter(plugparam, pChn->m_nPlugParamValueStep); + m_MixPlugins[nPlug-1].pMixPlugin->ModifyParameter(plugparam, pChn->m_plugParamValueStep); } } @@ -3238,6 +3238,25 @@ } +// Calculate smooth MIDI macro slide parameter for current tick. +float CSoundFile::CalculateSmoothParamChange(float currentValue, float param) const +//--------------------------------------------------------------------------------- +{ + ASSERT(GetNumTicksOnCurrentRow() > m_nTickCount); + const UINT ticksLeft = GetNumTicksOnCurrentRow() - m_nTickCount; + if(ticksLeft > 1) + { + // Slide param + const float step = ((float)param - currentValue) / (float)ticksLeft; + return (currentValue + step); + } else + { + // On last tick, set exact value. + return (float)param; + } +} + + // Process MIDI macro data parsed by ProcessMIDIMacro... return bytes sent on success, 0 on (parse) failure. size_t CSoundFile::SendMIDIData(CHANNELINDEX nChn, bool isSmooth, const unsigned char *macro, size_t macroLen, PLUGINDEX plugin) //------------------------------------------------------------------------------------------------------------------------------ @@ -3274,15 +3293,7 @@ pChn->nCutOff = param; } else { - // on the first tick only, calculate step - if(m_dwSongFlags & SONG_FIRSTTICK) - { - pChn->m_nPlugInitialParamValue = pChn->nCutOff; - // (dwParam & 0x7F) extracts the actual value that we're going to pass - pChn->m_nPlugParamValueStep = (float)((int)param - pChn->m_nPlugInitialParamValue) / (float)GetNumTicksOnCurrentRow(); - } - //update param on all ticks - pChn->nCutOff = (BYTE) (pChn->m_nPlugInitialParamValue + (m_nTickCount + 1) * pChn->m_nPlugParamValueStep + 0.5); + pChn->nCutOff = (BYTE)CalculateSmoothParamChange((float)pChn->nCutOff, (float)param); } pChn->nRestoreCutoffOnNewNote = 0; } @@ -3309,15 +3320,7 @@ pChn->nResonance = param; } else { - // on the first tick only, calculate step - if(m_dwSongFlags & SONG_FIRSTTICK) - { - pChn->m_nPlugInitialParamValue = pChn->nResonance; - // (dwParam & 0x7F) extracts the actual value that we're going to pass - pChn->m_nPlugParamValueStep = (float)((int)param - pChn->m_nPlugInitialParamValue) / (float)GetNumTicksOnCurrentRow(); - } - //update param on all ticks - pChn->nResonance = (BYTE) (pChn->m_nPlugInitialParamValue + (m_nTickCount + 1) * pChn->m_nPlugParamValueStep + 0.5); + pChn->nResonance = (BYTE)CalculateSmoothParamChange((float)pChn->nResonance, (float)param); } } @@ -3350,20 +3353,13 @@ const PLUGINDEX nPlug = (plugin != 0) ? plugin : GetBestPlugin(nChn, PRIORITISE_CHANNEL, EVEN_IF_MUTED); if ((nPlug) && (nPlug <= MAX_MIXPLUGINS) && param < 0x80) { + const float newRatio = 1.0 - (static_cast<float>(param) / 127.0f); if(!isSmooth) { - m_MixPlugins[nPlug - 1].fDryRatio = 1.0 - (static_cast<float>(param) / 127.0f); + m_MixPlugins[nPlug - 1].fDryRatio = newRatio; } else { - // on the first tick only, calculate step - if(m_dwSongFlags & SONG_FIRSTTICK) - { - pChn->m_nPlugInitialParamValue = m_MixPlugins[nPlug - 1].fDryRatio; - // (dwParam & 0x7F) extracts the actual value that we're going to pass - pChn->m_nPlugParamValueStep = ((1 - ((float)(param) / 127.0f)) - pChn->m_nPlugInitialParamValue) / (float)GetNumTicksOnCurrentRow(); - } - //update param on all ticks - m_MixPlugins[nPlug - 1].fDryRatio = pChn->m_nPlugInitialParamValue + (float)(m_nTickCount + 1) * pChn->m_nPlugParamValueStep; + m_MixPlugins[nPlug - 1].fDryRatio = CalculateSmoothParamChange(m_MixPlugins[nPlug - 1].fDryRatio, newRatio); } } return 4; @@ -3378,23 +3374,15 @@ const UINT plugParam = isExtended ? (0x80 + macroCode) : (macroCode & 0x7F); if((nPlug) && (nPlug <= MAX_MIXPLUGINS)) { - IMixPlugin *pPlugin = m_MixPlugins[nPlug-1].pMixPlugin; - if((pPlugin) && (m_MixPlugins[nPlug-1].pMixState)) + IMixPlugin *pPlugin = m_MixPlugins[nPlug - 1].pMixPlugin; + if((pPlugin) && (m_MixPlugins[nPlug - 1].pMixState) && (param < 0x80)) { if(!isSmooth) { - pPlugin->SetZxxParameter(plugParam, param & 0x7F); + pPlugin->SetZxxParameter(plugParam, param); } else { - // on the first tick only, calculate step - if(m_dwSongFlags & SONG_FIRSTTICK) - { - pChn->m_nPlugInitialParamValue = pPlugin->GetZxxParameter(plugParam); - // (dwParam & 0x7F) extracts the actual value that we're going to pass - pChn->m_nPlugParamValueStep = ((int)(param & 0x7F) - pChn->m_nPlugInitialParamValue) / (float)GetNumTicksOnCurrentRow(); - } - //update param on all ticks - pPlugin->SetZxxParameter(plugParam, (UINT) (pChn->m_nPlugInitialParamValue + (m_nTickCount + 1) * pChn->m_nPlugParamValueStep + 0.5)); + pPlugin->SetZxxParameter(plugParam, (UINT)CalculateSmoothParamChange(pPlugin->GetZxxParameter(plugParam), (float)param)); } } } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2011-08-08 15:00:31 UTC (rev 969) +++ trunk/OpenMPT/soundlib/Sndfile.h 2011-08-08 16:00:45 UTC (rev 970) @@ -253,10 +253,10 @@ BYTE nActiveMacro, nFilterMode; BYTE nEFxSpeed, nEFxDelay; // memory for Invert Loop (EFx, .MOD only) - uint16 m_RowPlugParam; //NOTE_PCs memory. - float m_nPlugParamValueStep; //rewbs.smoothVST - float m_nPlugInitialParamValue; //rewbs.smoothVST - PLUGINDEX m_RowPlug; //NOTE_PCs memory. + //NOTE_PCs memory. + uint16 m_RowPlugParam; + float m_plugParamValueStep, m_plugInitialParamValue; + PLUGINDEX m_RowPlug; void ClearRowCmd() {nRowNote = NOTE_NONE; nRowInstr = 0; nRowVolCmd = VOLCMD_NONE; nRowVolume = 0; nRowCommand = CMD_NONE; nRowParam = 0;} @@ -949,6 +949,7 @@ inline void InvertLoop(MODCHANNEL* pChn); void ProcessMacroOnChannel(CHANNELINDEX nChn); void ProcessMIDIMacro(CHANNELINDEX nChn, bool isSmooth, char *macro, uint8 param = 0, PLUGINDEX plugin = 0); + float CalculateSmoothParamChange(float currentValue, float param) const; size_t SendMIDIData(CHANNELINDEX nChn, bool isSmooth, const unsigned char *macro, size_t macroLen, PLUGINDEX plugin); void SetupChannelFilter(MODCHANNEL *pChn, bool bReset, int flt_modifier = 256) const; // Low-Level effect processing Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2011-08-08 15:00:31 UTC (rev 969) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2011-08-08 16:00:45 UTC (rev 970) @@ -636,7 +636,7 @@ BOOL CSoundFile::ProcessRow() //--------------------------- { - if (++m_nTickCount >= m_nMusicSpeed * (m_nPatternDelay + 1) + m_nFrameDelay) + if (++m_nTickCount >= GetNumTicksOnCurrentRow()) { HandlePatternTransitionEvents(); m_nPatternDelay = 0; @@ -837,7 +837,7 @@ pChn->nRightVol = pChn->nNewRightVol; pChn->dwFlags &= ~(CHN_PORTAMENTO | CHN_VIBRATO | CHN_TREMOLO | CHN_PANBRELLO); pChn->nCommand = 0; - pChn->m_nPlugParamValueStep = 0; + pChn->m_plugParamValueStep = 0; } // Now that we know which pattern we're on, we can update time signatures (global or pattern-specific) @@ -850,7 +850,7 @@ //End of row? stop pattern step (aka "play row"). #ifdef MODPLUG_TRACKER - if (m_nTickCount >= m_nMusicSpeed * (m_nPatternDelay + 1) + m_nFrameDelay - 1) + if (m_nTickCount >= GetNumTicksOnCurrentRow() - 1) { if (m_dwSongFlags & SONG_STEP) { @@ -2340,7 +2340,7 @@ if(pChn->nRowCommand == CMD_MIDI || pChn->nRowCommand == CMD_SMOOTHMIDI) { // Only smooth MIDI macros are processed on every tick - if((pChn->nRowCommand == CMD_MIDI) && !(m_dwSongFlags & SONG_FIRSTTICK)) return; + //if((pChn->nRowCommand == CMD_MIDI) && !(m_dwSongFlags & SONG_FIRSTTICK)) return; if(pChn->nRowParam < 0x80) ProcessMIDIMacro(nChn, (pChn->nRowCommand == CMD_SMOOTHMIDI), m_MidiCfg.szMidiSFXExt[pChn->nActiveMacro], pChn->nRowParam); else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-08-09 13:04:19
|
Revision: 971 http://modplug.svn.sourceforge.net/modplug/?rev=971&view=rev Author: saga-games Date: 2011-08-09 13:04:13 +0000 (Tue, 09 Aug 2011) Log Message: ----------- [Fix] Sample playback could be screwed up on channels where an instrument with a plugin assigned was stopped (since rev. 947). [Mod] OpenMPT: Version is now 1.20.00.06 Modified Paths: -------------- trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-08-08 16:00:45 UTC (rev 970) +++ trunk/OpenMPT/mptrack/version.h 2011-08-09 13:04:13 UTC (rev 971) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 05 +#define VER_MINORMINOR 06 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2011-08-08 16:00:45 UTC (rev 970) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2011-08-09 13:04:13 UTC (rev 971) @@ -1966,8 +1966,9 @@ // Also process envelopes etc. when there's a plugin on this channel, for possible fake automation using volume and pan data. // We only care about master channels, though, since automation only "happens" on them. + const bool samplePlaying = (pChn->nPeriod && pChn->nLength); const bool plugAssigned = (nChn < m_nChannels) && (ChnSettings[nChn].nMixPlugin || (pChn->pModInstrument != nullptr && pChn->pModInstrument->nMixPlug)); - if ((pChn->nPeriod && pChn->nLength) || plugAssigned) + if (samplePlaying || plugAssigned) { int vol = pChn->nVolume; @@ -2001,8 +2002,6 @@ // IMPORTANT: pChn->nRealVolume is 14 bits !!! // -> _muldiv( 14+8, 6+6, 18); => RealVolume: 14-bit result (22+12-20) - //UINT nPlugin = GetBestPlugin(nChn, PRIORITISE_INSTRUMENT, RESPECT_MUTES); - //Don't let global volume affect level of sample if //global volume is going to be applied to master output anyway. if (pChn->dwFlags & CHN_SYNCMUTE) @@ -2042,7 +2041,7 @@ ProcessMacroOnChannel(nChn); // After MIDI macros have been processed, we can also process the pitch / filter envelope and other pitch-related things. - if (pChn->nPeriod && pChn->nLength) + if (samplePlaying) { int nPeriodFrac = 0; @@ -2106,6 +2105,11 @@ if (m_nFreqFactor != 128) ninc = (ninc * m_nFreqFactor) >> 7; if (ninc > 0xFF0000) ninc = 0xFF0000; pChn->nInc = (ninc+1) & ~3; + } else + { + // Avoid nasty noises... + // This could have been != 0 if a plugin was assigned to the channel, for macro purposes. + pChn->nRealVolume = 0; } // Increment envelope positions This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-08-16 18:41:04
|
Revision: 978 http://modplug.svn.sourceforge.net/modplug/?rev=978&view=rev Author: saga-games Date: 2011-08-16 18:40:56 +0000 (Tue, 16 Aug 2011) Log Message: ----------- More project filters. Modified Paths: -------------- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters Added Paths: ----------- trunk/OpenMPT/soundtouch/soundtouch_10.vcxproj.filters trunk/OpenMPT/xsoundlib/xsoundlib_10.vcxproj.filters Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2011-08-16 18:18:13 UTC (rev 977) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2011-08-16 18:40:56 UTC (rev 978) @@ -807,6 +807,7 @@ <ItemGroup> <Filter Include="Header Files"> <UniqueIdentifier>{41a5e65d-7591-4871-b2b3-29e5293c5782}</UniqueIdentifier> + <Extensions>h;hpp;hxx;hm;inl</Extensions> </Filter> <Filter Include="Module Loaders"> <UniqueIdentifier>{bbe72ed0-6ebf-4cba-ace9-94d090d10e49}</UniqueIdentifier> @@ -816,6 +817,7 @@ </Filter> <Filter Include="Source Files"> <UniqueIdentifier>{cd3e5871-5f13-4cdf-a869-f807737d2906}</UniqueIdentifier> + <Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions> </Filter> <Filter Include="Source Files\MixGraph"> <UniqueIdentifier>{f0af5cea-2ec1-45c0-abe8-b93aa90e1df2}</UniqueIdentifier> @@ -837,6 +839,7 @@ </Filter> <Filter Include="Resource Files"> <UniqueIdentifier>{5a7bae01-9526-4d85-9c00-0a280e22ad0b}</UniqueIdentifier> + <Extensions>ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe</Extensions> </Filter> </ItemGroup> <ItemGroup> Added: trunk/OpenMPT/soundtouch/soundtouch_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/soundtouch/soundtouch_10.vcxproj.filters (rev 0) +++ trunk/OpenMPT/soundtouch/soundtouch_10.vcxproj.filters 2011-08-16 18:40:56 UTC (rev 978) @@ -0,0 +1,100 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <ClCompile Include="3dnow_win.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="AAFilter.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="BPMDetect.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="cpu_detect_x86_win.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="FIFOSampleBuffer.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="FIRFilter.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="mmx_optimized.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="PeakFinder.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="RateTransposer.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="SoundTouch.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="SoundTouchDLL.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="sse_optimized.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="TDStretch.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <ClInclude Include="TDStretch.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="AAFilter.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="BPMDetect.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="cpu_detect.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="FIFOSampleBuffer.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="FIFOSamplePipe.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="FIRFilter.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="PeakFinder.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="RateTransposer.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="resource.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="SoundTouch.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="SoundTouchDLL.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="STTypes.h"> + <Filter>Header Files</Filter> + </ClInclude> + </ItemGroup> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{305127c7-0d8a-4960-8522-7ff1aa015944}</UniqueIdentifier> + <Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{a74ecb2c-5a88-4414-97bc-f74e3d8c8105}</UniqueIdentifier> + <Extensions>h;hpp;hxx;hm;inl</Extensions> + </Filter> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="SoundTouchDLL.rc"> + <Filter>Header Files</Filter> + </ResourceCompile> + </ItemGroup> +</Project> \ No newline at end of file Added: trunk/OpenMPT/xsoundlib/xsoundlib_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/xsoundlib/xsoundlib_10.vcxproj.filters (rev 0) +++ trunk/OpenMPT/xsoundlib/xsoundlib_10.vcxproj.filters 2011-08-16 18:40:56 UTC (rev 978) @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <ClCompile Include="stdafx.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="src_zoh.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="src_sinc.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="src_linear.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="smbPitchShift.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="samplerate.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <ClInclude Include="common.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="unistd.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="config.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="fastest_coeffs.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="float_cast.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="high_qual_coeffs.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="mid_qual_coeffs.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="samplerate.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="smbPitchShift.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="stdafx.h"> + <Filter>Header Files</Filter> + </ClInclude> + </ItemGroup> + <ItemGroup> + <None Include="ReadMe.txt" /> + </ItemGroup> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{55eaaca8-b474-4b8a-b41f-f62e9212377e}</UniqueIdentifier> + <Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{629a457f-5ea0-42bc-9861-ca9eadd6cbd9}</UniqueIdentifier> + <Extensions>h;hpp;hxx;hm;inl</Extensions> + </Filter> + </ItemGroup> +</Project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-08-21 23:28:45
|
Revision: 990 http://modplug.svn.sourceforge.net/modplug/?rev=990&view=rev Author: saga-games Date: 2011-08-21 23:28:38 +0000 (Sun, 21 Aug 2011) Log Message: ----------- [Imp] Improved file dumping in exception handler a bit. Modified Paths: -------------- trunk/OpenMPT/installer/install.iss trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/version.h Modified: trunk/OpenMPT/installer/install.iss =================================================================== --- trunk/OpenMPT/installer/install.iss 2011-08-21 21:21:48 UTC (rev 989) +++ trunk/OpenMPT/installer/install.iss 2011-08-21 23:28:38 UTC (rev 990) @@ -124,10 +124,12 @@ ; internet shortcut has to be deleted manually Type: files; Name: {app}\ModPlug Central.url ; normal installation +Type: dirifempty; Name: {userappdata}\OpenMPT\CrashFiles; Tasks: not portable Type: dirifempty; Name: {userappdata}\OpenMPT\TemplateModules; Tasks: not portable Type: dirifempty; Name: {userappdata}\OpenMPT\tunings; Tasks: not portable Type: dirifempty; Name: {userappdata}\OpenMPT; Tasks: not portable ; portable installation +Type: dirifempty; Name: {app}\CrashFiles; Tasks: portable Type: dirifempty; Name: {app}\TemplateModules; Tasks: portable Type: dirifempty; Name: {app}\tunings; Tasks: portable #ifdef DOWNLOAD_MO3 Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2011-08-21 21:21:48 UTC (rev 989) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2011-08-21 23:28:38 UTC (rev 990) @@ -589,7 +589,6 @@ _CrtSetDebugFillThreshold(0); // Disable buffer filling in secure enhanced CRT functions. #endif - #ifdef WIN32 ::SetUnhandledExceptionFilter(UnhandledExceptionFilter); #endif // WIN32 @@ -2980,6 +2979,7 @@ //------------------------------------------------------------- { CMainFrame* pMainFrame = CMainFrame::GetMainFrame(); + // Shut down audio device... if(pMainFrame) { if(pMainFrame->gpSoundDevice) pMainFrame->gpSoundDevice->Reset(); @@ -2993,26 +2993,39 @@ POSITION pos = pDocTmpl->GetFirstDocPosition(); CDocument *pDoc; - int fileID = 0; - const CString timeStamp = (CTime::GetCurrentTime()).Format("%Y%m%d.%H%M%S"); + const HWND window = (pMainFrame ? pMainFrame->m_hWnd : NULL); + const CString timestampDir = (CTime::GetCurrentTime()).Format("%Y-%m-%d %H.%M.%S\\"); + CString baseRescuePath; + int numFiles = 0; while((pos != NULL) && ((pDoc = pDocTmpl->GetNextDoc(pos)) != NULL)) { CModDoc *pModDoc = (CModDoc *)pDoc; if(pModDoc->IsModified() && pModDoc->GetSoundFile() != nullptr) { - fileID++; + if(numFiles == 0) + { + // Need to create a rescue directory first + baseRescuePath.Format("%sCrashFiles\\", theApp.GetConfigPath()); + CreateDirectory(baseRescuePath, nullptr); + baseRescuePath.Append(timestampDir); + if(!CreateDirectory(baseRescuePath, nullptr)) + { + ::MessageBox(window, "A crash has been detected.\nThere are still some modified files open, but OpenMPT could not create a directory for rescueing them.", "OpenMPT Crash", MB_ICONERROR); + break; + } + } CString filename; - filename.Format("%scrash_%s_%d.%s", theApp.GetConfigPath(), timeStamp, fileID, pModDoc->GetSoundFile()->GetModSpecifications().fileExtension); + filename.Format("%s%d_%s.%s", baseRescuePath, ++numFiles, pModDoc->GetTitle(), pModDoc->GetSoundFile()->GetModSpecifications().fileExtension); pModDoc->OnSaveDocument(filename); } } - if(fileID > 0) + if(numFiles > 0) { CString message; - message.Format("A crash has been detected.\n%d modified file%s been rescued to %s", fileID, (fileID == 1 ? " has" : "s have"), theApp.GetConfigPath()); - ::MessageBox((pMainFrame ? pMainFrame->m_hWnd : NULL), message, "OpenMPT Crash", MB_ICONERROR); + message.Format("A crash has been detected.\n%d modified file%s been rescued to the following directory:\n%s", numFiles, (numFiles == 1 ? " has" : "s have"), baseRescuePath); + ::MessageBox(window, message, "OpenMPT Crash", MB_ICONERROR); } } Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-08-21 21:21:48 UTC (rev 989) +++ trunk/OpenMPT/mptrack/version.h 2011-08-21 23:28:38 UTC (rev 990) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 09 +#define VER_MINORMINOR 10 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-08-22 13:42:20
|
Revision: 991 http://modplug.svn.sourceforge.net/modplug/?rev=991&view=rev Author: saga-games Date: 2011-08-22 13:42:10 +0000 (Mon, 22 Aug 2011) Log Message: ----------- [Mod] Changed document rescue behaviour a bit (rescued modules are now dumped in %TEMP%\OpenMPT Crash Files) [Mod] Updated copyright notice in resources Modified Paths: -------------- trunk/OpenMPT/installer/install.iss trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/res/MPTRACK.RC2 Modified: trunk/OpenMPT/installer/install.iss =================================================================== --- trunk/OpenMPT/installer/install.iss 2011-08-21 23:28:38 UTC (rev 990) +++ trunk/OpenMPT/installer/install.iss 2011-08-22 13:42:10 UTC (rev 991) @@ -124,12 +124,10 @@ ; internet shortcut has to be deleted manually Type: files; Name: {app}\ModPlug Central.url ; normal installation -Type: dirifempty; Name: {userappdata}\OpenMPT\CrashFiles; Tasks: not portable Type: dirifempty; Name: {userappdata}\OpenMPT\TemplateModules; Tasks: not portable Type: dirifempty; Name: {userappdata}\OpenMPT\tunings; Tasks: not portable Type: dirifempty; Name: {userappdata}\OpenMPT; Tasks: not portable ; portable installation -Type: dirifempty; Name: {app}\CrashFiles; Tasks: portable Type: dirifempty; Name: {app}\TemplateModules; Tasks: portable Type: dirifempty; Name: {app}\tunings; Tasks: portable #ifdef DOWNLOAD_MO3 Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2011-08-21 23:28:38 UTC (rev 990) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2011-08-22 13:42:10 UTC (rev 991) @@ -2931,8 +2931,8 @@ /////////////////////////////////////////////////////////////////////////////////// // Internet-related functions -BOOL CTrackApp::OpenURL(LPCSTR lpszURL) -//------------------------------------- +BOOL CTrackApp::OpenURL(const LPCSTR lpszURL) +//------------------------------------------- { if ((lpszURL) && (lpszURL[0]) && (theApp.m_pMainWnd)) { @@ -2942,7 +2942,7 @@ lpszURL, NULL, NULL, - 0)) >= 32) return TRUE; + SW_SHOW)) >= 32) return TRUE; } return FALSE; } @@ -3006,12 +3006,14 @@ if(numFiles == 0) { // Need to create a rescue directory first - baseRescuePath.Format("%sCrashFiles\\", theApp.GetConfigPath()); + TCHAR tempPath[_MAX_PATH]; + GetTempPath(CountOf(tempPath), tempPath); + baseRescuePath.Format("%sOpenMPT Crash Files\\", tempPath); CreateDirectory(baseRescuePath, nullptr); baseRescuePath.Append(timestampDir); if(!CreateDirectory(baseRescuePath, nullptr)) { - ::MessageBox(window, "A crash has been detected.\nThere are still some modified files open, but OpenMPT could not create a directory for rescueing them.", "OpenMPT Crash", MB_ICONERROR); + ::MessageBox(window, "A crash has been detected and OpenMPT will be closed.\nThere are still some modified files open, but OpenMPT could not create a directory for rescueing them.", "OpenMPT Crash", MB_ICONERROR); break; } } @@ -3024,8 +3026,9 @@ if(numFiles > 0) { CString message; - message.Format("A crash has been detected.\n%d modified file%s been rescued to the following directory:\n%s", numFiles, (numFiles == 1 ? " has" : "s have"), baseRescuePath); + message.Format("A crash has been detected and OpenMPT will be closed.\n%d modified file%s been rescued to\n\n%s\n\nNote: It cannot be guaranteed that rescued files are still intact.", numFiles, (numFiles == 1 ? " has" : "s have"), baseRescuePath); ::MessageBox(window, message, "OpenMPT Crash", MB_ICONERROR); + OpenDirectory(baseRescuePath); } } Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2011-08-21 23:28:38 UTC (rev 990) +++ trunk/OpenMPT/mptrack/Mptrack.h 2011-08-22 13:42:10 UTC (rev 991) @@ -175,7 +175,9 @@ static BOOL SaveDefaultDLSBanks(); static BOOL RemoveDLSBank(UINT nBank); static BOOL AddDLSBank(LPCSTR); - static BOOL OpenURL(LPCSTR lpszURL); + static BOOL OpenURL(const LPCSTR lpszURL); + static BOOL OpenFile(const LPCSTR file) { return OpenURL(file); }; + static BOOL OpenDirectory(const LPCSTR directory) { return OpenURL(directory); }; static FileDlgResult ShowOpenSaveFileDialog(const bool load, const std::string defaultExtension, const std::string defaultFilename, const std::string extFilter, const std::string workingDirectory = "", const bool allowMultiSelect = false, int *filterIndex = nullptr); Modified: trunk/OpenMPT/mptrack/res/MPTRACK.RC2 =================================================================== --- trunk/OpenMPT/mptrack/res/MPTRACK.RC2 2011-08-21 23:28:38 UTC (rev 990) +++ trunk/OpenMPT/mptrack/res/MPTRACK.RC2 2011-08-22 13:42:10 UTC (rev 991) @@ -43,7 +43,7 @@ VALUE "FileDescription", "OpenMPT / ModPlug Tracker" VALUE "FileVersion", VER_FILEVERSION_STR VALUE "InternalName", "ModPlug Tracker" - VALUE "LegalCopyright", "Copyright \xA91997-2003 Olivier Lapicque; \xA92004-2010 contributors." + VALUE "LegalCopyright", "Copyright \xA91997-2003 Olivier Lapicque; \xA92004-2011 contributors." VALUE "LegalTrademarks", "M.O.D.P.L.U.G" VALUE "OriginalFilename", "mptrack.exe" VALUE "PrivateBuild", "" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-08-22 19:33:33
|
Revision: 994 http://modplug.svn.sourceforge.net/modplug/?rev=994&view=rev Author: saga-games Date: 2011-08-22 19:33:24 +0000 (Mon, 22 Aug 2011) Log Message: ----------- [Ref] General refactoring commit. Modified Paths: -------------- trunk/OpenMPT/mptrack/AutoSaver.cpp trunk/OpenMPT/mptrack/CleanupSong.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moptions.cpp trunk/OpenMPT/mptrack/SelectPluginDialog.cpp trunk/OpenMPT/mptrack/SelectPluginDialog.h trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_mo3.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp trunk/OpenMPT/soundlib/modcommand.cpp Modified: trunk/OpenMPT/mptrack/AutoSaver.cpp =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.cpp 2011-08-22 18:21:40 UTC (rev 993) +++ trunk/OpenMPT/mptrack/AutoSaver.cpp 2011-08-22 19:33:24 UTC (rev 994) @@ -302,7 +302,7 @@ if (pModDoc->m_bHasValidPath) // Check that the file has a user-chosen path { CString fullPath = pModDoc->GetPathName(); - path = fullPath.Left(fullPath.GetLength()-pModDoc->GetTitle().GetLength()); //remove file name if necessary + path = fullPath.Left(fullPath.GetLength() - pModDoc->GetTitle().GetLength()); //remove file name if necessary } else { path = theApp.GetConfigPath(); @@ -339,7 +339,6 @@ } - /////////////////////////////////////////////////////////////////////////////////////// // CAutoSaverGUI dialog : AutoSaver GUI /////////////////////////////////////////////////////////////////////////////////////// Modified: trunk/OpenMPT/mptrack/CleanupSong.cpp =================================================================== --- trunk/OpenMPT/mptrack/CleanupSong.cpp 2011-08-22 18:21:40 UTC (rev 993) +++ trunk/OpenMPT/mptrack/CleanupSong.cpp 2011-08-22 19:33:24 UTC (rev 994) @@ -653,7 +653,7 @@ pSndFile->Samples[i].pSample = nullptr; END_CRITICAL(); if(nSampleMap[i] > 0) strcpy(pSndFile->m_szNames[nSampleMap[i]], pSndFile->m_szNames[i]); - memset(pSndFile->m_szNames[i], 0, sizeof(pSndFile->m_szNames[i])); + MemsetZero(pSndFile->m_szNames[i]); // Also update instrument mapping (if module is in instrument mode) for(INSTRUMENTINDEX nIns = 1; nIns <= pSndFile->GetNumInstruments(); nIns++) Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-08-22 18:21:40 UTC (rev 993) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-08-22 19:33:24 UTC (rev 994) @@ -3077,7 +3077,7 @@ SAMPLEVIEWSTATE viewstate; MODSAMPLE *pSmp = &m_pSndFile->Samples[m_nSample]; - memset(&viewstate, 0, sizeof(viewstate)); + MemsetZero(viewstate); SendViewMessage(VIEWMSG_SAVESTATE, (LPARAM)&viewstate); points.nStart = viewstate.dwBeginSel; points.nEnd = viewstate.dwEndSel; @@ -3102,7 +3102,7 @@ nEnd = CLAMP(nEnd, 0, m_pSndFile->Samples[m_nSample].nLength); SAMPLEVIEWSTATE viewstate; - memset(&viewstate, 0, sizeof(viewstate)); + MemsetZero(viewstate); SendViewMessage(VIEWMSG_SAVESTATE, (LPARAM)&viewstate); viewstate.dwBeginSel = nStart; Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2011-08-22 18:21:40 UTC (rev 993) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2011-08-22 19:33:24 UTC (rev 994) @@ -696,7 +696,7 @@ m_SndFile.Patterns.Insert(0, 64); } - memset(m_SndFile.m_szNames, 0, sizeof(m_SndFile.m_szNames)); + MemsetZero(m_SndFile.m_szNames); strcpy(m_SndFile.m_szNames[0], "untitled"); m_SndFile.m_nMusicTempo = m_SndFile.m_nDefaultTempo = 125; @@ -1043,7 +1043,7 @@ BEGIN_CRITICAL(); //rewbs.vstiLive - if((nins > 0) && (nins <= m_SndFile.m_nInstruments) && (note >= NOTE_MIN) && (note <= NOTE_MAX)) + if((nins > 0) && (nins <= m_SndFile.GetNumInstruments()) && (note >= NOTE_MIN) && (note <= NOTE_MAX)) { MODINSTRUMENT *pIns = m_SndFile.Instruments[nins]; @@ -1107,40 +1107,50 @@ { DWORD muteType = (CMainFrame::GetSettings().m_dwPatternSetup&PATTERN_SYNCMUTE)? CHN_SYNCMUTE:CHN_MUTE; - if (nChn >= m_SndFile.m_nChannels) { + if (nChn >= m_SndFile.m_nChannels) + { return false; } //Mark channel as muted in channel settings - if (doMute) { + if (doMute) + { m_SndFile.ChnSettings[nChn].dwFlags |= CHN_MUTE; - } else { + } else + { m_SndFile.ChnSettings[nChn].dwFlags &= ~CHN_MUTE; } //Mute pattern channel - if (doMute) { + if (doMute) + { m_SndFile.Chn[nChn].dwFlags |= muteType; //Kill VSTi notes on muted channel. - UINT nPlug = m_SndFile.GetBestPlugin(nChn, PRIORITISE_INSTRUMENT, EVEN_IF_MUTED); - if ((nPlug) && (nPlug<=MAX_MIXPLUGINS)) { - CVstPlugin *pPlug = (CVstPlugin*)m_SndFile.m_MixPlugins[nPlug-1].pMixPlugin; + PLUGINDEX nPlug = m_SndFile.GetBestPlugin(nChn, PRIORITISE_INSTRUMENT, EVEN_IF_MUTED); + if ((nPlug) && (nPlug<=MAX_MIXPLUGINS)) + { + CVstPlugin *pPlug = (CVstPlugin*)m_SndFile.m_MixPlugins[nPlug - 1].pMixPlugin; MODINSTRUMENT* pIns = m_SndFile.Chn[nChn].pModInstrument; - if (pPlug && pIns) { + if (pPlug && pIns) + { pPlug->MidiCommand(pIns->nMidiChannel, pIns->nMidiProgram, pIns->wMidiBank, NOTE_KEYOFF, 0, nChn); } } - } else { + } else + { //on unmute alway cater for both mute types - this way there's no probs if user changes mute mode. m_SndFile.Chn[nChn].dwFlags &= ~(CHN_SYNCMUTE|CHN_MUTE); } //mute any NNA'd channels - for (UINT i=m_SndFile.m_nChannels; i<MAX_CHANNELS; i++) { + for (UINT i=m_SndFile.m_nChannels; i<MAX_CHANNELS; i++) + { if (m_SndFile.Chn[i].nMasterChn == nChn + 1u) { - if (doMute) { + if (doMute) + { m_SndFile.Chn[i].dwFlags |= muteType; - } else { + } else + { //on unmute alway cater for both mute types - this way there's no probs if user changes mute mode. m_SndFile.Chn[i].dwFlags &= ~(CHN_SYNCMUTE|CHN_MUTE); } @@ -1148,7 +1158,8 @@ } //Mark IT/MPTM/S3M as modified - if (m_SndFile.m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_S3M)) { + if (m_SndFile.GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_S3M)) + { CMainFrame::GetMainFrame()->ThreadSafeSetModified(this); } @@ -2220,18 +2231,18 @@ {CMD_MODCMDEX, 0xF0,0xF0, 0, MOD_TYPE_MOD, "Invert Loop"}, // Extended S3M/IT effects {CMD_S3MCMDEX, 0xF0,0x10, 0, MOD_TYPE_S3MITMPT, "Glissando Control"}, - {CMD_S3MCMDEX, 0xF0,0x20, 0, MOD_TYPE_S3M, "Set Finetune"}, + {CMD_S3MCMDEX, 0xF0,0x20, 0, MOD_TYPE_S3M, "Set Finetune"}, {CMD_S3MCMDEX, 0xF0,0x30, 0, MOD_TYPE_S3MITMPT, "Vibrato Waveform"}, {CMD_S3MCMDEX, 0xF0,0x40, 0, MOD_TYPE_S3MITMPT, "Tremolo Waveform"}, {CMD_S3MCMDEX, 0xF0,0x50, 0, MOD_TYPE_S3MITMPT, "Panbrello Waveform"}, {CMD_S3MCMDEX, 0xF0,0x60, 0, MOD_TYPE_S3MITMPT, "Fine Pattern Delay"}, {CMD_S3MCMDEX, 0xF0,0x80, 0, MOD_TYPE_S3MITMPT, "Set Panning"}, - {CMD_S3MCMDEX, 0xF0,0xA0, 0, MOD_TYPE_S3MITMPT, "Set High Offset"}, + {CMD_S3MCMDEX, 0xF0,0xA0, 0, MOD_TYPE_ITMPT, "Set High Offset"}, {CMD_S3MCMDEX, 0xF0,0xB0, 0, MOD_TYPE_S3MITMPT, "Pattern Loop"}, {CMD_S3MCMDEX, 0xF0,0xC0, 0, MOD_TYPE_S3MITMPT, "Note Cut"}, {CMD_S3MCMDEX, 0xF0,0xD0, 0, MOD_TYPE_S3MITMPT, "Note Delay"}, {CMD_S3MCMDEX, 0xF0,0xE0, 0, MOD_TYPE_S3MITMPT, "Pattern Delay"}, - {CMD_S3MCMDEX, 0xF0,0xF0, 0, MOD_TYPE_ITMPT, "Set Active Macro"}, + {CMD_S3MCMDEX, 0xF0,0xF0, 0, MOD_TYPE_ITMPT, "Set Active Macro"}, // MPT XM extensions and special effects {CMD_XFINEPORTAUPDOWN,0xF0,0x10,0, MOD_TYPE_XM, "Extra Fine Porta Up"}, {CMD_XFINEPORTAUPDOWN,0xF0,0x20,0, MOD_TYPE_XM, "Extra Fine Porta Down"}, @@ -2346,8 +2357,8 @@ case sfx_plug: { int nParam = MacroToPlugParam(macroText); char paramName[128]; - memset(paramName, 0, sizeof(paramName)); - UINT nPlug = m_SndFile.GetBestPlugin(nChn, PRIORITISE_CHANNEL, EVEN_IF_MUTED); + MemsetZero(paramName); + PLUGINDEX nPlug = m_SndFile.GetBestPlugin(nChn, PRIORITISE_CHANNEL, EVEN_IF_MUTED); if ((nPlug) && (nPlug<=MAX_MIXPLUGINS)) { CVstPlugin *pPlug = (CVstPlugin*)m_SndFile.m_MixPlugins[nPlug-1].pMixPlugin; if (pPlug) Modified: trunk/OpenMPT/mptrack/Moptions.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moptions.cpp 2011-08-22 18:21:40 UTC (rev 993) +++ trunk/OpenMPT/mptrack/Moptions.cpp 2011-08-22 19:33:24 UTC (rev 994) @@ -372,31 +372,7 @@ void COptionsColors::OnPresetMPT() //-------------------------------- { - CustomColors[MODCOLOR_BACKNORMAL] = RGB(0xFF, 0xFF, 0xFF); - CustomColors[MODCOLOR_TEXTNORMAL] = RGB(0x00, 0x00, 0x00); - CustomColors[MODCOLOR_BACKCURROW] = RGB(0xC0, 0xC0, 0xC0); - CustomColors[MODCOLOR_TEXTCURROW] = RGB(0x00, 0x00, 0x00); - CustomColors[MODCOLOR_BACKSELECTED] = RGB(0x00, 0x00, 0x00); - CustomColors[MODCOLOR_TEXTSELECTED] = RGB(0xFF, 0xFF, 0xFF); - CustomColors[MODCOLOR_SAMPLE] = RGB(0xFF, 0x00, 0x00); - CustomColors[MODCOLOR_BACKPLAYCURSOR] = RGB(0xFF, 0xFF, 0x80); - CustomColors[MODCOLOR_TEXTPLAYCURSOR] = RGB(0x00, 0x00, 0x00); - CustomColors[MODCOLOR_BACKHILIGHT] = RGB(0xE0, 0xE8, 0xE0); - CustomColors[MODCOLOR_NOTE] = RGB(0x00, 0x00, 0x80); - CustomColors[MODCOLOR_INSTRUMENT] = RGB(0x00, 0x80, 0x80); - CustomColors[MODCOLOR_VOLUME] = RGB(0x00, 0x80, 0x00); - CustomColors[MODCOLOR_PANNING] = RGB(0x00, 0x80, 0x80); - CustomColors[MODCOLOR_PITCH] = RGB(0x80, 0x80, 0x00); - CustomColors[MODCOLOR_GLOBALS] = RGB(0x80, 0x00, 0x00); - CustomColors[MODCOLOR_ENVELOPES] = RGB(0x00, 0x00, 0xFF); - CustomColors[MODCOLOR_VUMETER_LO] = RGB(0x00, 0xC8, 0x00); - CustomColors[MODCOLOR_VUMETER_MED] = RGB(0xFF, 0xC8, 0x00); - CustomColors[MODCOLOR_VUMETER_HI] = RGB(0xE1, 0x00, 0x00); - CustomColors[MODCOLOR_SEPSHADOW] = GetSysColor(COLOR_BTNSHADOW); - CustomColors[MODCOLOR_SEPFACE] = GetSysColor(COLOR_BTNFACE); - CustomColors[MODCOLOR_SEPHILITE] = GetSysColor(COLOR_BTNHIGHLIGHT); - CustomColors[MODCOLOR_BLENDCOLOR] = GetSysColor(COLOR_BTNFACE); - CustomColors[MODCOLOR_DODGY_COMMANDS] = RGB(0xC0, 0x00, 0x00); + TrackerSettings::GetDefaultColourScheme(CustomColors); OnPreviewChanged(); } Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2011-08-22 18:21:40 UTC (rev 993) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2011-08-22 19:33:24 UTC (rev 994) @@ -180,15 +180,18 @@ CMainFrame::GetSettings().gnPlugWindowWidth = rect.right - rect.left; CMainFrame::GetSettings().gnPlugWindowHeight = rect.bottom - rect.top; - if (bChanged) { + if (bChanged) + { CMainFrame::GetSettings().gnPlugWindowLast = m_pPlugin->Info.dwPluginId2; CDialog::OnOK(); } - else { + else + { CDialog::OnCancel(); } } + void CSelectPluginDlg::OnCancel() //------------------------------- { @@ -203,6 +206,7 @@ CDialog::OnCancel(); } + void CSelectPluginDlg::OnNameFilterChanged() //------------------------------------------ { @@ -211,8 +215,9 @@ UpdatePluginsList(); } -void CSelectPluginDlg::UpdatePluginsList(DWORD forceSelect/*=0*/) -//--------------------------------------------------------------- + +void CSelectPluginDlg::UpdatePluginsList(DWORD forceSelect /* = 0*/) +//------------------------------------------------------------------ { CVstPluginManager *pManager = theApp.GetPluginManager(); HTREEITEM cursel, hDmo, hVst, hSynth; @@ -232,18 +237,22 @@ while (p) { // Apply name filter - if (m_sNameFilter != "") { + if (m_sNameFilter != "") + { CString displayName = p->szLibraryName; - if (displayName.MakeLower().Find(m_sNameFilter) == -1) { + if (displayName.MakeLower().Find(m_sNameFilter) == -1) + { p = p->pNext; continue; } } HTREEITEM hParent; - if (p->dwPluginId1 == kDmoMagic) { + if (p->dwPluginId1 == kDmoMagic) + { hParent = hDmo; - } else { + } else + { hParent = (p->bIsInstrument) ? hSynth : hVst; } @@ -276,7 +285,8 @@ else if (/* (!pCurrent) && */ m_pPlugin->Info.dwPluginId1 !=0 || m_pPlugin->Info.dwPluginId2 != 0) { if ((p->dwPluginId1 == m_pPlugin->Info.dwPluginId1) - && (p->dwPluginId2 == m_pPlugin->Info.dwPluginId2)) { + && (p->dwPluginId2 == m_pPlugin->Info.dwPluginId2)) + { pCurrent = p; } } @@ -284,7 +294,8 @@ //Last selected plugin else { - if (p->dwPluginId2 == CMainFrame::GetSettings().gnPlugWindowLast) { + if (p->dwPluginId2 == CMainFrame::GetSettings().gnPlugWindowLast) + { pCurrent = p; } } @@ -294,7 +305,8 @@ } } m_treePlugins.SetRedraw(TRUE); - if (cursel) { + if (cursel) + { m_treePlugins.SelectItem(cursel); m_treePlugins.SetItemState(cursel, TVIS_BOLD, TVIS_BOLD); m_treePlugins.EnsureVisible(cursel); @@ -360,16 +372,16 @@ }; //TODO: Check whether the list is still valid. -static PROBLEMATIC_PLUG gProblemPlugs[] = +static const PROBLEMATIC_PLUG gProblemPlugs[] = { - {kEffectMagic, CCONST('N', 'i', '4', 'S'), 1, "Native Instruments B4", "* v1.1.1 hangs on playback. Do not proceed unless you have v1.1.5. *"}, - {kEffectMagic, CCONST('m', 'd', 'a', 'C'), 1, "MDA Degrade", "* This plugin can cause OpenMPT to behave erratically.\r\nYou should try SoundHack's Decimate, ConcreteFX's Lowbit or Subtek's LoFi Plus instead. *"}, - {kEffectMagic, CCONST('f', 'V', '2', 's'), 1, "Farbrausch V2", "* This plugin can cause OpenMPT to freeze when closing a module that uses V2 in a combination with various other plugins.\r\nIt is recommended to not use V2 in combination with any other plugins. *"}, - {kEffectMagic, CCONST('f', 'r', 'V', '2'), 1, "Farbrausch V2", "* This plugin can cause OpenMPT to freeze when closing a module that uses V2 in a combination with various other plugins.\r\nIt is recommended to not use V2 in combination with any other plugins. *"}, + { kEffectMagic, CCONST('N', 'i', '4', 'S'), 1, "Native Instruments B4", "* v1.1.1 hangs on playback. Do not proceed unless you have v1.1.5 or newer. *" }, + { kEffectMagic, CCONST('m', 'd', 'a', 'C'), 1, "MDA Degrade", "* Old versions of this plugin can crash OpenMPT.\nEnsure that you have the latest version of this plugin. *" }, + { kEffectMagic, CCONST('f', 'V', '2', 's'), 1, "Farbrausch V2", "* This plugin can cause OpenMPT to freeze if being used in a combination with various other plugins.\nIt is recommended to not use V2 in combination with any other plugins. *" }, + { kEffectMagic, CCONST('f', 'r', 'V', '2'), 1, "Farbrausch V2", "* This plugin can cause OpenMPT to freeze if being used in a combination with various other plugins.\nIt is recommended to not use V2 in combination with any other plugins. *" }, }; bool CSelectPluginDlg::VerifyPlug(PVSTPLUGINLIB plug) - //--------------------------------------------------- +//--------------------------------------------------- { CString s; for (size_t p = 0; p < CountOf(gProblemPlugs); p++) @@ -377,8 +389,8 @@ if ( (gProblemPlugs[p].id2 == plug->dwPluginId2) /*&& (gProblemPlugs[p].id1 == plug->dwPluginId1)*/) { - s.Format("WARNING: This plugin has been identified as %s,\r\nwhich is known to have the following problem with OpenMPT:\r\n\r\n%s\r\n\r\nWould you still like to add this plugin to the library?", gProblemPlugs[p].name, gProblemPlugs[p].problem); - return (AfxMessageBox(s, MB_YESNO) == IDYES); + s.Format("WARNING: This plugin has been identified as %s,\nwhich is known to have the following problem with OpenMPT:\n\n%s\n\nWould you still like to add this plugin to the library?", gProblemPlugs[p].name, gProblemPlugs[p].problem); + return (AfxMessageBox(s, MB_YESNO) == IDYES); } } @@ -406,7 +418,8 @@ CString sFilename = files.filenames[counter].c_str(); - if (pManager) { + if (pManager) + { plugLib = pManager->AddPlugin(sFilename, FALSE); if (plugLib) { @@ -424,7 +437,7 @@ UpdatePluginsList(plugLib ? plugLib->dwPluginId2 : 0); } else { - MessageBox("At least one selected file was not a valid VST-Plugin", NULL, MB_ICONERROR | MB_OK); + MessageBox("At least one selected file was not a valid VST-Plugin.", NULL, MB_ICONERROR | MB_OK); } } @@ -447,7 +460,8 @@ { CDialog::OnSize(nType, cx, cy); - if (m_treePlugins) { + if (m_treePlugins) + { m_treePlugins.MoveWindow(8, 36, cx - 104, cy - 63, FALSE); ::MoveWindow(GetDlgItem(IDC_STATIC_VSTNAMEFILTER)->m_hWnd, 8, 11, 40, 21, FALSE); Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.h =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.h 2011-08-22 18:21:40 UTC (rev 993) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.h 2011-08-22 19:33:24 UTC (rev 994) @@ -31,7 +31,7 @@ public: CSelectPluginDlg(CModDoc *pModDoc, int nPlugSlot, CWnd *parent); //rewbs.plugDocAware void DoClose(); - void UpdatePluginsList(DWORD forceSelect=0); + void UpdatePluginsList(DWORD forceSelect = 0); bool VerifyPlug(PVSTPLUGINLIB plug); virtual void DoDataExchange(CDataExchange* pDX); virtual BOOL OnInitDialog(); @@ -40,8 +40,8 @@ afx_msg void OnAddPlugin(); afx_msg void OnRemovePlugin(); afx_msg void OnNameFilterChanged(); - afx_msg void OnSelChanged(NMHDR *pNotifyStruct, LRESULT * result); - afx_msg void OnSelDblClk(NMHDR *pNotifyStruct, LRESULT * result); + afx_msg void OnSelChanged(NMHDR *pNotifyStruct, LRESULT *result); + afx_msg void OnSelDblClk(NMHDR *pNotifyStruct, LRESULT *result); DECLARE_MESSAGE_MAP() afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI); Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2011-08-22 18:21:40 UTC (rev 993) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2011-08-22 19:33:24 UTC (rev 994) @@ -101,36 +101,7 @@ m_nSampleUndoMaxBuffer = 0; // Real sample buffer undo size will be set later. // TODO duplicate code (see Moptions.cpp) - rgbCustomColors[MODCOLOR_BACKNORMAL] = RGB(0xFF, 0xFF, 0xFF); - rgbCustomColors[MODCOLOR_TEXTNORMAL] = RGB(0x00, 0x00, 0x00); - rgbCustomColors[MODCOLOR_BACKCURROW] = RGB(0xC0, 0xC0, 0xC0); - rgbCustomColors[MODCOLOR_TEXTCURROW] = RGB(0x00, 0x00, 0x00); - rgbCustomColors[MODCOLOR_BACKSELECTED] = RGB(0x00, 0x00, 0x00); - rgbCustomColors[MODCOLOR_TEXTSELECTED] = RGB(0xFF, 0xFF, 0xFF); - rgbCustomColors[MODCOLOR_SAMPLE] = RGB(0xFF, 0x00, 0x00); - rgbCustomColors[MODCOLOR_BACKPLAYCURSOR] = RGB(0xFF, 0xFF, 0x80); - rgbCustomColors[MODCOLOR_TEXTPLAYCURSOR] = RGB(0x00, 0x00, 0x00); - rgbCustomColors[MODCOLOR_BACKHILIGHT] = RGB(0xE0, 0xE8, 0xE0); - // Effect Colors - rgbCustomColors[MODCOLOR_NOTE] = RGB(0x00, 0x00, 0x80); - rgbCustomColors[MODCOLOR_INSTRUMENT] = RGB(0x00, 0x80, 0x80); - rgbCustomColors[MODCOLOR_VOLUME] = RGB(0x00, 0x80, 0x00); - rgbCustomColors[MODCOLOR_PANNING] = RGB(0x00, 0x80, 0x80); - rgbCustomColors[MODCOLOR_PITCH] = RGB(0x80, 0x80, 0x00); - rgbCustomColors[MODCOLOR_GLOBALS] = RGB(0x80, 0x00, 0x00); - rgbCustomColors[MODCOLOR_ENVELOPES] = RGB(0x00, 0x00, 0xFF); - // VU-Meters - rgbCustomColors[MODCOLOR_VUMETER_LO] = RGB(0x00, 0xC8, 0x00); - rgbCustomColors[MODCOLOR_VUMETER_MED] = RGB(0xFF, 0xC8, 0x00); - rgbCustomColors[MODCOLOR_VUMETER_HI] = RGB(0xE1, 0x00, 0x00); - // Channel separators - rgbCustomColors[MODCOLOR_SEPSHADOW] = GetSysColor(COLOR_BTNSHADOW); - rgbCustomColors[MODCOLOR_SEPFACE] = GetSysColor(COLOR_BTNFACE); - rgbCustomColors[MODCOLOR_SEPHILITE] = GetSysColor(COLOR_BTNHIGHLIGHT); - // Pattern blend colour - rgbCustomColors[MODCOLOR_BLENDCOLOR] = GetSysColor(COLOR_BTNFACE); - // Dodgy commands - rgbCustomColors[MODCOLOR_DODGY_COMMANDS] = RGB(0xC0, 0x00, 0x00); + GetDefaultColourScheme(rgbCustomColors); // Directory Arrays (Default + Last) for(size_t i = 0; i < NUM_DIRS; i++) @@ -177,6 +148,42 @@ } +void TrackerSettings::GetDefaultColourScheme(COLORREF (&colours)[MAX_MODCOLORS]) +//------------------------------------------------------------------------------ +{ + colours[MODCOLOR_BACKNORMAL] = RGB(0xFF, 0xFF, 0xFF); + colours[MODCOLOR_TEXTNORMAL] = RGB(0x00, 0x00, 0x00); + colours[MODCOLOR_BACKCURROW] = RGB(0xC0, 0xC0, 0xC0); + colours[MODCOLOR_TEXTCURROW] = RGB(0x00, 0x00, 0x00); + colours[MODCOLOR_BACKSELECTED] = RGB(0x00, 0x00, 0x00); + colours[MODCOLOR_TEXTSELECTED] = RGB(0xFF, 0xFF, 0xFF); + colours[MODCOLOR_SAMPLE] = RGB(0xFF, 0x00, 0x00); + colours[MODCOLOR_BACKPLAYCURSOR] = RGB(0xFF, 0xFF, 0x80); + colours[MODCOLOR_TEXTPLAYCURSOR] = RGB(0x00, 0x00, 0x00); + colours[MODCOLOR_BACKHILIGHT] = RGB(0xE0, 0xE8, 0xE0); + // Effect Colors + colours[MODCOLOR_NOTE] = RGB(0x00, 0x00, 0x80); + colours[MODCOLOR_INSTRUMENT] = RGB(0x00, 0x80, 0x80); + colours[MODCOLOR_VOLUME] = RGB(0x00, 0x80, 0x00); + colours[MODCOLOR_PANNING] = RGB(0x00, 0x80, 0x80); + colours[MODCOLOR_PITCH] = RGB(0x80, 0x80, 0x00); + colours[MODCOLOR_GLOBALS] = RGB(0x80, 0x00, 0x00); + colours[MODCOLOR_ENVELOPES] = RGB(0x00, 0x00, 0xFF); + // VU-Meters + colours[MODCOLOR_VUMETER_LO] = RGB(0x00, 0xC8, 0x00); + colours[MODCOLOR_VUMETER_MED] = RGB(0xFF, 0xC8, 0x00); + colours[MODCOLOR_VUMETER_HI] = RGB(0xE1, 0x00, 0x00); + // Channel separators + colours[MODCOLOR_SEPSHADOW] = GetSysColor(COLOR_BTNSHADOW); + colours[MODCOLOR_SEPFACE] = GetSysColor(COLOR_BTNFACE); + colours[MODCOLOR_SEPHILITE] = GetSysColor(COLOR_BTNHIGHLIGHT); + // Pattern blend colour + colours[MODCOLOR_BLENDCOLOR] = GetSysColor(COLOR_BTNFACE); + // Dodgy commands + colours[MODCOLOR_DODGY_COMMANDS] = RGB(0xC0, 0x00, 0x00); +} + + void TrackerSettings::LoadSettings() //---------------------------------- { @@ -824,15 +831,15 @@ } -LPCTSTR TrackerSettings::GetDefaultDirectory(Directory dir) -//--------------------------------------------------------- +LPCTSTR TrackerSettings::GetDefaultDirectory(Directory dir) const +//--------------------------------------------------------------- { return m_szDefaultDirectory[dir]; } -LPCTSTR TrackerSettings::GetWorkingDirectory(Directory dir) -//--------------------------------------------------------- +LPCTSTR TrackerSettings::GetWorkingDirectory(Directory dir) const +//--------------------------------------------------------------- { return m_szWorkingDirectory[dir]; } \ No newline at end of file Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2011-08-22 18:21:40 UTC (rev 993) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2011-08-22 19:33:24 UTC (rev 994) @@ -44,6 +44,7 @@ CString gcsPreviousVersion; CString gcsInstallGUID; MODTYPE defaultModType; + // Audio Setup DWORD m_dwSoundSetup, m_dwRate, m_dwQuality, m_nSrcMode, m_nBitsPerSample, m_nPreAmp, gbLoopSong, m_nChannels; LONG m_nWaveDevice; // use the SNDDEV_GET_NUMBER and SNDDEV_GET_TYPE macros to decode @@ -57,8 +58,10 @@ DWORD m_nRowHighlightMeasures, m_nRowHighlightBeats; // primary (measures) and secondary (beats) highlight bool m_bHideUnavailableCtxMenuItems; int orderlistMargins; + // Sample Editor Setup UINT m_nSampleUndoMaxBuffer; + // key config TCHAR m_szKbdFile[_MAX_PATH]; COLORREF rgbCustomColors[MAX_MODCOLORS]; @@ -88,19 +91,20 @@ int gnPlugWindowY; int gnPlugWindowWidth; int gnPlugWindowHeight; - DWORD gnPlugWindowLast; + DWORD gnPlugWindowLast; // Last selected plugin ID public: TrackerSettings(); void LoadSettings(); void SaveSettings(); + static void GetDefaultColourScheme(COLORREF (&colours)[MAX_MODCOLORS]); // access to default + working directories void SetWorkingDirectory(const LPCTSTR szFilenameFrom, Directory dir, bool bStripFilename = false); - LPCTSTR GetWorkingDirectory(Directory dir); + LPCTSTR GetWorkingDirectory(Directory dir) const; void SetDefaultDirectory(const LPCTSTR szFilenameFrom, Directory dir, bool bStripFilename = false); - LPCTSTR GetDefaultDirectory(Directory dir); + LPCTSTR GetDefaultDirectory(Directory dir) const; protected: Modified: trunk/OpenMPT/soundlib/Fastmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Fastmix.cpp 2011-08-22 18:21:40 UTC (rev 993) +++ trunk/OpenMPT/soundlib/Fastmix.cpp 2011-08-22 19:33:24 UTC (rev 994) @@ -1608,7 +1608,7 @@ #endif //Look for plugins associated with this implicit tracker channel. - UINT nMixPlugin = GetBestPlugin(ChnMix[nChn], PRIORITISE_INSTRUMENT, RESPECT_MUTES); + PLUGINDEX nMixPlugin = GetBestPlugin(ChnMix[nChn], PRIORITISE_INSTRUMENT, RESPECT_MUTES); //rewbs.instroVSTi /* UINT nMixPlugin=0; Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2011-08-22 18:21:40 UTC (rev 993) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2011-08-22 19:33:24 UTC (rev 994) @@ -2805,18 +2805,6 @@ } nTotalSize += nChInfo*4 + 8; } - if (m_SongEQ.nEQBands > 0) - { - nTotalSize += 8 + m_SongEQ.nEQBands * 4; - if (f) - { - nPluginSize = 'XFQE'; - fwrite(&nPluginSize, 1, 4, f); - nPluginSize = m_SongEQ.nEQBands*4; - fwrite(&nPluginSize, 1, 4, f); - fwrite(m_SongEQ.EQFreq_Gains, 1, nPluginSize, f); - } - } return nTotalSize; } #endif @@ -2828,40 +2816,27 @@ const BYTE *p = (const BYTE *)pData; UINT nPos = 0; - while (nPos+8 < nLen) // read 4 magic bytes + size + while (nLen - nPos >= 8) // read 4 magic bytes + size { DWORD nPluginSize; UINT nPlugin; - nPluginSize = *(DWORD *)(p+nPos+4); - if (nPluginSize > nLen-nPos-8) break;; - if ((*(DWORD *)(p+nPos)) == 'XFHC') + nPluginSize = *(DWORD *)(p + nPos + 4); + if (nPluginSize > nLen - nPos - 8) break; + + // Channel FX + if (!memcmp(p + nPos, "CHFX", 4)) { -// -> CODE#0006 -// -> DESC="misc quantity changes" -// for (UINT ch=0; ch<64; ch++) if (ch*4 < nPluginSize) - for (UINT ch=0; ch<MAX_BASECHANNELS; ch++) if (ch*4 < nPluginSize) -// -! BEHAVIOUR_CHANGE#0006 + for (size_t ch = 0; ch < MAX_BASECHANNELS; ch++) if (ch * 4 < nPluginSize) { - ChnSettings[ch].nMixPlugin = *(DWORD *)(p+nPos+8+ch*4); + ChnSettings[ch].nMixPlugin = *(DWORD *)(p + nPos + 8 + ch * 4); } } - - else if ((*(DWORD *)(p+nPos)) == 'XFQE') + // Plugin Data + else if (memcmp(p + nPos, "FX00", 4) >= 0 && memcmp(p + nPos, "FX99", 4) <= 0) { - m_SongEQ.nEQBands = nPluginSize/4; - if (m_SongEQ.nEQBands > MAX_EQ_BANDS) m_SongEQ.nEQBands = MAX_EQ_BANDS; - memcpy(m_SongEQ.EQFreq_Gains, p+nPos+8, m_SongEQ.nEQBands * 4); - } - //Load plugin Data - else - { - if ((p[nPos] != 'F') || (p[nPos+1] != 'X') || (p[nPos+2] < '0') || (p[nPos+3] < '0')) - { - break; - } - nPlugin = (p[nPos+2]-'0')*10 + (p[nPos+3]-'0'); //calculate plug-in number. + nPlugin = (p[nPos + 2] - '0') * 10 + (p[nPos + 3] - '0'); //calculate plug-in number. if ((nPlugin < MAX_MIXPLUGINS) && (nPluginSize >= sizeof(SNDMIXPLUGININFO)+4)) { @@ -2892,25 +2867,30 @@ DWORD endPos = startPos + dwXPlugData; // end of extra data for this plug DWORD currPos = startPos; - while (currPos < endPos) //cycle through all the bytes + while (endPos - currPos >= 4) //cycle through all the bytes { // do we recognize this chunk? //rewbs.dryRatio //TODO: turn this into a switch statement like for modular instrument data - if ((p[currPos] == 'D') && (p[currPos+1] == 'W') && (p[currPos+2] == 'R') && (p[currPos+3] == 'T')) - { - currPos+=4;// move past ID - m_MixPlugins[nPlugin].fDryRatio = *(float*) (p+currPos); - currPos+= sizeof(float); //move past data + if (!memcmp(p + currPos, "DWRT", 4)) + { + currPos += 4; // move past ID + if (endPos - currPos >= sizeof(float)) + { + m_MixPlugins[nPlugin].fDryRatio = *(float*) (p+currPos); + currPos += sizeof(float); //move past data + } } //end rewbs.dryRatio - //rewbs.plugDefaultProgram - else if ((p[currPos] == 'P') && (p[currPos+1] == 'R') && (p[currPos+2] == 'O') && (p[currPos+3] == 'G')) - { - currPos+=4;// move past ID - m_MixPlugins[nPlugin].defaultProgram = *(long*) (p+currPos); - currPos+= sizeof(long); //move past data + else if (!memcmp(p + currPos, "PROG", 4)) + { + currPos += 4; // move past ID + if (endPos - currPos >= sizeof(long)) + { + m_MixPlugins[nPlugin].defaultProgram = *(long*) (p+currPos); + currPos += sizeof(long); //move past data + } } //end rewbs.plugDefaultProgram //else if.. (add extra attempts to recognize chunks here) @@ -3021,7 +3001,8 @@ void CSoundFile::SaveExtendedSongProperties(FILE* f) //-------------------------------------------------- -{ //Extra song data - Yet Another Hack. +{ + //Extra song data - Yet Another Hack. __int16 size; __int32 code = 'MPTS'; //Extra song file data fwrite(&code, 1, sizeof(__int32), f); Modified: trunk/OpenMPT/soundlib/Load_mo3.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mo3.cpp 2011-08-22 18:21:40 UTC (rev 993) +++ trunk/OpenMPT/soundlib/Load_mo3.cpp 2011-08-22 19:33:24 UTC (rev 994) @@ -22,7 +22,7 @@ bool CSoundFile::ReadMO3(LPCBYTE lpStream, const DWORD dwMemLength) -//----------------------------------------------------------- +//----------------------------------------------------------------- { // no valid MO3 file (magic bytes: "MO3") if(dwMemLength < 4 || lpStream[0] != 'M' || lpStream[1] != 'O' || lpStream[2] != '3') @@ -60,7 +60,7 @@ if(m_pModDoc != nullptr) m_pModDoc->AddToLog(GetStrI18N(_TEXT("Loading MO3 file failed because unmo3.dll could not be loaded."))); #endif // MODPLUG_TRACKER } - else //case: dll loaded succesfully. + else // case: dll loaded succesfully. { UNMO3_DECODE UNMO3_Decode = (UNMO3_DECODE)GetProcAddress(unmo3, "UNMO3_Decode"); UNMO3_FREE UNMO3_Free = (UNMO3_FREE)GetProcAddress(unmo3, "UNMO3_Free"); @@ -76,12 +76,12 @@ { bResult = true; if ((!ReadXM((const BYTE *)*mo3Stream, (DWORD)iLen)) - && (!ReadIT((const BYTE *)*mo3Stream, (DWORD)iLen)) - && (!ReadS3M((const BYTE *)*mo3Stream, (DWORD)iLen)) - #ifndef FASTSOUNDLIB - && (!ReadMTM((const BYTE *)*mo3Stream, (DWORD)iLen)) - #endif // FASTSOUNDLIB - && (!ReadMod((const BYTE *)*mo3Stream, (DWORD)iLen))) bResult = false; + && (!ReadIT((const BYTE *)*mo3Stream, (DWORD)iLen)) + && (!ReadS3M((const BYTE *)*mo3Stream, (DWORD)iLen)) +#ifndef FASTSOUNDLIB + && (!ReadMTM((const BYTE *)*mo3Stream, (DWORD)iLen)) +#endif // FASTSOUNDLIB + && (!ReadMod((const BYTE *)*mo3Stream, (DWORD)iLen))) bResult = false; } UNMO3_Free(*mo3Stream); Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-08-22 18:21:40 UTC (rev 993) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-08-22 19:33:24 UTC (rev 994) @@ -1218,7 +1218,7 @@ IMixPlugin *pPlugin = NULL; if (pChn->pModInstrument && pChn->pModInstrument->nMidiChannel > 0 && pChn->pModInstrument->nMidiChannel < 17 && pChn->nNote>0 && pChn->nNote<128) // instro sends to a midi chan { - UINT nPlugin = GetBestPlugin(nChn, PRIORITISE_INSTRUMENT, RESPECT_MUTES); + PLUGINDEX nPlugin = GetBestPlugin(nChn, PRIORITISE_INSTRUMENT, RESPECT_MUTES); /* UINT nPlugin = 0; nPlugin = pChn->pModInstrument->nMixPlug; // first try intrument VST @@ -1609,12 +1609,8 @@ { pChn->dwFlags |= CHN_FASTVOLRAMP; ResetChannelEnvelopes(pChn); - // IT Compatibility: Autovibrato reset - if(!IsCompatibleMode(TRK_IMPULSETRACKER)) - { - pChn->nAutoVibDepth = 0; - pChn->nAutoVibPos = 0; - } + pChn->nAutoVibDepth = 0; + pChn->nAutoVibPos = 0; } } // Tick-0 only volume commands @@ -3076,7 +3072,7 @@ size_t outPos = 0; // output buffer position, which also equals the number of complete bytes bool firstNibble = true; - for(size_t pos = 0; pos < MACRO_LENGTH && macro[pos]; pos++) + for(size_t pos = 0; pos < (MACRO_LENGTH - 1) && macro[pos]; pos++) { bool isNibble = false; // did we parse a nibble or a byte value? unsigned char data = 0; // data that has just been parsed @@ -3247,12 +3243,12 @@ if(ticksLeft > 1) { // Slide param - const float step = ((float)param - currentValue) / (float)ticksLeft; + const float step = (param - currentValue) / (float)ticksLeft; return (currentValue + step); } else { // On last tick, set exact value. - return (float)param; + return param; } } @@ -3601,7 +3597,8 @@ } // IT compatibility: Really weird combination of envelopes and retrigger (see Storlek's q.it testcase) NoteChange(nChn, nNote, IsCompatibleMode(TRK_IMPULSETRACKER) ? true : false, bResetEnv); - if (m_nInstruments) { + if (m_nInstruments) + { ProcessMidiOut(nChn, pChn); //Send retrig to Midi } if ((m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT)) && (!pChn->nRowNote) && (nOldPeriod)) pChn->nPeriod = nOldPeriod; @@ -4065,17 +4062,18 @@ } -UINT CSoundFile::GetBestPlugin(CHANNELINDEX nChn, UINT priority, bool respectMutes) -//--------------------------------------------------------------------------------- +PLUGINDEX CSoundFile::GetBestPlugin(CHANNELINDEX nChn, UINT priority, bool respectMutes) +//-------------------------------------------------------------------------------------- { - if (nChn > MAX_CHANNELS) //Check valid channel number + if (nChn >= MAX_CHANNELS) //Check valid channel number { return 0; } //Define search source order - UINT nPlugin=0; - switch (priority) { + PLUGINDEX nPlugin = 0; + switch (priority) + { case CHANNEL_ONLY: nPlugin = GetChannelPlugin(nChn, respectMutes); break; @@ -4084,13 +4082,15 @@ break; case PRIORITISE_INSTRUMENT: nPlugin = GetActiveInstrumentPlugin(nChn, respectMutes); - if ((!nPlugin) || (nPlugin>MAX_MIXPLUGINS)) { + if ((!nPlugin) || (nPlugin>MAX_MIXPLUGINS)) + { nPlugin = GetChannelPlugin(nChn, respectMutes); } break; case PRIORITISE_CHANNEL: nPlugin = GetChannelPlugin(nChn, respectMutes); - if ((!nPlugin) || (nPlugin>MAX_MIXPLUGINS)) { + if ((!nPlugin) || (nPlugin>MAX_MIXPLUGINS)) + { nPlugin = GetActiveInstrumentPlugin(nChn, respectMutes); } break; @@ -4100,8 +4100,8 @@ } -UINT __cdecl CSoundFile::GetChannelPlugin(CHANNELINDEX nChn, bool respectMutes) const -//----------------------------------------------------------------------------------- +PLUGINDEX __cdecl CSoundFile::GetChannelPlugin(CHANNELINDEX nChn, bool respectMutes) const +//---------------------------------------------------------------------------------------- { const MODCHANNEL *pChn = &Chn[nChn]; @@ -4110,7 +4110,7 @@ // NB: nMasterChn==0 means no master channel, so we need to -1 to get correct index. if (nChn>=m_nChannels && pChn && pChn->nMasterChn > 0) { - nChn = pChn->nMasterChn-1; + nChn = pChn->nMasterChn - 1; } UINT nPlugin; @@ -4125,8 +4125,8 @@ } -UINT CSoundFile::GetActiveInstrumentPlugin(CHANNELINDEX nChn, bool respectMutes) const -//------------------------------------------------------------------------------------ +PLUGINDEX CSoundFile::GetActiveInstrumentPlugin(CHANNELINDEX nChn, bool respectMutes) const +//----------------------------------------------------------------------------------------- { const MODCHANNEL *pChn = &Chn[nChn]; // Unlike channel settings, pModInstrument is copied from the original chan to the NNA chan, @@ -4176,7 +4176,7 @@ } // Channel mutes - for (CHANNELINDEX chan=0; chan<m_nChannels; chan++) + for (CHANNELINDEX chan = 0; chan < GetNumChannels(); chan++) { if (m_bChannelMuteTogglePending[chan]) { Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2011-08-22 18:21:40 UTC (rev 993) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2011-08-22 19:33:24 UTC (rev 994) @@ -494,7 +494,6 @@ MemsetZero(Instruments); MemsetZero(m_szNames); MemsetZero(m_MixPlugins); - MemsetZero(m_SongEQ); Order.Init(); Patterns.ClearPatterns(); m_lTotalSampleCount=0; @@ -555,7 +554,6 @@ MemsetZero(Instruments); MemsetZero(m_szNames); MemsetZero(m_MixPlugins); - MemsetZero(m_SongEQ); //Order.assign(MAX_ORDERS, Order.GetInvalidPatIndex()); Order.resize(1); Patterns.ClearPatterns(); Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2011-08-22 18:21:40 UTC (rev 993) +++ trunk/OpenMPT/soundlib/Sndfile.h 2011-08-22 19:33:24 UTC (rev 994) @@ -402,12 +402,6 @@ class CModDoc; typedef BOOL (__cdecl *PMIXPLUGINCREATEPROC)(PSNDMIXPLUGIN, CSoundFile*); -struct SNDMIXSONGEQ -{ - ULONG nEQBands; - ULONG EQFreq_Gains[MAX_EQ_BANDS]; -}; -typedef SNDMIXSONGEQ* PSNDMIXSONGEQ; //////////////////////////////////////////////////////////////////////// // Reverberation @@ -645,7 +639,7 @@ ROWINDEX m_nCurrentRowsPerBeat, m_nCurrentRowsPerMeasure; // current rows per beat and measure for this module BYTE m_nTempoMode; // rewbs.betterBPM BYTE m_nMixLevels; - UINT m_nMusicSpeed, m_nMusicTempo; + UINT m_nMusicSpeed, m_nMusicTempo; // Current speed and tempo ROWINDEX m_nNextRow, m_nRow; ROWINDEX m_nNextPatStartRow; // for FT2's E60 bug PATTERNINDEX m_nPattern; @@ -672,7 +666,6 @@ CHAR m_szNames[MAX_SAMPLES][MAX_SAMPLENAME]; // Song and sample names MODMIDICFG m_MidiCfg; // Midi macro config table SNDMIXPLUGIN m_MixPlugins[MAX_MIXPLUGINS]; // Mix plugins - SNDMIXSONGEQ m_SongEQ; // Default song EQ preset CHAR CompressionTable[16]; // ADPCM compression LUT bool m_bChannelMuteTogglePending[MAX_BASECHANNELS]; @@ -695,11 +688,11 @@ BOOL Create(LPCBYTE lpStream, CModDoc *pModDoc, DWORD dwMemLength=0); BOOL Destroy(); MODTYPE GetType() const { return m_nType; } - inline bool TypeIsIT_MPT() const { return (m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT)) != 0; } - inline bool TypeIsIT_MPT_XM() const { return (m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_XM)) != 0; } - inline bool TypeIsS3M_IT_MPT() const { return (m_nType & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT)) != 0; } - inline bool TypeIsXM_MOD() const { return (m_nType & (MOD_TYPE_XM | MOD_TYPE_MOD)) != 0; } - inline bool TypeIsMOD_S3M() const { return (m_nType & (MOD_TYPE_MOD | MOD_TYPE_S3M)) != 0; } + bool TypeIsIT_MPT() const { return (m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT)) != 0; } + 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; } + bool TypeIsXM_MOD() const { return (m_nType & (MOD_TYPE_XM | MOD_TYPE_MOD)) != 0; } + bool TypeIsMOD_S3M() const { return (m_nType & (MOD_TYPE_MOD | MOD_TYPE_S3M)) != 0; } CModDoc* GetpModDoc() const { return m_pModDoc; } void SetMasterVolume(UINT vol, bool adjustAGC = false); @@ -951,6 +944,7 @@ void ProcessMIDIMacro(CHANNELINDEX nChn, bool isSmooth, char *macro, uint8 param = 0, PLUGINDEX plugin = 0); float CalculateSmoothParamChange(float currentValue, float param) const; size_t SendMIDIData(CHANNELINDEX nChn, bool isSmooth, const unsigned char *macro, size_t macroLen, PLUGINDEX plugin); + void SetupChannelFilter(MODCHANNEL *pChn, bool bReset, int flt_modifier = 256) const; // Low-Level effect processing void DoFreqSlide(MODCHANNEL *pChn, LONG nFreqSlide); @@ -1030,9 +1024,9 @@ DWORD CutOffToFrequency(UINT nCutOff, int flt_modifier=256) const; // [0-255] => [1-10KHz] #endif #ifdef MODPLUG_TRACKER - VOID ProcessMidiOut(CHANNELINDEX nChn, MODCHANNEL *pChn); //rewbs.VSTdelay : added arg. + void ProcessMidiOut(CHANNELINDEX nChn, MODCHANNEL *pChn); //rewbs.VSTdelay : added arg. #endif - VOID ApplyGlobalVolume(int SoundBuffer[], long lTotalSampleCount); + void ApplyGlobalVolume(int SoundBuffer[], long lTotalSampleCount); // Static helper functions public: @@ -1086,8 +1080,8 @@ void ResetChannelEnvelope(MODCHANNEL_ENVINFO &env); void SetDefaultInstrumentValues(MODINSTRUMENT *pIns); private: - UINT __cdecl GetChannelPlugin(CHANNELINDEX nChn, bool respectMutes) const; - UINT __cdecl GetActiveInstrumentPlugin(CHANNELINDEX, bool respectMutes) const; + PLUGINDEX __cdecl GetChannelPlugin(CHANNELINDEX nChn, bool respectMutes) const; + PLUGINDEX __cdecl GetActiveInstrumentPlugin(CHANNELINDEX, bool respectMutes) const; UINT GetBestMidiChan(const MODCHANNEL *pChn) const; void HandlePatternTransitionEvents(); @@ -1095,7 +1089,7 @@ long GetSampleOffset(); public: - UINT GetBestPlugin(CHANNELINDEX nChn, UINT priority, bool respectMutes); + PLUGINDEX GetBestPlugin(CHANNELINDEX nChn, UINT priority, bool respectMutes); // A couple of functions for handling backwards jumps and stuff to prevent infinite loops when counting the mod length or rendering to wav. public: @@ -1108,7 +1102,7 @@ public: // "importance" of every FX command. Table is used for importing from formats with multiple effect columns // and is approximately the same as in SchismTracker. - static uint16 CSoundFile::GetEffectWeight(MODCOMMAND::COMMAND cmd); + static size_t CSoundFile::GetEffectWeight(MODCOMMAND::COMMAND cmd); // try to convert a an effect into a volume column effect. static bool ConvertVolEffect(uint8 *e, uint8 *p, bool bForce); }; Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2011-08-22 18:21:40 UTC (rev 993) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2011-08-22 19:33:24 UTC (rev 994) @@ -2356,7 +2356,7 @@ #ifdef MODPLUG_TRACKER -VOID CSoundFile::ProcessMidiOut(CHANNELINDEX nChn, MODCHANNEL *pChn) //rewbs.VSTdelay: added arg +void CSoundFile::ProcessMidiOut(CHANNELINDEX nChn, MODCHANNEL *pChn) //rewbs.VSTdelay: added arg //------------------------------------------------------------------ { // Do we need to process midi? @@ -2465,6 +2465,7 @@ } } + int CSoundFile::GetVolEnvValueFromPosition(int position, const MODINSTRUMENT* pIns) const //--------------------------------------------------------------------------------------- { @@ -2513,7 +2514,7 @@ #endif -VOID CSoundFile::ApplyGlobalVolume(int SoundBuffer[], long lTotalSampleCount) +void CSoundFile::ApplyGlobalVolume(int SoundBuffer[], long lTotalSampleCount) //--------------------------------------------------------------------------- { long delta=0; Modified: trunk/OpenMPT/soundlib/modcommand.cpp =================================================================== --- trunk/OpenMPT/soundlib/modcommand.cpp 2011-08-22 18:21:40 UTC (rev 993) +++ trunk/OpenMPT/soundlib/modcommand.cpp 2011-08-22 19:33:24 UTC (rev 994) @@ -646,50 +646,61 @@ // "importance" of every FX command. Table is used for importing from formats with multiple effect colums // and is approximately the same as in SchismTracker. -uint16 CSoundFile::GetEffectWeight(MODCOMMAND::COMMAND cmd) +size_t CSoundFile::GetEffectWeight(MODCOMMAND::COMMAND cmd) //--------------------------------------------------------- { - switch(cmd) + // Effect weights, sorted from lowest to highest weight. + static const MODCOMMAND::COMMAND weights[] = { - case CMD_PATTERNBREAK: return 288; - case CMD_POSITIONJUMP: return 280; - case CMD_SPEED: return 272; - case CMD_TEMPO: return 264; - case CMD_GLOBALVOLUME: return 256; - case CMD_GLOBALVOLSLIDE: return 248; - case CMD_CHANNELVOLUME: return 240; - case CMD_CHANNELVOLSLIDE: return 232; - case CMD_TONEPORTAVOL: return 224; - case CMD_TONEPORTAMENTO: return 216; - case CMD_ARPEGGIO: return 208; - case CMD_RETRIG: return 200; - case CMD_TREMOR: return 192; - case CMD_OFFSET: return 184; - case CMD_VOLUME: return 176; - case CMD_VIBRATOVOL: return 168; - case CMD_VOLUMESLIDE: return 160; - case CMD_PORTAMENTODOWN: return 152; - case CMD_PORTAMENTOUP: return 133; - case CMD_NOTESLIDEDOWN: return 136; - case CMD_NOTESLIDEUP: return 128; - case CMD_PANNING8: return 120; - case CMD_PANNINGSLIDE: return 112; - case CMD_SMOOTHMIDI: return 104; - case CMD_MIDI: return 96; - case CMD_DELAYCUT: return 88; - case CMD_MODCMDEX: return 80; - case CMD_S3MCMDEX: return 72; - case CMD_PANBRELLO: return 64; - case CMD_XFINEPORTAUPDOWN: return 56; - case CMD_VIBRATO: return 48; - case CMD_FINEVIBRATO: return 40; - case CMD_TREMOLO: return 32; - case CMD_KEYOFF: return 24; - case CMD_SETENVPOSITION: return 16; - case CMD_XPARAM: return 8; - case CMD_NONE: - default: return 0; + CMD_NONE, + CMD_XPARAM, + CMD_SETENVPOSITION, + CMD_KEYOFF, + CMD_TREMOLO, + CMD_FINEVIBRATO, + CMD_VIBRATO, + CMD_XFINEPORTAUPDOWN, + CMD_PANBRELLO, + CMD_S3MCMDEX, + CMD_MODCMDEX, + CMD_DELAYCUT, + CMD_MIDI, + CMD_SMOOTHMIDI, + CMD_PANNINGSLIDE, + CMD_PANNING8, + CMD_NOTESLIDEUP, + CMD_NOTESLIDEDOWN, + CMD_PORTAMENTOUP, + CMD_PORTAMENTODOWN, + CMD_VOLUMESLIDE, + CMD_VIBRATOVOL, + CMD_VOLUME, + CMD_OFFSET, + CMD_TREMOR, + CMD_RETRIG, + CMD_ARPEGGIO, + CMD_TONEPORTAMENTO, + CMD_TONEPORTAVOL, + CMD_GLOBALVOLSLIDE, + CMD_CHANNELVOLUME, + CMD_GLOBALVOLSLIDE, + CMD_GLOBALVOLUME, + CMD_TEMPO, + CMD_SPEED, + CMD_POSITIONJUMP, + CMD_PATTERNBREAK, + }; + STATIC_ASSERT(CountOf(weights) == MAX_EFFECTS); + + for(size_t i = 0; i < CountOf(weights); i++) + { + if(weights[i] == cmd) + { + return i; + } } + // Invalid / unknown command. + return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-08-24 16:43:09
|
Revision: 998 http://modplug.svn.sourceforge.net/modplug/?rev=998&view=rev Author: saga-games Date: 2011-08-24 16:43:02 +0000 (Wed, 24 Aug 2011) Log Message: ----------- [Fix] Plugins using JUCE (f.e. TAL-NoiseMaker) don't crash during WAV export anymore. [Mod] Note Properties: Renamed "frames" to "ticks" (like in the rest of the program) Modified Paths: -------------- trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/soundlib/Sndfile.cpp Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2011-08-24 15:33:32 UTC (rev 997) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2011-08-24 16:43:02 UTC (rev 998) @@ -2693,7 +2693,7 @@ break; case CMD_SPEED: - wsprintf(s, "%d frames/row", param); + wsprintf(s, "%d ticks/row", param); break; case CMD_TEMPO: @@ -2944,7 +2944,7 @@ break; case 0x60: // fine pattern delay (ticks) - strcat(s, " rows"); + strcat(s, " ticks"); break; case 0xA0: // high offset @@ -2961,9 +2961,9 @@ case 0xD0: // note delay //IT compatibility 22. SD0 == SD1, SC0 == SC1 if(((param & 0x0F) == 1) || ((param & 0x0F) == 0 && m_SndFile.IsCompatibleMode(TRK_IMPULSETRACKER))) - strcpy(s, "1 frame"); + strcpy(s, "1 tick"); else - strcat(s, " frames"); + strcat(s, " ticks"); break; case 0xE0: // pattern delay (rows) strcat(s, " rows"); @@ -3019,7 +3019,7 @@ break; case 0xC0: // note cut case 0xD0: // note delay - strcat(s, " frames"); + strcat(s, " ticks"); break; case 0xE0: // pattern delay (rows) strcat(s, " rows"); Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2011-08-24 15:33:32 UTC (rev 997) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2011-08-24 16:43:02 UTC (rev 998) @@ -319,7 +319,8 @@ if (m_pVstHead) m_pVstHead->pPrev = p; m_pVstHead = p; - try { + try + { AEffect *pEffect = pMainProc(MasterCallBack); if ((pEffect) && (pEffect->magic == kEffectMagic) && (pEffect->dispatcher)) @@ -350,7 +351,8 @@ bOk = TRUE; } - } catch(...) { + } catch(...) + { CVstPluginManager::ReportPlugException("Exception while trying to load plugin \"%s\"!\n", p->szLibraryName); } @@ -1741,7 +1743,8 @@ { long lresult = 0; - try { + try + { if ((m_pEffect) && (m_pEffect->dispatcher)) { #ifdef VST_LOG @@ -1749,7 +1752,8 @@ #endif lresult = m_pEffect->dispatcher(m_pEffect, opCode, index, value, ptr, opt); } - } catch (...) { + } catch (...) + { CVstPluginManager::ReportPlugException("Exception in Dispatch(%d) (Plugin=\"%s\")!\n", opCode, m_pFactory->szLibraryName); } @@ -1797,9 +1801,11 @@ FLOAT fResult = 0; if ((m_pEffect) && (nIndex < m_pEffect->numParams) && (m_pEffect->getParameter)) { - try { + try + { fResult = m_pEffect->getParameter(m_pEffect, nIndex); - } catch (...) { + } catch (...) + { //CVstPluginManager::ReportPlugException("Exception in getParameter (Plugin=\"%s\")!\n", m_pFactory->szLibraryName); } } @@ -1817,13 +1823,15 @@ VOID CVstPlugin::SetParameter(PlugParamIndex nIndex, PlugParamValue fValue) //------------------------------------------------------------------------- { - try { + try + { if ((m_pEffect) && (nIndex < m_pEffect->numParams) && (m_pEffect->setParameter)) { if ((fValue >= 0.0f) && (fValue <= 1.0f)) m_pEffect->setParameter(m_pEffect, nIndex, fValue); } - } catch (...) { + } catch (...) + { CVstPluginManager::ReportPlugException("Exception in SetParameter(%d, 0.%03d) (Plugin=%s)\n", nIndex, (int)(fValue*1000), m_pFactory->szLibraryName); } } @@ -1890,7 +1898,8 @@ { const DWORD sampleRate = CSoundFile::gdwMixingFreq; - try { + try + { //reset some stuf m_MixState.nVolDecayL = 0; m_MixState.nVolDecayR = 0; @@ -1905,7 +1914,8 @@ Dispatch(effMainsChanged, 0, 1, NULL, 0.0f); // calls plugin's resume Dispatch(effStartProcess, 0, 0, NULL, 0.0f); m_bPlugResumed = true; - } catch (...) { + } catch (...) + { CVstPluginManager::ReportPlugException("Exception in Resume() (Plugin=%s)\n", m_pFactory->szLibraryName); } @@ -1915,11 +1925,16 @@ void CVstPlugin::Suspend() //------------------------ { - try { - Dispatch(effStopProcess, 0, 0, NULL, 0.0f); - Dispatch(effMainsChanged, 0, 0, NULL, 0.0f); // calls plugin's suspend - m_bPlugResumed=false; - } catch (...) { + try + { + if(m_bPlugResumed) + { + Dispatch(effStopProcess, 0, 0, NULL, 0.0f); + Dispatch(effMainsChanged, 0, 0, NULL, 0.0f); // calls plugin's suspend + m_bPlugResumed = false; + } + } catch (...) + { CVstPluginManager::ReportPlugException("Exception in Suspend() (Plugin=%s)\n", m_pFactory->szLibraryName); } } @@ -1931,11 +1946,17 @@ // Process VST events if ((m_pEffect) && (m_pEffect->dispatcher) && (m_pEvList) && (m_pEvList->numEvents > 0)) { - try { + try + { m_pEffect->dispatcher(m_pEffect, effProcessEvents, 0, 0, m_pEvList, 0); - } catch (...) { - CVstPluginManager::ReportPlugException("Exception in ProcessVSTEvents() (Plugin=%s, pEventList:%p, numEvents:%d, MidicodeCh:%d, MidicodeEv:%d, MidicodeNote:%d, MidiCodeVel:%d)\n", m_pFactory->szLibraryName, m_pEvList, m_pEvList->numEvents, -(((VstMidiEvent *)(m_pEvList->events[0]))->midiData[0])&0x0f, (((VstMidiEvent *)(m_pEvList->events[0]))->midiData[0])&0xf0, (((VstMidiEvent *)(m_pEvList->events[0]))->midiData[1])&0xff, (((VstMidiEvent *)(m_pEvList->events[0]))->midiData[2])&0xff); + } catch (...) + { + CVstPluginManager::ReportPlugException("Exception in ProcessVSTEvents() (Plugin=%s, pEventList:%p, numEvents:%d, MidicodeCh:%d, MidicodeEv:%d, MidicodeNote:%d, MidiCodeVel:%d)\n", + m_pFactory->szLibraryName, m_pEvList, m_pEvList->numEvents, + (((VstMidiEvent *)(m_pEvList->events[0]))->midiData[0])&0x0f, + (((VstMidiEvent *)(m_pEvList->events[0]))->midiData[0])&0xf0, + (((VstMidiEvent *)(m_pEvList->events[0]))->midiData[1])&0xff, + (((VstMidiEvent *)(m_pEvList->events[0]))->midiData[2])&0xff); } } @@ -1945,7 +1966,8 @@ //------------------------------- { // Clear VST events - if ((m_pEvList) && (m_pEvList->numEvents > 0)) { + if ((m_pEvList) && (m_pEvList->numEvents > 0)) + { m_pEvList->numEvents = 0; } } @@ -1956,7 +1978,8 @@ float gain = 0.1f * (float)( m_pMixStruct ? (m_pMixStruct->Info.dwInputRouting>>16) & 0xff : 10 ); if(gain < 0.1f) gain = 1.0f; - if (m_bIsInstrument && m_pSndFile) { + if (m_bIsInstrument && m_pSndFile) + { gain /= m_pSndFile->m_pConfig->getVSTiAttenuation(); gain = static_cast<float>(gain * (m_pSndFile->m_nVSTiVolume / m_pSndFile->m_pConfig->getNormalVSTiVol())); } @@ -2035,7 +2058,8 @@ if ((m_pEffect) && (m_pProcessFP) && (m_pInputs) && (m_pOutputs) && (m_pMixStruct)) { int mixop; - if (m_bIsInstrument) { + if (m_bIsInstrument) + { mixop = 0; //force normal mix mode for instruments } else { mixop = m_pMixStruct ? (m_pMixStruct->Info.dwInputRouting>>8) & 0xff : 0; @@ -2046,23 +2070,26 @@ //Merge stereo input before sending to the plug if the plug can only handle one input. if (m_pEffect->numInputs == 1) { - for (UINT i=0; i<nSamples; i++) { + for (UINT i=0; i<nSamples; i++) + { m_MixState.pOutBufferL[i] = 0.5f*m_MixState.pOutBufferL[i] + 0.5f*m_MixState.pOutBufferR[i]; } } for (UINT iOut=0; iOut<m_nOutputs; iOut++) { - memset(m_pTempBuffer[iOut], 0, nSamples*sizeof(float)); + memset(m_pTempBuffer[iOut], 0, nSamples * sizeof(float)); m_pOutputs[iOut] = m_pTempBuffer[iOut]; } m_dwTimeAtStartOfProcess = timeGetTime(); //Do the VST processing magic - try { - ASSERT(nSamples<=MIXBUFFERSIZE); + try + { + ASSERT(nSamples <= MIXBUFFERSIZE); m_pProcessFP(m_pEffect, m_pInputs, m_pOutputs, nSamples); - } catch (...) { + } catch (...) + { m_pMixStruct->Info.dwInputRouting |= MIXPLUG_INPUTF_BYPASS; CString processMethod = (m_pEffect->flags & effFlagsCanReplacing) ? "processReplacing" : "process"; CVstPluginManager::ReportPlugException("The plugin %s threw an exception in %s. It has automatically been set to \"Bypass\".", m_pMixStruct->Info.szName, processMethod); @@ -2071,22 +2098,26 @@ } //mix outputs of multi-output VSTs: - if(m_nOutputs>2){ + if(m_nOutputs>2) + { // first, mix extra outputs on a stereo basis UINT nOuts = m_nOutputs; // so if nOuts is not even, let process the last output later if((nOuts % 2) == 1) nOuts--; // mix extra stereo outputs - for(UINT iOut=2; iOut<nOuts; iOut++){ - for(UINT i=0; i<nSamples; i++) - m_pTempBuffer[iOut%2][i] += m_pTempBuffer[iOut][i]; //assumed stereo. + for(UINT iOut = 2; iOut < nOuts; iOut++) + { + for(UINT i = 0; i < nSamples; i++) + m_pTempBuffer[iOut % 2][i] += m_pTempBuffer[iOut][i]; //assumed stereo. } // if m_nOutputs is odd, mix half the signal of last output to each channel - if(nOuts != m_nOutputs){ - // trick : if we are here, nOuts = m_nOutputs-1 !!! - for(UINT i=0; i<nSamples; i++){ + if(nOuts != m_nOutputs) + { + // trick : if we are here, nOuts = m_nOutputs - 1 !!! + for(UINT i=0; i<nSamples; i++) + { float v = 0.5f * m_pTempBuffer[nOuts][i]; m_pTempBuffer[0][i] += v; m_pTempBuffer[1][i] += v; @@ -2097,7 +2128,7 @@ // If there was just the one plugin output we copy it into our 2 outputs if(m_pEffect->numOutputs == 1) { - wetRatio = 1-m_pMixStruct->fDryRatio; //rewbs.dryRatio + wetRatio = 1 - m_pMixStruct->fDryRatio; //rewbs.dryRatio dryRatio = m_bIsInstrument ? 1 : m_pMixStruct->fDryRatio; //always mix full dry if this is an instrument // -> CODE#0028 @@ -2119,7 +2150,8 @@ } */ // Wet/Dry range expansion [0,1] -> [-1,1] update#02 - if(m_pEffect->numInputs > 0 && m_pMixStruct->Info.dwInputRouting & MIXPLUG_INPUTF_MIXEXPAND){ + if(m_pEffect->numInputs > 0 && m_pMixStruct->Info.dwInputRouting & MIXPLUG_INPUTF_MIXEXPAND) + { wetRatio = 2.0f * wetRatio - 1.0f; dryRatio = -wetRatio; } @@ -2128,11 +2160,13 @@ dryRatio *= m_fGain; // update#02 // Mix operation - switch(mixop){ + switch(mixop) + { // Default mix (update#02) case 0: - for(UINT i=0; i<nSamples; i++){ + for(UINT i = 0; i < nSamples; i++) + { //rewbs.wetratio - added the factors. [20040123] pOutL[i] += m_pTempBuffer[0][i]*wetRatio + m_MixState.pOutBufferL[i]*dryRatio; pOutR[i] += m_pTempBuffer[0][i]*wetRatio + m_MixState.pOutBufferR[i]*dryRatio; @@ -2141,7 +2175,8 @@ // Wet subtract case 1: - for(UINT i=0; i<nSamples; i++){ + for(UINT i = 0; i < nSamples; i++) + { pOutL[i] += m_MixState.pOutBufferL[i] - m_pTempBuffer[0][i]*wetRatio; pOutR[i] += m_MixState.pOutBufferR[i] - m_pTempBuffer[0][i]*wetRatio; } @@ -2149,7 +2184,8 @@ // Dry subtract case 2: - for(UINT i=0; i<nSamples; i++){ + for(UINT i = 0; i < nSamples; i++) + { pOutL[i] += m_pTempBuffer[0][i] - m_MixState.pOutBufferL[i]*dryRatio; pOutR[i] += m_pTempBuffer[0][i] - m_MixState.pOutBufferR[i]*dryRatio; } @@ -2157,7 +2193,8 @@ // Mix subtract case 3: - for(UINT i=0; i<nSamples; i++){ + for(UINT i = 0; i < nSamples; i++) + { pOutL[i] -= m_pTempBuffer[0][i] - m_MixState.pOutBufferL[i]*wetRatio; pOutR[i] -= m_pTempBuffer[0][i] - m_MixState.pOutBufferR[i]*wetRatio; } @@ -2165,7 +2202,8 @@ // Middle subtract case 4: - for(UINT i=0; i<nSamples; i++){ + for(UINT i = 0; i < nSamples; i++) + { float middle = ( pOutL[i] + m_MixState.pOutBufferL[i] + pOutR[i] + m_MixState.pOutBufferR[i] )/2.0f; pOutL[i] -= middle - m_pTempBuffer[0][i]*wetRatio + middle - m_MixState.pOutBufferL[i]; pOutR[i] -= middle - m_pTempBuffer[0][i]*wetRatio + middle - m_MixState.pOutBufferR[i]; @@ -2174,11 +2212,13 @@ // Left/Right balance case 5: - if(m_pMixStruct->Info.dwInputRouting & MIXPLUG_INPUTF_MIXEXPAND){ + if(m_pMixStruct->Info.dwInputRouting & MIXPLUG_INPUTF_MIXEXPAND) + { wetRatio /= 2.0f; dryRatio /= 2.0f; } - for(UINT i=0; i<nSamples; i++){ + for(UINT i = 0; i < nSamples; i++) + { pOutL[i] += wetRatio * (m_pTempBuffer[0][i] - m_MixState.pOutBufferL[i]) + dryRatio * (m_MixState.pOutBufferR[i] - m_pTempBuffer[0][i]); pOutR[i] += dryRatio * (m_pTempBuffer[0][i] - m_MixState.pOutBufferL[i]) + wetRatio * (m_MixState.pOutBufferR[i] - m_pTempBuffer[0][i]); } @@ -2187,8 +2227,10 @@ //If dry mix is ticked we add the unprocessed buffer, //except if this is an instrument since this it has already been done: - if((m_pMixStruct->Info.dwInputRouting & MIXPLUG_INPUTF_WETMIX) && !m_bIsInstrument){ - for (UINT i=0; i<nSamples; i++){ + if((m_pMixStruct->Info.dwInputRouting & MIXPLUG_INPUTF_WETMIX) && !m_bIsInstrument) + { + for (UINT i=0; i<nSamples; i++) + { pOutL[i] += m_MixState.pOutBufferL[i]; pOutR[i] += m_MixState.pOutBufferR[i]; } @@ -2223,7 +2265,8 @@ } */ // Wet/Dry range expansion [0,1] -> [-1,1] update#02 - if(m_pEffect->numInputs > 0 && m_pMixStruct->Info.dwInputRouting & MIXPLUG_INPUTF_MIXEXPAND){ + if(m_pEffect->numInputs > 0 && m_pMixStruct->Info.dwInputRouting & MIXPLUG_INPUTF_MIXEXPAND) + { wetRatio = 2.0f * wetRatio - 1.0f; dryRatio = -wetRatio; } @@ -2236,7 +2279,8 @@ // Default mix (update#02) case 0: - for(UINT i=0; i<nSamples; i++){ + for(UINT i=0; i<nSamples; i++) + { //rewbs.wetratio - added the factors. [20040123] pOutL[i] += m_pTempBuffer[0][i]*wetRatio + m_MixState.pOutBufferL[i]*dryRatio; pOutR[i] += m_pTempBuffer[1][i]*wetRatio + m_MixState.pOutBufferR[i]*dryRatio; @@ -2245,7 +2289,8 @@ // Wet subtract case 1: - for(UINT i=0; i<nSamples; i++){ + for(UINT i=0; i<nSamples; i++) + { pOutL[i] += m_MixState.pOutBufferL[i] - m_pTempBuffer[0][i]*wetRatio; pOutR[i] += m_MixState.pOutBufferR[i] - m_pTempBuffer[1][i]*wetRatio; } @@ -2253,7 +2298,8 @@ // Dry subtract case 2: - for(UINT i=0; i<nSamples; i++){ + for(UINT i=0; i<nSamples; i++) + { pOutL[i] += m_pTempBuffer[0][i] - m_MixState.pOutBufferL[i]*dryRatio; pOutR[i] += m_pTempBuffer[1][i] - m_MixState.pOutBufferR[i]*dryRatio; } @@ -2261,7 +2307,8 @@ // Mix subtract case 3: - for(UINT i=0; i<nSamples; i++){ + for(UINT i=0; i<nSamples; i++) + { pOutL[i] -= m_pTempBuffer[0][i] - m_MixState.pOutBufferL[i]*wetRatio; pOutR[i] -= m_pTempBuffer[1][i] - m_MixState.pOutBufferR[i]*wetRatio; } @@ -2269,7 +2316,8 @@ // Middle subtract case 4: - for(UINT i=0; i<nSamples; i++){ + for(UINT i=0; i<nSamples; i++) + { float middle = ( pOutL[i] + m_MixState.pOutBufferL[i] + pOutR[i] + m_MixState.pOutBufferR[i] )/2.0f; pOutL[i] -= middle - m_pTempBuffer[0][i]*wetRatio + middle - m_MixState.pOutBufferL[i]; pOutR[i] -= middle - m_pTempBuffer[1][i]*wetRatio + middle - m_MixState.pOutBufferR[i]; @@ -2278,11 +2326,13 @@ // Left/Right balance case 5: - if(m_pMixStruct->Info.dwInputRouting & MIXPLUG_INPUTF_MIXEXPAND){ + if(m_pMixStruct->Info.dwInputRouting & MIXPLUG_INPUTF_MIXEXPAND) + { wetRatio /= 2.0f; dryRatio /= 2.0f; } - for(UINT i=0; i<nSamples; i++){ + for(UINT i=0; i<nSamples; i++) + { pOutL[i] += wetRatio * (m_pTempBuffer[0][i] - m_MixState.pOutBufferL[i]) + dryRatio * (m_MixState.pOutBufferR[i] - m_pTempBuffer[1][i]); pOutR[i] += dryRatio * (m_pTempBuffer[0][i] - m_MixState.pOutBufferL[i]) + wetRatio * (m_MixState.pOutBufferR[i] - m_pTempBuffer[1][i]); } @@ -2291,7 +2341,8 @@ //If dry mix is ticked we add the unprocessed buffer, //except if this is an instrument since this it has already been done: - if((m_pMixStruct->Info.dwInputRouting & MIXPLUG_INPUTF_WETMIX) && !m_bIsInstrument){ + if((m_pMixStruct->Info.dwInputRouting & MIXPLUG_INPUTF_WETMIX) && !m_bIsInstrument) + { for (UINT i=0; i<nSamples; i++){ pOutL[i] += m_MixState.pOutBufferL[i]; pOutR[i] += m_MixState.pOutBufferR[i]; @@ -2370,7 +2421,8 @@ //if (IsBypassed()) // return; - do { + do + { overflow=false; for (int mc=0; mc<16; mc++) //all midi chans { @@ -2433,7 +2485,7 @@ } short CVstPlugin::getMIDI14bitValueFromShort(short value) -//--------------------------------------------------------------------------------- +//------------------------------------------------------- { //http://www.srm.com/qtma/davidsmidispec.html: // The two bytes of the pitch bend message form a 14 bit number, 0 to 16383. @@ -2454,7 +2506,7 @@ //Bend midi pitch for given midi channel using tracker param (0x00-0xFF) void CVstPlugin::MidiPitchBend(UINT nMidiCh, int nParam, UINT /*trackChannel*/) -//------------------------------------------------------------------------- +//----------------------------------------------------------------------------- { nMidiCh--; // move from 1-17 range to 0-16 range @@ -2466,8 +2518,9 @@ } //Set midi pitch for given midi channel using uncoverted midi value (0-16383) -void CVstPlugin::MidiPitchBend(UINT nMidiCh, short newPitchBendPos) { -//---------------------------------------------------------------- +void CVstPlugin::MidiPitchBend(UINT nMidiCh, short newPitchBendPos) +//----------------------------------------------------------------- +{ m_nMidiPitchBendPos[nMidiCh] = newPitchBendPos; //store pitch bend position short converted = getMIDI14bitValueFromShort(newPitchBendPos); MidiSend(converted<<8 | MIDI_PitchBend_Command|nMidiCh); @@ -2535,10 +2588,8 @@ dwMidiCode = 0x80|nCh|(vol<<16); //note off, on chan nCh; vol is note off velocity. for (UINT i=0; i<128; i++) //all notes { - //if (!(m_pEffect->uniqueID==1413633619L) || pCh->uNoteOnMap[i][trackChannel]>0) { //only send necessary NOs for TBVS. - pCh->uNoteOnMap[i][trackChannel]=0; - MidiSend(dwMidiCode|(i<<8)); - //} + pCh->uNoteOnMap[i][trackChannel]=0; + MidiSend(dwMidiCode|(i<<8)); } } @@ -2555,9 +2606,12 @@ // But this can cause a VST event overflow if we have many active notes... while (pCh->uNoteOnMap[i][trackChannel]) { - if (MidiSend(dwMidiCode|(i<<8))) { + if (MidiSend(dwMidiCode|(i<<8))) + { pCh->uNoteOnMap[i][trackChannel]--; - } else { //VST event queue overflow, no point in submitting more note offs. + } else + { + // VST event queue overflow, no point in submitting more note offs. break; //todo: secondary buffer? } } @@ -2572,7 +2626,8 @@ note--; //reset pitch bend on each new note, tracker style. - if (m_nMidiPitchBendPos[nCh] != MIDI_PitchBend_Centre) { + if (m_nMidiPitchBendPos[nCh] != MIDI_PitchBend_Centre) + { MidiPitchBend(nCh, MIDI_PitchBend_Centre); } @@ -2620,7 +2675,7 @@ void CVstPlugin::SetZxxParameter(UINT nParam, UINT nValue) //-------------------------------------------------------- { - FLOAT fValue = nValue / 127.0f; + PlugParamValue fValue = (PlugParamValue)nValue / 127.0f; SetParameter(nParam, fValue); } @@ -2628,7 +2683,7 @@ UINT CVstPlugin::GetZxxParameter(UINT nParam) //------------------------------------------- { - return (UINT) (GetParameter(nParam) * 127.0f+0.5f); + return (UINT) (GetParameter(nParam) * 127.0f + 0.5f); } //end rewbs.smoothVST @@ -2649,13 +2704,18 @@ LONG nByteSize = 0; // Try to get whole bank - if (m_pEffect->uniqueID != 1984054788) { //special case: VB ffx4 pretends to get a valid bank but gives us garbage. + if (m_pEffect->uniqueID != CCONST('v', 'B', 'F', '\4')) + { + //special case: VB ffx4 pretends to get a valid bank but gives us garbage. nByteSize = Dispatch(effGetChunk, 0,0, &p, 0); } - if (/*(nByteSize < 8) ||*/ !p) { //If bank is less that 8 bytes, the plug must be kidding. :) (e.g.: imageline sytrus) + if (/*(nByteSize < 8) ||*/ !p) + { + //If bank is less that 8 bytes, the plug must be kidding. :) (e.g.: imageline sytrus) nByteSize = Dispatch(effGetChunk, 1,0, &p, 0); // Getting bank failed, try to get get just preset - } else { + } else + { m_pMixStruct->defaultProgram = GetCurrentProgram(); //we managed to get the bank, now we need to remember which program we're on. } if (/*(nByteSize >= 8) && */(p)) //If program is less that 8 bytes, the plug must be kidding. :) (e.g.: imageline sytrus) @@ -2683,7 +2743,7 @@ } // This plug doesn't support chunks: save parameters UINT nParams = (m_pEffect->numParams > 0) ? m_pEffect->numParams : 0; - UINT nLen = nParams * sizeof(FLOAT); + UINT nLen = nParams * sizeof(float); if (!nLen) return; nLen += 4; if ((m_pMixStruct->pPluginData) && (m_pMixStruct->nPluginDataSize >= nLen)) @@ -2701,7 +2761,7 @@ } if (m_pMixStruct->pPluginData) { - FLOAT *p = (FLOAT *)m_pMixStruct->pPluginData; + float *p = (float *)m_pMixStruct->pPluginData; *(ULONG *)p = 0; p++; for (UINT i=0; i<nParams; i++) @@ -2720,7 +2780,7 @@ if ((m_pEffect) && (m_pMixStruct) && (m_pMixStruct->pPluginData) && (m_pMixStruct->nPluginDataSize >= 4)) { UINT nParams = (m_pEffect->numParams > 0) ? m_pEffect->numParams : 0; - UINT nLen = nParams * sizeof(FLOAT); + UINT nLen = nParams * sizeof(float); ULONG nType = *(ULONG *)m_pMixStruct->pPluginData; if ((Dispatch(effIdentify, 0,0, NULL, 0) == 'NvEf') && (nType == 'NvEf')) @@ -2756,7 +2816,8 @@ { if (!m_pEffect) return; - try { + try + { if ((m_pEditor) && (!m_pEditor->m_hWnd)) { delete m_pEditor; @@ -2779,7 +2840,8 @@ if (m_pEditor) m_pEditor->OpenEditor(CMainFrame::GetMainFrame()); } - } catch (...) { + } catch (...) + { CVstPluginManager::ReportPlugException("Exception in ToggleEditor() (Plugin=%s)\n", m_pFactory->szLibraryName); } } Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2011-08-24 15:33:32 UTC (rev 997) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2011-08-24 16:43:02 UTC (rev 998) @@ -1189,7 +1189,7 @@ continue; //most common branch IMixPlugin *pPlugin = m_MixPlugins[iPlug].pMixPlugin; - if (m_MixPlugins[iPlug].pMixState) + if (m_MixPlugins[iPlug].pMixState && pPlugin->IsResumed()) { pPlugin->NotifySongPlaying(false); pPlugin->HardAllNotesOff(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-08-25 21:11:22
|
Revision: 1000 http://modplug.svn.sourceforge.net/modplug/?rev=1000&view=rev Author: saga-games Date: 2011-08-25 21:11:13 +0000 (Thu, 25 Aug 2011) Log Message: ----------- What a boring commit #1000... :) [Ref] Changed critical section handling to (safer) RAII style. [Mod] Using the same code for getting program names in general tab and VST editor now; Program counting starts at 1 everywhere now (previously, it just started at 1 in the instrument editor) Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/ChannelManagerDlg.cpp trunk/OpenMPT/mptrack/CleanupSong.cpp trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Ctrl_seq.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/EffectVis.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/ModConvert.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/SelectPluginDialog.cpp trunk/OpenMPT/mptrack/View_gen.cpp trunk/OpenMPT/mptrack/View_ins.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/Vstplug.h trunk/OpenMPT/soundlib/modsmp_ctrl.cpp trunk/OpenMPT/soundlib/pattern.cpp Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2011-08-25 15:46:25 UTC (rev 999) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2011-08-25 21:11:13 UTC (rev 1000) @@ -13,25 +13,6 @@ #ifndef NO_VST -static void CreateVerifiedProgramName(const char* rawname, const size_t rnSize, - char* name, const size_t nSize, - const long p) -//----------------------------------------------------------------------------- -{ - if(rawname[0] < 32) - { - wsprintf(name, "%02d - Program %d",p,p); - } - else - { - size_t k=0; - while(k < rnSize-1 && rawname[k] != 0 && rawname[k] <= ' ' && k<255) k++; - wsprintf(name, "%02d - %s", p, &rawname[k]); - } - name[nSize-1] = 0; -} - - BEGIN_MESSAGE_MAP(CAbstractVstEditor, CDialog) ON_WM_CLOSE() ON_WM_INITMENU() @@ -96,8 +77,10 @@ delete m_pMacroMenu; delete m_pOptionsMenu; - for (int i=0; i<m_pPresetMenuGroup.GetSize(); i++) { - if (m_pPresetMenuGroup[i]->m_hMenu) { + for (int i=0; i<m_pPresetMenuGroup.GetSize(); i++) + { + if (m_pPresetMenuGroup[i]->m_hMenu) + { m_pPresetMenuGroup[i]->DestroyMenu(); delete m_pPresetMenuGroup[i]; } @@ -191,21 +174,8 @@ m_pMenu->AppendMenu(MF_BYPOSITION, ID_VSTPRESETFORWARDJUMP, TEXT(">>")); m_pMenu->AppendMenu(MF_BYPOSITION|MF_DISABLED, 0, TEXT("")); } - long index = m_pVstPlugin->GetCurrentProgram(); - char name[266]; - char rawname[256]; - if(!m_pVstPlugin->GetProgramNameIndexed(index, -1, rawname)) - { - // Fallback: Try to get current program name. - if(m_pVstPlugin->Dispatch(effGetProgramName, 0, 0, rawname, 0) != 1) - { - strcpy(rawname, ""); - } - } - StringFixer::SetNullTerminator(rawname); - CreateVerifiedProgramName(rawname, CountOf(rawname), name, CountOf(name), index); - m_pMenu->ModifyMenu(8, MF_BYPOSITION, 0, name); + m_pMenu->ModifyMenu(8, MF_BYPOSITION, 0, m_pVstPlugin->GetFormattedProgramName(m_pVstPlugin->GetCurrentProgram(), true)); } DrawMenuBar(); @@ -229,7 +199,8 @@ void CAbstractVstEditor::OnBypassPlug() //------------------------------------- { - if (m_pVstPlugin) { + if (m_pVstPlugin) + { m_pVstPlugin->Bypass(); } } @@ -237,7 +208,8 @@ void CAbstractVstEditor::OnRecordAutomation() //------------------------------------------- { - if (m_pVstPlugin) { + if (m_pVstPlugin) + { m_pVstPlugin->m_bRecordAutomation = !m_pVstPlugin->m_bRecordAutomation; } } @@ -409,18 +381,17 @@ { long numProgs = m_pVstPlugin->GetNumPrograms(); long curProg = m_pVstPlugin->GetCurrentProgram(); - char s[266]; - char sname[256]; - - if (m_pPresetMenu->m_hMenu) // We rebuild menu from scratch { // So remove any exiting menus... if (curProg == m_nCurProg) //.. unless menu exists and is accurate, return; //in which case we are done. - for (int i=0; i<m_pPresetMenuGroup.GetSize(); i++) { //Destroy any submenus - if (m_pPresetMenuGroup[i]->m_hMenu) { + for (int i=0; i<m_pPresetMenuGroup.GetSize(); i++) + { + //Destroy any submenus + if (m_pPresetMenuGroup[i]->m_hMenu) + { m_pPresetMenuGroup[i]->DestroyMenu(); delete m_pPresetMenuGroup[i]; } @@ -432,49 +403,51 @@ m_pMenu->DeleteMenu(1, MF_BYPOSITION); } - if (!m_pPresetMenu->m_hMenu) { // Create Factory preset menu + if (!m_pPresetMenu->m_hMenu) + { + // Create Factory preset menu m_pPresetMenu->CreatePopupMenu(); } - for (long p=0; p<numProgs; p++) { - if(!m_pVstPlugin->GetProgramNameIndexed(p, -1, sname)) - { - strcpy(sname, ""); - } - StringFixer::SetNullTerminator(sname); + for (long p = 0; p < numProgs; p++) + { + CString programName = m_pVstPlugin->GetFormattedProgramName(p); - CreateVerifiedProgramName(sname, sizeof(sname), s, sizeof(s), p); - // Get menu item properties - bool checkedItem = (p==curProg); - bool splitMenu = (p%PRESETS_PER_COLUMN==0 && p%PRESETS_PER_GROUP!=0); - int subMenuIndex = p/PRESETS_PER_GROUP; + const bool checkedItem = (p == curProg); + const bool splitMenu = (p % PRESETS_PER_COLUMN == 0 && p % PRESETS_PER_GROUP != 0); + const int subMenuIndex = p / PRESETS_PER_GROUP; - if (numProgs>PRESETS_PER_GROUP) { // If necessary, add to appropriate submenu. - if (subMenuIndex >= m_pPresetMenuGroup.GetSize()) { //create new submenu if required. - m_pPresetMenuGroup.SetSize(m_pPresetMenuGroup.GetSize()+1); + if (numProgs > PRESETS_PER_GROUP) + { + // If necessary, add to appropriate submenu. + if (subMenuIndex >= m_pPresetMenuGroup.GetSize()) + { + //create new submenu if required. + m_pPresetMenuGroup.SetSize(m_pPresetMenuGroup.GetSize() + 1); m_pPresetMenuGroup[subMenuIndex] = new CMenu(); m_pPresetMenuGroup[subMenuIndex]->CreatePopupMenu(); CString label; - label.Format("Presets %d-%d", subMenuIndex*PRESETS_PER_GROUP, min((subMenuIndex+1)*PRESETS_PER_GROUP-1, numProgs)); + label.Format("Bank %d (%d-%d)", subMenuIndex, 1 + subMenuIndex * PRESETS_PER_GROUP, 1 + min((subMenuIndex + 1) * PRESETS_PER_GROUP - 1, numProgs)); m_pPresetMenu->AppendMenu(MF_POPUP, (UINT) m_pPresetMenuGroup[subMenuIndex]->m_hMenu, label); } - m_pPresetMenuGroup[subMenuIndex]->AppendMenu(MF_STRING|(checkedItem?MF_CHECKED:0)|(splitMenu?MF_MENUBARBREAK:0), ID_PRESET_SET+p, (LPCTSTR)s); - } - else { // If there would only be 1 submenu, we add directly to factory menu - m_pPresetMenu->AppendMenu(MF_STRING|(checkedItem?MF_CHECKED:0)|(splitMenu?MF_MENUBARBREAK:0), ID_PRESET_SET+p, (LPCTSTR)s); + m_pPresetMenuGroup[subMenuIndex]->AppendMenu(MF_STRING | (checkedItem ? MF_CHECKED : 0) | (splitMenu ? MF_MENUBARBREAK : 0), ID_PRESET_SET + p, programName); + + } else + { + // If there would only be 1 submenu, we add directly to factory menu + m_pPresetMenu->AppendMenu(MF_STRING | (checkedItem ? MF_CHECKED : MF_UNCHECKED) | (splitMenu ? MF_MENUBARBREAK : 0), ID_PRESET_SET + p, programName); } } - for (int i=0; i<m_pPresetMenuGroup.GetSize(); i++) { - } - //Add Factory menu to main menu - if (numProgs) { - m_pMenu->InsertMenu(1, MF_BYPOSITION|MF_POPUP, (UINT) m_pPresetMenu->m_hMenu, (LPCTSTR)"&Presets"); - } else { - m_pMenu->InsertMenu(1, MF_BYPOSITION|MF_POPUP|MF_GRAYED, (UINT) m_pPresetMenu->m_hMenu, (LPCTSTR)"&Presets"); + if (numProgs) + { + m_pMenu->InsertMenu(1, MF_BYPOSITION | MF_POPUP, (UINT) m_pPresetMenu->m_hMenu, (LPCTSTR)"&Presets"); + } else + { + m_pMenu->InsertMenu(1, MF_BYPOSITION | MF_POPUP | MF_GRAYED, (UINT) m_pPresetMenu->m_hMenu, (LPCTSTR)"&Presets"); } m_nCurProg=curProg; Modified: trunk/OpenMPT/mptrack/ChannelManagerDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/ChannelManagerDlg.cpp 2011-08-25 15:46:25 UTC (rev 999) +++ trunk/OpenMPT/mptrack/ChannelManagerDlg.cpp 2011-08-25 21:11:13 UTC (rev 1000) @@ -192,7 +192,7 @@ } BeginWaitCursor(); - BEGIN_CRITICAL(); + CriticalSection cs; //Creating new order-vector for ReArrangeChannels. vector<CHANNELINDEX> newChnOrder; newChnOrder.reserve(nChannels); @@ -202,7 +202,7 @@ } if(pModDoc->ReArrangeChannels(newChnOrder) != nChannels) { - END_CRITICAL(); + cs.Leave(); EndWaitCursor(); MessageBox("Rearranging channels failed"); @@ -232,7 +232,7 @@ } */ - END_CRITICAL(); + cs.Leave(); EndWaitCursor(); ResetState(true, true, true, true, true); Modified: trunk/OpenMPT/mptrack/CleanupSong.cpp =================================================================== --- trunk/OpenMPT/mptrack/CleanupSong.cpp 2011-08-25 15:46:25 UTC (rev 999) +++ trunk/OpenMPT/mptrack/CleanupSong.cpp 2011-08-25 21:11:13 UTC (rev 1000) @@ -400,7 +400,7 @@ } // Remove all completely empty patterns above last used pattern (those are safe to remove) - BEGIN_CRITICAL(); + CriticalSection cs; for (PATTERNINDEX nPat = maxpat; nPat < maxPatIndex; nPat++) if ((pSndFile->Patterns[nPat]) && (nPat >= nMinToRemove)) { if(pSndFile->Patterns.IsPatternEmpty(nPat)) @@ -409,7 +409,7 @@ nPatRemoved++; } } - END_CRITICAL(); + cs.Leave(); // Number of unused patterns size_t nWaste = 0; @@ -466,7 +466,7 @@ pSndFile->Order.SetSequence(oldSequence); // Reorder patterns & Delete unused patterns - BEGIN_CRITICAL(); + cs.Enter(); { for (PATTERNINDEX i = 0; i < maxPatIndex; i++) { @@ -496,7 +496,7 @@ pSndFile->Patterns[nPat].SetName(patternSettings[nPat].name); } } - END_CRITICAL(); + cs.Leave(); EndWaitCursor(); if ((nPatRemoved) || (bReordered)) { @@ -531,10 +531,13 @@ m_pModDoc->GetSampleUndo()->PrepareUndo(nSmp, sundo_delete); } } - BEGIN_CRITICAL(); - SAMPLEINDEX nRemoved = pSndFile->RemoveSelectedSamples(samplesUsed); - END_CRITICAL(); + SAMPLEINDEX nRemoved; + { + CriticalSection cs; + nRemoved = pSndFile->RemoveSelectedSamples(samplesUsed); + } + SAMPLEINDEX nExt = pSndFile->DetectUnusedSamples(samplesUsed); EndWaitCursor(); @@ -545,15 +548,14 @@ "but not used in the song. Do you want to remove them?", nExt, (nExt == 1) ? "" : "s"); if (::MessageBox(NULL, s, "Sample Cleanup", MB_YESNO | MB_ICONQUESTION) == IDYES) { + CriticalSection cs; for (SAMPLEINDEX nSmp = 1; nSmp <= pSndFile->GetNumSamples(); nSmp++) { if ((!samplesUsed[nSmp]) && (pSndFile->Samples[nSmp].pSample)) { m_pModDoc->GetSampleUndo()->PrepareUndo(nSmp, sundo_delete); - BEGIN_CRITICAL(); pSndFile->DestroySample(nSmp); if ((nSmp == pSndFile->m_nSamples) && (nSmp > 1)) pSndFile->m_nSamples--; - END_CRITICAL(); nRemoved++; m_pModDoc->GetSampleUndo()->ClearUndo(nSmp); } @@ -648,10 +650,9 @@ if(nSampleMap[i] != i) { // This gotta be moved - BEGIN_CRITICAL(); + CriticalSection cs; pSndFile->MoveSample(i, nSampleMap[i]); pSndFile->Samples[i].pSample = nullptr; - END_CRITICAL(); if(nSampleMap[i] > 0) strcpy(pSndFile->m_szNames[nSampleMap[i]], pSndFile->m_szNames[i]); MemsetZero(pSndFile->m_szNames[i]); @@ -727,7 +728,7 @@ { if (!pSndFile->IsInstrumentUsed(i)) { - BEGIN_CRITICAL(); + CriticalSection cs; // -> CODE#0003 // -> DESC="remove instrument's samples" // pSndFile->DestroyInstrument(i); @@ -737,7 +738,6 @@ pSndFile->m_nInstruments--; else bReorg = true; - END_CRITICAL(); nRemoved++; } else { @@ -749,7 +749,7 @@ && (::MessageBox(NULL, "Do you want to reorganize the remaining instruments?", "Removing unused instruments", MB_YESNO | MB_ICONQUESTION) == IDYES)) { BeginWaitCursor(); - BEGIN_CRITICAL(); + CriticalSection cs; nSwap = 0; nIndex = 1; for (INSTRUMENTINDEX nIns = 1; nIns <= pSndFile->m_nInstruments; nIns++) @@ -775,7 +775,7 @@ } } while ((pSndFile->m_nInstruments > 1) && (!pSndFile->Instruments[pSndFile->m_nInstruments])) pSndFile->m_nInstruments--; - END_CRITICAL(); + cs.Leave(); if (nSwap > 0) { for (PATTERNINDEX iPat = 0; iPat < pSndFile->Patterns.Size(); iPat++) if (pSndFile->Patterns[iPat]) @@ -876,7 +876,7 @@ CMainFrame::GetMainFrame()->StopMod(m_pModDoc); BeginWaitCursor(); - BEGIN_CRITICAL(); + CriticalSection cs; // convert to IT... m_pModDoc->ChangeModType(MOD_TYPE_IT); @@ -915,7 +915,7 @@ pSndFile->SetModFlag(MSF_OLDVOLSWING, false); pSndFile->SetModFlag(MSF_COMPATIBLE_PLAY, true); - END_CRITICAL(); + cs.Leave(); EndWaitCursor(); return true; @@ -968,9 +968,10 @@ m_pModDoc->GetSampleUndo()->PrepareUndo(nSmp, sundo_delete, 0, pSndFile->Samples[nSmp].nLength); } ctrlSmp::ResetSamples(*pSndFile, ctrlSmp::SmpResetInit); - BEGIN_CRITICAL(); + + CriticalSection cs; pSndFile->RemoveSelectedSamples(keepSamples); - END_CRITICAL(); + return true; } Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-08-25 15:46:25 UTC (rev 999) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-08-25 21:11:13 UTC (rev 1000) @@ -1402,32 +1402,35 @@ if (len > CTrackApp::gMemStatus.dwTotalPhys) len = CTrackApp::gMemStatus.dwTotalPhys; lpFile = f.Lock(len); bOk = FALSE; - if (!lpFile) goto OpenError; - BEGIN_CRITICAL(); - if (!m_pSndFile->m_nInstruments) + if (lpFile) { - bFirst = TRUE; - m_pSndFile->m_nInstruments = 1; - m_NoteMap.SetCurrentInstrument(m_pModDoc, 1); - m_pModDoc->SetModified(); + CriticalSection cs; + + if (!m_pSndFile->GetNumInstruments()) + { + bFirst = TRUE; + m_pSndFile->m_nInstruments = 1; + m_NoteMap.SetCurrentInstrument(m_pModDoc, 1); + m_pModDoc->SetModified(); + } + if (!m_nInstrument) m_nInstrument = 1; + if (m_pSndFile->ReadInstrumentFromFile(m_nInstrument, lpFile, len)) + { + m_pModDoc->UpdateAllViews(NULL, HINT_SAMPLEINFO | HINT_MODTYPE, NULL); + // -> CODE#0023 + // -> DESC="IT project files (.itp)" + int n = strlen(lpszFileName); + if(n >= _MAX_PATH) n = _MAX_PATH-1; + strncpy(m_pSndFile->m_szInstrumentPath[m_nInstrument-1],lpszFileName,n); + m_pSndFile->m_szInstrumentPath[m_nInstrument-1][n] = '\0'; + SetInstrumentModified(false); + // -! NEW_FEATURE#0023 + bOk = TRUE; + } + + f.Unlock(); } - if (!m_nInstrument) m_nInstrument = 1; - if (m_pSndFile->ReadInstrumentFromFile(m_nInstrument, lpFile, len)) - { - m_pModDoc->UpdateAllViews(NULL, HINT_SAMPLEINFO | HINT_MODTYPE, NULL); -// -> CODE#0023 -// -> DESC="IT project files (.itp)" - int n = strlen(lpszFileName); - if(n >= _MAX_PATH) n = _MAX_PATH-1; - strncpy(m_pSndFile->m_szInstrumentPath[m_nInstrument-1],lpszFileName,n); - m_pSndFile->m_szInstrumentPath[m_nInstrument-1][n] = '\0'; - SetInstrumentModified(false); -// -! NEW_FEATURE#0023 - bOk = TRUE; - } - END_CRITICAL(); - f.Unlock(); -OpenError: + f.Close(); EndWaitCursor(); if (bOk) @@ -1471,7 +1474,9 @@ { if ((!pSndFile) || (!nInstr) || (nInstr > pSndFile->m_nInstruments)) return FALSE; BeginWaitCursor(); - BEGIN_CRITICAL(); + + CriticalSection cs; + BOOL bFirst = FALSE; if (!m_pSndFile->m_nInstruments) { @@ -1487,7 +1492,9 @@ bFirst = TRUE; } m_pSndFile->ReadInstrumentFromSong(m_nInstrument, pSndFile, nInstr); - END_CRITICAL(); + + cs.Leave(); + m_pModDoc->SetModified(); m_pModDoc->UpdateAllViews(NULL, (m_nInstrument << HINT_SHIFT_INS) | HINT_INSTRUMENT | HINT_ENVELOPE | HINT_INSNAMES | HINT_SMPNAMES); if (bFirst) m_pModDoc->UpdateAllViews(NULL, HINT_MODTYPE | HINT_INSNAMES | HINT_SMPNAMES); @@ -2536,9 +2543,10 @@ size_t sel = m_ComboTuning.GetCurSel(); if(sel == 0) //Setting IT behavior { - BEGIN_CRITICAL(); + CriticalSection cs; pInstH->SetTuning(NULL); - END_CRITICAL(); + cs.Leave(); + m_pModDoc->SetModified(); UpdateView((m_nInstrument << HINT_SHIFT_INS) | HINT_INSTRUMENT); return; @@ -2564,9 +2572,10 @@ if(tc) { - BEGIN_CRITICAL(); + CriticalSection cs; pInstH->SetTuning(&tc->GetTuning(sel)); - END_CRITICAL(); + cs.Leave(); + m_pModDoc->SetModified(); UpdateView((m_nInstrument << HINT_SHIFT_INS) | HINT_INSTRUMENT); return; @@ -2642,9 +2651,10 @@ CString str; str.Format(TEXT("Tuning %s was not found. Setting to default tuning."), m_pSndFile->Instruments[m_nInstrument]->pTuning->GetName().c_str()); MessageBox(str); - BEGIN_CRITICAL(); + + CriticalSection cs; pIns->SetTuning(pIns->s_DefaultTuning); - END_CRITICAL(); + m_pModDoc->SetModified(); } @@ -2663,9 +2673,9 @@ if(ptlTempo > MAXTEMPO) ptlTempo = MAXTEMPO; - BEGIN_CRITICAL(); + CriticalSection cs; m_pSndFile->Instruments[m_nInstrument]->wPitchToTempoLock = ptlTempo; - END_CRITICAL(); + m_pModDoc->SetModified(); } @@ -2738,9 +2748,9 @@ if(m_pSndFile && m_nInstrument && m_pSndFile->Instruments[m_nInstrument] && m_pSndFile->Instruments[m_nInstrument]->wPitchToTempoLock > 0) { - BEGIN_CRITICAL(); + CriticalSection cs; m_pSndFile->Instruments[m_nInstrument]->wPitchToTempoLock = 0; - END_CRITICAL(); + m_pModDoc->SetModified(); } } Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2011-08-25 15:46:25 UTC (rev 999) +++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2011-08-25 21:11:13 UTC (rev 1000) @@ -300,7 +300,7 @@ bool bIsPlaying = (pMainFrm->GetModPlaying() == m_pModDoc); if ((bIsPlaying) && (pSndFile->m_dwSongFlags & SONG_PATTERNLOOP)) { - BEGIN_CRITICAL(); + CriticalSection cs; // update channel parameters and play time m_pModDoc->SetElapsedTime(m_nScrollPos, 0); @@ -308,10 +308,11 @@ pSndFile->m_nCurrentPattern = pSndFile->m_nNextPattern = m_nScrollPos; pMainFrm->ResetNotificationBuffer(); //rewbs.toCheck pSndFile->m_nNextRow = 0; - END_CRITICAL(); + } else if (m_pParent->GetFollowSong()) { - BEGIN_CRITICAL(); + CriticalSection cs; + DWORD dwPaused = pSndFile->m_dwSongFlags & (SONG_PAUSED|SONG_STEP|SONG_PATTERNLOOP); //if (!(dwPaused & SONG_PATTERNLOOP)) // why? @@ -322,7 +323,6 @@ pSndFile->SetCurrentOrder(m_nScrollPos); pSndFile->m_dwSongFlags |= dwPaused; if (bIsPlaying) pMainFrm->ResetNotificationBuffer(); - END_CRITICAL(); } m_pParent->SetCurrentPattern(n); } @@ -1390,7 +1390,8 @@ void COrderList::SelectSequence(const SEQUENCEINDEX nSeq) //------------------------------------------------------- { - BEGIN_CRITICAL(); + CriticalSection cs; + CMainFrame::GetMainFrame()->ResetNotificationBuffer(); CSoundFile& rSf = *m_pModDoc->GetSoundFile(); if (nSeq == MAX_SEQUENCES + 2) @@ -1402,7 +1403,6 @@ rSf.Order.RemoveSequence(); else { - END_CRITICAL(); return; } } @@ -1416,7 +1416,9 @@ m_pParent->SetCurrentPattern(rSf.Order[m_nScrollPos]); UpdateScrollInfo(); - END_CRITICAL(); + + cs.Leave(); + UpdateView(HINT_MODSEQUENCE); m_pModDoc->SetModified(); m_pModDoc->UpdateAllViews(NULL, HINT_MODSEQUENCE, this); Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-08-25 15:46:25 UTC (rev 999) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-08-25 21:11:13 UTC (rev 1000) @@ -720,13 +720,13 @@ if (len > CTrackApp::gMemStatus.dwTotalPhys) len = CTrackApp::gMemStatus.dwTotalPhys; lpFile = f.Lock(len); if (!lpFile) goto OpenError; - BEGIN_CRITICAL(); + + { + CriticalSection cs; + m_pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_replace); + bOk = m_pSndFile->ReadSampleFromFile(m_nSample, lpFile, len); + } - m_pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_replace); - bOk = m_pSndFile->ReadSampleFromFile(m_nSample, lpFile, len); - - END_CRITICAL(); - if (!bOk) { CRawSampleDlg dlg(this); @@ -744,7 +744,9 @@ BeginWaitCursor(); UINT flags = 0; MODSAMPLE *pSmp = &m_pSndFile->Samples[m_nSample]; - BEGIN_CRITICAL(); + + CriticalSection cs; + m_pSndFile->DestroySample(m_nSample); pSmp->nLength = len; pSmp->uFlags = RS_PCM8S; @@ -784,7 +786,7 @@ { m_pModDoc->GetSampleUndo()->Undo(m_nSample); } - END_CRITICAL(); + } else { m_pModDoc->GetSampleUndo()->RemoveLastUndoStep(m_nSample); @@ -839,7 +841,9 @@ if ((!pSndFile) || (!nSample) || (nSample > pSndFile->m_nSamples)) return false; BeginWaitCursor(); - BEGIN_CRITICAL(); + + CriticalSection cs; + m_pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_replace); m_pSndFile->DestroySample(m_nSample); m_pSndFile->ReadSampleFromSong(m_nSample, pSndFile, nSample); @@ -849,10 +853,13 @@ pSmp->nPan = 128; pSmp->uFlags |= CHN_PANNING; } - END_CRITICAL(); + + cs.Leave(); + EndWaitCursor(); + m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA | HINT_SAMPLEINFO | HINT_SMPNAMES, NULL); m_pModDoc->SetModified(); - EndWaitCursor(); + return true; } @@ -1500,7 +1507,9 @@ if (pSmp->nSustainStart > dwStart) pSmp->nSustainStart += (pSmp->nSustainStart - dwStart); if (pSmp->nSustainEnd >= dwEnd) pSmp->nSustainEnd += (dwEnd-dwStart); else if (pSmp->nSustainEnd > dwStart) pSmp->nSustainEnd += (pSmp->nSustainEnd - dwStart); - BEGIN_CRITICAL(); + + CriticalSection cs; + for (UINT iFix=0; iFix<MAX_CHANNELS; iFix++) { if ((PVOID)m_pSndFile->Chn[iFix].pSample == pOriginal) @@ -1523,7 +1532,9 @@ pSmp->nLength = dwNewLen; CSoundFile::FreeSample(pOriginal); - END_CRITICAL(); + + cs.Leave(); + m_pModDoc->AdjustEndOfSample(m_nSample); if (selection.bSelected == true) { @@ -1629,7 +1640,9 @@ if (pSmp->nSustainEnd >= dwEnd) pSmp->nSustainEnd -= dwRemove; else if (pSmp->nSustainEnd > dwStart) pSmp->nSustainEnd -= (pSmp->nSustainEnd - dwStart)/2; if (pSmp->nSustainEnd > dwNewLen) pSmp->nSustainEnd = dwNewLen; - BEGIN_CRITICAL(); + + CriticalSection cs; + for (UINT iFix=0; iFix<MAX_CHANNELS; iFix++) { if ((PVOID)m_pSndFile->Chn[iFix].pSample == pOriginal) @@ -1650,7 +1663,9 @@ pSmp->nLength = dwNewLen; pSmp->pSample = (LPSTR)pNewSample; CSoundFile::FreeSample(pOriginal); - END_CRITICAL(); + + cs.Leave(); + m_pModDoc->AdjustEndOfSample(m_nSample); if (selection.bSelected == true) { Modified: trunk/OpenMPT/mptrack/EffectVis.cpp =================================================================== --- trunk/OpenMPT/mptrack/EffectVis.cpp 2011-08-25 15:46:25 UTC (rev 999) +++ trunk/OpenMPT/mptrack/EffectVis.cpp 2011-08-25 21:11:13 UTC (rev 1000) @@ -131,18 +131,16 @@ if (IsPcNote(row)) { uint16 param = ScreenYToPCParam(y); - BEGIN_CRITICAL(); + CriticalSection cs; pcmd[offset].SetValueEffectCol(param); - END_CRITICAL(); } else { int param = ScreenYToFXParam(y); // Cap the parameter value as appropriate, based on effect type (e.g. Zxx gets capped to [0x00,0x7F]) m_pModDoc->GetEffectFromIndex(m_pModDoc->GetIndexFromEffect(pcmd[offset].command, param), param); - BEGIN_CRITICAL(); + CriticalSection cs; pcmd[offset].param = static_cast<BYTE>(param); - END_CRITICAL(); } } @@ -159,8 +157,9 @@ void CEffectVis::SetCommand(UINT row, BYTE command) { MODCOMMAND *pcmd = m_pSndFile->Patterns[m_nPattern]; - BEGIN_CRITICAL(); - if (pcmd) { + if (pcmd) + { + CriticalSection cs; int offset = row*m_pSndFile->m_nChannels + m_nChan; if (pcmd[offset].IsPcNote()) { // Clear PC note @@ -171,7 +170,6 @@ } pcmd[offset].command = command; } - END_CRITICAL(); } int CEffectVis::RowToScreenX(UINT row) @@ -893,17 +891,16 @@ return; } - int offset = row*m_pSndFile->m_nChannels + m_nChan; - BEGIN_CRITICAL(); + int offset = row * m_pSndFile->GetNumChannels() + m_nChan; + CriticalSection cs; pcmd[offset].Set(m_templatePCNote.note, m_templatePCNote.instr, m_templatePCNote.GetValueVolCol(), 0); - END_CRITICAL(); } bool CEffectVis::IsPcNote(int row) { MODCOMMAND *pcmd = m_pSndFile->Patterns[m_nPattern]; if (pcmd) - return pcmd[row*m_pSndFile->m_nChannels + m_nChan].IsPcNote(); + return pcmd[row * m_pSndFile->GetNumChannels() + m_nChan].IsPcNote(); else return false; } \ No newline at end of file Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2011-08-25 15:46:25 UTC (rev 999) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2011-08-25 21:11:13 UTC (rev 1000) @@ -501,12 +501,11 @@ if (pMDIActive) pMDIActive->SavePosition(TRUE); if (gpSoundDevice) { - BEGIN_CRITICAL(); + CriticalSection cs; //gpSoundDevice->Reset(); //audioCloseDevice(); gpSoundDevice->Release(); gpSoundDevice = NULL; - END_CRITICAL(); } // Save Settings RemoveControlBar(&m_wndStatusBar); //Remove statusbar so that its state won't get saved. @@ -680,7 +679,7 @@ BOOL bOk = FALSE; CMainFrame *pMainFrm = (CMainFrame *)theApp.m_pMainWnd; if (gbStopSent) return FALSE; - BEGIN_CRITICAL(); + CriticalSection cs; if ((pMainFrm) && (pMainFrm->IsPlaying()) && (CMainFrame::gpSoundDevice)) { bOk = CMainFrame::gpSoundDevice->FillAudioBuffer(&gMPTSoundSource, gdwPlayLatency, dwUser); @@ -693,7 +692,6 @@ gbStopSent = TRUE; pMainFrm->PostMessage(WM_COMMAND, ID_PLAYER_STOP); } - END_CRITICAL(); return bOk; } @@ -743,7 +741,7 @@ } bWait = TRUE; pMainFrm = (CMainFrame *)theApp.m_pMainWnd; - BEGIN_CRITICAL(); + CriticalSection cs; if ((!gbStopSent) && (pMainFrm) && (pMainFrm->IsPlaying()) && (CMainFrame::gpSoundDevice)) { if (!CMainFrame::gpSoundDevice->Directcallback()) @@ -767,7 +765,6 @@ nSleep = 50; } } - END_CRITICAL(); } // -> CODE#0021 @@ -978,13 +975,12 @@ void CMainFrame::audioCloseDevice() //--------------------------------- { - BEGIN_CRITICAL(); + CriticalSection cs; if (gpSoundDevice) { gpSoundDevice->Reset(); gpSoundDevice->Close(); } - END_CRITICAL(); } @@ -1374,9 +1370,10 @@ if (gpSoundDevice) gpSoundDevice->Reset(); audioCloseDevice(); - BEGIN_CRITICAL(); - m_pSndFile->SuspendPlugins(); //rewbs.VSTCompliance - END_CRITICAL(); + { + CriticalSection cs; + m_pSndFile->SuspendPlugins(); //rewbs.VSTCompliance + } m_nMixChn = m_nAvgMixChn = 0; Sleep(1); @@ -1665,9 +1662,10 @@ GetSettings().m_nBufferLength = bufsize; GetSettings().m_nBitsPerSample = nBits; GetSettings().m_nChannels = nChns; - BEGIN_CRITICAL(); - UpdateAudioParameters(FALSE); - END_CRITICAL(); + { + CriticalSection cs; + UpdateAudioParameters(FALSE); + } if (pActiveMod) PlayMod(pActiveMod, hFollow, m_dwNotifyType); UpdateWindow(); } else @@ -1691,11 +1689,12 @@ { GetSettings().m_nSrcMode = srcmode; GetSettings().m_dwQuality = q; - BEGIN_CRITICAL(); - CSoundFile::SetResamplingMode(GetSettings().m_nSrcMode); - CSoundFile::UPDATEDSPEFFECTS(); - CSoundFile::SetAGC(GetSettings().m_dwQuality & QUALITY_AGC); - END_CRITICAL(); + { + CriticalSection cs; + CSoundFile::SetResamplingMode(GetSettings().m_nSrcMode); + CSoundFile::UPDATEDSPEFFECTS(); + CSoundFile::SetAGC(GetSettings().m_dwQuality & QUALITY_AGC); + } PostMessage(WM_MOD_INVALIDATEPATTERNS, HINT_MPTSETUP); } return TRUE; @@ -2459,11 +2458,10 @@ BOOL CMainFrame::InitRenderer(CSoundFile* pSndFile) //------------------------------------------------- { - BEGIN_CRITICAL(); + CriticalSection cs; pSndFile->m_bIsRendering=true; pSndFile->SuspendPlugins(); pSndFile->ResumePlugins(); - END_CRITICAL(); m_dwStatus |= MODSTATUS_RENDERING; m_pModPlaying = GetActiveDoc(); return true; @@ -2472,12 +2470,11 @@ BOOL CMainFrame::StopRenderer(CSoundFile* pSndFile) //------------------------------------------------- { + CriticalSection cs; m_dwStatus &= ~MODSTATUS_RENDERING; m_pModPlaying = NULL; - BEGIN_CRITICAL(); pSndFile->SuspendPlugins(); pSndFile->m_bIsRendering=false; - END_CRITICAL(); return true; } //end rewbs.VSTTimeInfo Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2011-08-25 15:46:25 UTC (rev 999) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2011-08-25 21:11:13 UTC (rev 1000) @@ -385,8 +385,6 @@ GetSettings().m_dwQuality & QUALITY_MEGABASS,\ GetSettings().m_dwQuality & QUALITY_NOISEREDUCTION,\ GetSettings().m_dwQuality & QUALITY_EQ) -#define BEGIN_CRITICAL() EnterCriticalSection(&CMainFrame::m_csAudio) -#define END_CRITICAL() LeaveCriticalSection(&CMainFrame::m_csAudio) #include "mainbar.h" #include "TrackerSettings.h" @@ -665,6 +663,22 @@ static std::vector<CString> s_TemplateModulePaths; }; +// Critical section handling done in (safe) RAII style. +// Create a CriticalSection object whenever you need exclusive access CSoundFile. +// One object = one lock. +// The critical section is automatically left when the object is destroyed, but +// Enter() and Leave() can also be called manually if needed. +class CriticalSection +{ +protected: + bool inSection; +public: + CriticalSection() { inSection = false; Enter(); }; + ~CriticalSection() { Leave(); }; + void Enter() { if(!inSection) { inSection = true; EnterCriticalSection(&CMainFrame::m_csAudio); } }; + void Leave() { if(inSection) { inSection = false; LeaveCriticalSection(&CMainFrame::m_csAudio); } }; +}; + const CHAR gszBuildDate[] = __DATE__ " " __TIME__; Modified: trunk/OpenMPT/mptrack/ModConvert.cpp =================================================================== --- trunk/OpenMPT/mptrack/ModConvert.cpp 2011-08-25 15:46:25 UTC (rev 999) +++ trunk/OpenMPT/mptrack/ModConvert.cpp 2011-08-25 21:11:13 UTC (rev 1000) @@ -126,7 +126,7 @@ "and resize all patterns to 64 rows.\n" "Do you want to continue?", "Warning", MB_YESNO | MB_ICONQUESTION) != IDYES) return false; BeginWaitCursor(); - BEGIN_CRITICAL(); + CriticalSection cs; // Converting instruments to samples if(m_SndFile.m_nInstruments) @@ -159,7 +159,8 @@ m_SndFile.Instruments[nIns] = nullptr; } m_SndFile.m_nInstruments = 0; - END_CRITICAL(); + + cs.Leave(); EndWaitCursor(); } //End if (((m_SndFile.m_nInstruments) || (b64)) && (nNewType & (MOD_TYPE_MOD|MOD_TYPE_S3M))) BeginWaitCursor(); @@ -448,7 +449,7 @@ CHANGEMODTYPE_WARNING(wEditHistory); } - BEGIN_CRITICAL(); + CriticalSection cs; m_SndFile.ChangeModTypeTo(nNewType); if(!newTypeIsXM_IT_MPT && (m_SndFile.m_dwSongFlags & SONG_LINEARSLIDES)) { @@ -482,7 +483,7 @@ CHANGEMODTYPE_WARNING(wCompatibilityMode); } - END_CRITICAL(); + cs.Leave(); ChangeFileExtension(nNewType); // Check mod specifications Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2011-08-25 15:46:25 UTC (rev 999) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2011-08-25 21:11:13 UTC (rev 1000) @@ -870,11 +870,11 @@ if (NOTE_IS_VALID(note)) { - BEGIN_CRITICAL(); - //kill notes if required. if ( (bpause) || (m_SndFile.IsPaused()) || pMainFrm->GetModPlaying() != this) { + CriticalSection cs; + //OnPlayerPause(); // pause song - pausing VSTis is too slow pMainFrm->SetLastMixActiveTime(); // mark activity @@ -889,8 +889,6 @@ } } - END_CRITICAL(); - if (pMainFrm->GetModPlaying() != this) { m_SndFile.m_dwSongFlags |= SONG_PAUSED; @@ -898,7 +896,7 @@ } CMainFrame::EnableLowLatencyMode(); - BEGIN_CRITICAL(); + CriticalSection cs; //find a channel if required //if (nCurrentChn<0) { @@ -1024,14 +1022,11 @@ } //end rewbs.vstiLive - END_CRITICAL(); - } else { - BEGIN_CRITICAL(); + CriticalSection cs; m_SndFile.NoteChange(nChn, note); if (bpause) m_SndFile.m_dwSongFlags |= SONG_PAUSED; - END_CRITICAL(); } return nChn; } @@ -1040,7 +1035,7 @@ BOOL CModDoc::NoteOff(UINT note, BOOL bFade, UINT nins, UINT nCurrentChn) //rewbs.vstiLive: added chan and nins //----------------------------------------------------------------------- { - BEGIN_CRITICAL(); + CriticalSection cs; //rewbs.vstiLive if((nins > 0) && (nins <= m_SndFile.GetNumInstruments()) && (note >= NOTE_MIN) && (note <= NOTE_MAX)) @@ -1080,7 +1075,7 @@ if (note) break; } } - END_CRITICAL(); + return TRUE; } @@ -1880,7 +1875,9 @@ OnPlayerPause(); return; } - BEGIN_CRITICAL(); + + CriticalSection cs; + for (UINT i=m_SndFile.m_nChannels; i<MAX_CHANNELS; i++) if (!m_SndFile.Chn[i].nMasterChn) { m_SndFile.Chn[i].dwFlags |= (CHN_NOTEFADE|CHN_KEYOFF); @@ -1891,7 +1888,9 @@ } else { m_SndFile.ResumePlugins(); } - END_CRITICAL(); + + cs.Leave(); + //m_SndFile.m_dwSongFlags &= ~(SONG_STEP|SONG_PAUSED); m_SndFile.m_dwSongFlags &= ~(SONG_STEP|SONG_PAUSED|SONG_PATTERNLOOP); pMainFrm->PlayMod(this, m_hWndFollow, m_dwNotifyType); @@ -1912,9 +1911,11 @@ UINT nRow = m_SndFile.m_nRow; UINT nNextRow = m_SndFile.m_nNextRow; pMainFrm->PauseMod(); - BEGIN_CRITICAL(); + if ((bLoop) && (nPat < m_SndFile.Patterns.Size())) { + CriticalSection cs; + if ((m_SndFile.m_nCurrentPattern < m_SndFile.Order.size()) && (m_SndFile.Order[m_SndFile.m_nCurrentPattern] == nPat)) { m_SndFile.m_nNextPattern = m_SndFile.m_nCurrentPattern; @@ -1936,7 +1937,6 @@ } } } - END_CRITICAL(); } else { pMainFrm->PauseMod(); @@ -1973,9 +1973,11 @@ m_SndFile.SetCurrentPos(0); m_SndFile.InitializeVisitedRows(true); pMainFrm->ResetElapsedTime(); - BEGIN_CRITICAL(); + + CriticalSection cs; m_SndFile.ResumePlugins(); - END_CRITICAL(); + cs.Leave(); + pMainFrm->PlayMod(this, m_hWndFollow, m_dwNotifyType); CMainFrame::EnableLowLatencyMode(FALSE); } @@ -3458,7 +3460,7 @@ followSonghWnd = GetEditPosition(nRow, nPat, nOrd); CModDoc *pModPlaying = pMainFrm->GetModPlaying(); - BEGIN_CRITICAL(); + CriticalSection cs; // set playback timer in the status bar (and update channel status) SetElapsedTime(nOrd, 0); @@ -3485,7 +3487,7 @@ pSndFile->ResumePlugins(); } //end rewbs.vstCompliance - END_CRITICAL(); + cs.Leave(); if (pModPlaying != this) { @@ -3520,7 +3522,7 @@ followSonghWnd = GetEditPosition(nRow,nPat,nOrd); CModDoc *pModPlaying = pMainFrm->GetModPlaying(); - BEGIN_CRITICAL(); + CriticalSection cs; // set playback timer in the status bar (and update channel status) SetElapsedTime(nOrd, nRow); @@ -3543,7 +3545,7 @@ pSndFile->ResumePlugins(); } //end rewbs.VSTCompliance - END_CRITICAL(); + cs.Leave(); if (pModPlaying != this) { @@ -3579,7 +3581,7 @@ followSonghWnd = GetEditPosition(nRow,nPat,nOrd); CModDoc *pModPlaying = pMainFrm->GetModPlaying(); - BEGIN_CRITICAL(); + CriticalSection cs; // set playback timer in the status bar (and update channel status) SetElapsedTime(nOrd, nRow); @@ -3603,7 +3605,7 @@ pSndFile->ResumePlugins(); } //rewbs.VSTCompliance - END_CRITICAL(); + cs.Leave(); if (pModPlaying != this) { @@ -3925,10 +3927,9 @@ void CModDoc::OnPanic() //--------------------- { - BEGIN_CRITICAL(); + CriticalSection cs; m_SndFile.ResetChannels(); m_SndFile.StopAllVsti(); - END_CRITICAL(); } Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2011-08-25 15:46:25 UTC (rev 999) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2011-08-25 21:11:13 UTC (rev 1000) @@ -174,7 +174,7 @@ } } - BEGIN_CRITICAL(); + CriticalSection cs; for(PATTERNINDEX nPat = 0; nPat <= highestPattern; nPat++) { if(m_SndFile.Patterns.IsValidPat(nPat)) @@ -189,7 +189,7 @@ MODCOMMAND *newp = CPattern::AllocatePattern(m_SndFile.Patterns[nPat].GetNumRows(), nRemainingChannels); if(!newp) { - END_CRITICAL(); + cs.Leave(); CMainFrame::GetMainFrame()->MessageBox("ERROR: Pattern allocation failed in ReArrangechannels(...)" , "ReArrangeChannels", MB_OK | MB_ICONINFORMATION); return CHANNELINDEX_INVALID; } @@ -252,8 +252,6 @@ m_SndFile.Chn[nChn].dwFlags |= CHN_MUTE; } - END_CRITICAL(); - return GetNumChannels(); } @@ -350,7 +348,6 @@ } - UINT CModDoc::RemovePlugs(const bool (&keepMask)[MAX_MIXPLUGINS]) //--------------------------------------------------------------- { @@ -566,7 +563,8 @@ if (inssmp != SAMPLEINDEX_INVALID) newsmp = inssmp; } } - BEGIN_CRITICAL(); + + CriticalSection cs; if (pDup) { *pIns = *pDup; @@ -580,7 +578,7 @@ InitializeInstrument(pIns, newsmp); } m_SndFile.Instruments[newins] = pIns; - END_CRITICAL(); + SetModified(); } else { @@ -617,7 +615,8 @@ if (nSeq >= m_SndFile.Order.GetNumSequences() || nOrd >= m_SndFile.Order.GetSequence(nSeq).size()) return false; - BEGIN_CRITICAL(); + CriticalSection cs; + SEQUENCEINDEX nOldSeq = m_SndFile.Order.GetCurrentSequenceIndex(); m_SndFile.Order.SetSequence(nSeq); for (ORDERINDEX i = nOrd; i < m_SndFile.Order.GetSequence(nSeq).size() - 1; i++) @@ -626,8 +625,8 @@ } m_SndFile.Order[m_SndFile.Order.GetLastIndex()] = m_SndFile.Order.GetInvalidPatIndex(); m_SndFile.Order.SetSequence(nOldSeq); - END_CRITICAL(); SetModified(); + return true; } @@ -638,10 +637,11 @@ { if ((nPat < m_SndFile.Patterns.Size()) && (m_SndFile.Patterns[nPat])) { - BEGIN_CRITICAL(); + CriticalSection cs; + m_SndFile.Patterns.Remove(nPat); - END_CRITICAL(); SetModified(); + return true; } return false; @@ -653,7 +653,8 @@ { if ((nSmp) && (nSmp <= m_SndFile.GetNumSamples())) { - BEGIN_CRITICAL(); + CriticalSection cs; + m_SndFile.DestroySample(nSmp); m_SndFile.m_szNames[nSmp][0] = 0; while ((m_SndFile.GetNumSamples() > 1) @@ -662,8 +663,8 @@ { m_SndFile.m_nSamples--; } - END_CRITICAL(); SetModified(); + return true; } return false; @@ -676,13 +677,14 @@ if ((nIns) && (nIns <= m_SndFile.GetNumInstruments()) && (m_SndFile.Instruments[nIns])) { bool instrumentsLeft = false; - BEGIN_CRITICAL(); + CriticalSection cs; + m_SndFile.DestroyInstrument(nIns); if (nIns == m_SndFile.m_nInstruments) m_SndFile.m_nInstruments--; for (UINT i=1; i<MAX_INSTRUMENTS; i++) if (m_SndFile.Instruments[i]) instrumentsLeft = true; if (!instrumentsLeft) m_SndFile.m_nInstruments = 0; - END_CRITICAL(); SetModified(); + return true; } return false; Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2011-08-25 15:46:25 UTC (rev 999) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2011-08-25 21:11:13 UTC (rev 1000) @@ -590,7 +590,7 @@ m_CbnWFIRType.SetCurSel(0); m_CbnWFIRType.EnableWindow(FALSE); m_CEditWFIRCutoff.EnableWindow(TRUE); - wsprintf(s, "%d", static_cast<int>((CMainFrame::GetSettings().gdWFIRCutoff*100))); + wsprintf(s, "%d", static_cast<int>((CMainFrame::GetSettings().gdWFIRCutoff * 100))); break; case SRCMODE_FIRFILTER: m_CbnWFIRType.AddString("Hann"); @@ -926,9 +926,8 @@ void CEQSetupDlg::UpdateEQ(BOOL bReset) //------------------------------------- { - BEGIN_CRITICAL(); + CriticalSection cs; CSoundFile::SetEQGains( m_pEqPreset->Gains, MAX_EQ_BANDS, m_pEqPreset->Freqs, bReset); - END_CRITICAL(); } Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2011-08-25 15:46:25 UTC (rev 999) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2011-08-25 21:11:13 UTC (rev 1000) @@ -108,7 +108,7 @@ { if ((!pCurrentPlugin) || (pCurrentPlugin->GetPluginFactory() != pFactory)) { - BEGIN_CRITICAL(); + CriticalSection cs; if (pCurrentPlugin) pCurrentPlugin->Release(); // Just in case... m_pPlugin->pMixPlugin = NULL; @@ -132,7 +132,9 @@ lstrcpyn(m_pPlugin->Info.szName, pFactory->szLibraryName, 32); lstrcpyn(m_pPlugin->Info.szLibraryName, pFactory->szLibraryName, 64); - END_CRITICAL(); + + cs.Leave(); + // Now, create the new plugin if (pManager) { @@ -154,7 +156,7 @@ } else // No effect { - BEGIN_CRITICAL(); + CriticalSection cs; if (pCurrentPlugin) { pCurrentPlugin->Release(); @@ -169,7 +171,6 @@ m_pPlugin->pPluginData = NULL; // Clear plugin info MemsetZero(m_pPlugin->Info); - END_CRITICAL(); } //remember window size: Modified: trunk/OpenMPT/mptrack/View_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_gen.cpp 2011-08-25 15:46:25 UTC (rev 999) +++ trunk/OpenMPT/mptrack/View_gen.cpp 2011-08-25 21:11:13 UTC (rev 1000) @@ -1383,11 +1383,11 @@ BeginWaitCursor(); - BEGIN_CRITICAL(); + CriticalSection cs; // Move plug data memcpy(&(pSndFile->m_MixPlugins[dest]), &(pSndFile->m_MixPlugins[src]), sizeof(SNDMIXPLUGIN)); - memset(&(pSndFile->m_MixPlugins[src]), 0, sizeof(SNDMIXPLUGIN)); + MemsetZero(pSndFile->m_MixPlugins[src]); //Prevent plug from pointing backwards. if (pSndFile->m_MixPlugins[dest].Info.dwOutputRouting & 0x80) { @@ -1429,7 +1429,7 @@ if (bAdjustPat && pSndFile->GetType() == MOD_TYPE_MPT) pSndFile->Patterns.ForEachModCommand(PlugIndexModifier(src + 1, src + 1, int(dest) - int(src))); - END_CRITICAL(); + cs.Leave(); if(pSndFile->GetModSpecifications().supportsPlugins) pModDoc->SetModified(); @@ -1448,8 +1448,10 @@ emptySlots.RemoveAll(); - for (UINT nSlot=0; nSlot<MAX_MIXPLUGINS; nSlot++) { - if (pSndFile->m_MixPlugins[nSlot].pMixPlugin == NULL) { + for (UINT nSlot=0; nSlot<MAX_MIXPLUGINS; nSlot++) + { + if (pSndFile->m_MixPlugins[nSlot].pMixPlugin == nullptr) + { emptySlots.Add(nSlot); } } @@ -1463,13 +1465,16 @@ CModDoc *pModDoc = GetDocument(); CSoundFile* pSndFile = pModDoc->GetSoundFile(); prompt.Format("Insert empty slot before slot FX%d?", m_nCurrentPlugin+1); - if (pSndFile->m_MixPlugins[MAX_MIXPLUGINS-1].pMixPlugin) { + if (pSndFile->m_MixPlugins[MAX_MIXPLUGINS-1].pMixPlugin) + { prompt.Append("\nWarning: plugin data in last slot will be lost."); } - if (AfxMessageBox(prompt, MB_YESNO) == IDYES) { + if (AfxMessageBox(prompt, MB_YESNO) == IDYES) + { //Delete last plug... - if (pSndFile->m_MixPlugins[MAX_MIXPLUGINS-1].pMixPlugin) { + if (pSndFile->m_MixPlugins[MAX_MIXPLUGINS-1].pMixPlugin) + { pSndFile->m_MixPlugins[MAX_MIXPLUGINS-1].pMixPlugin->Release(); memset(&(pSndFile->m_MixPlugins[MAX_MIXPLUGINS-1]), 0, sizeof(SNDMIXPLUGIN)); //possible mem leak here... @@ -1480,8 +1485,10 @@ pSndFile->Patterns.ForEachModCommand(PlugIndexModifier(m_nCurrentPlugin + 1, MAX_MIXPLUGINS - 1, 1)); - for (PLUGINDEX nSlot = MAX_MIXPLUGINS-1; nSlot > m_nCurrentPlugin; nSlot--) { - if (pSndFile->m_MixPlugins[nSlot-1].pMixPlugin) { + for (PLUGINDEX nSlot = MAX_MIXPLUGINS-1; nSlot > m_nCurrentPlugin; nSlot--) + { + if (pSndFile->m_MixPlugins[nSlot-1].pMixPlugin) + { MovePlug(nSlot-1, nSlot, NoPatternAdjust); } } @@ -1519,32 +1526,13 @@ CVstPlugin *pVstPlugin = (pPlugin->pMixPlugin) ? (CVstPlugin *)pPlugin->pMixPlugin : nullptr; if(pVstPlugin == nullptr) return; - CHAR sname[64]; - CHAR s2[128]; UINT nProg = pVstPlugin->GetNumPrograms(); m_CbnPreset.SetRedraw(FALSE); m_CbnPreset.ResetContent(); - wsprintf(s2, _T("current")); - m_CbnPreset.SetItemData(m_CbnPreset.AddString(s2), 0); + m_CbnPreset.SetItemData(m_CbnPreset.AddString(_T("current")), 0); for (UINT i = 0; i < nProg; i++) { - if(!pVstPlugin->GetProgramNameIndexed(i, 0, sname)) - { - strcpy(sname, ""); - } - StringFixer::SetNullTerminator(sname); - - if(sname[0] < ' ') - { - wsprintf(s2, "%02X - Program %d", i, i); - } else - { - size_t k = 0; - while(k < ARRAYELEMCOUNT(sname) - 1 && sname[k] <= ' ') k++; - wsprintf(s2, "%02X - %s",i,&sname[k]); - } - - m_CbnPreset.SetItemData(m_CbnPreset.AddString(s2), i+1); + m_CbnPreset.SetItemData(m_CbnPreset.AddString(pVstPlugin->GetFormattedProgramName(i)), i + 1); } m_nCurrentPreset = 0; m_CbnPreset.SetRedraw(TRUE); Modified: trunk/OpenMPT/mptrack/View_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_ins.cpp 2011-08-25 15:46:25 UTC (rev 999) +++ trunk/OpenMPT/mptrack/View_ins.cpp 2011-08-25 21:11:13 UTC (rev 1000) @@ -2042,9 +2042,8 @@ bCanDrop = FALSE; if (pDlsIns) { - BEGIN_CRITICAL(); + CriticalSection cs; bCanDrop = dlsbank.ExtractInstrument(pSndFile, m_nInstrument, nIns, nRgn); - END_CRITICAL(); } bUpdate = TRUE; break; @@ -2069,9 +2068,10 @@ { nRgn = pDLSBank->GetRegionFromKey(nIns, 60); } - BEGIN_CRITICAL(); + + CriticalSection cs; + bCanDrop = pDLSBank->ExtractInstrument(pSndFile, m_nInstrument, nIns, nRgn); - END_CRITICAL(); bUpdate = TRUE; } break; Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2011-08-25 15:46:25 UTC (rev 999) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2011-08-25 21:11:13 UTC (rev 1000) @@ -2175,7 +2175,9 @@ { CSoundFile *pSndFile = pModDoc->GetSoundFile(); if ((!pSndFile->Patterns.IsValidPat(m_nPattern)) || (!pSndFile->Patterns[m_nPattern].GetNumRows())) return; - BEGIN_CRITICAL(); + + CriticalSection cs; + // Cut instruments/samples in virtual channels for (CHANNELINDEX i = pSndFile->GetNumChannels(); i < MAX_CHANNELS; i++) { @@ -2185,7 +2187,9 @@ pSndFile->m_nNextRow = GetCurrentRow(); pSndFile->m_dwSongFlags &= ~SONG_PAUSED; pSndFile->m_dwSongFlags |= SONG_STEP; - END_CRITICAL(); + + cs.Leave(); + if (pMainFrm->GetModPlaying() != pModDoc) { pMainFrm->PlayMod(pModDoc, m_hWnd, MPTNOTIFY_POSITION|MPTNOTIFY_VUMETERS); @@ -2636,9 +2640,9 @@ } } - BEGIN_CRITICAL(); + CriticalSection cs; pSndFile->Patterns[m_nPattern] = pNewPattern; - END_CRITICAL(); + cs.Leave(); x1 += dx; Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2011-08-25 15:46:25 UTC (rev 999) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2011-08-25 21:11:13 UTC (rev 1000) @@ -1733,14 +1733,18 @@ { if (MessageBox("Remove this sample?", "Remove Sample", MB_YESNOCANCEL | MB_ICONQUESTION) != IDYES) return; pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_replace); - BEGIN_CRITICAL(); + + CriticalSection cs; pSndFile->DestroySample(m_nSample); - END_CRITICAL(); + cs.Leave(); + dwUpdateFlags |= HINT_SMPNAMES; } else { pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_delete, m_dwBeginSel, m_dwEndSel); - BEGIN_CRITICAL(); + + CriticalSection cs; + UINT cutlen = m_dwEndSel - m_dwBeginSel; UINT istart = m_dwBeginSel; UINT iend = len; @@ -1794,7 +1798,6 @@ pSmp->nLoopStart = pSmp->nLoopEnd = 0; pSmp->uFlags &= ~CHN_LOOP; } - END_CRITICAL(); } SetCurSel(0, 0); pModDoc->AdjustEndOfSample(m_nSample); @@ -1948,7 +1951,9 @@ CSoundFile *pSndFile = pModDoc->GetSoundFile(); DWORD dwMemSize = GlobalSize(hCpy); - BEGIN_CRITICAL(); + + CriticalSection cs; + memcpy(s, pSndFile->m_szNames[m_nSample], 32); memcpy(s2, pSndFile->Samples[m_nSample].filename, 22); pSndFile->DestroySample(m_nSample); @@ -1963,7 +1968,9 @@ { memcpy(pSndFile->Samples[m_nSample].filename, s2, 22); } - END_CRITICAL(); + + cs.Leave(); + GlobalUnlock(hCpy); SetCurSel(0, 0); pModDoc->AdjustEndOfSample(m_nSample); @@ -1998,7 +2005,9 @@ if ((pSmp->uFlags & CHN_16BIT) && (pSmp->pSample) && (pSmp->nLength)) { pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_replace); - BEGIN_CRITICAL(); + + CriticalSection cs; + signed char *p = (signed char *)(pSmp->pSample); UINT len = (pSmp->nLength + 1) * pSmp->GetNumChannels(); for (UINT i=0; i<=len; i++) @@ -2010,7 +2019,9 @@ { pSndFile->Chn[j].dwFlags &= ~(CHN_16BIT); } - END_CRITICAL(); + + cs.Leave(); + pModDoc->SetModified(); pModDoc->AdjustEndOfSample(m_nSample); pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA | HINT_SAMPLEINFO, NULL); @@ -2072,7 +2083,9 @@ if ((pSmp->pSample) && (nStart+nEnd <= pSmp->nLength) && (nEnd >= MIN_TRIM_LENGTH)) { pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_replace); - BEGIN_CRITICAL(); + + CriticalSection cs; + // Note: Sample is overwritten in-place! Unused data is not deallocated! const UINT bend = nEnd * pSmp->GetBytesPerSample() , bstart = nStart * pSmp->GetBytesPerSample(); @@ -2099,7 +2112,9 @@ pSmp->uFlags &= ~(CHN_SUSTAINLOOP|CHN_PINGPONGSUSTAIN); } pSmp->nLength = nEnd; - END_CRITICAL(); + + cs.Leave(); + pModDoc->SetModified(); pModDoc->AdjustEndOfSample(m_nSample); SetCurSel(0, 0); @@ -2267,10 +2282,10 @@ bCanDrop = FALSE; if (pDlsIns) { - BEGIN_CRITICAL(); + CriticalSection cs; + pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_replace); bCanDrop = dlsbank.ExtractSample(pSndFile, m_nSample, nIns, nRgn); - END_CRITICAL(); } bUpdate = TRUE; break; @@ -2295,10 +2310,11 @@ { nRgn = pDLSBank->GetRegionFromKey(nIns, 60); } - BEGIN_CRITICAL(); + CriticalSection cs; + pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_replace); bCanDrop = pDLSBank->ExtractSample(pSndFile, m_nSample, nIns, nRgn); - END_CRITICAL(); + bUpdate = TRUE; } break; @@ -2487,13 +2503,14 @@ } BeginWaitCursor(); - BEGIN_CRITICAL(); if(dlg.m_nEditOption == addsilence_resize) { // resize - dlg.m_nSamples = new size if(dlg.m_nSamples != pSmp->nLength) { + CriticalSection cs; + if(dlg.m_nSamples < pSmp->nLength) // make it shorter! pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_delete, dlg.m_nSamples, pSmp->nLength); else // make it longer! @@ -2505,13 +2522,14 @@ // add silence - dlg.m_nSamples = amount of bytes to be added if(dlg.m_nSamples > 0) { + CriticalSection cs; + UINT nStart = (dlg.m_nEditOption == addsilence_at_end) ? pSndFile->Samples[m_nSample].nLength : 0; pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_insert, nStart, nStart + dlg.m_nSamples); ctrlSmp::InsertSilence(pSndFile->Samples[m_nSample], dlg.m_nSamples, nStart, pSndFile); } } - END_CRITICAL(); EndWaitCursor(); if(nOldLength != pSmp->nLength) Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2011-08-25 15:46:25 UTC (rev 999) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2011-08-25 21:11:13 UTC (rev 1000) @@ -41,15 +41,15 @@ AEffect *DmoToVst(PVSTPLUGINLIB pLib); #ifdef VST_USE_ALTERNATIVE_MAGIC -UINT32 CalculateCRC32fromFilename(const char * s) -//----------------------------------------------- +UINT32 CalculateCRC32fromFilename(const char *s) +//---------------------------------------------- { char fn[_MAX_PATH]; strncpy(fn, s, sizeof(fn)); fn[sizeof(fn)-1] = 0; int f; for(f = 0; fn[f] != 0; f++) fn[f] = toupper(fn[f]); - return crc32(0, (BYTE *)fn, f); + return LittleEndian(crc32(0, (BYTE *)fn, f)); } #endif // VST_USE_ALTERNATIVE_MAGIC @@ -120,7 +120,7 @@ } -VOID CVstPluginManager::EnumerateDirectXDMOs() +void CVstPluginManager::EnumerateDirectXDMOs() //-------------------------------------------- { HKEY hkEnum; @@ -311,7 +311,7 @@ p->dwPluginId2 = 0; p->bIsInstrument = FALSE; p->pPluginsList = NULL; - lstrcpyn(p->szDllPath, pszDllPath, sizeof(p->szDllPath)); + lstrcpyn(p->szDllPath, pszDllPath, CountOf(p->szDllPath)); _splitpath(pszDllPath, NULL, NULL, p->szLibraryName, NULL); p->szLibraryName[63] = 0; p->pNext = m_pVstHead; @@ -386,25 +386,27 @@ p->dwPluginId1 = kBuzzMagic; p->dwPluginId2 = 0; p->pPluginsList = NULL; - lstrcpyn(p->szDllPath, pszDllPath, sizeof(p->szDllPath)); + lstrcpyn(p->szDllPath, pszDllPath, CountOf(p->szDllPath)); _splitpath(pszDllPath, NULL, NULL, p->szLibraryName, NULL); p->szLibraryName[63] = 0; p->pNext = m_pVstHead; p->pPrev = NULL; if (m_pVstHead) m_pVstHead->pPrev = p; m_pVstHead = p; - try { + try + { const CMachineInfo *pInfo = pBuzzGetInfo(); if (pInfo) { p->dwPluginId2 = pInfo->Version; if (pInfo->Name) { - lstrcpyn(p->szLibraryName, pInfo->Name, sizeof(p->szLibraryName)); + lstrcpyn(p->szLibraryName, pInfo->Name, CountOf(p->szLibraryName)); } bOk = TRUE; } - } catch (...) { + } catch (...) + { CVstPluginManager::ReportPlugException("Exception while trying to load buzz plugin \"%s\"!\n", p->szLibraryName); } } else @@ -421,14 +423,14 @@ // CVstPluginManager::ReportPlugException("Exception in FreeLibrary(\"%s\")!\n", pszDllPath); //} - return (bOk) ? m_pVstHead : NULL; + return (bOk) ? m_pVstHead : nullptr; } else { #ifdef VST_LOG Log("LoadLibrary(%s) failed!\n", pszDllPath); #endif // VST_LOG } - return NULL; + return nullptr; } @@ -445,19 +447,21 @@ if (p->pPrev) p->pPrev->pNext = p->pNext; if (p->pNext) p->pNext->pPrev = p->pPrev; p->pPrev = p->pNext = NULL; - BEGIN_CRITICAL(); - try { + try + { + CriticalSection cs; + while ((volatile void *)(p->pPluginsList) != NULL) { p->pPluginsList->Release(); } delete p; - } catch (...) { + } catch (...) + { CVstPluginManager::ReportPlugException("Exception while trying to release plugin \"%s\"!\n", pFactory->szLibraryName); } - END_CRITICAL(); return TRUE; } p = p->pNext; @@ -516,14 +520,15 @@ if ((pEffect) && (pEffect->dispatcher) && (pEffect->magic == kDmoMagic)) { BOOL bOk = FALSE; - BEGIN_CRITICAL(); + + CriticalSection cs; + CVstPlugin *pVstPlug = new CVstPlugin(NULL, pFound, pMixPlugin, pEffect); if (pVstPlug) { pVstPlug->Initialize(pSndFile); bOk = TRUE; } - END_CRITICAL(); return bOk; } } @@ -555,9 +560,10 @@ HINSTANCE hLibrary = NULL; BOOL bOk = FALSE; - BEGIN_CRITICAL(); - - try { + try + { + CriticalSection cs; + hLibrary = LoadLibrary(pFound->szDllPath); if (hLibrary != NULL) { @@ -614,11 +620,11 @@ #endif } if ((!bOk) && (hLibrary)) FreeLibrary(hLibrary); - } catch(...) { + } catch(...) + { CVstPluginManager::ReportPlugException("Exception while trying to create plugin \"%s\"!\n", pFound->szLibraryName); } - END_CRITICAL(); return bOk; } else { @@ -631,7 +637,7 @@ } -VOID CVstPluginManager::OnIdle() +void CVstPluginManager::OnIdle() //------------------------------ { PVSTPLUGINLIB pFactory = m_pVstHead; @@ -648,7 +654,8 @@ p->m_bNeedIdle=false; } //We need to update all open editors - if ((p->m_pEditor) && (p->m_pEditor->m_hWnd)) { + if ((p->m_pEditor) && (p->m_pEditor->m_hWnd)) + { p->m_pEditor->UpdateParamDisplays(); } //end rewbs. VSTCompliance: @@ -685,20 +692,22 @@ //Mark track modified CModDoc* pModDoc = pVstPlugin->GetModDoc(); - if (pModDoc) { + if (pModDoc) + { CAbstractVstEditor *pVstEditor = pVstPlugin->GetEditor(); if (pVstEditor && pVstEditor->m_hWnd) // Check GUI is open { if(pModDoc->GetSoundFile() && pModDoc->GetSoundFile()->GetModSpecifications().supportsPlugins) CMainFrame::GetMainFrame()->ThreadSafeSetModified(pModDoc); } - // Could be used to update general tab in real time, but causes flickers in treeview + // TODO: Could be used to update general tab in real time, but causes flickers in treeview // Better idea: add an update hint just for plugin params? //pModDoc->UpdateAllViews(NULL, HINT_MIXPLUGINS, NULL); } //Record param change - if (pVstPlugin->m_bRecordAutomation) { + if (pVstPlugin->m_bRecordAutomation) + { pModDoc->RecordParamChange(pVstPlugin->GetSlot(), index); } @@ -1560,7 +1569,7 @@ } -VOID CVstPlugin::GetPluginType(LPSTR pszType) +void CVstPlugin::GetPluginType(LPSTR pszType) //------------------------------------------- { pszType[0] = 0; @@ -1771,6 +1780,7 @@ return 0; } + bool CVstPlugin::GetProgramNameIndexed(long index, long category, char *text) //--------------------------------------------------------------------------- { @@ -1782,7 +1792,38 @@ } -VOID CVstPlugin::SetCurrentProgram(UINT nIndex) +CString CVstPlugin::GetFormattedProgramName(VstInt32 index, bool allowFallback) +//----------------------------------------------------------------------------- +{ + char rawname[256]; // kVstMaxProgNameLen is 24... + if(!GetProgramNameIndexed(index, -1, rawname)) + { + // Fallback: Try to get current program name. + if(!allowFallback || Dispatch(effGetProgramName, 0, 0, rawname, 0) != 1) + { + strcpy(rawname, ""); + } + } + StringFixer::SetNullTerminator(rawname); + + // Let's start counting at 1 for the program name (as most MIDI hardware / software does) + index++; + + CString formattedName; + if(rawname[0] < ' ') + { + formattedName.Format("%02d - Program %d", index, index); + } + else + { + formattedName.Format("%02d - %s", index, rawname); + } + + return formattedName; +} + + +void CVstPlugin::SetCurrentProgram(UINT nIndex) //--------------------------------------------- { if ((m_pEffect) && (m_pEffect->numPrograms > 0)) @@ -1798,7 +1839,7 @@ PlugParamValue CVstPlugin::GetParameter(PlugParamIndex nIndex) //------------------------------------------------------------ { - FLOAT fResult = 0; + float fResult = 0; if ((m_pEffect) && (nIndex < m_pEffect->numParams) && (m_pEffect->getParameter)) { try @@ -1820,7 +1861,7 @@ } -VOID CVstPlugin::SetParameter(PlugParamIndex nIndex, PlugParamValue fValue) +void CVstPlugin::SetParameter(PlugParamIndex nIndex, PlugParamValue fValue) //------------------------------------------------------------------------- { try @@ -1837,7 +1878,7 @@ } -VOID CVstPlugin::GetParamName(UINT nIndex, LPSTR pszName, UINT cbSize) +void CVstPlugin::GetParamName(UINT nIndex, LPSTR pszName, UINT cbSize) //-------------------------------------------------------------------- { if ((!pszName) || (!cbSize)) return; @@ -1853,7 +1894,7 @@ } -VOID CVstPlugin::GetParamLabel(UINT nIndex, LPSTR pszLabel) +void CVstPlugin::GetParamLabel(UINT nIndex, LPSTR pszLabel) //--------------------------------------------------------- { pszLabel[0] = 0; @@ -1864,7 +1905,7 @@ } -VOID CVstPlugin::GetParamDisplay(UINT nIndex, LPSTR pszDisplay) +void CVstPlugin::GetParamDisplay(UINT nIndex, LPSTR pszDisplay) //------------------------------------------------------------- { pszDisplay[0] = 0; @@ -1881,7 +1922,7 @@ pszName[0] = 0; if (m_bIsVst2) { - Dispatch(effGetEffectName, 0,0, pszName, 0); + Dispatch(effGetEffectName, 0, 0, pszName, 0); return TRUE; } return FALSE; @@ -1900,12 +1941,13 @@ try { - //reset some stuf + //reset some stuff m_MixState.nVolDecayL = 0; m_MixState.nVolDecayR = 0; Dispatch(effStopProcess, 0, 0, NULL, 0.0f); Dispatch(effMainsChanged, 0, 0, NULL, 0.0f); // calls plugin's suspend - if (sampleRate != m_nSampleRate) { + if (sampleRate != m_nSampleRate) + { m_nSampleRate=sampleRate; Dispatch(effSetSampleRate, 0, 0, NULL, static_cast<float>(m_nSampleRate)); } @@ -1994,50 +2036,7 @@ m_pMixStruct->fDryRatio = static_cast<float>(1.0-(static_cast<double>(param)/127.0)); } -/* -void CVstPlugin::Process(float **pOutputs, unsigned long nSamples) -//---------------------------------------------------------------- -{ - float wetRatio, dryRatio; - wetRatio *= m_fGain; - dryRatio *= m_fGain; - ProcessVSTEvents(); - if ((m_pEffect) && (m_pProcessFP) && (m_pInputs) && (m_pOutputs) && (m_pMixStruct)) { - - //Merge stereo input before sending to the plug if the plug can only handle one input. - if (m_pEffect->numInputs == 1) { - for (UINT i=0; i<nSamples; i++) { - m_pInputs[0][i] = 0.5f*m_pInputs[0][i] + 0.5f*m_pInputs[1][i]; - } - } - - //Clear the buffers that will be receiving the plugin's output. - for (UINT iOut=0; iOut<m_nOutputs; iOut++) { - memset(m_pTempBuffer[iOut], 0, nSamples*... [truncated message content] |
From: <sag...@us...> - 2011-08-31 18:00:21
|
Revision: 1003 http://modplug.svn.sourceforge.net/modplug/?rev=1003&view=rev Author: saga-games Date: 2011-08-31 18:00:14 +0000 (Wed, 31 Aug 2011) Log Message: ----------- [Ref] Some refactoring [Fix] Added critical section when opening param editor (previously, a debug assert could be triggered because updates were sent to the editor before it was painted for the first time) [Mod] OpenMPT: Version is now 1.20.00.14 Modified Paths: -------------- trunk/OpenMPT/mptrack/CleanupSong.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/mptrack/Undo.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/misc_util.h trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/pattern.cpp Modified: trunk/OpenMPT/mptrack/CleanupSong.cpp =================================================================== --- trunk/OpenMPT/mptrack/CleanupSong.cpp 2011-08-31 17:51:46 UTC (rev 1002) +++ trunk/OpenMPT/mptrack/CleanupSong.cpp 2011-08-31 18:00:14 UTC (rev 1003) @@ -702,7 +702,6 @@ vector<bool> usedmap; INSTRUMENTINDEX swapmap[MAX_INSTRUMENTS]; INSTRUMENTINDEX swapdest[MAX_INSTRUMENTS]; - CHAR s[512]; UINT nRemoved = 0; INSTRUMENTINDEX nSwap, nIndex; bool bReorg = false; @@ -718,7 +717,7 @@ } } else { - ::MessageBox(NULL, "This is an IT project file, so no samples associated with a used instrument will be removed.", "Removing unused instruments", MB_OK | MB_ICONINFORMATION); + ::MessageBox(NULL, "This is an IT project file, so no samples associated with an used instrument will be removed.", "Removing unused instruments", MB_OK | MB_ICONINFORMATION); } BeginWaitCursor(); @@ -734,7 +733,7 @@ // pSndFile->DestroyInstrument(i); pSndFile->DestroyInstrument(i, removeSamples); // -! BEHAVIOUR_CHANGE#0003 - if ((i == pSndFile->GetNumInstruments()) && (i>1)) + if ((i == pSndFile->GetNumInstruments()) && (i >1)) pSndFile->m_nInstruments--; else bReorg = true; @@ -799,6 +798,7 @@ } if (nRemoved) { + CHAR s[64]; wsprintf(s, "%d unused instrument%s removed\n", nRemoved, (nRemoved == 1) ? "" : "s"); m_pModDoc->AddToLog(s); return true; @@ -814,12 +814,12 @@ CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); if(pSndFile == nullptr) return false; - bool usedmap[MAX_MIXPLUGINS]; - memset(usedmap, false, sizeof(usedmap)); + vector<bool> usedmap(MAX_MIXPLUGINS, false); - for (PLUGINDEX nPlug = 0; nPlug < MAX_MIXPLUGINS; nPlug++) { + for (PLUGINDEX nPlug = 0; nPlug < MAX_MIXPLUGINS; nPlug++) + { - //Is the plugin assigned to a channel? + // Is the plugin assigned to a channel? for (CHANNELINDEX nChn = 0; nChn < pSndFile->GetNumChannels(); nChn++) { if (pSndFile->ChnSettings[nChn].nMixPlugin == nPlug + 1) @@ -829,8 +829,8 @@ } } - //Is the plugin used by an instrument? - for (INSTRUMENTINDEX nIns=1; nIns<=pSndFile->GetNumInstruments(); nIns++) + // Is the plugin used by an instrument? + for (INSTRUMENTINDEX nIns = 1; nIns <= pSndFile->GetNumInstruments(); nIns++) { if (pSndFile->Instruments[nIns] && (pSndFile->Instruments[nIns]->nMixPlug == nPlug + 1)) { @@ -839,11 +839,11 @@ } } - //Is the plugin assigned to master? + // Is the plugin assigned to master? if (pSndFile->m_MixPlugins[nPlug].Info.dwInputRouting & MIXPLUG_INPUTF_MASTEREFFECT) usedmap[nPlug] = true; - //all outputs of used plugins count as used + // All outputs of used plugins count as used if (usedmap[nPlug] != false) { if (pSndFile->m_MixPlugins[nPlug].Info.dwOutputRouting & 0x80) @@ -1006,8 +1006,7 @@ bool CModCleanupDlg::RemoveAllPlugins() //------------------------------------- { - bool keepMask[MAX_MIXPLUGINS]; - memset(keepMask, false, sizeof(keepMask)); + vector<bool> keepMask(MAX_MIXPLUGINS, false); m_pModDoc->RemovePlugs(keepMask); return true; } Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2011-08-31 17:51:46 UTC (rev 1002) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2011-08-31 18:00:14 UTC (rev 1003) @@ -975,9 +975,10 @@ void CMainFrame::audioCloseDevice() //--------------------------------- { - CriticalSection cs; if (gpSoundDevice) { + CriticalSection cs; + gpSoundDevice->Reset(); gpSoundDevice->Close(); } Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2011-08-31 17:51:46 UTC (rev 1002) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2011-08-31 18:00:14 UTC (rev 1003) @@ -664,8 +664,8 @@ }; // Critical section handling done in (safe) RAII style. -// Create a CriticalSection object whenever you need exclusive access CSoundFile. -// One object = one lock. +// Create a CriticalSection object whenever you need exclusive access to CSoundFile. +// One object = one lock / critical section. // The critical section is automatically left when the object is destroyed, but // Enter() and Leave() can also be called manually if needed. class CriticalSection Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2011-08-31 17:51:46 UTC (rev 1002) +++ trunk/OpenMPT/mptrack/Moddoc.h 2011-08-31 18:00:14 UTC (rev 1003) @@ -285,7 +285,7 @@ void CheckUsedChannels(vector<bool> &usedMask, CHANNELINDEX maxRemoveCount = MAX_BASECHANNELS) const; bool ConvertInstrumentsToSamples(); - UINT RemovePlugs(const bool (&keepMask)[MAX_MIXPLUGINS]); + UINT RemovePlugs(const vector<bool> &keepMask); PATTERNINDEX InsertPattern(ORDERINDEX nOrd = ORDERINDEX_INVALID, ROWINDEX nRows = 64); SAMPLEINDEX InsertSample(bool bLimit = false); Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2011-08-31 17:51:46 UTC (rev 1002) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2011-08-31 18:00:14 UTC (rev 1003) @@ -348,17 +348,18 @@ } -UINT CModDoc::RemovePlugs(const bool (&keepMask)[MAX_MIXPLUGINS]) -//--------------------------------------------------------------- +UINT CModDoc::RemovePlugs(const vector<bool> &keepMask) +//----------------------------------------------------- { //Remove all plugins whose keepMask[plugindex] is false. - UINT nRemoved=0; - for (PLUGINDEX nPlug=0; nPlug<MAX_MIXPLUGINS; nPlug++) + UINT nRemoved = 0; + const PLUGINDEX maxPlug = min(MAX_MIXPLUGINS, keepMask.size()); + + for (PLUGINDEX nPlug = 0; nPlug < maxPlug; nPlug++) { SNDMIXPLUGIN* pPlug = &m_SndFile.m_MixPlugins[nPlug]; if (keepMask[nPlug] || !pPlug) { - Log("Keeping mixplug addess (%d): %X\n", nPlug, &(pPlug->pMixPlugin)); continue; } Modified: trunk/OpenMPT/mptrack/Undo.cpp =================================================================== --- trunk/OpenMPT/mptrack/Undo.cpp 2011-08-31 17:51:46 UTC (rev 1002) +++ trunk/OpenMPT/mptrack/Undo.cpp 2011-08-31 18:00:14 UTC (rev 1003) @@ -58,7 +58,7 @@ if (firstRow + numRows >= nRows) numRows = nRows - firstRow; if (firstChn + numChns >= pSndFile->GetNumChannels()) numChns = pSndFile->GetNumChannels() - firstChn; - pUndoData = new MODCOMMAND[numChns * numRows]; + pUndoData = CPattern::AllocatePattern(numRows, numChns); if (!pUndoData) return false; const bool bUpdate = !CanUndo(); // update undo status? @@ -210,7 +210,7 @@ bool CPatternUndo::CanUndo() //-------------------------- { - return (UndoBuffer.size() > 0) ? true : false; + return (UndoBuffer.size() > 0); } @@ -291,8 +291,8 @@ SAMPLEUNDOBUFFER sUndo; // Save old sample header - memcpy(&sUndo.OldSample, &pSndFile->Samples[nSmp], sizeof(MODSAMPLE)); - memcpy(sUndo.szOldName, pSndFile->m_szNames[nSmp], sizeof(sUndo.szOldName)); + MemCopy(sUndo.OldSample, pSndFile->Samples[nSmp]); + MemCopy(sUndo.szOldName, pSndFile->m_szNames[nSmp]); sUndo.nChangeType = nChangeType; if(nChangeType == sundo_replace) @@ -426,9 +426,9 @@ } // Restore old sample header - memcpy(&pSndFile->Samples[nSmp], &pUndo->OldSample, sizeof(MODSAMPLE)); + MemCopy(pSndFile->Samples[nSmp], pUndo->OldSample); pSndFile->Samples[nSmp].pSample = pCurrentSample; // select the "correct" old sample - memcpy(pSndFile->m_szNames[nSmp], pUndo->szOldName, sizeof(pUndo->szOldName)); + MemCopy(pSndFile->m_szNames[nSmp], pUndo->szOldName); if(pNewSample != nullptr) { Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2011-08-31 17:51:46 UTC (rev 1002) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2011-08-31 18:00:14 UTC (rev 1003) @@ -2321,6 +2321,8 @@ else { //Open window & send data + CriticalSection cs; + m_pEffectVis = new CEffectVis(this, row0, row1, nchn, pModDoc, m_nPattern); if (m_pEffectVis) { @@ -2885,10 +2887,10 @@ { CHANNELINDEX firstChannel = GetSelectionStartChan(), lastChannel = GetSelectionEndChan(); ROWINDEX firstRow = GetSelectionStartRow(), lastRow = GetSelectionEndRow(); - firstChannel = CLAMP(firstChannel, 0, pSndFile->GetNumChannels() - 1); - lastChannel = CLAMP(lastChannel, firstChannel, pSndFile->GetNumChannels() - 1); - firstRow = CLAMP(firstRow, 0, pSndFile->Patterns[m_nPattern].GetNumRows() - 1); - lastRow = CLAMP(lastRow, firstRow, pSndFile->Patterns[m_nPattern].GetNumRows() - 1); + Limit(firstChannel, (CHANNELINDEX)0, (CHANNELINDEX)(pSndFile->GetNumChannels() - 1)); + Limit(lastChannel, firstChannel, (CHANNELINDEX)(pSndFile->GetNumChannels() - 1)); + Limit(firstRow, (ROWINDEX)0, pSndFile->Patterns[m_nPattern].GetNumRows() - 1); + Limit(lastRow, firstRow, pSndFile->Patterns[m_nPattern].GetNumRows() - 1); // adjust min/max channel if they're only partly selected (i.e. volume column or effect column (when using .MOD) is not covered) if(CreateCursor(0, firstChannel, useVolCol ? VOL_COLUMN : EFFECT_COLUMN) < (m_dwBeginSel & 0xFFFF)) @@ -3071,7 +3073,8 @@ m_nLastPlayedOrder = nOrd; } - if (nRow < m_nLastPlayedRow) { + if (nRow < m_nLastPlayedRow) + { InvalidateChannelsHeaders(); } m_nLastPlayedRow = nRow; @@ -3092,12 +3095,14 @@ } */ - if (nOrd >= pSndFile->Order.GetLength() || pSndFile->Order[nOrd] != nPat) { + if (nOrd >= pSndFile->Order.GetLength() || pSndFile->Order[nOrd] != nPat) + { //order doesn't correlate with pattern, so mark it as invalid nOrd = 0xFFFF; } - if (m_pEffectVis && m_pEffectVis->m_hWnd) { + if (m_pEffectVis && m_pEffectVis->m_hWnd) + { m_pEffectVis->SetPlayCursor(nPat, nRow); } @@ -4948,7 +4953,7 @@ if (pModDoc->GetSplitKeyboardSettings()->octaveLink && note <= NOTE_MAX) { note += 12 * pModDoc->GetSplitKeyboardSettings()->octaveModifier; - note = CLAMP(note, NOTE_MIN, NOTE_MAX); + Limit(note, NOTE_MIN, NOTE_MAX); } if (pModDoc->GetSplitKeyboardSettings()->splitInstrument) { @@ -4969,27 +4974,34 @@ { CHAR s[512]; bool itemFound; - for (UINT plug=0; plug<=MAX_MIXPLUGINS; plug++) { + for (UINT plug=0; plug<=MAX_MIXPLUGINS; plug++) + { itemFound=false; s[0] = 0; - if (!plug) { + if (!plug) + { strcpy(s, "No plugin"); itemFound=true; - } else { + } else + { PSNDMIXPLUGIN p = &(pSndFile->m_MixPlugins[plug-1]); - if (p->Info.szLibraryName[0]) { + if (p->Info.szLibraryName[0]) + { wsprintf(s, "FX%d: %s", plug, p->Info.szName); itemFound=true; } } - if (itemFound){ - m_nMenuOnChan=nChn+1; - if (plug == pSndFile->ChnSettings[nChn].nMixPlugin) { + if (itemFound) + { + m_nMenuOnChan = nChn + 1; + if (plug == pSndFile->ChnSettings[nChn].nMixPlugin) + { AppendMenu(hMenu, (MF_STRING|MF_CHECKED), ID_PLUGSELECT+plug, s); - } else { + } else + { AppendMenu(hMenu, MF_STRING, ID_PLUGSELECT+plug, s); } } @@ -5006,7 +5018,8 @@ bool bSolo = false, bUnmuteAll = false; bool bSoloPending = false, bUnmuteAllPending = false; // doesn't work perfectly yet - for (CHANNELINDEX i = 0; i < pSndFile->m_nChannels; i++) { + for (CHANNELINDEX i = 0; i < pSndFile->m_nChannels; i++) + { if (i != nChn) { if (!(pSndFile->ChnSettings[i].dwFlags & CHN_MUTE)) bSolo = bSoloPending = true; @@ -5024,8 +5037,7 @@ if (bUnmuteAll) AppendMenu(hMenu, MF_STRING, ID_PATTERN_UNMUTEALL, "Unmute All\t" + ih->GetKeyTextFromCommand(kcChannelUnmuteAll)); AppendMenu(hMenu, - pSndFile->m_bChannelMuteTogglePending[nChn] ? - (MF_STRING|MF_CHECKED) : MF_STRING, + pSndFile->m_bChannelMuteTogglePending[nChn] ? (MF_STRING|MF_CHECKED) : MF_STRING, ID_PATTERN_TRANSITIONMUTE, (pSndFile->ChnSettings[nChn].dwFlags & CHN_MUTE) ? "On transition: Unmute\t" + ih->GetKeyTextFromCommand(kcToggleChanMuteOnPatTransition) : @@ -5052,12 +5064,7 @@ bool CViewPattern::BuildRowInsDelCtxMenu(HMENU hMenu, CInputHandler* ih) //---------------------------------------------------------------------- { - CString label = ""; - if (GetSelectionStartRow() != GetSelectionEndRow()) { - label = "Rows"; - } else { - label = "Row"; - } + const CString label = (GetSelectionStartRow() != GetSelectionEndRow() ? "Rows" : "Row"); AppendMenu(hMenu, MF_STRING, ID_PATTERN_INSERTROW, "Insert " + label + "\t" + ih->GetKeyTextFromCommand(kcInsertRow)); AppendMenu(hMenu, MF_STRING, ID_PATTERN_DELETEROW, "Delete " + label + "\t" + ih->GetKeyTextFromCommand(kcDeleteRows) ); @@ -5241,7 +5248,8 @@ //AppendMenu(hMenu, MF_STRING, ID_RUN_SCRIPT, "Run script"); - if (!greyed || !(CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_OLDCTXMENUSTYLE)) { + if (!greyed || !(CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_OLDCTXMENUSTYLE)) + { AppendMenu(hMenu, MF_STRING|greyed, ID_TRANSPOSE_UP, "Transpose +1\t" + ih->GetKeyTextFromCommand(kcTransposeUp)); AppendMenu(hMenu, MF_STRING|greyed, ID_TRANSPOSE_DOWN, "Transpose -1\t" + ih->GetKeyTextFromCommand(kcTransposeDown)); AppendMenu(hMenu, MF_STRING|greyed, ID_TRANSPOSE_OCTUP, "Transpose +12\t" + ih->GetKeyTextFromCommand(kcTransposeOctUp)); @@ -5257,7 +5265,8 @@ CArray<UINT, UINT> validChans; DWORD greyed = (ListChansWhereColSelected(VOL_COLUMN, validChans)>0)?FALSE:MF_GRAYED; - if (!greyed || !(CMainFrame::GetSettings().m_dwPatternSetup&PATTERN_OLDCTXMENUSTYLE)) { + if (!greyed || !(CMainFrame::GetSettings().m_dwPatternSetup&PATTERN_OLDCTXMENUSTYLE)) + { AppendMenu(hMenu, MF_STRING|greyed, ID_PATTERN_AMPLIFY, "Amplify\t" + ih->GetKeyTextFromCommand(kcPatternAmplify)); return true; } @@ -5450,13 +5459,16 @@ UINT startChan = GetSelectionStartChan(); UINT endChan = GetSelectionEndChan(); - if (GetColTypeFromCursor(m_dwBeginSel) <= colType) { + if (GetColTypeFromCursor(m_dwBeginSel) <= colType) + { chans.Add(startChan); //first selected chan includes this col type } - for (UINT chan=startChan+1; chan<endChan; chan++) { + for (UINT chan=startChan+1; chan<endChan; chan++) + { chans.Add(chan); //All chans between first & last must include this col type } - if ((startChan != endChan) && colType <= GetColTypeFromCursor(m_dwEndSel)) { + if ((startChan != endChan) && colType <= GetColTypeFromCursor(m_dwEndSel)) + { chans.Add(endChan); //last selected chan includes this col type } Modified: trunk/OpenMPT/mptrack/misc_util.h =================================================================== --- trunk/OpenMPT/mptrack/misc_util.h 2011-08-31 17:51:46 UTC (rev 1002) +++ trunk/OpenMPT/mptrack/misc_util.h 2011-08-31 18:00:14 UTC (rev 1003) @@ -1,5 +1,6 @@ #ifndef MISC_UTIL_H #define MISC_UTIL_H +#pragma once #include <sstream> #include <string> @@ -41,17 +42,30 @@ // Memset given object to zero. template <class T> -inline void MemsetZero(T& a) -//_------------------------- +inline void MemsetZero(T &a) +//-------------------------- { - #if _HAS_TR1 - static_assert(std::tr1::is_pointer<T>::value == false, "Won't memset pointers."); - static_assert(std::tr1::is_pod<T>::value == true, "Won't memset non-pods."); - #endif +#if _HAS_TR1 + static_assert(std::tr1::is_pointer<T>::value == false, "Won't memset pointers."); + static_assert(std::tr1::is_pod<T>::value == true, "Won't memset non-pods."); +#endif memset(&a, 0, sizeof(T)); } +// Copy given object to other location. +template <class T> +inline void MemCopy(T &destination, T &source) +//-------------------------------------------- +{ +#if _HAS_TR1 + static_assert(std::tr1::is_pointer<T>::value == false, "Won't copy pointers."); + static_assert(std::tr1::is_pod<T>::value == true, "Won't copy non-pods."); +#endif + memcpy(&destination, &source, 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. @@ -65,6 +79,18 @@ } +// Like Limit, but returns value +template<class T, class C> +inline T Clamp(T val, const C lowerLimit, const C upperLimit) +//----------------------------------------------------------- +{ + if(lowerLimit > upperLimit) return val; + if(val < lowerLimit) return lowerLimit; + else if(val > upperLimit) return upperLimit; + else return val; +} + + // Like Limit, but with upperlimit only. template<class T, class C> inline void LimitMax(T& val, const C upperLimit) @@ -151,7 +177,7 @@ template <class T> inline const T& Min(const T& a, const T& b) {return (std::min)(a, b);} // Returns maximum value of given integer type. - template <class T> inline T MaxValueOfType(const T&) {static_assert(std::numeric_limits<T>::is_integer == true, "Only interger types are allowed."); return (std::numeric_limits<T>::max)();} + template <class T> inline T MaxValueOfType(const T&) {static_assert(std::numeric_limits<T>::is_integer == true, "Only integer types are allowed."); return (std::numeric_limits<T>::max)();} /// Returns value rounded to nearest integer. inline double Round(const double& val) {return std::floor(val + 0.5);} Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-08-31 17:51:46 UTC (rev 1002) +++ trunk/OpenMPT/mptrack/version.h 2011-08-31 18:00:14 UTC (rev 1003) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 13 +#define VER_MINORMINOR 14 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of Modified: trunk/OpenMPT/soundlib/pattern.cpp =================================================================== --- trunk/OpenMPT/soundlib/pattern.cpp 2011-08-31 17:51:46 UTC (rev 1002) +++ trunk/OpenMPT/soundlib/pattern.cpp 2011-08-31 18:00:14 UTC (rev 1003) @@ -252,9 +252,15 @@ MODCOMMAND *CPattern::AllocatePattern(ROWINDEX rows, CHANNELINDEX nchns) //---------------------------------------------------------------------- { - MODCOMMAND *p = new MODCOMMAND[rows*nchns]; - if (p) memset(p, 0, rows*nchns*sizeof(MODCOMMAND)); - return p; + try + { + MODCOMMAND *p = new MODCOMMAND[rows*nchns]; + memset(p, 0, rows * nchns * sizeof(MODCOMMAND)); + return p; + } catch (...) + { + return nullptr; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-02 19:08:26
|
Revision: 1008 http://modplug.svn.sourceforge.net/modplug/?rev=1008&view=rev Author: saga-games Date: 2011-09-02 19:08:16 +0000 (Fri, 02 Sep 2011) Log Message: ----------- [Ref] Made access to CSoundFile::Samples protected + a few smaller changes Modified Paths: -------------- trunk/OpenMPT/mptrack/CleanupSong.cpp trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Ctrl_pat.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/MPTHacks.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/ModConvert.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp trunk/OpenMPT/mptrack/Undo.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/View_tre.h trunk/OpenMPT/mptrack/mod2midi.cpp trunk/OpenMPT/mptrack/test/test.cpp trunk/OpenMPT/mptrack/view_com.cpp trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/LOAD_DMF.CPP trunk/OpenMPT/soundlib/Load_okt.cpp trunk/OpenMPT/soundlib/Sampleio.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/modsmp_ctrl.cpp Modified: trunk/OpenMPT/mptrack/CleanupSong.cpp =================================================================== --- trunk/OpenMPT/mptrack/CleanupSong.cpp 2011-09-02 15:00:22 UTC (rev 1007) +++ trunk/OpenMPT/mptrack/CleanupSong.cpp 2011-09-02 19:08:16 UTC (rev 1008) @@ -523,7 +523,7 @@ vector<bool> samplesUsed(pSndFile->GetNumSamples() + 1, true); BeginWaitCursor(); - for (SAMPLEINDEX nSmp = pSndFile->GetNumSamples(); nSmp >= 1; nSmp--) if (pSndFile->Samples[nSmp].pSample) + for (SAMPLEINDEX nSmp = pSndFile->GetNumSamples(); nSmp >= 1; nSmp--) if (pSndFile->GetSample(nSmp).pSample) { if (!pSndFile->IsSampleUsed(nSmp)) { @@ -551,7 +551,7 @@ CriticalSection cs; for (SAMPLEINDEX nSmp = 1; nSmp <= pSndFile->GetNumSamples(); nSmp++) { - if ((!samplesUsed[nSmp]) && (pSndFile->Samples[nSmp].pSample)) + if ((!samplesUsed[nSmp]) && (pSndFile->GetSample(nSmp).pSample)) { m_pModDoc->GetSampleUndo()->PrepareUndo(nSmp, sundo_delete); pSndFile->DestroySample(nSmp); @@ -580,8 +580,8 @@ for (SAMPLEINDEX nSmp=1; nSmp <= pSndFile->m_nSamples; nSmp++) { - if(pSndFile->Samples[nSmp].pSample && (pSndFile->Samples[nSmp].uFlags & CHN_LOOP) - && (pSndFile->Samples[nSmp].nLength > pSndFile->Samples[nSmp].nLoopEnd + 2)) nLoopOpt++; + if(pSndFile->GetSample(nSmp).pSample && (pSndFile->GetSample(nSmp).uFlags & CHN_LOOP) + && (pSndFile->GetSample(nSmp).nLength > pSndFile->GetSample(nSmp).nLoopEnd + 2)) nLoopOpt++; } if (nLoopOpt == 0) return false; @@ -592,14 +592,15 @@ { for (SAMPLEINDEX nSmp = 1; nSmp <= pSndFile->m_nSamples; nSmp++) { - if ((pSndFile->Samples[nSmp].uFlags & CHN_LOOP) - && (pSndFile->Samples[nSmp].nLength > pSndFile->Samples[nSmp].nLoopEnd + 2)) + MODSAMPLE &sample = pSndFile->GetSample(nSmp); + if ((sample.uFlags & CHN_LOOP) + && (sample.nLength > sample.nLoopEnd + 2)) { - UINT lmax = pSndFile->Samples[nSmp].nLoopEnd + 2; - if ((lmax < pSndFile->Samples[nSmp].nLength) && (lmax >= 2)) + UINT lmax = sample.nLoopEnd + 2; + if ((lmax < sample.nLength) && (lmax >= 2)) { - m_pModDoc->GetSampleUndo()->PrepareUndo(nSmp, sundo_delete, lmax, pSndFile->Samples[nSmp].nLength); - ctrlSmp::ResizeSample(pSndFile->Samples[nSmp], lmax, pSndFile); + m_pModDoc->GetSampleUndo()->PrepareUndo(nSmp, sundo_delete, lmax, sample.nLength); + ctrlSmp::ResizeSample(sample, lmax, pSndFile); } } } @@ -631,7 +632,7 @@ // First, find out which sample slots are unused and create the new sample map for(SAMPLEINDEX i = 1; i <= pSndFile->GetNumSamples(); i++) { - if(!pSndFile->Samples[i].pSample) + if(pSndFile->GetSample(i).pSample == nullptr) { // Move all following samples nRemap++; @@ -652,7 +653,7 @@ // This gotta be moved CriticalSection cs; pSndFile->MoveSample(i, nSampleMap[i]); - pSndFile->Samples[i].pSample = nullptr; + pSndFile->GetSample(i).pSample = nullptr; if(nSampleMap[i] > 0) strcpy(pSndFile->m_szNames[nSampleMap[i]], pSndFile->m_szNames[i]); MemsetZero(pSndFile->m_szNames[i]); @@ -965,7 +966,7 @@ for (SAMPLEINDEX nSmp = 1; nSmp <= pSndFile->GetNumSamples(); nSmp++) { - m_pModDoc->GetSampleUndo()->PrepareUndo(nSmp, sundo_delete, 0, pSndFile->Samples[nSmp].nLength); + m_pModDoc->GetSampleUndo()->PrepareUndo(nSmp, sundo_delete, 0, pSndFile->GetSample(nSmp).nLength); } ctrlSmp::ResetSamples(*pSndFile, ctrlSmp::SmpResetInit); Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-09-02 15:00:22 UTC (rev 1007) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-09-02 19:08:16 UTC (rev 1008) @@ -1881,7 +1881,7 @@ for(BYTE i = 0; i < CountOf(pIns->Keyboard); i++) { const SAMPLEINDEX smp = pIns->Keyboard[i]; - if(smp <= m_pSndFile->GetNumSamples() && m_pSndFile->Samples[smp].uFlags & CHN_PANNING) + if(smp <= m_pSndFile->GetNumSamples() && m_pSndFile->GetSample(smp).uFlags & CHN_PANNING) { smpPanningInUse = true; break; @@ -1900,7 +1900,7 @@ { const SAMPLEINDEX smp = pIns->Keyboard[i]; if(smp <= m_pSndFile->GetNumSamples()) - m_pSndFile->Samples[smp].uFlags &= ~CHN_PANNING; + m_pSndFile->GetSample(smp).uFlags &= ~CHN_PANNING; } m_pModDoc->UpdateAllViews(NULL, HINT_SAMPLEINFO | HINT_MODTYPE); } Modified: trunk/OpenMPT/mptrack/Ctrl_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2011-09-02 15:00:22 UTC (rev 1007) +++ trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2011-09-02 19:08:16 UTC (rev 1008) @@ -307,8 +307,8 @@ } else { UINT nmax = m_pSndFile->m_nSamples; - while ((nmax > 1) && (m_pSndFile->Samples[nmax].pSample == NULL) && (!m_pSndFile->m_szNames[nmax][0])) nmax--; - for (UINT i=1; i<=nmax; i++) if ((m_pSndFile->m_szNames[i][0]) || (m_pSndFile->Samples[i].pSample)) + while ((nmax > 1) && (m_pSndFile->GetSample(nmax).pSample == nullptr) && (!m_pSndFile->m_szNames[nmax][0])) nmax--; + for (UINT i=1; i<=nmax; i++) if ((m_pSndFile->m_szNames[i][0]) || (m_pSndFile->GetSample(i).pSample)) { if (m_pModDoc->GetSplitKeyboardSettings()->IsSplitActive() && nSplitIns < ARRAYELEMCOUNT(m_pSndFile->m_szNames)) wsprintf(s, szSplitFormat, nSplitIns, GetNoteStr(noteSplit), i, m_pSndFile->m_szNames[nSplitIns], m_pSndFile->m_szNames[i]); Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-09-02 15:00:22 UTC (rev 1007) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-09-02 19:08:16 UTC (rev 1008) @@ -522,8 +522,8 @@ case IDC_COMBO_BASENOTE: if ((m_pSndFile) && (m_pSndFile->m_nType & (MOD_TYPE_XM|MOD_TYPE_MOD)) && (m_nSample)) { - MODSAMPLE *pSmp = &m_pSndFile->Samples[m_nSample]; - UINT nFreqHz = CSoundFile::TransposeToFrequency(pSmp->RelativeTone, pSmp->nFineTune); + const MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); + UINT nFreqHz = CSoundFile::TransposeToFrequency(sample.RelativeTone, sample.nFineTune); wsprintf(pszText, "%ldHz", nFreqHz); return TRUE; } @@ -623,49 +623,49 @@ // Updating Values if (dwHintMask & (HINT_MODTYPE|HINT_SAMPLEINFO)) { - MODSAMPLE *pSmp = &m_pSndFile->Samples[m_nSample]; + const MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); CHAR s[128]; DWORD d; // Length / Type - wsprintf(s, "%d-bit %s, len: %d", pSmp->GetElementarySampleSize() * 8, (pSmp->uFlags & CHN_STEREO) ? "stereo" : "mono", pSmp->nLength); + wsprintf(s, "%d-bit %s, len: %d", sample.GetElementarySampleSize() * 8, (sample.uFlags & CHN_STEREO) ? "stereo" : "mono", sample.nLength); SetDlgItemText(IDC_TEXT5, s); // Name memcpy(s, m_pSndFile->m_szNames[m_nSample], MAX_SAMPLENAME); s[31] = 0; SetDlgItemText(IDC_SAMPLE_NAME, s); // File Name - memcpy(s, pSmp->filename, MAX_SAMPLEFILENAME); + memcpy(s, sample.filename, MAX_SAMPLEFILENAME); s[21] = 0; if (m_pSndFile->m_nType & (MOD_TYPE_MOD|MOD_TYPE_XM)) s[0] = 0; SetDlgItemText(IDC_SAMPLE_FILENAME, s); // Volume - SetDlgItemInt(IDC_EDIT7, pSmp->nVolume >> 2); + SetDlgItemInt(IDC_EDIT7, sample.nVolume >> 2); // Global Volume - SetDlgItemInt(IDC_EDIT8, pSmp->nGlobalVol); + SetDlgItemInt(IDC_EDIT8, sample.nGlobalVol); // Panning - CheckDlgButton(IDC_CHECK1, (pSmp->uFlags & CHN_PANNING) ? MF_CHECKED : MF_UNCHECKED); + CheckDlgButton(IDC_CHECK1, (sample.uFlags & CHN_PANNING) ? MF_CHECKED : MF_UNCHECKED); //rewbs.fix36944 if (m_pSndFile->m_nType == MOD_TYPE_XM) { - SetDlgItemInt(IDC_EDIT9, pSmp->nPan); //displayed panning with XM is 0-256, just like MPT's internal engine + SetDlgItemInt(IDC_EDIT9, sample.nPan); //displayed panning with XM is 0-256, just like MPT's internal engine } else { - SetDlgItemInt(IDC_EDIT9, pSmp->nPan>>2); //displayed panning with anything but XM is 0-64 so we divide by 4 + SetDlgItemInt(IDC_EDIT9, sample.nPan>>2); //displayed panning with anything but XM is 0-64 so we divide by 4 } //end rewbs.fix36944 // FineTune / C-4 Speed / BaseNote int transp = 0; if (m_pSndFile->m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT)) { - wsprintf(s, "%lu", pSmp->nC5Speed); + wsprintf(s, "%lu", sample.nC5Speed); m_EditFineTune.SetWindowText(s); - transp = CSoundFile::FrequencyToTranspose(pSmp->nC5Speed) >> 7; + transp = CSoundFile::FrequencyToTranspose(sample.nC5Speed) >> 7; } else { - int ftune = ((int)pSmp->nFineTune); + int ftune = ((int)sample.nFineTune); // MOD finetune range -8 to 7 translates to -128 to 112 if(m_pSndFile->m_nType & MOD_TYPE_MOD) ftune >>= 4; SetDlgItemInt(IDC_EDIT5, ftune); - transp = (int)pSmp->RelativeTone; + transp = (int)sample.RelativeTone; } int basenote = 60 - transp; if (basenote < BASENOTE_MIN) basenote = BASENOTE_MIN; @@ -673,25 +673,25 @@ basenote -= BASENOTE_MIN; if (basenote != m_CbnBaseNote.GetCurSel()) m_CbnBaseNote.SetCurSel(basenote); // AutoVibrato - m_ComboAutoVib.SetCurSel(pSmp->nVibType); - SetDlgItemInt(IDC_EDIT14, (UINT)pSmp->nVibSweep); - SetDlgItemInt(IDC_EDIT15, (UINT)pSmp->nVibDepth); - SetDlgItemInt(IDC_EDIT16, (UINT)pSmp->nVibRate); + m_ComboAutoVib.SetCurSel(sample.nVibType); + SetDlgItemInt(IDC_EDIT14, (UINT)sample.nVibSweep); + SetDlgItemInt(IDC_EDIT15, (UINT)sample.nVibDepth); + SetDlgItemInt(IDC_EDIT16, (UINT)sample.nVibRate); // Loop d = 0; - if (pSmp->uFlags & CHN_LOOP) d = (pSmp->uFlags & CHN_PINGPONGLOOP) ? 2 : 1; + if (sample.uFlags & CHN_LOOP) d = (sample.uFlags & CHN_PINGPONGLOOP) ? 2 : 1; m_ComboLoopType.SetCurSel(d); - wsprintf(s, "%lu", pSmp->nLoopStart); + wsprintf(s, "%lu", sample.nLoopStart); m_EditLoopStart.SetWindowText(s); - wsprintf(s, "%lu", pSmp->nLoopEnd); + wsprintf(s, "%lu", sample.nLoopEnd); m_EditLoopEnd.SetWindowText(s); // Sustain Loop d = 0; - if (pSmp->uFlags & CHN_SUSTAINLOOP) d = (pSmp->uFlags & CHN_PINGPONGSUSTAIN) ? 2 : 1; + if (sample.uFlags & CHN_SUSTAINLOOP) d = (sample.uFlags & CHN_PINGPONGSUSTAIN) ? 2 : 1; m_ComboSustainType.SetCurSel(d); - wsprintf(s, "%lu", pSmp->nSustainStart); + wsprintf(s, "%lu", sample.nSustainStart); m_EditSustainStart.SetWindowText(s); - wsprintf(s, "%lu", pSmp->nSustainEnd); + wsprintf(s, "%lu", sample.nSustainEnd); m_EditSustainEnd.SetWindowText(s); } if (!m_bInitialized) @@ -746,17 +746,17 @@ BeginWaitCursor(); UINT flags = 0; - MODSAMPLE *pSmp = &m_pSndFile->Samples[m_nSample]; + MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); CriticalSection cs; m_pSndFile->DestroySample(m_nSample); - pSmp->nLength = len; - pSmp->uFlags = RS_PCM8S; + sample.nLength = len; + sample.uFlags = RS_PCM8S; if (dlg.GetSampleFormat() & ER_16BIT) { - pSmp->nLength >>= 1; + sample.nLength >>= 1; flags = RS_PCM16S; } if (dlg.GetSampleFormat() & ER_UNSIGNED) @@ -766,25 +766,25 @@ // Interleaved Stereo Sample if (dlg.GetSampleFormat() & ER_STEREO) { - pSmp->nLength >>= 1; + sample.nLength >>= 1; flags |= 0x40|RSF_STEREO; } LPSTR p16 = (LPSTR)lpFile; DWORD l16 = len; - if ((pSmp->uFlags & CHN_16BIT) && (len & 1)) + if ((sample.uFlags & CHN_16BIT) && (len & 1)) { p16++; l16--; } - if (m_pSndFile->ReadSample(pSmp, flags, p16, l16)) + if (m_pSndFile->ReadSample(&sample, flags, p16, l16)) { bOk = true; - pSmp->nGlobalVol = 64; - pSmp->nVolume = 256; - pSmp->nPan = 128; - pSmp->filename[0] = 0; - if (!pSmp->nC5Speed) pSmp->nC5Speed = 22050; + sample.nGlobalVol = 64; + sample.nVolume = 256; + sample.nPan = 128; + sample.filename[0] = 0; + if (!sample.nC5Speed) sample.nC5Speed = 22050; } else { m_pModDoc->GetSampleUndo()->Undo(m_nSample); @@ -801,9 +801,9 @@ EndWaitCursor(); if (bOk) { - MODSAMPLE *pSmp = &m_pSndFile->Samples[m_nSample]; + MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); CMainFrame::GetSettings().SetWorkingDirectory(lpszFileName, DIR_SAMPLES, true); - if (!pSmp->filename[0]) + if (!sample.filename[0]) { CHAR szFullFilename[_MAX_PATH]; _splitpath(lpszFileName, 0, 0, szName, szExt); @@ -824,12 +824,12 @@ if (strlen(szFullFilename) < 9) strcat(szFullFilename, szExt); } szFullFilename[21] = 0; - memcpy(pSmp->filename, szFullFilename, MAX_SAMPLEFILENAME); + memcpy(sample.filename, szFullFilename, MAX_SAMPLEFILENAME); } - if ((m_pSndFile->m_nType & MOD_TYPE_XM) && (!(pSmp->uFlags & CHN_PANNING))) + if ((m_pSndFile->m_nType & MOD_TYPE_XM) && (!(sample.uFlags & CHN_PANNING))) { - pSmp->nPan = 128; - pSmp->uFlags |= CHN_PANNING; + sample.nPan = 128; + sample.uFlags |= CHN_PANNING; } m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA | HINT_SAMPLEINFO | HINT_SMPNAMES, NULL); m_pModDoc->SetModified(); @@ -850,11 +850,11 @@ m_pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_replace); m_pSndFile->DestroySample(m_nSample); m_pSndFile->ReadSampleFromSong(m_nSample, pSndFile, nSample); - MODSAMPLE *pSmp = &m_pSndFile->Samples[m_nSample]; - if ((m_pSndFile->m_nType & MOD_TYPE_XM) && (!(pSmp->uFlags & CHN_PANNING))) + MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); + if ((m_pSndFile->m_nType & MOD_TYPE_XM) && (!(sample.uFlags & CHN_PANNING))) { - pSmp->nPan = 128; - pSmp->uFlags |= CHN_PANNING; + sample.nPan = 128; + sample.uFlags |= CHN_PANNING; } cs.Leave(); @@ -922,12 +922,12 @@ if(bDuplicate && nOldSmp >= 1 && nOldSmp < MAX_SAMPLES) { m_pModDoc->GetSampleUndo()->PrepareUndo(smp, sundo_replace); - memcpy(&m_pSndFile->Samples[smp], &m_pSndFile->Samples[nOldSmp], sizeof(MODSAMPLE)); + MemCopy(m_pSndFile->GetSample(smp), m_pSndFile->GetSample(nOldSmp)); strcpy(m_pSndFile->m_szNames[smp], m_pSndFile->m_szNames[nOldSmp]); // clone sample. - if((m_pSndFile->Samples[smp].pSample = CSoundFile::AllocateSample(m_pSndFile->Samples[nOldSmp].GetSampleSizeInBytes())) != nullptr) + if((m_pSndFile->GetSample(smp).pSample = CSoundFile::AllocateSample(m_pSndFile->GetSample(nOldSmp).GetSampleSizeInBytes())) != nullptr) { - memcpy(m_pSndFile->Samples[smp].pSample, m_pSndFile->Samples[nOldSmp].pSample, m_pSndFile->Samples[nOldSmp].GetSampleSizeInBytes()); + memcpy(m_pSndFile->GetSample(smp).pSample, m_pSndFile->GetSample(nOldSmp).pSample, m_pSndFile->GetSample(nOldSmp).GetSampleSizeInBytes()); } } @@ -1002,14 +1002,14 @@ if(!bBatchSave) { // save this sample - if ((!m_nSample) || (!m_pSndFile->Samples[m_nSample].pSample)) + if ((!m_nSample) || (m_pSndFile->GetSample(m_nSample).pSample == nullptr)) { SwitchToView(); return; } if (m_pSndFile->m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT)) { - strncpy(szFileName, m_pSndFile->Samples[m_nSample].filename, min(CountOf(m_pSndFile->Samples[m_nSample].filename), CountOf(szFileName) - 1)); + strncpy(szFileName, m_pSndFile->GetSample(m_nSample).filename, min(CountOf(m_pSndFile->GetSample(m_nSample).filename), CountOf(szFileName) - 1)); } else { strncpy(szFileName, m_pSndFile->m_szNames[m_nSample], min(CountOf(m_pSndFile->m_szNames[m_nSample]), CountOf(szFileName) - 1)); @@ -1045,18 +1045,18 @@ _splitpath(files.first_file.c_str(), NULL, NULL, NULL, ext); bool bOk = false; - UINT iMinSmp = m_nSample, iMaxSmp = m_nSample; + SAMPLEINDEX iMinSmp = m_nSample, iMaxSmp = m_nSample; CString sFilename = files.first_file.c_str(), sNumberFormat; if(bBatchSave) { iMinSmp = 1; - iMaxSmp = m_pSndFile->m_nSamples; + iMaxSmp = m_pSndFile->GetNumSamples(); sNumberFormat.Format("%s%d%s", "%.", ((int)log10((float)iMaxSmp)) + 1, "d"); } - for(UINT iSmp = iMinSmp; iSmp <= iMaxSmp; iSmp++) + for(SAMPLEINDEX iSmp = iMinSmp; iSmp <= iMaxSmp; iSmp++) { - if (m_pSndFile->Samples[iSmp].pSample) + if (m_pSndFile->GetSample(iSmp).pSample) { if(bBatchSave) { @@ -1065,7 +1065,7 @@ sSampleNumber.Format(sNumberFormat, iSmp); strcpy(sSampleName, (m_pSndFile->m_szNames[iSmp]) ? m_pSndFile->m_szNames[iSmp] : "untitled"); - strcpy(sSampleFilename, (m_pSndFile->Samples[iSmp].filename[0]) ? m_pSndFile->Samples[iSmp].filename : m_pSndFile->m_szNames[iSmp]); + strcpy(sSampleFilename, (m_pSndFile->GetSample(iSmp).filename[0]) ? m_pSndFile->GetSample(iSmp).filename : m_pSndFile->m_szNames[iSmp]); SanitizeFilename(sSampleName); SanitizeFilename(sSampleFilename); @@ -1145,34 +1145,34 @@ for(SAMPLEINDEX iSmp = iMinSample; iSmp <= iMaxSample; iSmp++) { - if (m_pSndFile->Samples[iSmp].pSample) + if (m_pSndFile->GetSample(iSmp).pSample) { bool bOk = false; - MODSAMPLE *pSmp = &m_pSndFile->Samples[iSmp]; + MODSAMPLE &sample = m_pSndFile->GetSample(iSmp); if(iMinSample != iMaxSample) { //if more than one sample is selected, always amplify the whole sample. iStart = 0; - iEnd = pSmp->nLength; + iEnd = sample.nLength; } else { //one sample: correct the boundaries, if needed - if (iEnd > pSmp->nLength) iEnd = pSmp->nLength; + if (iEnd > sample.nLength) iEnd = sample.nLength; if (iStart > iEnd) iStart = iEnd; if (iStart == iEnd) { iStart = 0; - iEnd = pSmp->nLength; + iEnd = sample.nLength; } } m_pModDoc->GetSampleUndo()->PrepareUndo(iSmp, sundo_update, iStart, iEnd); - if (pSmp->uFlags & CHN_STEREO) { iStart *= 2; iEnd *= 2; } + if (sample.uFlags & CHN_STEREO) { iStart *= 2; iEnd *= 2; } - if (pSmp->uFlags & CHN_16BIT) + if (sample.uFlags & CHN_16BIT) { - int16 *p = (int16 *)pSmp->pSample; + int16 *p = (int16 *)sample.pSample; int max = 1; for (UINT i = iStart; i < iEnd; i++) { @@ -1191,7 +1191,7 @@ } } else { - int8 *p = (int8 *)pSmp->pSample; + int8 *p = (int8 *)sample.pSample; int max = 1; for (UINT i = iStart; i < iEnd; i++) { @@ -1230,23 +1230,21 @@ void CCtrlSamples::ApplyAmplify(LONG lAmp, bool bFadeIn, bool bFadeOut) //----------------------------------------------------------------------- { - MODSAMPLE *pSmp; - - if ((!m_pModDoc) || (!m_pSndFile) || (!m_pSndFile->Samples[m_nSample].pSample)) return; + if ((!m_pModDoc) || (!m_pSndFile) || (!m_pSndFile->GetSample(m_nSample).pSample)) return; BeginWaitCursor(); - pSmp = &m_pSndFile->Samples[m_nSample]; + MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); SELECTIONPOINTS selection = GetSelectionPoints(); m_pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_update, selection.nStart, selection.nEnd); - if (pSmp->uFlags & CHN_STEREO) { selection.nStart *= 2; selection.nEnd *= 2; } + if (sample.uFlags & CHN_STEREO) { selection.nStart *= 2; selection.nEnd *= 2; } UINT len = selection.nEnd - selection.nStart; if ((bFadeIn) && (bFadeOut)) lAmp *= 4; - if (pSmp->uFlags & CHN_16BIT) + if (sample.uFlags & CHN_16BIT) { - signed short *p = ((signed short *)pSmp->pSample) + selection.nStart; + signed short *p = ((signed short *)sample.pSample) + selection.nStart; for (UINT i=0; i<len; i++) { @@ -1259,7 +1257,7 @@ } } else { - signed char *p = ((signed char *)pSmp->pSample) + selection.nStart; + signed char *p = ((signed char *)sample.pSample) + selection.nStart; for (UINT i=0; i<len; i++) { @@ -1306,13 +1304,13 @@ { UINT iStart, iEnd; - if(m_pSndFile->Samples[iSmp].pSample == nullptr) + if(m_pSndFile->GetSample(iSmp).pSample == nullptr) continue; if (iMinSample != iMaxSample) { iStart = 0; - iEnd = m_pSndFile->Samples[iSmp].nLength; + iEnd = m_pSndFile->GetSample(iSmp).nLength; } else { @@ -1323,7 +1321,7 @@ m_pModDoc->GetSampleUndo()->PrepareUndo(iSmp, sundo_update, iStart, iEnd); - const float fOffset = ctrlSmp::RemoveDCOffset(m_pSndFile->Samples[iSmp], iStart, iEnd, m_pSndFile->GetType(), m_pSndFile); + const float fOffset = ctrlSmp::RemoveDCOffset(m_pSndFile->GetSample(iSmp), iStart, iEnd, m_pSndFile->GetType(), m_pSndFile); if(fOffset == 0.0f) // No offset removed. continue; @@ -1379,12 +1377,12 @@ void CCtrlSamples::OnQuickFade() //------------------------------ { - if ((!m_pSndFile) || (!m_pSndFile->Samples[m_nSample].pSample)) return; + if ((!m_pSndFile) || (m_pSndFile->GetSample(m_nSample).pSample == nullptr)) return; SELECTIONPOINTS sel = GetSelectionPoints(); - if(sel.bSelected && (sel.nStart == 0 || sel.nEnd == m_pSndFile->Samples[m_nSample].nLength)) + if(sel.bSelected && (sel.nStart == 0 || sel.nEnd == m_pSndFile->GetSample(m_nSample).nLength)) { - ApplyAmplify(100, (sel.nStart == 0), (sel.nEnd == m_pSndFile->Samples[m_nSample].nLength)); + ApplyAmplify(100, (sel.nStart == 0), (sel.nEnd == m_pSndFile->GetSample(m_nSample).nLength)); } else { // Can't apply quick fade as no appropriate selection has been made, so ask the user to amplify the whole sample instead. @@ -1402,41 +1400,41 @@ void CCtrlSamples::OnUpsample() //----------------------------- { - MODSAMPLE *pSmp; DWORD dwStart, dwEnd, dwNewLen; UINT smplsize, newsmplsize; PVOID pOriginal, pNewSample; - if ((!m_pSndFile) || (!m_pSndFile->Samples[m_nSample].pSample)) return; + if ((!m_pSndFile) || (m_pSndFile->GetSample(m_nSample).pSample == nullptr)) return; BeginWaitCursor(); - pSmp = &m_pSndFile->Samples[m_nSample]; + + MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); SELECTIONPOINTS selection = GetSelectionPoints(); dwStart = selection.nStart; dwEnd = selection.nEnd; - if (dwEnd > pSmp->nLength) dwEnd = pSmp->nLength; + if (dwEnd > sample.nLength) dwEnd = sample.nLength; if (dwStart >= dwEnd) { dwStart = 0; - dwEnd = pSmp->nLength; + dwEnd = sample.nLength; } - smplsize = pSmp->GetBytesPerSample(); - newsmplsize = pSmp->GetNumChannels() * 2; // new sample is always 16-Bit - pOriginal = pSmp->pSample; - dwNewLen = pSmp->nLength + (dwEnd-dwStart); + smplsize = sample.GetBytesPerSample(); + newsmplsize = sample.GetNumChannels() * 2; // new sample is always 16-Bit + pOriginal = sample.pSample; + dwNewLen = sample.nLength + (dwEnd-dwStart); pNewSample = NULL; if (dwNewLen+4 <= MAX_SAMPLE_LENGTH) pNewSample = CSoundFile::AllocateSample((dwNewLen+4)*newsmplsize); if (pNewSample) { m_pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_replace); - const UINT nCh = pSmp->GetNumChannels(); + const UINT nCh = sample.GetNumChannels(); for (UINT iCh=0; iCh<nCh; iCh++) { int len = dwEnd-dwStart; - int maxndx = pSmp->nLength; - if (pSmp->uFlags & CHN_16BIT) + 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; @@ -1480,10 +1478,10 @@ } } } - if (pSmp->uFlags & CHN_16BIT) + if (sample.uFlags & CHN_16BIT) { if (dwStart > 0) memcpy(pNewSample, pOriginal, dwStart*smplsize); - if (dwEnd < pSmp->nLength) memcpy(((LPSTR)pNewSample)+(dwStart+(dwEnd-dwStart)*2)*smplsize, ((LPSTR)pOriginal)+(dwEnd*smplsize), (pSmp->nLength-dwEnd)*smplsize); + if (dwEnd < sample.nLength) memcpy(((LPSTR)pNewSample)+(dwStart+(dwEnd-dwStart)*2)*smplsize, ((LPSTR)pOriginal)+(dwEnd*smplsize), (sample.nLength-dwEnd)*smplsize); } else { if (dwStart > 0) @@ -1493,24 +1491,24 @@ ((signed short *)pNewSample)[i] = (signed short)(((signed char *)pOriginal)[i] << 8); } } - if (dwEnd < pSmp->nLength) + if (dwEnd < sample.nLength) { signed short *pdest = ((signed short *)pNewSample) + (dwEnd-dwStart)*nCh; - for (UINT i=dwEnd*nCh; i<pSmp->nLength*nCh; i++) + for (UINT i=dwEnd*nCh; i<sample.nLength*nCh; i++) { pdest[i] = (signed short)(((signed char *)pOriginal)[i] << 8); } } } - if (pSmp->nLoopStart >= dwEnd) pSmp->nLoopStart += (dwEnd-dwStart); else - if (pSmp->nLoopStart > dwStart) pSmp->nLoopStart += (pSmp->nLoopStart - dwStart); - if (pSmp->nLoopEnd >= dwEnd) pSmp->nLoopEnd += (dwEnd-dwStart); else - if (pSmp->nLoopEnd > dwStart) pSmp->nLoopEnd += (pSmp->nLoopEnd - dwStart); - if (pSmp->nSustainStart >= dwEnd) pSmp->nSustainStart += (dwEnd-dwStart); else - if (pSmp->nSustainStart > dwStart) pSmp->nSustainStart += (pSmp->nSustainStart - dwStart); - if (pSmp->nSustainEnd >= dwEnd) pSmp->nSustainEnd += (dwEnd-dwStart); else - if (pSmp->nSustainEnd > dwStart) pSmp->nSustainEnd += (pSmp->nSustainEnd - dwStart); - + if (sample.nLoopStart >= dwEnd) sample.nLoopStart += (dwEnd-dwStart); else + if (sample.nLoopStart > dwStart) sample.nLoopStart += (sample.nLoopStart - dwStart); + if (sample.nLoopEnd >= dwEnd) sample.nLoopEnd += (dwEnd-dwStart); else + if (sample.nLoopEnd > dwStart) sample.nLoopEnd += (sample.nLoopEnd - dwStart); + if (sample.nSustainStart >= dwEnd) sample.nSustainStart += (dwEnd-dwStart); else + if (sample.nSustainStart > dwStart) sample.nSustainStart += (sample.nSustainStart - dwStart); + if (sample.nSustainEnd >= dwEnd) sample.nSustainEnd += (dwEnd-dwStart); else + if (sample.nSustainEnd > dwStart) sample.nSustainEnd += (sample.nSustainEnd - dwStart); + CriticalSection cs; for (UINT iFix=0; iFix<MAX_CHANNELS; iFix++) @@ -1526,13 +1524,13 @@ { if(!(m_pSndFile->m_nType & MOD_TYPE_MOD)) { - if (pSmp->nC5Speed < 200000) pSmp->nC5Speed *= 2; - if (pSmp->RelativeTone < 84) pSmp->RelativeTone += 12; + if (sample.nC5Speed < 200000) sample.nC5Speed *= 2; + if (sample.RelativeTone < 84) sample.RelativeTone += 12; } } - pSmp->uFlags |= CHN_16BIT; - pSmp->pSample = (LPSTR)pNewSample; - pSmp->nLength = dwNewLen; + sample.uFlags |= CHN_16BIT; + sample.pSample = (LPSTR)pNewSample; + sample.nLength = dwNewLen; CSoundFile::FreeSample(pOriginal); @@ -1554,28 +1552,28 @@ void CCtrlSamples::OnDownsample() //------------------------------- { - MODSAMPLE *pSmp; DWORD dwStart, dwEnd, dwRemove, dwNewLen; UINT smplsize; PVOID pOriginal, pNewSample; - if ((!m_pSndFile) || (!m_pSndFile->Samples[m_nSample].pSample)) return; + if ((!m_pSndFile) || (!m_pSndFile->GetSample(m_nSample).pSample)) return; BeginWaitCursor(); - pSmp = &m_pSndFile->Samples[m_nSample]; + + MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); SELECTIONPOINTS selection = GetSelectionPoints(); dwStart = selection.nStart; dwEnd = selection.nEnd; - if (dwEnd > pSmp->nLength) dwEnd = pSmp->nLength; + if (dwEnd > sample.nLength) dwEnd = sample.nLength; if (dwStart >= dwEnd) { dwStart = 0; - dwEnd = pSmp->nLength; + dwEnd = sample.nLength; } - smplsize = pSmp->GetBytesPerSample(); - pOriginal = pSmp->pSample; + smplsize = sample.GetBytesPerSample(); + pOriginal = sample.pSample; dwRemove = (dwEnd-dwStart+1)>>1; - dwNewLen = pSmp->nLength - dwRemove; + dwNewLen = sample.nLength - dwRemove; dwEnd = dwStart+dwRemove*2; pNewSample = NULL; if ((dwNewLen > 32) && (dwRemove)) pNewSample = CSoundFile::AllocateSample((dwNewLen+4)*smplsize); @@ -1584,12 +1582,12 @@ m_pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_replace); - const UINT nCh = pSmp->GetNumChannels(); + const UINT nCh = sample.GetNumChannels(); for (UINT iCh=0; iCh<nCh; iCh++) { int len = dwRemove; - int maxndx = pSmp->nLength; - if (pSmp->uFlags & CHN_16BIT) + 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; @@ -1632,17 +1630,17 @@ } } if (dwStart > 0) memcpy(pNewSample, pOriginal, dwStart*smplsize); - if (dwEnd < pSmp->nLength) memcpy(((LPSTR)pNewSample)+(dwStart+dwRemove)*smplsize, ((LPSTR)pOriginal)+((dwStart+dwRemove*2)*smplsize), (pSmp->nLength-dwEnd)*smplsize); - if (pSmp->nLoopStart >= dwEnd) pSmp->nLoopStart -= dwRemove; else - if (pSmp->nLoopStart > dwStart) pSmp->nLoopStart -= (pSmp->nLoopStart - dwStart)/2; - if (pSmp->nLoopEnd >= dwEnd) pSmp->nLoopEnd -= dwRemove; else - if (pSmp->nLoopEnd > dwStart) pSmp->nLoopEnd -= (pSmp->nLoopEnd - dwStart)/2; - if (pSmp->nLoopEnd > dwNewLen) pSmp->nLoopEnd = dwNewLen; - if (pSmp->nSustainStart >= dwEnd) pSmp->nSustainStart -= dwRemove; else - if (pSmp->nSustainStart > dwStart) pSmp->nSustainStart -= (pSmp->nSustainStart - dwStart)/2; - if (pSmp->nSustainEnd >= dwEnd) pSmp->nSustainEnd -= dwRemove; else - if (pSmp->nSustainEnd > dwStart) pSmp->nSustainEnd -= (pSmp->nSustainEnd - dwStart)/2; - if (pSmp->nSustainEnd > dwNewLen) pSmp->nSustainEnd = dwNewLen; + if (dwEnd < sample.nLength) memcpy(((LPSTR)pNewSample)+(dwStart+dwRemove)*smplsize, ((LPSTR)pOriginal)+((dwStart+dwRemove*2)*smplsize), (sample.nLength-dwEnd)*smplsize); + if (sample.nLoopStart >= dwEnd) sample.nLoopStart -= dwRemove; else + if (sample.nLoopStart > dwStart) sample.nLoopStart -= (sample.nLoopStart - dwStart)/2; + if (sample.nLoopEnd >= dwEnd) sample.nLoopEnd -= dwRemove; else + if (sample.nLoopEnd > dwStart) sample.nLoopEnd -= (sample.nLoopEnd - dwStart)/2; + if (sample.nLoopEnd > dwNewLen) sample.nLoopEnd = dwNewLen; + if (sample.nSustainStart >= dwEnd) sample.nSustainStart -= dwRemove; else + if (sample.nSustainStart > dwStart) sample.nSustainStart -= (sample.nSustainStart - dwStart)/2; + if (sample.nSustainEnd >= dwEnd) sample.nSustainEnd -= dwRemove; else + if (sample.nSustainEnd > dwStart) sample.nSustainEnd -= (sample.nSustainEnd - dwStart)/2; + if (sample.nSustainEnd > dwNewLen) sample.nSustainEnd = dwNewLen; CriticalSection cs; @@ -1659,12 +1657,12 @@ { if(!(m_pSndFile->m_nType & MOD_TYPE_MOD)) { - if (pSmp->nC5Speed > 2000) pSmp->nC5Speed /= 2; - if (pSmp->RelativeTone > -84) pSmp->RelativeTone -= 12; + if (sample.nC5Speed > 2000) sample.nC5Speed /= 2; + if (sample.RelativeTone > -84) sample.RelativeTone -= 12; } } - pSmp->nLength = dwNewLen; - pSmp->pSample = (LPSTR)pNewSample; + sample.nLength = dwNewLen; + sample.pSample = (LPSTR)pNewSample; CSoundFile::FreeSample(pOriginal); cs.Leave(); @@ -1730,24 +1728,24 @@ } void CCtrlSamples::OnEstimateSampleSize() +//--------------------------------------- { - if((!m_pSndFile) || (!m_pSndFile->Samples[m_nSample].pSample)) return; - MODSAMPLE *pSmp = &m_pSndFile->Samples[m_nSample]; - if(!pSmp) return; + if((!m_pSndFile) || (m_pSndFile->GetSample(m_nSample).pSample == nullptr)) return; + MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); //rewbs.timeStretchMods //Ensure m_dTimeStretchRatio is up-to-date with textbox content UpdateData(TRUE); //Calculate/verify samplerate at C5. - long lSampleRate = pSmp->nC5Speed; + long lSampleRate = sample.nC5Speed; if(m_pSndFile->m_nType & (MOD_TYPE_MOD|MOD_TYPE_XM)) - lSampleRate = CSoundFile::TransposeToFrequency(pSmp->RelativeTone, pSmp->nFineTune); + lSampleRate = CSoundFile::TransposeToFrequency(sample.RelativeTone, sample.nFineTune); if(lSampleRate <= 0) lSampleRate = 8363; //Open dialog - CPSRatioCalc dlg(pSmp->nLength, lSampleRate, + CPSRatioCalc dlg(sample.nLength, lSampleRate, m_pSndFile->m_nMusicSpeed, m_pSndFile->m_nMusicTempo, m_pSndFile->m_nDefaultRowsPerBeat, m_pSndFile->m_nTempoMode, m_dTimeStretchRatio, this); @@ -1761,14 +1759,15 @@ void CCtrlSamples::OnPitchShiftTimeStretch() +//------------------------------------------ { // Error management int errorcode = -1; - if((!m_pSndFile) || (!m_pSndFile->Samples[m_nSample].pSample)) goto error; - MODSAMPLE *pSmp = &m_pSndFile->Samples[m_nSample]; - if(!pSmp || pSmp->nLength == 0) goto error; + if((!m_pSndFile) || (m_pSndFile->GetSample(m_nSample).pSample == nullptr)) goto error; + MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); + // Time stretching if(IsDlgButtonChecked(IDC_CHECK3)) { @@ -1778,10 +1777,10 @@ //Update loop points only if no error occured. if(errorcode == 0) { - pSmp->nLoopStart = (UINT)min(pSmp->nLoopStart * (m_dTimeStretchRatio / 100.0), pSmp->nLength); - pSmp->nLoopEnd = (UINT)min(pSmp->nLoopEnd * (m_dTimeStretchRatio/100.0), pSmp->nLength); - pSmp->nSustainStart = (UINT)min(pSmp->nSustainStart * (m_dTimeStretchRatio/100.0), pSmp->nLength); - pSmp->nSustainEnd = (UINT)min(pSmp->nSustainEnd * (m_dTimeStretchRatio/100.0), pSmp->nLength); + sample.nLoopStart = (UINT)min(sample.nLoopStart * (m_dTimeStretchRatio / 100.0), sample.nLength); + sample.nLoopEnd = (UINT)min(sample.nLoopEnd * (m_dTimeStretchRatio/100.0), sample.nLength); + sample.nSustainStart = (UINT)min(sample.nSustainStart * (m_dTimeStretchRatio/100.0), sample.nLength); + sample.nSustainEnd = (UINT)min(sample.nSustainEnd * (m_dTimeStretchRatio/100.0), sample.nLength); } } @@ -1838,16 +1837,16 @@ //---------------------------------------- { static HANDLE handleSt = NULL; // Handle to SoundTouch object. - if((!m_pSndFile) || (!m_pSndFile->Samples[m_nSample].pSample)) return -1; - MODSAMPLE *pSmp = &m_pSndFile->Samples[m_nSample]; - if(!pSmp) return -1; + if((!m_pSndFile) || (m_pSndFile->GetSample(m_nSample).pSample == nullptr)) return -1; - const uint32 nSampleRate = pSmp->GetSampleRate(m_pSndFile->GetType()); + MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); + const uint32 nSampleRate = sample.GetSampleRate(m_pSndFile->GetType()); + // SoundTouch(1.3.1) seems to crash with short samples. Don't know what // the actual limit or whether it depends on sample rate, // but simply set some semiarbitrary threshold here. - if(pSmp->nLength < 256) + if(sample.nLength < 256) return 6; // Refuse processing when ratio is negative, equal to zero or equal to 1.0 @@ -1876,8 +1875,8 @@ } // Get number of channels & sample size - uint8 smpsize = pSmp->GetElementarySampleSize(); - const uint8 nChn = pSmp->GetNumChannels(); + uint8 smpsize = sample.GetElementarySampleSize(); + const uint8 nChn = sample.GetNumChannels(); // Stretching is implemented only for 16-bit samples. if(smpsize != 2) @@ -1885,7 +1884,7 @@ // This has to be converted to 16-bit first. SetSelectionPoints(0, 0); // avoid partial upsampling. OnUpsample(); - smpsize = pSmp->GetElementarySampleSize(); + smpsize = sample.GetElementarySampleSize(); } // SoundTouch(v1.4.0) documentation says that sample rates 8000-48000 are supported. @@ -1902,8 +1901,8 @@ // Allocate new sample. Returned sample may not be exactly the size what ratio would suggest // so allocate a bit more(1.03*). - const DWORD nNewSampleLength = (DWORD)(1.03 * ratio * (double)pSmp->nLength); - //const DWORD nNewSampleLength = (DWORD)(0.5 + ratio * (double)pSmp->nLength); + const DWORD nNewSampleLength = (DWORD)(1.03 * ratio * (double)sample.nLength); + //const DWORD nNewSampleLength = (DWORD)(0.5 + ratio * (double)sample.nLength); PVOID pNewSample = CSoundFile::AllocateSample(nNewSampleLength * nChn * smpsize); if(pNewSample == NULL) return 3; @@ -1975,14 +1974,14 @@ UINT nLengthCounter = 0; // Process sample in steps. - while(pos < pSmp->nLength) + while(pos < sample.nLength) { // Current chunk size limit test - if(len >= pSmp->nLength - pos) len = pSmp->nLength - pos; + if(len >= sample.nLength - pos) len = sample.nLength - pos; // Show progress bar using process button painting & text label CHAR progress[16]; - float percent = 100.0f * (pos + len) / pSmp->nLength; + float percent = 100.0f * (pos + len) / sample.nLength; progressBarRECT.right = processButtonRect.left + (int)percent * (processButtonRect.right - processButtonRect.left) / 100; wsprintf(progress,"%d%%",(UINT)percent); @@ -1995,7 +1994,7 @@ ::GdiFlush(); // Send sampledata for processing. - soundtouch_putSamples(handleSt, reinterpret_cast<int16*>(pSmp->pSample + pos * smpsize * nChn), len); + soundtouch_putSamples(handleSt, reinterpret_cast<int16*>(sample.pSample + pos * smpsize * nChn), len); // Receive some processed samples (it's not guaranteed that there is any available). nLengthCounter += soundtouch_receiveSamples(handleSt, reinterpret_cast<int16*>(pNewSample) + nChn * nLengthCounter, nNewSampleLength - nLengthCounter); @@ -2017,7 +2016,7 @@ m_pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_replace); // Swap sample buffer pointer to new buffer, update song + sample data & free old sample buffer - ctrlSmp::ReplaceSample(*pSmp, (LPSTR)pNewSample, min(nLengthCounter, nNewSampleLength), m_pSndFile); + ctrlSmp::ReplaceSample(sample, (LPSTR)pNewSample, min(nLengthCounter, nNewSampleLength), m_pSndFile); // Free progress bar brushes DeleteObject((HBRUSH)green); @@ -2035,17 +2034,16 @@ int CCtrlSamples::PitchShift(float pitch) //--------------------------------------- { - if((!m_pSndFile) || (!m_pSndFile->Samples[m_nSample].pSample)) return -1; + if((!m_pSndFile) || (m_pSndFile->GetSample(m_nSample).pSample == nullptr)) return -1; if(pitch < 0.5f) return 1 + (1<<8); if(pitch > 2.0f) return 1 + (2<<8); // Get sample struct pointer - MODSAMPLE *pSmp = &m_pSndFile->Samples[m_nSample]; - if(!pSmp) return 2; + MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); // Get number of channels & sample size - BYTE smpsize = pSmp->GetElementarySampleSize(); - UINT nChn = pSmp->GetNumChannels(); + BYTE smpsize = sample.GetElementarySampleSize(); + UINT nChn = sample.GetNumChannels(); // Get selected oversampling - quality - (also refered as FFT overlapping) factor CComboBox *combo = (CComboBox *)GetDlgItem(IDC_COMBO5); @@ -2084,11 +2082,11 @@ // This has to be converted to 16-bit first. SetSelectionPoints(0, 0); // avoid partial upsampling. OnUpsample(); - smpsize = pSmp->GetElementarySampleSize(); + smpsize = sample.GetElementarySampleSize(); } // Get original sample rate - long lSampleRate = pSmp->GetSampleRate(m_pSndFile->GetType()); + long lSampleRate = sample.GetSampleRate(m_pSndFile->GetType()); // Deduce max sample value (float conversion step) float maxSampleValue = float(( 1 << (smpsize * 8 - 1) ) - 1); @@ -2107,10 +2105,10 @@ // Process sample buffer using MAX_BUFFER_LENGTH (max) sized chunk steps (in order to allow // the processing of BIG samples...) - while(pos < pSmp->nLength){ + while(pos < sample.nLength){ // Current chunk size limit test - if(pos + len >= pSmp->nLength) len = pSmp->nLength - pos; + if(pos + len >= sample.nLength) len = sample.nLength - pos; // TRICK : output buffer offset management // as the pitch-shifter adds some blank signal in head of output buffer (matching FFT @@ -2121,14 +2119,14 @@ // FFT data computed during the previous steps resulting in a correct and consistent // signal output). bool bufstart = ( pos == 0 ); - bool bufend = ( pos + MAX_BUFFER_LENGTH >= pSmp->nLength ); + bool bufend = ( pos + MAX_BUFFER_LENGTH >= sample.nLength ); UINT startoffset = ( bufstart ? fft : 0 ); UINT inneroffset = ( bufstart ? 0 : fft ); UINT finaloffset = ( bufend ? fft : 0 ); // Show progress bar using process button painting & text label CHAR progress[16]; - float percent = (float)i * 50.0f + (100.0f / nChn) * (pos + len) / pSmp->nLength; + float percent = (float)i * 50.0f + (100.0f / nChn) * (pos + len) / sample.nLength; progressBarRECT.right = processButtonRect.left + (int)percent * (processButtonRect.right - processButtonRect.left) / 100; wsprintf(progress,"%d%%",(UINT)percent); @@ -2147,7 +2145,7 @@ } // Convert current channel's data chunk to float - BYTE * ptr = (BYTE *)pSmp->pSample + pos * smpsize * nChn + i * smpsize; + BYTE * ptr = (BYTE *)sample.pSample + pos * smpsize * nChn + i * smpsize; for(UINT j = 0 ; j < len ; j++){ switch(smpsize){ @@ -2168,7 +2166,7 @@ smbPitchShift(pitch, len + finaloffset, fft, ovs, (float)lSampleRate, buffer, outbuf, false); // Restore pitched-shifted float sample into original sample buffer - ptr = (BYTE *)pSmp->pSample + (pos - inneroffset) * smpsize * nChn + i * smpsize; + ptr = (BYTE *)sample.pSample + (pos - inneroffset) * smpsize * nChn + i * smpsize; for(UINT j = startoffset ; j < len + finaloffset ; j++){ // Just perform a little bit of clipping... @@ -2212,12 +2210,12 @@ void CCtrlSamples::OnReverse() //---------------------------- { - MODSAMPLE *pSmp = &m_pSndFile->Samples[m_nSample]; + MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); SELECTIONPOINTS selection = GetSelectionPoints(); m_pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_reverse, selection.nStart, selection.nEnd); - if(ctrlSmp::ReverseSample(pSmp, selection.nStart, selection.nEnd, m_pSndFile) == true) + if(ctrlSmp::ReverseSample(&sample, selection.nStart, selection.nEnd, m_pSndFile) == true) { m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA, NULL); m_pModDoc->SetModified(); @@ -2233,12 +2231,12 @@ void CCtrlSamples::OnInvert() //--------------------------- { - MODSAMPLE *pSmp = &m_pSndFile->Samples[m_nSample]; + MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); SELECTIONPOINTS selection = GetSelectionPoints(); m_pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_invert, selection.nStart, selection.nEnd); - if(ctrlSmp::InvertSample(pSmp, selection.nStart, selection.nEnd, m_pSndFile) == true) + if(ctrlSmp::InvertSample(&sample, selection.nStart, selection.nEnd, m_pSndFile) == true) { m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA, NULL); m_pModDoc->SetModified(); @@ -2254,19 +2252,17 @@ void CCtrlSamples::OnSignUnSign() //------------------------------- { - MODSAMPLE *pSmp; - - if ((!m_pModDoc) || (!m_pSndFile) || (!m_pSndFile->Samples[m_nSample].pSample)) return; + if ((!m_pModDoc) || (!m_pSndFile) || (m_pSndFile->GetSample(m_nSample).pSample == nullptr)) return; if(m_pModDoc->IsNotePlaying(0, m_nSample, 0) == TRUE) MsgBoxHidable(ConfirmSignUnsignWhenPlaying); BeginWaitCursor(); - pSmp = &m_pSndFile->Samples[m_nSample]; + MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); SELECTIONPOINTS selection = GetSelectionPoints(); m_pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_unsign, selection.nStart, selection.nEnd); - if(ctrlSmp::UnsignSample(pSmp, selection.nStart, selection.nEnd, m_pSndFile) == true) + if(ctrlSmp::UnsignSample(&sample, selection.nStart, selection.nEnd, m_pSndFile) == true) { m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA, NULL); m_pModDoc->SetModified(); @@ -2282,29 +2278,27 @@ void CCtrlSamples::OnSilence() //---------------------------- { - MODSAMPLE *pSmp; - - if ((!m_pSndFile) || (!m_pSndFile->Samples[m_nSample].pSample)) return; + if ((!m_pSndFile) || (m_pSndFile->GetSample(m_nSample).pSample == nullptr)) return; BeginWaitCursor(); SELECTIONPOINTS selection = GetSelectionPoints(); // never apply silence to a sample that has no selection if(selection.bSelected == true) { - pSmp = &m_pSndFile->Samples[m_nSample]; + MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); m_pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_update, selection.nStart, selection.nEnd); int len = selection.nEnd - selection.nStart; - if (pSmp->uFlags & CHN_STEREO) + if (sample.uFlags & CHN_STEREO) { - int smplsize = (pSmp->uFlags & CHN_16BIT) ? 4 : 2; - signed char *p = ((signed char *)pSmp->pSample) + selection.nStart * smplsize; + int smplsize = (sample.uFlags & CHN_16BIT) ? 4 : 2; + signed char *p = ((signed char *)sample.pSample) + selection.nStart * smplsize; memset(p, 0, len*smplsize); } else - if (pSmp->uFlags & CHN_16BIT) + if (sample.uFlags & CHN_16BIT) { - short int *p = ((short int *)pSmp->pSample) + selection.nStart; - int dest = (selection.nEnd < pSmp->nLength) ? p[len-1] : 0; + short int *p = ((short int *)sample.pSample) + selection.nStart; + 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++) @@ -2314,8 +2308,8 @@ } } else { - signed char *p = ((signed char *)pSmp->pSample) + selection.nStart; - int dest = (selection.nEnd < pSmp->nLength) ? p[len-1] : 0; + signed char *p = ((signed char *)sample.pSample) + selection.nStart; + 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++) @@ -2383,16 +2377,16 @@ void CCtrlSamples::OnFileNameChanged() //------------------------------------ { - CHAR s[32]; + CHAR s[MAX_SAMPLEFILENAME]; if ((IsLocked()) || (!m_pSndFile)) return; s[0] = 0; m_EditFileName.GetWindowText(s, sizeof(s)); - s[21] = 0; - for (UINT i=strlen(s); i<22; i++) s[i] = 0; - if (strncmp(s, m_pSndFile->Samples[m_nSample].filename, MAX_SAMPLEFILENAME)) + StringFixer::SetNullTerminator(s); + + if (strncmp(s, m_pSndFile->GetSample(m_nSample).filename, MAX_SAMPLEFILENAME)) { - memcpy(m_pSndFile->Samples[m_nSample].filename, s, MAX_SAMPLEFILENAME); + memcpy(m_pSndFile->GetSample(m_nSample).filename, s, MAX_SAMPLEFILENAME); m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEINFO, this); if (m_pSndFile->m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT)) m_pModDoc->SetModified(); } @@ -2404,12 +2398,11 @@ { if (IsLocked()) return; int nVol = GetDlgItemInt(IDC_EDIT7); - if (nVol < 0) nVol = 0; - if (nVol > 64) nVol = 64; - nVol <<= 2; - if (nVol != m_pSndFile->Samples[m_nSample].nVolume) + Limit(nVol, 0, 64); + nVol *= 4; + if (nVol != m_pSndFile->GetSample(m_nSample).nVolume) { - m_pSndFile->Samples[m_nSample].nVolume = (WORD)nVol; + m_pSndFile->GetSample(m_nSample).nVolume = (WORD)nVol; m_pModDoc->SetModified(); } } @@ -2420,11 +2413,10 @@ { if (IsLocked()) return; int nVol = GetDlgItemInt(IDC_EDIT8); - if (nVol < 0) nVol = 0; - if (nVol > 64) nVol = 64; - if (nVol != m_pSndFile->Samples[m_nSample].nGlobalVol) + Limit(nVol, 0, 64); + if (nVol != m_pSndFile->GetSample(m_nSample).nGlobalVol) { - m_pSndFile->Samples[m_nSample].nGlobalVol = (WORD)nVol; + m_pSndFile->GetSample(m_nSample).nGlobalVol = (WORD)nVol; m_pModDoc->SetModified(); } } @@ -2439,18 +2431,21 @@ { b = IsDlgButtonChecked(IDC_CHECK1); } + + MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); + if (b) { - if (!(m_pSndFile->Samples[m_nSample].uFlags & CHN_PANNING)) + if (!(sample.uFlags & CHN_PANNING)) { - m_pSndFile->Samples[m_nSample].uFlags |= CHN_PANNING; + sample.uFlags |= CHN_PANNING; m_pModDoc->SetModified(); } } else { - if (m_pSndFile->Samples[m_nSample].uFlags & CHN_PANNING) + if (sample.uFlags & CHN_PANNING) { - m_pSndFile->Samples[m_nSample].uFlags &= ~CHN_PANNING; + sample.uFlags &= ~CHN_PANNING; m_pModDoc->SetModified(); } } @@ -2471,9 +2466,9 @@ nPan = nPan << 2; // so we x4 to get MPT's internal 0-256 range. } //end rewbs.fix36944 - if (nPan != m_pSndFile->Samples[m_nSample].nPan) + if (nPan != m_pSndFile->GetSample(m_nSample).nPan) { - m_pSndFile->Samples[m_nSample].nPan = (WORD)nPan; + m_pSndFile->GetSample(m_nSample).nPan = (WORD)nPan; if (m_pSndFile->m_nType & (MOD_TYPE_XM|MOD_TYPE_IT|MOD_TYPE_MPT)) m_pModDoc->SetModified(); } } @@ -2486,9 +2481,9 @@ int n = GetDlgItemInt(IDC_EDIT5); if (m_pSndFile->m_nType & (MOD_TYPE_IT|MOD_TYPE_S3M|MOD_TYPE_MPT)) { - if ((n > 0) && (n <= (m_pSndFile->GetType() == MOD_TYPE_S3M ? 65535 : 9999999)) && (n != (int)m_pSndFile->Samples[m_nSample].nC5Speed)) + if ((n > 0) && (n <= (m_pSndFile->GetType() == MOD_TYPE_S3M ? 65535 : 9999999)) && (n != (int)m_pSndFile->GetSample(m_nSample).nC5Speed)) { - m_pSndFile->Samples[m_nSample].nC5Speed = n; + m_pSndFile->GetSample(m_nSample).nC5Speed = n; int transp = CSoundFile::FrequencyToTranspose(n) >> 7; int basenote = 60 - transp; if (basenote < BASENOTE_MIN) basenote = BASENOTE_MIN; @@ -2508,7 +2503,7 @@ n = MOD2XMFineTune(n); if ((n >= -128) && (n <= 127)) { - m_pSndFile->Samples[m_nSample].nFineTune = (signed char)n; + m_pSndFile->GetSample(m_nSample).nFineTune = (signed char)n; m_pModDoc->SetModified(); } @@ -2521,14 +2516,17 @@ { if (IsLocked()) return; int n = (NOTE_MIDDLEC - 1) - (m_CbnBaseNote.GetCurSel() + BASENOTE_MIN); + + MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); + if (m_pSndFile->m_nType & (MOD_TYPE_IT|MOD_TYPE_S3M|MOD_TYPE_MPT)) { - LONG ft = CSoundFile::FrequencyToTranspose(m_pSndFile->Samples[m_nSample].nC5Speed) & 0x7f; + LONG ft = CSoundFile::FrequencyToTranspose(sample.nC5Speed) & 0x7F; n = CSoundFile::TransposeToFrequency(n, ft); - if ((n > 0) && (n <= (m_pSndFile->GetType() == MOD_TYPE_S3M ? 65535 : 9999999)) && (n != (int)m_pSndFile->Samples[m_nSample].nC5Speed)) + if ((n > 0) && (n <= (m_pSndFile->GetType() == MOD_TYPE_S3M ? 65535 : 9999999)) && (n != (int)sample.nC5Speed)) { CHAR s[32]; - m_pSndFile->Samples[m_nSample].nC5Speed = n; + sample.nC5Speed = n; wsprintf(s, "%lu", n); LockControls(); m_EditFineTune.SetWindowText(s); @@ -2539,7 +2537,7 @@ { if ((n >= -128) && (n < 128)) { - m_pSndFile->Samples[m_nSample].RelativeTone = (signed char)n; + sample.RelativeTone = (signed char)n; m_pModDoc->SetModified(); } } @@ -2551,7 +2549,7 @@ { if (IsLocked()) return; int n = m_ComboAutoVib.GetCurSel(); - if (n >= 0) m_pSndFile->Samples[m_nSample].nVibType = (BYTE)n; + if (n >= 0) m_pSndFile->GetSample(m_nSample).nVibType = (BYTE)n; m_pModDoc->SetModified(); } @@ -2563,8 +2561,9 @@ int lmin = 0, lmax = 0; m_SpinVibDepth.GetRange(lmin, lmax); int n = GetDlgItemInt(IDC_EDIT15); - if ((n >= lmin) && (n <= lmax)) { - m_pSndFile->Samples[m_nSample].nVibDepth = (BYTE)n; + if ((n >= lmin) && (n <= lmax)) + { + m_pSndFile->GetSample(m_nSample).nVibDepth = (BYTE)n; m_pModDoc->SetModified(); } } @@ -2577,8 +2576,9 @@ int lmin = 0, lmax = 0; m_SpinVibSweep.GetRange(lmin, lmax); int n = GetDlgItemInt(IDC_EDIT14); - if ((n >= lmin) && (n <= lmax)) { - m_pSndFile->Samples[m_nSample].nVibSweep = (BYTE)n; + if ((n >= lmin) && (n <= lmax)) + { + m_pSndFile->GetSample(m_nSample).nVibSweep = (BYTE)n; m_pModDoc->SetModified(); } } @@ -2591,8 +2591,9 @@ int lmin = 0, lmax = 0; m_SpinVibRate.GetRange(lmin, lmax); int n = GetDlgItemInt(IDC_EDIT16); - if ((n >= lmin) && (n <= lmax)) { - m_pSndFile->Samples[m_nSample].nVibRate = (BYTE)n; + if ((n >= lmin) && (n <= lmax)) + { + m_pSndFile->GetSample(m_nSample).nVibRate = (BYTE)n; m_pModDoc->SetModified(); } } @@ -2603,32 +2604,32 @@ { if ((IsLocked()) || (!m_pSndFile)) return; int n = m_ComboLoopType.GetCurSel(); - MODSAMPLE *pSmp = &m_pSndFile->Samples[m_nSample]; - bool wasDisabled = (pSmp->uFlags & CHN_LOOP) == 0; + MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); + bool wasDisabled = (sample.uFlags & CHN_LOOP) == 0; switch(n) { case 0: // Off - pSmp->uFlags &= ~(CHN_LOOP|CHN_PINGPONGLOOP|CHN_PINGPONGFLAG); + sample.uFlags &= ~(CHN_LOOP|CHN_PINGPONGLOOP|CHN_PINGPONGFLAG); break; case 1: // On - pSmp->uFlags &= ~CHN_PINGPONGLOOP; - pSmp->uFlags |= CHN_LOOP; + sample.uFlags &= ~CHN_PINGPONGLOOP; + sample.uFlags |= CHN_LOOP; break; case 2: // PingPong - pSmp->uFlags |= CHN_LOOP|CHN_PINGPONGLOOP; + sample.uFlags |= CHN_LOOP|CHN_PINGPONGLOOP; break; } // set loop points if theren't any - if(wasDisabled && ((pSmp->uFlags & CHN_LOOP) != 0) && (pSmp->nLoopStart == pSmp->nLoopEnd) && (pSmp->nLoopStart == 0)) + if(wasDisabled && ((sample.uFlags & CHN_LOOP) != 0) && (sample.nLoopStart == sample.nLoopEnd) && (sample.nLoopStart == 0)) { SELECTIONPOINTS selection = GetSelectionPoints(); if(selection.bSelected) { - pSmp->nLoopStart = selection.nStart; - pSmp->nLoopEnd = selection.nEnd; + sample.nLoopStart = selection.nStart; + sample.nLoopEnd = selection.nEnd; } else { - pSmp->nLoopEnd = pSmp->nLength; + sample.nLoopEnd = sample.nLength; } m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA | HINT_SAMPLEINFO, NULL); } @@ -2641,12 +2642,12 @@ //-------------------------------------- { if ((IsLocked()) || (!m_pSndFile)) return; - MODSAMPLE *pSmp = &m_pSndFile->Samples[m_nSample]; + MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); LONG n = GetDlgItemInt(IDC_EDIT1); - if ((n >= 0) && (n < (LONG)pSmp->nLength) && ((n < (LONG)pSmp->nLoopEnd) || (!(pSmp->uFlags & CHN_LOOP)))) + if ((n >= 0) && (n < (LONG)sample.nLength) && ((n < (LONG)sample.nLoopEnd) || (!(sample.uFlags & CHN_LOOP)))) { - pSmp->nLoopStart = n; - if(pSmp->uFlags & CHN_LOOP) + sample.nLoopStart = n; + if(sample.uFlags & CHN_LOOP) { /* only update sample buffer if the loop is actually enabled (resets sound without any reason otherwise) - http://forum.openmpt.org/index.php?topic=1874.0 */ @@ -2662,12 +2663,12 @@ //------------------------------------ { if ((IsLocked()) || (!m_pSndFile)) return; - MODSAMPLE *pSmp = &m_pSndFile->Samples[m_nSample]; + MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); LONG n = GetDlgItemInt(IDC_EDIT2); - if ((n >= 0) && (n <= (LONG)pSmp->nLength) && ((n > (LONG)pSmp->nLoopStart) || (!(pSmp->uFlags & CHN_LOOP)))) + if ((n >= 0) && (n <= (LONG)sample.nLength) && ((n > (LONG)sample.nLoopStart) || (!(sample.uFlags & CHN_LOOP)))) { - pSmp->nLoopEnd = n; - if(pSmp->uFlags & CHN_LOOP) + sample.nLoopEnd = n; + if(sample.uFlags & CHN_LOOP) { /* only update sample buffer if the loop is actually enabled (resets sound without any reason otherwise) - http://forum.openmpt.org/index.php?topic=1874.0 */ @@ -2684,32 +2685,32 @@ { if ((IsLocked()) || (!m_pSndFile)) return; int n = m_ComboSustainType.GetCurSel(); - MODSAMPLE *pSmp = &m_pSndFile->Samples[m_nSample]; - bool wasDisabled = (pSmp->uFlags & CHN_SUSTAINLOOP) == 0; + MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); + bool wasDisabled = (sample.uFlags & CHN_SUSTAINLOOP) == 0; switch(n) { case 0: // Off - pSmp->uFlags &= ~(CHN_SUSTAINLOOP|CHN_PINGPONGSUSTAIN|CHN_PINGPONGFLAG); + sample.uFlags &= ~(CHN_SUSTAINLOOP|CHN_PINGPONGSUSTAIN|CHN_PINGPONGFLAG); break; case 1: // On - pSmp->uFlags &= ~CHN_PINGPONGSUSTAIN; - pSmp->uFlags |= CHN_SUSTAINLOOP; + sample.uFlags &= ~CHN_PINGPONGSUSTAIN; + sample.uFlags |= CHN_SUSTAINLOOP; break; case 2: // PingPong - pSmp->uFlags |= CHN_SUSTAINLOOP|CHN_PINGPONGSUSTAIN; + sample.uFlags |= CHN_SUSTAINLOOP|CHN_PINGPONGSUSTAIN; break; } // set sustain loop points if theren't any - if(wasDisabled && ((pSmp->uFlags & CHN_SUSTAINLOOP) != 0) && (pSmp->nSustainStart == pSmp->nSustainEnd) && (pSmp->nSustainStart == 0)) + if(wasDisabled && ((sample.uFlags & CHN_SUSTAINLOOP) != 0) && (sample.nSustainStart == sample.nSustainEnd) && (sample.nSustainStart == 0)) { SELECTIONPOINTS selection = GetSelectionPoints(); if(selection.bSelected) { - pSmp->nSustainStart = selection.nStart; - pSmp->nSustainEnd = selection.nEnd; + sample.nSustainStart = selection.nStart; + sample.nSustainEnd = selection.nEnd; } else { - pSmp->nSustainEnd = pSmp->nLength; + sample.nSustainEnd = sample.nLength; } m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA | HINT_SAMPLEINFO, NULL); } @@ -2721,12 +2722,12 @@ //---------------------------------------- { if ((IsLocked()) || (!m_pSndFile)) return; - MODSAMPLE *pSmp = &m_pSndFile->Samples[m_nSample]; + MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); LONG n = GetDlgItemInt(IDC_EDIT3); - if ((n >= 0) && (n <= (LONG)pSmp->nLength) - && ((n < (LONG)pSmp->nSustainEnd) || (!(pSmp->uFlags & CHN_SUSTAINLOOP)))) + if ((n >= 0) && (n <= (LONG)sample.nLength) + && ((n < (LONG)sample.nSustainEnd) || (!(sample.uFlags & CHN_SUSTAINLOOP)))) { - pSmp->nSustainStart = n; + sample.nSustainStart = n; m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA, this); m_pModDoc->SetModified(); } @@ -2737,12 +2738,12 @@ //-------------------------------------- { if ((IsLocked()) || (!m_pSndFile)) return; - MODSAMPLE *pSmp = &m_pSndFile->Samples[m_nSample]; + MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); LONG n = GetDlgItemInt(IDC_EDIT4); - if ((n >= 0) && (n <= (LONG)pSmp->nLength) - && ((n > (LONG)pSmp->nSustainStart) || (!(pSmp->uFlags & CHN_SUSTAINLOOP)))) + if ((n >= 0) && (n <= (LONG)sample.nLength) + && ((n > (LONG)sample.nSustainStart) || (!(sample.uFlags & CHN_SUSTAINLOOP)))) { - pSmp->nSustainEnd = n; + sample.nSustainEnd = n; m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA, this); m_pModDoc->SetModified(); } @@ -2802,58 +2803,58 @@ { CHAR s[256]; if ((IsLocked()) || (!m_pSndFile)) return; - UINT nsample = m_nSample, pinc = 1; - MODSAMPLE *pSmp = &m_pSndFile->Samples[nsample]; - LPSTR pSample = pSmp->pSample; + UINT pinc = 1; + MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); + LPSTR pSample = sample.pSample; short int pos; bool bRedraw = false; LockControls(); - if ((!pSmp->nLength) || (!pSample)) goto NoSample; - if (pSmp->uFlags & CHN_16BIT) + if ((!sample.nLength) || (!pSample)) goto NoSample; + if (sample.uFlags & CHN_16BIT) { pSample++; pinc *= 2; } - if (pSmp->uFlags & CHN_STEREO) pinc *= 2; + if (sample.uFlags & CHN_STEREO) pinc *= 2; // Loop Start if ((pos = (short int)m_SpinLoopStart.GetPos()) != 0) { bool bOk = false; - LPSTR p = pSample+pSmp->nLoopStart*pinc; - int find0 = (int)pSample[pSmp->nLoopEnd*pinc-pinc]; - int find1 = (int)pSample[pSmp->nLoopEnd*pinc]; + LPSTR p = pSample+sample.nLoopStart*pinc; + int find0 = (int)pSample[sample.nLoopEnd*pinc-pinc]; + int find1 = (int)pSample[sample.nLoopEnd*pinc]; // Find Next LoopStart Point if (pos > 0) { - for (UINT i=pSmp->nLoopStart+1; i+16<pSmp->nLoopEnd; i++) + for (UINT i=sample.nLoopStart+1; i+16<sample.nLoopEnd; i++) { p += pinc; - bOk = (pSmp->uFlags & CHN_PINGPONGLOOP) ? MPT_BidiStartCheck(p[0], p[pinc], p[pinc*2]) : MPT_LoopCheck(find0, find1, p[0], p[pinc]); + bOk = (sample.uFlags & CHN_PINGPONGLOOP) ? MPT_BidiStartCheck(p[0], p[pinc], p[pinc*2]) : MPT_LoopCheck(find0, find1, p[0], p[pinc]); if (bOk) { - pSmp->nLoopStart = i; + sample.nLoopStart = i; break; } } } else // Find Prev LoopStart Point { - for (UINT i=pSmp->nLoopStart; i; ) + for (UINT i=sample.nLoopStart; i; ) { i--; p -= pinc; - bOk = (pSmp->uFlags & CHN_PINGPONGLOOP) ? MPT_BidiStartCheck(p[0], p[pinc], p[pinc*2]) : MPT_LoopCheck(find0, find1, p[0], p[pinc]); + bOk = (sample.uFlags & CHN_PINGPONGLOOP) ? MPT_BidiStartCheck(p[0], p[pinc], p[pinc*2]) : MPT_LoopCheck(find0, find1, p[0], p[pinc]); if (bOk) { - pSmp->nLoopStart = i; + sample.nLoopStart = i; break; } } } if (bOk) { - wsprintf(s, "%u", pSmp->nLoopStart); + wsprintf(s, "%u", sample.nLoopStart); m_EditLoopStart.SetWindowText(s); m_pModDoc->AdjustEndOfSample(m_nSample); bRedraw = true; @@ -2862,42 +2863,4... [truncated message content] |
From: <sag...@us...> - 2011-09-03 00:55:11
|
Revision: 1009 http://modplug.svn.sourceforge.net/modplug/?rev=1009&view=rev Author: saga-games Date: 2011-09-03 00:55:03 +0000 (Sat, 03 Sep 2011) Log Message: ----------- [Ref] Merged the two ugly IT savers into one. [Mod] OpenMPT: Version is now 1.20.00.16 Modified Paths: -------------- trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2011-09-02 19:08:16 UTC (rev 1008) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2011-09-03 00:55:03 UTC (rev 1009) @@ -1849,7 +1849,7 @@ m_SndFile.SaveXM(files.first_file.c_str(), 0, true); break; case MOD_TYPE_IT: - m_SndFile.SaveCompatIT(files.first_file.c_str()); + m_SndFile.SaveIT(files.first_file.c_str(), 0, true); break; } ShowLog(); @@ -3885,7 +3885,7 @@ if (instrumentName.IsEmpty()) { const SAMPLEINDEX nSmp = m_SndFile.Instruments[nInstr]->Keyboard[NOTE_MIDDLEC - 1]; - if (nSmp < MAX_SAMPLES && m_SndFile.GetSample(nSmp).pSample) + if (nSmp <= m_SndFile.GetNumSamples() && m_SndFile.GetSample(nSmp).pSample) instrumentName.Format(TEXT("s: %s"), m_SndFile.GetSampleName(nSmp)); //60 is C-5 } Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-09-02 19:08:16 UTC (rev 1008) +++ trunk/OpenMPT/mptrack/version.h 2011-09-03 00:55:03 UTC (rev 1009) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 15 +#define VER_MINORMINOR 16 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2011-09-02 19:08:16 UTC (rev 1008) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2011-09-03 00:55:03 UTC (rev 1009) @@ -1361,17 +1361,16 @@ #pragma warning(disable:4100) -bool CSoundFile::SaveIT(LPCSTR lpszFileName, UINT nPacking) -//--------------------------------------------------------- +bool CSoundFile::SaveIT(LPCSTR lpszFileName, UINT nPacking, const bool compatExport) +//---------------------------------------------------------------------------------- { + const CModSpecifications &specs = (GetType() == MOD_TYPE_MPT ? ModSpecs::mptm : (compatExport ? ModSpecs::it : ModSpecs::itEx)); + DWORD dwPatNamLen, dwChnNamLen; ITFILEHEADER header; ITINSTRUMENT iti; ITSAMPLESTRUCT itss; vector<bool>smpcount(GetNumSamples(), false); - DWORD inspos[MAX_INSTRUMENTS]; - vector<DWORD> patpos; - DWORD smppos[MAX_SAMPLES]; DWORD dwPos = 0, dwHdrPos = 0, dwExtra = 0; WORD patinfo[4]; // -> CODE#0006 @@ -1387,11 +1386,8 @@ if ((!lpszFileName) || ((f = fopen(lpszFileName, "wb")) == NULL)) return false; - - memset(inspos, 0, sizeof(inspos)); - memset(smppos, 0, sizeof(smppos)); // Writing Header - memset(&header, 0, sizeof(header)); + MemsetZero(header); dwPatNamLen = 0; dwChnNamLen = 0; header.id = LittleEndian(IT_IMPM); @@ -1411,7 +1407,7 @@ { // An additional "---" pattern is appended so Impulse Tracker won't ignore the last order item. // Interestingly, this can exceed IT's 256 order limit. Also, IT will always save at least two orders. - header.ordnum = min(Order.GetLengthTailTrimmed(), ModSpecs::itEx.ordersMax) + 1; + header.ordnum = min(Order.GetLengthTailTrimmed(), specs.ordersMax) + 1; if(header.ordnum < 2) header.ordnum = 2; } @@ -1421,7 +1417,10 @@ if(Patterns.Size() < header.patnum) Patterns.ResizeArray(header.patnum); while ((header.patnum > 0) && (!Patterns[header.patnum - 1])) header.patnum--; - patpos.resize(header.patnum, 0); + // Parapointers + vector<DWORD> patpos(header.patnum, 0); + vector<DWORD> smppos(header.smpnum, 0); + vector<DWORD> inspos(header.insnum, 0); //VERSION if(GetType() == MOD_TYPE_MPT) @@ -1443,8 +1442,12 @@ break; } } - // This way, we indicate that the file will most likely contain OpenMPT hacks. Compatibility export puts 0 here. - header.reserved = LittleEndian(IT_OMPT); + + if(!compatExport) + { + // This way, we indicate that the file will most likely contain OpenMPT hacks. Compatibility export puts 0 here. + header.reserved = LittleEndian(IT_OMPT); + } } header.flags = 0x0001; @@ -1453,7 +1456,7 @@ if (m_dwSongFlags & SONG_LINEARSLIDES) header.flags |= 0x08; if (m_dwSongFlags & SONG_ITOLDEFFECTS) header.flags |= 0x10; if (m_dwSongFlags & SONG_ITCOMPATGXX) header.flags |= 0x20; - if (m_dwSongFlags & SONG_EXFILTERRANGE) header.flags |= 0x1000; + if ((m_dwSongFlags & SONG_EXFILTERRANGE) && !compatExport) header.flags |= 0x1000; header.globalvol = m_nDefaultGlobalVolume >> 1; header.mv = CLAMP(m_nSamplePreAmp, 0, 128); header.speed = m_nDefaultSpeed; @@ -1463,6 +1466,7 @@ // Channel Pan and Volume memset(header.chnpan, 0xA0, 64); memset(header.chnvol, 64, 64); + for (UINT ich=0; ich</*m_nChannels*/64; ich++) //Header only has room for settings for 64 chans... { header.chnpan[ich] = ChnSettings[ich].nPan >> 2; @@ -1471,14 +1475,18 @@ if (ChnSettings[ich].dwFlags & CHN_MUTE) header.chnpan[ich] |= 0x80; } - for (UINT ich=0; ich<m_nChannels; ich++) + // Channel names + if(!compatExport) { - if (ChnSettings[ich].szName[0]) + for (UINT ich=0; ich<m_nChannels; ich++) { - dwChnNamLen = (ich+1) * MAX_CHANNELNAME; + if (ChnSettings[ich].szName[0]) + { + dwChnNamLen = (ich + 1) * MAX_CHANNELNAME; + } } + if (dwChnNamLen) dwExtra += dwChnNamLen + 8; } - if (dwChnNamLen) dwExtra += dwChnNamLen + 8; if (m_dwSongFlags & SONG_EMBEDMIDICFG) { @@ -1486,15 +1494,23 @@ header.special |= 0x08; dwExtra += sizeof(MODMIDICFG); } + // Pattern Names const PATTERNINDEX numNamedPats = Patterns.GetNumNamedPatterns(); - if (numNamedPats > 0) + if(numNamedPats > 0 && !compatExport) { dwExtra += (numNamedPats * MAX_PATTERNNAME) + 8; } - // Mix Plugins - dwExtra += SaveMixPlugins(NULL, TRUE); - dwExtra += SaveITEditHistory(this, nullptr); // Just calculate the size of this extra block for now. + + // Mix Plugins. Just calculate the size of this extra block for now. + if(!compatExport) + { + dwExtra += SaveMixPlugins(NULL, TRUE); + } + + // Edit History. Just calculate the size of this extra block for now. + dwExtra += SaveITEditHistory(this, nullptr); + // Comments if (m_lpszSongComments) { @@ -1502,21 +1518,25 @@ header.msglength = strlen(m_lpszSongComments)+1; header.msgoffset = dwHdrPos + dwExtra + header.insnum*4 + header.patnum*4 + header.smpnum*4; } + // Write file header fwrite(&header, 1, sizeof(header), f); Order.WriteAsByte(f, header.ordnum); - if (header.insnum) fwrite(inspos, 4, header.insnum, f); - if (header.smpnum) fwrite(smppos, 4, header.smpnum, f); + if (header.insnum) fwrite(&inspos[0], 4, header.insnum, f); + if (header.smpnum) fwrite(&smppos[0], 4, header.smpnum, f); if (header.patnum) fwrite(&patpos[0], 4, header.patnum, f); + // Writing edit history information SaveITEditHistory(this, f); + // Writing midi cfg if (header.flags & 0x80) { fwrite(&m_MidiCfg, 1, sizeof(MODMIDICFG), f); } + // Writing pattern names - if (numNamedPats) + if (numNamedPats && !compatExport) { DWORD d = 0x4d414e50; fwrite(&d, 1, 4, f); @@ -1531,8 +1551,9 @@ fwrite(name, 1, MAX_PATTERNNAME, f); } } + // Writing channel names - if (dwChnNamLen) + if (dwChnNamLen && !compatExport) { DWORD d = 0x4d414e43; fwrite(&d, 1, 4, f); @@ -1543,8 +1564,13 @@ fwrite(ChnSettings[inam].szName, 1, MAX_CHANNELNAME, f); } } + // Writing mix plugins info - SaveMixPlugins(f, FALSE); + if(!compatExport) + { + SaveMixPlugins(f, FALSE); + } + // Writing song message dwPos = dwHdrPos + dwExtra + (header.insnum + header.smpnum + header.patnum) * 4; if (header.special & 1) @@ -1552,35 +1578,36 @@ dwPos += strlen(m_lpszSongComments) + 1; fwrite(m_lpszSongComments, 1, strlen(m_lpszSongComments)+1, f); } + // Writing instruments for (UINT nins=1; nins<=header.insnum; nins++) { bool bKbdEx = false; // extended sample map (for samples > 255) BYTE keyboardex[NOTE_MAX]; - memset(&iti, 0, sizeof(iti)); + MemsetZero(iti); iti.id = LittleEndian(IT_IMPI); // "IMPI" - //iti.trkvers = 0x211; - iti.trkvers = 0x220; //rewbs.itVersion + iti.trkvers = (compatExport ? LittleEndianW(0x0214) : LittleEndianW(0x220)); //rewbs.itVersion if (Instruments[nins]) { MODINSTRUMENT *pIns = Instruments[nins]; memcpy(iti.filename, pIns->filename, 12); memcpy(iti.name, pIns->name, 26); + StringFixer::SetNullTerminator(iti.name); + iti.mbank = pIns->wMidiBank; iti.mpr = pIns->nMidiProgram; - if(pIns->nMidiChannel || pIns->nMixPlug == 0) + if(pIns->nMidiChannel || pIns->nMixPlug == 0 || compatExport) { - // default. prefer midi channel over mixplug to keep the semantics intact. + // Default. Prefer MIDI channel over mixplug to keep the semantics intact. iti.mch = pIns->nMidiChannel; } else { - // keep compatibility with MPT 1.16's instrument format if possible, as XMPlay/BASS also uses this. + // Keep compatibility with MPT 1.16's instrument format if possible, as XMPlay / BASS also uses this. iti.mch = pIns->nMixPlug + 128; } iti.nna = pIns->nNNA; - //if (pIns->nDCT<DCT_PLUGIN) iti.dct = pIns->nDCT; else iti.dct =0; - iti.dct = pIns->nDCT; //rewbs.instroVSTi: will other apps barf if they get an unknown DCT? + iti.dct = (pIns->nDCT < DCT_PLUGIN || !compatExport) ? pIns->nDCT : 0; iti.dca = pIns->nDNA; iti.fadeout = min(pIns->nFadeOut >> 5, 256); iti.pps = pIns->nPPS; @@ -1603,7 +1630,7 @@ } iti.keyboard[i*2] = (pIns->NoteMap[i] >= NOTE_MIN && pIns->NoteMap[i] <= NOTE_MAX) ? (pIns->NoteMap[i] - 1) : i; iti.keyboard[i*2+1] = smp; - if (smp > 0xff) bKbdEx = true; + if (smp > 0xff && !compatExport) bKbdEx = true; keyboardex[i] = (smp>>8); } else keyboardex[i] = 0; // Writing Volume envelope @@ -1635,7 +1662,7 @@ } //------------ rewbs.modularInstData - if (Instruments[nins]) + if (Instruments[nins] && !compatExport) { long modularInstSize = 0; UINT ModInstID = 'INSM'; @@ -1674,14 +1701,16 @@ } //------------ end rewbs.modularInstData } + // Writing sample headers - memset(&itss, 0, sizeof(itss)); + MemsetZero(itss); for (UINT hsmp=0; hsmp<header.smpnum; hsmp++) { smppos[hsmp] = dwPos; dwPos += sizeof(ITSAMPLESTRUCT); fwrite(&itss, 1, sizeof(ITSAMPLESTRUCT), f); } + // Writing Patterns bool bNeedsMptPatSave = false; for (UINT npat=0; npat<header.patnum; npat++) @@ -1708,15 +1737,20 @@ dwPos += 8; memset(chnmask, 0xFF, sizeof(chnmask)); memset(lastvalue, 0, sizeof(lastvalue)); - MODCOMMAND *m = Patterns[npat]; + for (UINT row=0; row<Patterns[npat].GetNumRows(); row++) { UINT len = 0; - for (UINT ch=0; ch<m_nChannels; ch++, m++) + MODCOMMAND *m = Patterns[npat].GetRow(row); + + for (UINT ch = 0; ch < specs.channelsMax; ch++, m++) { // Skip mptm-specific notes. - if(GetType() == MOD_TYPE_MPT && (m->IsPcNote())) - {bNeedsMptPatSave = true; continue;} + if(m->IsPcNote()) + { + bNeedsMptPatSave = true; + continue; + } BYTE b = 0; UINT command = m->command; @@ -1739,18 +1773,28 @@ case VOLCMD_FINEVOLUP: vol = 65 + ConvertVolParam(m->vol); break; case VOLCMD_FINEVOLDOWN: vol = 75 + ConvertVolParam(m->vol); break; case VOLCMD_VIBRATODEPTH: vol = 203 + ConvertVolParam(m->vol); break; - case VOLCMD_VIBRATOSPEED: vol = 0xFF /*203 + ConvertVolParam(m->vol)*/; break; // not supported! + case VOLCMD_VIBRATOSPEED: if(command == CMD_NONE) + { + // illegal command -> move if possible + command = CMD_VIBRATO; + param = ConvertVolParam(m->vol) << 4; + } else + { + vol = 203; + } + break; case VOLCMD_TONEPORTAMENTO: vol = 193 + ConvertVolParam(m->vol); break; case VOLCMD_PORTADOWN: vol = 105 + ConvertVolParam(m->vol); break; case VOLCMD_PORTAUP: vol = 115 + ConvertVolParam(m->vol); break; - case VOLCMD_OFFSET: vol = 223 + ConvertVolParam(m->vol); break; //rewbs.volOff + case VOLCMD_OFFSET: if(!compatExport) vol = 223 + ConvertVolParam(m->vol); //rewbs.volOff + break; default: vol = 0xFF; } } if (vol != 0xFF) b |= 4; if (command) { - S3MSaveConvert(&command, ¶m, true); + S3MSaveConvert(&command, ¶m, true, compatExport); if (command) b |= 8; } // Packing information @@ -1856,9 +1900,11 @@ for (UINT nsmp=1; nsmp<=header.smpnum; nsmp++) { MODSAMPLE *psmp = &Samples[nsmp]; - memset(&itss, 0, sizeof(itss)); + MemsetZero(itss); memcpy(itss.filename, psmp->filename, 12); memcpy(itss.name, m_szNames[nsmp], 26); + StringFixer::SetNullTerminator(itss.name); + itss.id = LittleEndian(IT_IMPS); itss.gvl = (BYTE)psmp->nGlobalVol; @@ -1871,7 +1917,7 @@ if (psmp->uFlags & CHN_PINGPONGLOOP) itss.flags |= 0x40; if (psmp->uFlags & CHN_PINGPONGSUSTAIN) itss.flags |= 0x80; #ifndef NO_PACKING - if (nPacking) + if (nPacking && !compatExport) { if ((!(psmp->uFlags & (CHN_16BIT|CHN_STEREO))) && (CanPackSample(psmp->pSample, psmp->nLength, nPacking))) @@ -1926,13 +1972,16 @@ } //Save hacked-on extra info - SaveExtendedInstrumentProperties(Instruments, header.insnum, f); - SaveExtendedSongProperties(f); + if(!compatExport) + { + SaveExtendedInstrumentProperties(Instruments, header.insnum, f); + SaveExtendedSongProperties(f); + } // Updating offsets fseek(f, dwHdrPos, SEEK_SET); - if (header.insnum) fwrite(inspos, 4, header.insnum, f); - if (header.smpnum) fwrite(smppos, 4, header.smpnum, f); + if (header.insnum) fwrite(&inspos[0], 4, header.insnum, f); + if (header.smpnum) fwrite(&smppos[0], 4, header.smpnum, f); if (header.patnum) fwrite(&patpos[0], 4, header.patnum, f); if(GetType() == MOD_TYPE_IT) @@ -1993,518 +2042,7 @@ #pragma warning(default:4100) #endif // MODPLUG_NO_FILESAVE -//HACK: This is a quick fix. Needs to be better integrated into player and GUI. -//And need to split into subroutines and eliminate code duplication with SaveIT. -bool CSoundFile::SaveCompatIT(LPCSTR lpszFileName) -//------------------------------------------------ -{ - const int IT_MAX_CHANNELS=64; - DWORD dwPatNamLen, dwChnNamLen; - ITFILEHEADER header; - ITINSTRUMENT iti; - ITSAMPLESTRUCT itss; - vector<bool>smpcount(GetNumSamples(), false); - DWORD inspos[MAX_INSTRUMENTS]; - DWORD patpos[MAX_PATTERNS]; - DWORD smppos[MAX_SAMPLES]; - DWORD dwPos = 0, dwHdrPos = 0, dwExtra = 0; - WORD patinfo[4]; -// -> CODE#0006 -// -> DESC="misc quantity changes" - BYTE chnmask[IT_MAX_CHANNELS]; - MODCOMMAND lastvalue[IT_MAX_CHANNELS]; - UINT nChannels = min(m_nChannels, IT_MAX_CHANNELS); -// -! BEHAVIOUR_CHANGE#0006 - BYTE buf[512]; - FILE *f; - - if ((!lpszFileName) || ((f = fopen(lpszFileName, "wb")) == NULL)) return false; - memset(inspos, 0, sizeof(inspos)); - memset(patpos, 0, sizeof(patpos)); - memset(smppos, 0, sizeof(smppos)); - // Writing Header - memset(&header, 0, sizeof(header)); - dwPatNamLen = 0; - dwChnNamLen = 0; - header.id = LittleEndian(IT_IMPM); - lstrcpyn(header.songname, m_szNames[0], 26); - - header.highlight_minor = (BYTE)min(m_nDefaultRowsPerBeat, 0xFF); - header.highlight_major = (BYTE)min(m_nDefaultRowsPerMeasure, 0xFF); - - // An additional "---" pattern is appended so Impulse Tracker won't ignore the last order item. - // Interestingly, this can exceed IT's 256 order limit. Also, IT will always save at least two orders. - header.ordnum = min(Order.GetLengthTailTrimmed(), ModSpecs::it.ordersMax) + 1; - if(header.ordnum < 2) header.ordnum = 2; - - header.patnum = MAX_PATTERNS; - while ((header.patnum > 0) && (!Patterns[header.patnum-1])) { - header.patnum--; - } - - header.insnum = m_nInstruments; - header.smpnum = m_nSamples; - - MptVersion::VersionNum vVersion = MptVersion::num; - header.cwtv = LittleEndianW(0x5000 | (WORD)((vVersion >> 16) & 0x0FFF)); // format: txyy (t = tracker ID, x = version major, yy = version minor), e.g. 0x5117 (OpenMPT = 5, 117 = v1.17) - header.cmwt = LittleEndianW(0x0214); // Common compatible tracker :) - // hack from schism tracker: - for(INSTRUMENTINDEX nIns = 1; nIns <= GetNumInstruments(); nIns++) - { - if(Instruments[nIns] && Instruments[nIns]->PitchEnv.dwFlags & ENV_FILTER) - { - header.cmwt = LittleEndianW(0x0217); - break; - } - } - - header.flags = 0x0001; - header.special = 0x02 | 0x04 ; // 0x02: embed file edit history, 0x04: store row highlight in the header - if (m_nInstruments) header.flags |= 0x04; - if (m_dwSongFlags & SONG_LINEARSLIDES) header.flags |= 0x08; - if (m_dwSongFlags & SONG_ITOLDEFFECTS) header.flags |= 0x10; - if (m_dwSongFlags & SONG_ITCOMPATGXX) header.flags |= 0x20; - //if (m_dwSongFlags & SONG_EXFILTERRANGE) header.flags |= 0x1000; - header.globalvol = m_nDefaultGlobalVolume >> 1; - header.mv = CLAMP(m_nSamplePreAmp, 0, 128); - header.speed = m_nDefaultSpeed; - header.tempo = min(m_nDefaultTempo, 255); //Limit this one to 255, we save the real one as an extension below. - header.sep = 128; // pan separation - dwHdrPos = sizeof(header) + header.ordnum; - // Channel Pan and Volume - memset(header.chnpan, 0xA0, 64); - memset(header.chnvol, 64, 64); - for (UINT ich=0; ich</*m_nChannels*/64; ich++) //Header only has room for settings for 64 chans... - { - header.chnpan[ich] = ChnSettings[ich].nPan >> 2; - if (ChnSettings[ich].dwFlags & CHN_SURROUND) header.chnpan[ich] = 100; - header.chnvol[ich] = ChnSettings[ich].nVolume; - if (ChnSettings[ich].dwFlags & CHN_MUTE) header.chnpan[ich] |= 0x80; -/* if (ChnSettings[ich].szName[0]) - { - dwChnNamLen = (ich+1) * MAX_CHANNELNAME; - } -*/ - } -// if (dwChnNamLen) dwExtra += dwChnNamLen + 8; - - if (m_dwSongFlags & SONG_EMBEDMIDICFG) - { - header.flags |= 0x80; - header.special |= 0x08; - dwExtra += sizeof(MODMIDICFG); - } - // Pattern Names -/* if ((m_nPatternNames) && (m_lpszPatternNames)) - { - dwPatNamLen = m_nPatternNames * MAX_PATTERNNAME; - while ((dwPatNamLen >= MAX_PATTERNNAME) && (!m_lpszPatternNames[dwPatNamLen-MAX_PATTERNNAME])) dwPatNamLen -= MAX_PATTERNNAME; - if (dwPatNamLen < MAX_PATTERNNAME) dwPatNamLen = 0; - if (dwPatNamLen) dwExtra += dwPatNamLen + 8; - } -*/ // Mix Plugins - //dwExtra += SaveMixPlugins(NULL, TRUE); - dwExtra += SaveITEditHistory(this, nullptr); // Just calculate the size of this extra block for now. - // Comments - if (m_lpszSongComments) - { - header.special |= 1; - header.msglength = strlen(m_lpszSongComments)+1; - header.msgoffset = dwHdrPos + dwExtra + header.insnum*4 + header.patnum*4 + header.smpnum*4; - } - // Write file header - fwrite(&header, 1, sizeof(header), f); - Order.WriteAsByte(f, header.ordnum); - if (header.insnum) fwrite(inspos, 4, header.insnum, f); - if (header.smpnum) fwrite(smppos, 4, header.smpnum, f); - if (header.patnum) fwrite(patpos, 4, header.patnum, f); - // Writing edit history information - SaveITEditHistory(this, f); - // Writing midi cfg - if (header.flags & 0x80) - { - fwrite(&m_MidiCfg, 1, sizeof(MODMIDICFG), f); - } - // Writing pattern names -/* if (dwPatNamLen) - { - DWORD d = 0x4d414e50; - fwrite(&d, 1, 4, f); - fwrite(&dwPatNamLen, 1, 4, f); - fwrite(m_lpszPatternNames, 1, dwPatNamLen, f); - } -*/ // Writing channel Names -/* if (dwChnNamLen) - { - DWORD d = 0x4d414e43; - fwrite(&d, 1, 4, f); - fwrite(&dwChnNamLen, 1, 4, f); - UINT nChnNames = dwChnNamLen / MAX_CHANNELNAME; - for (UINT inam=0; inam<nChnNames; inam++) - { - fwrite(ChnSettings[inam].szName, 1, MAX_CHANNELNAME, f); - } - } -*/ // Writing mix plugins info -/* SaveMixPlugins(f, FALSE); -*/ // Writing song message - dwPos = dwHdrPos + dwExtra + (header.insnum + header.smpnum + header.patnum) * 4; - if (header.special & 1) - { - dwPos += strlen(m_lpszSongComments) + 1; - fwrite(m_lpszSongComments, 1, strlen(m_lpszSongComments)+1, f); - } - // Writing instruments - for (UINT nins=1; nins<=header.insnum; nins++) - { - bool bKbdEx = false; // extended sample map (for samples > 255) - BYTE keyboardex[NOTE_MAX]; - - memset(&iti, 0, sizeof(iti)); - iti.id = LittleEndian(IT_IMPI); // "IMPI" - iti.trkvers = 0x0214; - if (Instruments[nins]) - { - MODINSTRUMENT *pIns = Instruments[nins]; - memcpy(iti.filename, pIns->filename, 12); - memcpy(iti.name, pIns->name, 26); - StringFixer::SetNullTerminator(iti.name); - iti.mbank = pIns->wMidiBank; - iti.mpr = pIns->nMidiProgram; - iti.mch = pIns->nMidiChannel; - iti.nna = pIns->nNNA; - if (pIns->nDCT<DCT_PLUGIN) iti.dct = pIns->nDCT; else iti.dct =0; - iti.dca = pIns->nDNA; - iti.fadeout = min(pIns->nFadeOut >> 5 , 256); - iti.pps = pIns->nPPS; - iti.ppc = pIns->nPPC; - iti.gbv = (BYTE)(pIns->nGlobalVol << 1); - iti.dfp = (BYTE)(pIns->nPan >> 2); - if (!(pIns->dwFlags & INS_SETPANNING)) iti.dfp |= 0x80; - iti.rv = pIns->nVolSwing; - iti.rp = pIns->nPanSwing; - iti.ifc = pIns->nIFC; - iti.ifr = pIns->nIFR; - iti.nos = 0; - for (UINT i=0; i<NOTE_MAX; i++) if (pIns->Keyboard[i] < MAX_SAMPLES) - { - const UINT smp = pIns->Keyboard[i]; - if (smp && smp <= GetNumSamples() && !smpcount[smp - 1]) - { - smpcount[smp - 1] = true; - iti.nos++; - } - iti.keyboard[i*2] = (pIns->NoteMap[i] >= NOTE_MIN && pIns->NoteMap[i] <= NOTE_MAX) ? (pIns->NoteMap[i] - 1) : i; - iti.keyboard[i*2+1] = smp; - //if (smp > 0xFF) bKbdEx = true; // no extended sample map in compat mode - keyboardex[i] = (smp>>8); - } else keyboardex[i] = 0; - // Writing Volume envelope - MPTEnvToIT(&pIns->VolEnv, &iti.volenv, 0, 64); - // Writing Panning envelope - MPTEnvToIT(&pIns->PanEnv, &iti.panenv, 32, 32); - // Writing Pitch Envelope - MPTEnvToIT(&pIns->PitchEnv, &iti.pitchenv, 32, 32); - if (pIns->PitchEnv.dwFlags & ENV_FILTER) iti.pitchenv.flags |= 0x80; - } else - // Save Empty Instrument - { - for (UINT i=0; i<NOTE_MAX; i++) iti.keyboard[i*2] = i; - iti.ppc = 5*12; - iti.gbv = 128; - iti.dfp = 0x20; - iti.ifc = 0xFF; - } - if (!iti.nos) iti.trkvers = 0; - // Writing instrument - if (bKbdEx) *((int *)iti.dummy) = 'MPTX'; - inspos[nins-1] = dwPos; - dwPos += sizeof(ITINSTRUMENT); - fwrite(&iti, 1, sizeof(ITINSTRUMENT), f); - if (bKbdEx) - { - dwPos += NOTE_MAX; - fwrite(keyboardex, 1, NOTE_MAX, f); - } - - //------------ rewbs.modularInstData -/* if (Instruments[nins]) - { - long modularInstSize = 0; - UINT ModInstID = 'INSM'; - fwrite(&ModInstID, 1, sizeof(ModInstID), f); // mark this as an instrument with modular extensions - long sizePos = ftell(f); // we will want to write the modular data's total size here - fwrite(&modularInstSize, 1, sizeof(modularInstSize), f); // write a DUMMY size, just to move file pointer by a long - - //Write chunks - UINT ID; - { //VST Slot chunk: - ID='PLUG'; - fwrite(&ID, 1, sizeof(int), f); - MODINSTRUMENT *pIns = Instruments[nins]; - fwrite(&(pIns->nMixPlug), 1, sizeof(BYTE), f); - modularInstSize += sizeof(int)+sizeof(BYTE); - } -*/ //How to save your own modular instrument chunk: - /* { - ID='MYID'; - fwrite(&ID, 1, sizeof(int), f); - instModularDataSize+=sizeof(int); - - //You can save your chunk size somwhere here if you need variable chunk size. - fwrite(myData, 1, myDataSize, f); - instModularDataSize+=myDataSize; - } - */ -/* //write modular data's total size - long curPos = ftell(f); // remember current pos - fseek(f, sizePos, SEEK_SET); // go back to sizePos - fwrite(&modularInstSize, 1, sizeof(modularInstSize), f); // write data - fseek(f, curPos, SEEK_SET); // go back to where we were. - - //move forward - dwPos+=sizeof(ModInstID)+sizeof(modularInstSize)+modularInstSize; - } -*/ //------------ end rewbs.modularInstData - } - // Writing sample headers - memset(&itss, 0, sizeof(itss)); - for (UINT hsmp=0; hsmp<header.smpnum; hsmp++) - { - smppos[hsmp] = dwPos; - dwPos += sizeof(ITSAMPLESTRUCT); - fwrite(&itss, 1, sizeof(ITSAMPLESTRUCT), f); - } - // Writing Patterns - for (UINT npat=0; npat<header.patnum; npat++) - { - DWORD dwPatPos = dwPos; - UINT len; - if (!Patterns[npat]) continue; - patpos[npat] = dwPos; - patinfo[0] = 0; - patinfo[1] = Patterns[npat].GetNumRows(); - patinfo[2] = 0; - patinfo[3] = 0; - - // Check for empty pattern - if (Patterns[npat].GetNumRows() == 64 && Patterns.IsPatternEmpty(npat)) - { - patpos[npat] = 0; - continue; - } - - fwrite(patinfo, 8, 1, f); - dwPos += 8; - memset(chnmask, 0xFF, sizeof(chnmask)); - memset(lastvalue, 0, sizeof(lastvalue)); - MODCOMMAND *m = Patterns[npat]; - for (UINT row=0; row<Patterns[npat].GetNumRows(); row++) - { - len = 0; - for (UINT ch = 0; ch < m_nChannels; ch++, m++) - { - if(ch >= nChannels) continue; - BYTE b = 0; - UINT command = m->command; - UINT param = m->param; - UINT vol = 0xFF; - UINT note = m->note; - if(note == NOTE_PC || note == NOTE_PCS) note = NOTE_NONE; - if (note) b |= 1; - if ((note) && (note < NOTE_MIN_SPECIAL)) note--; - if (note == NOTE_FADE) note = 0xF6; - if (m->instr) b |= 2; - if (m->volcmd) - { - UINT volcmd = m->volcmd; - switch(volcmd) - { - case VOLCMD_VOLUME: vol = m->vol; if (vol > 64) vol = 64; break; - case VOLCMD_PANNING: vol = m->vol + 128; if (vol > 192) vol = 192; break; - case VOLCMD_VOLSLIDEUP: vol = 85 + ConvertVolParam(m->vol); break; - case VOLCMD_VOLSLIDEDOWN: vol = 95 + ConvertVolParam(m->vol); break; - case VOLCMD_FINEVOLUP: vol = 65 + ConvertVolParam(m->vol); break; - case VOLCMD_FINEVOLDOWN: vol = 75 + ConvertVolParam(m->vol); break; - case VOLCMD_VIBRATODEPTH: vol = 203 + ConvertVolParam(m->vol); break; - case VOLCMD_VIBRATOSPEED: if(command == CMD_NONE) { // illegal command -> move if possible - command = CMD_VIBRATO; param = ConvertVolParam(m->vol) << 4; vol = 0xFF; - } else { vol = 203;} - break; - case VOLCMD_TONEPORTAMENTO: vol = 193 + ConvertVolParam(m->vol); break; - case VOLCMD_PORTADOWN: vol = 105 + ConvertVolParam(m->vol); break; - case VOLCMD_PORTAUP: vol = 115 + ConvertVolParam(m->vol); break; - default: vol = 0xFF; - } - } - if (vol != 0xFF) b |= 4; - if (command) - { - S3MSaveConvert(&command, ¶m, true, true); - if (command) b |= 8; - } - // Packing information - if (b) - { - // Same note ? - if (b & 1) - { - if ((note == lastvalue[ch].note) && (lastvalue[ch].volcmd & 1)) - { - b &= ~1; - b |= 0x10; - } else - { - lastvalue[ch].note = note; - lastvalue[ch].volcmd |= 1; - } - } - // Same instrument ? - if (b & 2) - { - if ((m->instr == lastvalue[ch].instr) && (lastvalue[ch].volcmd & 2)) - { - b &= ~2; - b |= 0x20; - } else - { - lastvalue[ch].instr = m->instr; - lastvalue[ch].volcmd |= 2; - } - } - // Same volume column byte ? - if (b & 4) - { - if ((vol == lastvalue[ch].vol) && (lastvalue[ch].volcmd & 4)) - { - b &= ~4; - b |= 0x40; - } else - { - lastvalue[ch].vol = vol; - lastvalue[ch].volcmd |= 4; - } - } - // Same command / param ? - if (b & 8) - { - if ((command == lastvalue[ch].command) && (param == lastvalue[ch].param) && (lastvalue[ch].volcmd & 8)) - { - b &= ~8; - b |= 0x80; - } else - { - lastvalue[ch].command = command; - lastvalue[ch].param = param; - lastvalue[ch].volcmd |= 8; - } - } - if (b != chnmask[ch]) - { - chnmask[ch] = b; - buf[len++] = (ch+1) | 0x80; - buf[len++] = b; - } else - { - buf[len++] = ch+1; - } - if (b & 1) buf[len++] = note; - if (b & 2) buf[len++] = m->instr; - if (b & 4) buf[len++] = vol; - if (b & 8) - { - buf[len++] = command; - buf[len++] = param; - } - } - } - buf[len++] = 0; - dwPos += len; - patinfo[0] += len; - fwrite(buf, 1, len, f); - } - fseek(f, dwPatPos, SEEK_SET); - fwrite(patinfo, 8, 1, f); - fseek(f, dwPos, SEEK_SET); - } - // Writing Sample Data - for (UINT nsmp=1; nsmp<=header.smpnum; nsmp++) - { - MODSAMPLE *psmp = &Samples[nsmp]; - memset(&itss, 0, sizeof(itss)); - memcpy(itss.filename, psmp->filename, 12); - memcpy(itss.name, m_szNames[nsmp], 26); - StringFixer::SetNullTerminator(itss.name); - itss.id = LittleEndian(IT_IMPS); - itss.gvl = (BYTE)psmp->nGlobalVol; - - UINT flags = RS_PCM8S; - if(psmp->nLength && psmp->pSample) - { - itss.flags = 0x01; - if (psmp->uFlags & CHN_LOOP) itss.flags |= 0x10; - if (psmp->uFlags & CHN_SUSTAINLOOP) itss.flags |= 0x20; - if (psmp->uFlags & CHN_PINGPONGLOOP) itss.flags |= 0x40; - if (psmp->uFlags & CHN_PINGPONGSUSTAIN) itss.flags |= 0x80; - - if (psmp->uFlags & CHN_STEREO) - { - flags = RS_STPCM8S; - itss.flags |= 0x04; - } - if (psmp->uFlags & CHN_16BIT) - { - itss.flags |= 0x02; - flags = (psmp->uFlags & CHN_STEREO) ? RS_STPCM16S : RS_PCM16S; - } - - itss.cvt = 0x01; - } - else - { - itss.flags = 0x00; - } - - itss.C5Speed = psmp->nC5Speed; - if (!itss.C5Speed) itss.C5Speed = 8363; - itss.length = psmp->nLength; - itss.loopbegin = psmp->nLoopStart; - itss.loopend = psmp->nLoopEnd; - itss.susloopbegin = psmp->nSustainStart; - itss.susloopend = psmp->nSustainEnd; - itss.vol = psmp->nVolume >> 2; - itss.dfp = psmp->nPan >> 2; - itss.vit = autovibxm2it[psmp->nVibType & 7]; - itss.vis = min(psmp->nVibRate, 64); - itss.vid = min(psmp->nVibDepth, 32); - itss.vir = min(psmp->nVibSweep, 255); - if (psmp->uFlags & CHN_PANNING) itss.dfp |= 0x80; - - itss.samplepointer = dwPos; - fseek(f, smppos[nsmp-1], SEEK_SET); - fwrite(&itss, 1, sizeof(ITSAMPLESTRUCT), f); - fseek(f, dwPos, SEEK_SET); - if ((psmp->pSample) && (psmp->nLength)) - { - dwPos += WriteSample(f, psmp, flags); - } - } - - //Save hacked-on extra info -// SaveExtendedInstrumentProperties(Instruments, header.insnum, f); -// SaveExtendedSongProperties(f); - - // Updating offsets - fseek(f, dwHdrPos, SEEK_SET); - if (header.insnum) fwrite(inspos, 4, header.insnum, f); - if (header.smpnum) fwrite(smppos, 4, header.smpnum, f); - if (header.patnum) fwrite(patpos, 4, header.patnum, f); - fclose(f); - return true; - -} - ////////////////////////////////////////////////////////////////////////////// // IT 2.14 compression Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2011-09-02 19:08:16 UTC (rev 1008) +++ trunk/OpenMPT/soundlib/Sndfile.h 2011-09-03 00:55:03 UTC (rev 1009) @@ -621,7 +621,7 @@ public: // for Editing - CModDoc* m_pModDoc; // Can be a null pointer f.e. when previewing samples from the treeview. + CModDoc *m_pModDoc; // Can be a null pointer f.e. when previewing samples from the treeview. MODTYPE m_nType; CHANNELINDEX m_nChannels; SAMPLEINDEX m_nSamples; @@ -784,8 +784,7 @@ bool SaveXM(LPCSTR lpszFileName, UINT nPacking=0, const bool bCompatibilityExport = false); bool SaveS3M(LPCSTR lpszFileName, UINT nPacking=0); bool SaveMod(LPCSTR lpszFileName, UINT nPacking=0, const bool bCompatibilityExport = false); - bool SaveIT(LPCSTR lpszFileName, UINT nPacking=0); - bool SaveCompatIT(LPCSTR lpszFileName); + bool SaveIT(LPCSTR lpszFileName, UINT nPacking=0, const bool compatExport = false); bool SaveITProject(LPCSTR lpszFileName); // -> CODE#0023 -> DESC="IT project files (.itp)" -! NEW_FEATURE#0023 UINT SaveMixPlugins(FILE *f=NULL, BOOL bUpdate=TRUE); void WriteInstrumentPropertyForAllInstruments(__int32 code, __int16 size, FILE* f, MODINSTRUMENT* instruments[], UINT nInstruments); @@ -1015,8 +1014,8 @@ UINT GetPeriodFromNote(UINT note, int nFineTune, UINT nC5Speed) const; UINT GetFreqFromPeriod(UINT period, UINT nC5Speed, int nPeriodFrac=0) const; // Misc functions - MODSAMPLE &GetSample(SAMPLEINDEX sample) { ASSERT(sample < CountOf(Samples)); return Samples[sample]; } - const MODSAMPLE &GetSample(SAMPLEINDEX sample) const { ASSERT(sample < CountOf(Samples)); return Samples[sample]; } + MODSAMPLE &GetSample(SAMPLEINDEX sample) { ASSERT(sample <= m_nSamples && sample < CountOf(Samples)); return Samples[sample]; } + const MODSAMPLE &GetSample(SAMPLEINDEX sample) const { ASSERT(sample <= m_nSamples && sample < CountOf(Samples)); return Samples[sample]; } static void ResetMidiCfg(MODMIDICFG &midiConfig); void SanitizeMacros(); UINT MapMidiInstrument(DWORD dwProgram, UINT nChannel, UINT nNote); @@ -1024,7 +1023,7 @@ UINT LoadMixPlugins(const void *pData, UINT nLen); // PSNDMIXPLUGIN GetSndPlugMixPlug(IMixPlugin *pPlugin); //rewbs.plugDocAware #ifndef NO_FILTER - DWORD CutOffToFrequency(UINT nCutOff, int flt_modifier=256) const; // [0-255] => [1-10KHz] + DWORD CutOffToFrequency(UINT nCutOff, int flt_modifier=256) const; // [0-127] => [1-10KHz] #endif #ifdef MODPLUG_TRACKER void ProcessMidiOut(CHANNELINDEX nChn, MODCHANNEL *pChn); //rewbs.VSTdelay : added arg. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-03 01:34:48
|
Revision: 1010 http://modplug.svn.sourceforge.net/modplug/?rev=1010&view=rev Author: saga-games Date: 2011-09-03 01:34:39 +0000 (Sat, 03 Sep 2011) Log Message: ----------- [Ref] A bit more cleanup Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/MPTHacks.cpp trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/mptrack/Moptions.cpp trunk/OpenMPT/mptrack/Undo.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/soundlib/IT_DEFS.H trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/modsmp_ctrl.cpp trunk/OpenMPT/soundlib/modsmp_ctrl.h Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-09-03 00:55:03 UTC (rev 1009) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-09-03 01:34:39 UTC (rev 1010) @@ -919,15 +919,18 @@ CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); SetCurrentSample(smp); - if(bDuplicate && nOldSmp >= 1 && nOldSmp < MAX_SAMPLES) + if(bDuplicate && nOldSmp >= 1 && nOldSmp <= pSndFile->GetNumSamples()) { m_pModDoc->GetSampleUndo()->PrepareUndo(smp, sundo_replace); MemCopy(m_pSndFile->GetSample(smp), m_pSndFile->GetSample(nOldSmp)); strcpy(m_pSndFile->m_szNames[smp], m_pSndFile->m_szNames[nOldSmp]); - // clone sample. - if((m_pSndFile->GetSample(smp).pSample = CSoundFile::AllocateSample(m_pSndFile->GetSample(nOldSmp).GetSampleSizeInBytes())) != nullptr) + // Clone sample. + if(m_pSndFile->GetSample(nOldSmp).pSample != nullptr) { - memcpy(m_pSndFile->GetSample(smp).pSample, m_pSndFile->GetSample(nOldSmp).pSample, m_pSndFile->GetSample(nOldSmp).GetSampleSizeInBytes()); + if((m_pSndFile->GetSample(smp).pSample = CSoundFile::AllocateSample(m_pSndFile->GetSample(nOldSmp).GetSampleSizeInBytes())) != nullptr) + { + memcpy(m_pSndFile->GetSample(smp).pSample, m_pSndFile->GetSample(nOldSmp).pSample, m_pSndFile->GetSample(nOldSmp).GetSampleSizeInBytes()); + } } } @@ -1501,14 +1504,14 @@ } } if (sample.nLoopStart >= dwEnd) sample.nLoopStart += (dwEnd-dwStart); else - if (sample.nLoopStart > dwStart) sample.nLoopStart += (sample.nLoopStart - dwStart); + if (sample.nLoopStart > dwStart) sample.nLoopStart += (sample.nLoopStart - dwStart); if (sample.nLoopEnd >= dwEnd) sample.nLoopEnd += (dwEnd-dwStart); else - if (sample.nLoopEnd > dwStart) sample.nLoopEnd += (sample.nLoopEnd - dwStart); + if (sample.nLoopEnd > dwStart) sample.nLoopEnd += (sample.nLoopEnd - dwStart); if (sample.nSustainStart >= dwEnd) sample.nSustainStart += (dwEnd-dwStart); else - if (sample.nSustainStart > dwStart) sample.nSustainStart += (sample.nSustainStart - dwStart); + if (sample.nSustainStart > dwStart) sample.nSustainStart += (sample.nSustainStart - dwStart); if (sample.nSustainEnd >= dwEnd) sample.nSustainEnd += (dwEnd-dwStart); else - if (sample.nSustainEnd > dwStart) sample.nSustainEnd += (sample.nSustainEnd - dwStart); - + if (sample.nSustainEnd > dwStart) sample.nSustainEnd += (sample.nSustainEnd - dwStart); + CriticalSection cs; for (UINT iFix=0; iFix<MAX_CHANNELS; iFix++) @@ -2215,7 +2218,7 @@ SELECTIONPOINTS selection = GetSelectionPoints(); m_pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_reverse, selection.nStart, selection.nEnd); - if(ctrlSmp::ReverseSample(&sample, selection.nStart, selection.nEnd, m_pSndFile) == true) + if(ctrlSmp::ReverseSample(sample, selection.nStart, selection.nEnd, m_pSndFile) == true) { m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA, NULL); m_pModDoc->SetModified(); @@ -2236,7 +2239,7 @@ SELECTIONPOINTS selection = GetSelectionPoints(); m_pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_invert, selection.nStart, selection.nEnd); - if(ctrlSmp::InvertSample(&sample, selection.nStart, selection.nEnd, m_pSndFile) == true) + if(ctrlSmp::InvertSample(sample, selection.nStart, selection.nEnd, m_pSndFile) == true) { m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA, NULL); m_pModDoc->SetModified(); @@ -2262,7 +2265,7 @@ SELECTIONPOINTS selection = GetSelectionPoints(); m_pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_unsign, selection.nStart, selection.nEnd); - if(ctrlSmp::UnsignSample(&sample, selection.nStart, selection.nEnd, m_pSndFile) == true) + if(ctrlSmp::UnsignSample(sample, selection.nStart, selection.nEnd, m_pSndFile) == true) { m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA, NULL); m_pModDoc->SetModified(); @@ -3163,7 +3166,7 @@ sample.nLoopStart = nFadeLength; } - if(ctrlSmp::XFadeSample(&sample, nFadeLength, m_pSndFile)) + if(ctrlSmp::XFadeSample(sample, nFadeLength, m_pSndFile)) { m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA | HINT_SAMPLEINFO, NULL); m_pModDoc->SetModified(); Modified: trunk/OpenMPT/mptrack/MPTHacks.cpp =================================================================== --- trunk/OpenMPT/mptrack/MPTHacks.cpp 2011-09-03 00:55:03 UTC (rev 1009) +++ trunk/OpenMPT/mptrack/MPTHacks.cpp 2011-09-03 01:34:39 UTC (rev 1010) @@ -265,7 +265,7 @@ foundHere = foundHacks = true; if(autofix) { - ctrlSmp::ConvertToMono(&smp, &m_SndFile); + ctrlSmp::ConvertToMono(smp, &m_SndFile); } else { break; Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2011-09-03 00:55:03 UTC (rev 1009) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2011-09-03 01:34:39 UTC (rev 1010) @@ -462,8 +462,8 @@ return SAMPLEINDEX_INVALID; } if (!m_SndFile.m_szNames[i][0]) strcpy(m_SndFile.m_szNames[i], "untitled"); + if (i > m_SndFile.GetNumSamples()) m_SndFile.m_nSamples = i; InitializeSample(m_SndFile.GetSample(i)); - if (i > m_SndFile.GetNumSamples()) m_SndFile.m_nSamples = i; SetModified(); return i; } @@ -474,9 +474,10 @@ INSTRUMENTINDEX CModDoc::InsertInstrument(SAMPLEINDEX nSample, INSTRUMENTINDEX nDuplicate) //---------------------------------------------------------------------------------------- { + if (m_SndFile.GetModSpecifications().instrumentsMax == 0) return INSTRUMENTINDEX_INVALID; + MODINSTRUMENT *pDup = nullptr; const INSTRUMENTINDEX nInstrumentMax = m_SndFile.GetModSpecifications().instrumentsMax - 1; - if ((m_SndFile.m_nType != MOD_TYPE_XM) && !(m_SndFile.m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT))) return INSTRUMENTINDEX_INVALID; if ((nDuplicate > 0) && (nDuplicate <= m_SndFile.m_nInstruments)) { pDup = m_SndFile.Instruments[nDuplicate]; @@ -494,15 +495,17 @@ m_SndFile.GetSample(smp).uFlags &= ~CHN_MUTE; if (!m_SndFile.Instruments[smp]) { - MODINSTRUMENT *p = new MODINSTRUMENT; - if (!p) + try { + MODINSTRUMENT *p = new MODINSTRUMENT; + InitializeInstrument(p, smp); + m_SndFile.Instruments[smp] = p; + lstrcpyn(p->name, m_SndFile.m_szNames[smp], sizeof(p->name)); + } catch(...) + { ErrorBox(IDS_ERR_OUTOFMEMORY, CMainFrame::GetMainFrame()); return INSTRUMENTINDEX_INVALID; } - InitializeInstrument(p, smp); - m_SndFile.Instruments[smp] = p; - lstrcpyn(p->name, m_SndFile.m_szNames[smp], sizeof(p->name)); } } m_SndFile.m_nInstruments = nInstruments; Modified: trunk/OpenMPT/mptrack/Moptions.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moptions.cpp 2011-09-03 00:55:03 UTC (rev 1009) +++ trunk/OpenMPT/mptrack/Moptions.cpp 2011-09-03 01:34:39 UTC (rev 1010) @@ -81,7 +81,7 @@ { CPropertyPage::OnInitDialog(); m_pPreviewDib = LoadDib(MAKEINTRESOURCE(IDB_COLORSETUP)); - memcpy(CustomColors, CMainFrame::GetSettings().rgbCustomColors, sizeof(CustomColors)); + MemCopy(CustomColors, CMainFrame::GetSettings().rgbCustomColors); for (UINT i = 0; i < CountOf(gColorDefs); i++) { m_ComboItem.SetItemData(m_ComboItem.AddString(gColorDefs[i].pszName), i); @@ -129,7 +129,7 @@ CMainFrame::GetSettings().m_nRowHighlightMeasures = GetDlgItemInt(IDC_PRIMARYHILITE); CMainFrame::GetSettings().m_nRowHighlightBeats = GetDlgItemInt(IDC_SECONDARYHILITE); - memcpy(CMainFrame::GetSettings().rgbCustomColors, CustomColors, sizeof(CMainFrame::GetSettings().rgbCustomColors)); + MemCopy(CMainFrame::GetSettings().rgbCustomColors, CustomColors); CMainFrame::UpdateColors(); CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); if (pMainFrm) pMainFrm->PostMessage(WM_MOD_INVALIDATEPATTERNS, HINT_MPTOPTIONS); Modified: trunk/OpenMPT/mptrack/Undo.cpp =================================================================== --- trunk/OpenMPT/mptrack/Undo.cpp 2011-09-03 00:55:03 UTC (rev 1009) +++ trunk/OpenMPT/mptrack/Undo.cpp 2011-09-03 01:34:39 UTC (rev 1010) @@ -381,17 +381,17 @@ case sundo_invert: // invert again - ctrlSmp::InvertSample(&sample, pUndo->nChangeStart, pUndo->nChangeEnd, pSndFile); + ctrlSmp::InvertSample(sample, pUndo->nChangeStart, pUndo->nChangeEnd, pSndFile); break; case sundo_reverse: // reverse again - ctrlSmp::ReverseSample(&sample, pUndo->nChangeStart, pUndo->nChangeEnd, pSndFile); + ctrlSmp::ReverseSample(sample, pUndo->nChangeStart, pUndo->nChangeEnd, pSndFile); break; case sundo_unsign: // unsign again - ctrlSmp::UnsignSample(&sample, pUndo->nChangeStart, pUndo->nChangeEnd, pSndFile); + ctrlSmp::UnsignSample(sample, pUndo->nChangeStart, pUndo->nChangeEnd, pSndFile); break; case sundo_insert: Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2011-09-03 00:55:03 UTC (rev 1009) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2011-09-03 01:34:39 UTC (rev 1010) @@ -2045,7 +2045,7 @@ if ((sample.uFlags & CHN_STEREO) && (sample.pSample) && (sample.nLength)) { pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_replace); - if(ctrlSmp::ConvertToMono(&sample, pSndFile)) + if(ctrlSmp::ConvertToMono(sample, pSndFile)) { pModDoc->SetModified(); pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA | HINT_SAMPLEINFO, NULL); Modified: trunk/OpenMPT/soundlib/IT_DEFS.H =================================================================== --- trunk/OpenMPT/soundlib/IT_DEFS.H 2011-09-03 00:55:03 UTC (rev 1009) +++ trunk/OpenMPT/soundlib/IT_DEFS.H 2011-09-03 01:34:39 UTC (rev 1010) @@ -3,7 +3,7 @@ #pragma pack(1) -typedef struct tagITFILEHEADER +struct ITFILEHEADER { DWORD id; // 0x4D504D49 CHAR songname[26]; @@ -28,10 +28,10 @@ DWORD reserved; // ChibiTracker writes "CHBI" here. OpenMPT writes "OMPT" here in some cases, see Load_it.cpp BYTE chnpan[64]; BYTE chnvol[64]; -} ITFILEHEADER; +}; -typedef struct tagITENVELOPE +struct ITENVELOPE { BYTE flags; BYTE num; @@ -41,10 +41,10 @@ BYTE sle; BYTE data[25*3]; BYTE reserved; -} ITENVELOPE; +}; // Old Impulse Instrument Format (cmwt < 0x200) -typedef struct tagITOLDINSTRUMENT +struct ITOLDINSTRUMENT { DWORD id; // IMPI = 0x49504D49 CHAR filename[12]; // DOS file name @@ -66,11 +66,11 @@ BYTE keyboard[240]; BYTE volenv[200]; BYTE nodes[50]; -} ITOLDINSTRUMENT; +}; // Impulse Instrument Format -typedef struct tagITINSTRUMENT +struct ITINSTRUMENT { DWORD id; CHAR filename[12]; @@ -99,19 +99,19 @@ ITENVELOPE panenv; ITENVELOPE pitchenv; BYTE dummy[4]; // was 7, but IT v2.17 saves 554 bytes -} ITINSTRUMENT; +}; // MPT IT Instrument Extension -typedef struct _ITINSTRUMENTEX +struct ITINSTRUMENTEX { ITINSTRUMENT iti; BYTE keyboardhi[120]; -} ITINSTRUMENTEX, *PITINSTRUMENTEX; +}; // IT Sample Format -typedef struct tagITSAMPLESTRUCT +struct ITSAMPLESTRUCT { DWORD id; // 0x53504D49 CHAR filename[12]; @@ -133,16 +133,16 @@ BYTE vid; BYTE vir; BYTE vit; -} ITSAMPLESTRUCT; +}; // IT Header extension: Save history -typedef struct tagITHISTORYSTRUCT +struct ITHISTORYSTRUCT { - uint16 fatdate; // DOS/FAT date when the file was opened / created in the editor. For details, read http://msdn.microsoft.com/en-us/library/ms724247(VS.85).aspx - uint16 fattime; // DOS/FAT time when the file was opened / created in the editor. + uint16 fatdate; // DOS / FAT date when the file was opened / created in the editor. For details, read http://msdn.microsoft.com/en-us/library/ms724247(VS.85).aspx + uint16 fattime; // DOS / FAT time when the file was opened / created in the editor. uint32 runtime; // The time how long the file was open in the editor, in 1/18.2th seconds. (= ticks of the DOS timer) -} ITHISTORYSTRUCT; +}; #pragma pack() @@ -159,6 +159,10 @@ #define IT_OMPT 0x54504D4F // "OMPT" magic bytes for non-standard OpenMPT IT files #define IT_CHBI 0x49424843 // "CHBI" magic bytes in the IT header to identify ChibiTracker +// MPT stuff +#define IT_PNAM 0x4D414E50 // "PNAM" pattern names +#define IT_CNAM 0x4D414E43 // "CNAM" channel names + enum IT_ReaderBitMasks { // pattern row parsing, the channel data is read to obtain Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2011-09-03 00:55:03 UTC (rev 1009) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2011-09-03 01:34:39 UTC (rev 1010) @@ -493,7 +493,7 @@ // -> DESC="misc quantity changes" // BYTE chnmask[64], channels_used[64]; // MODCOMMAND lastvalue[64]; - BYTE chnmask[MAX_BASECHANNELS], channels_used[MAX_BASECHANNELS]; + BYTE chnmask[MAX_BASECHANNELS]; MODCOMMAND lastvalue[MAX_BASECHANNELS]; // -! BEHAVIOUR_CHANGE#0006 @@ -825,7 +825,7 @@ // Read pattern names: "PNAM" char *patNames = nullptr; UINT patNamesLen = 0; - if ((dwMemPos + 8 < dwMemLength) && (*((DWORD *)(lpStream+dwMemPos)) == 0x4d414e50)) + if ((dwMemPos + 8 < dwMemLength) && (*((DWORD *)(lpStream+dwMemPos)) == LittleEndian(IT_PNAM))) { patNamesLen = *((DWORD *)(lpStream + dwMemPos + 4)); dwMemPos += 8; @@ -838,7 +838,7 @@ m_nChannels = GetModSpecifications().channelsMin; // Read channel names: "CNAM" - if ((dwMemPos + 8 < dwMemLength) && (*((DWORD *)(lpStream+dwMemPos)) == 0x4d414e43)) + if ((dwMemPos + 8 < dwMemLength) && (*((DWORD *)(lpStream+dwMemPos)) == LittleEndian(IT_CNAM))) { UINT len = *((DWORD *)(lpStream+dwMemPos+4)); dwMemPos += 8; @@ -1151,7 +1151,6 @@ } m[ch].note = note; lastvalue[ch].note = note; - channels_used[ch] = TRUE; } } if (chnmask[ch] & 2) @@ -1411,11 +1410,9 @@ if(header.ordnum < 2) header.ordnum = 2; } - header.insnum = m_nInstruments; - header.smpnum = m_nSamples; - header.patnum = (GetType() == MOD_TYPE_MPT) ? Patterns.Size() : MAX_PATTERNS; - if(Patterns.Size() < header.patnum) Patterns.ResizeArray(header.patnum); - while ((header.patnum > 0) && (!Patterns[header.patnum - 1])) header.patnum--; + header.insnum = min(m_nInstruments, specs.instrumentsMax); + header.smpnum = min(m_nSamples, specs.samplesMax); + header.patnum = min(Patterns.GetNumPatterns(), specs.patternsMax); // Parapointers vector<DWORD> patpos(header.patnum, 0); @@ -1433,7 +1430,7 @@ MptVersion::VersionNum vVersion = MptVersion::num; header.cwtv = LittleEndianW(0x5000 | (WORD)((vVersion >> 16) & 0x0FFF)); // format: txyy (t = tracker ID, x = version major, yy = version minor), e.g. 0x5117 (OpenMPT = 5, 117 = v1.17) header.cmwt = LittleEndianW(0x0214); // Common compatible tracker :) - // hack from schism tracker: + // Hack from schism tracker: for(INSTRUMENTINDEX nIns = 1; nIns <= GetNumInstruments(); nIns++) { if(Instruments[nIns] && Instruments[nIns]->PitchEnv.dwFlags & ENV_FILTER) @@ -1458,7 +1455,7 @@ if (m_dwSongFlags & SONG_ITCOMPATGXX) header.flags |= 0x20; if ((m_dwSongFlags & SONG_EXFILTERRANGE) && !compatExport) header.flags |= 0x1000; header.globalvol = m_nDefaultGlobalVolume >> 1; - header.mv = CLAMP(m_nSamplePreAmp, 0, 128); + header.mv = min(m_nSamplePreAmp, 128); header.speed = m_nDefaultSpeed; header.tempo = min(m_nDefaultTempo, 255); //Limit this one to 255, we save the real one as an extension below. header.sep = 128; // pan separation @@ -1467,7 +1464,7 @@ memset(header.chnpan, 0xA0, 64); memset(header.chnvol, 64, 64); - for (UINT ich=0; ich</*m_nChannels*/64; ich++) //Header only has room for settings for 64 chans... + for (size_t ich = 0; ich < 64; ich++) //Header only has room for settings for 64 chans... { header.chnpan[ich] = ChnSettings[ich].nPan >> 2; if (ChnSettings[ich].dwFlags & CHN_SURROUND) header.chnpan[ich] = 100; @@ -1515,8 +1512,8 @@ if (m_lpszSongComments) { header.special |= 1; - header.msglength = strlen(m_lpszSongComments)+1; - header.msgoffset = dwHdrPos + dwExtra + header.insnum*4 + header.patnum*4 + header.smpnum*4; + header.msglength = strlen(m_lpszSongComments) + 1; + header.msgoffset = dwHdrPos + dwExtra + (header.insnum + header.smpnum + header.patnum) * 4; } // Write file header @@ -1538,7 +1535,7 @@ // Writing pattern names if (numNamedPats && !compatExport) { - DWORD d = 0x4d414e50; + DWORD d = LittleEndian(IT_PNAM); // "PNAM" fwrite(&d, 1, 4, f); d = numNamedPats * MAX_PATTERNNAME; fwrite(&d, 1, 4, f); @@ -1555,7 +1552,7 @@ // Writing channel names if (dwChnNamLen && !compatExport) { - DWORD d = 0x4d414e43; + DWORD d = LittleEndian(IT_CNAM); // "CNAM" fwrite(&d, 1, 4, f); fwrite(&dwChnNamLen, 1, 4, f); UINT nChnNames = dwChnNamLen / MAX_CHANNELNAME; Modified: trunk/OpenMPT/soundlib/modsmp_ctrl.cpp =================================================================== --- trunk/OpenMPT/soundlib/modsmp_ctrl.cpp 2011-09-03 00:55:03 UTC (rev 1009) +++ trunk/OpenMPT/soundlib/modsmp_ctrl.cpp 2011-09-03 01:34:39 UTC (rev 1010) @@ -11,7 +11,7 @@ namespace ctrlSmp { -void ReplaceSample(MODSAMPLE& smp, const LPSTR pNewSample, const SmpLength nNewLength, CSoundFile* pSndFile) +void ReplaceSample(MODSAMPLE &smp, const LPSTR pNewSample, const SmpLength nNewLength, CSoundFile* pSndFile) //---------------------------------------------------------------------------------------------------------- { LPSTR const pOldSmp = smp.pSample; @@ -36,7 +36,7 @@ } -SmpLength InsertSilence(MODSAMPLE& smp, const SmpLength nSilenceLength, const SmpLength nStartFrom, CSoundFile* pSndFile) +SmpLength InsertSilence(MODSAMPLE &smp, const SmpLength nSilenceLength, const SmpLength nStartFrom, CSoundFile* pSndFile) //----------------------------------------------------------------------------------------------------------------------- { if(nSilenceLength == 0 || nSilenceLength >= MAX_SAMPLE_LENGTH || smp.nLength > MAX_SAMPLE_LENGTH - nSilenceLength) @@ -92,7 +92,7 @@ } -SmpLength ResizeSample(MODSAMPLE& smp, const SmpLength nNewLength, CSoundFile* pSndFile) +SmpLength ResizeSample(MODSAMPLE &smp, const SmpLength nNewLength, CSoundFile* pSndFile) //-------------------------------------------------------------------------------------- { // Invalid sample size @@ -140,7 +140,7 @@ template <class T> -void AdjustEndOfSampleImpl(MODSAMPLE& smp) +void AdjustEndOfSampleImpl(MODSAMPLE &smp) //---------------------------------------- { MODSAMPLE* const pSmp = &smp; @@ -169,46 +169,44 @@ } // unnamed namespace. -bool AdjustEndOfSample(MODSAMPLE& smp, CSoundFile* pSndFile) +bool AdjustEndOfSample(MODSAMPLE &smp, CSoundFile* pSndFile) //---------------------------------------------------------- { - MODSAMPLE* const pSmp = &smp; - - if ((!pSmp->nLength) || (!pSmp->pSample)) + if ((!smp.nLength) || (!smp.pSample)) return false; CriticalSection cs; - if (pSmp->GetElementarySampleSize() == 2) - AdjustEndOfSampleImpl<int16>(*pSmp); - else if(pSmp->GetElementarySampleSize() == 1) - AdjustEndOfSampleImpl<int8>(*pSmp); + if (smp.GetElementarySampleSize() == 2) + AdjustEndOfSampleImpl<int16>(smp); + else if(smp.GetElementarySampleSize() == 1) + AdjustEndOfSampleImpl<int8>(smp); // Update channels with new loop values if(pSndFile != nullptr) { CSoundFile& rSndFile = *pSndFile; - for (UINT i=0; i<MAX_CHANNELS; i++) if ((rSndFile.Chn[i].pModSample == pSmp) && (rSndFile.Chn[i].nLength)) + for (UINT i=0; i<MAX_CHANNELS; i++) if ((rSndFile.Chn[i].pModSample == &smp) && (rSndFile.Chn[i].nLength)) { - if ((pSmp->nLoopStart + 3 < pSmp->nLoopEnd) && (pSmp->nLoopEnd <= pSmp->nLength)) + if ((smp.nLoopStart + 3 < smp.nLoopEnd) && (smp.nLoopEnd <= smp.nLength)) { - rSndFile.Chn[i].nLoopStart = pSmp->nLoopStart; - rSndFile.Chn[i].nLoopEnd = pSmp->nLoopEnd; - rSndFile.Chn[i].nLength = pSmp->nLoopEnd; + rSndFile.Chn[i].nLoopStart = smp.nLoopStart; + rSndFile.Chn[i].nLoopEnd = smp.nLoopEnd; + rSndFile.Chn[i].nLength = smp.nLoopEnd; if (rSndFile.Chn[i].nPos > rSndFile.Chn[i].nLength) { rSndFile.Chn[i].nPos = rSndFile.Chn[i].nLoopStart; rSndFile.Chn[i].dwFlags &= ~CHN_PINGPONGFLAG; } DWORD d = rSndFile.Chn[i].dwFlags & ~(CHN_PINGPONGLOOP|CHN_LOOP); - if (pSmp->uFlags & CHN_LOOP) + if (smp.uFlags & CHN_LOOP) { d |= CHN_LOOP; - if (pSmp->uFlags & CHN_PINGPONGLOOP) d |= CHN_PINGPONGLOOP; + if (smp.uFlags & CHN_PINGPONGLOOP) d |= CHN_PINGPONGLOOP; } rSndFile.Chn[i].dwFlags = d; } else - if (!(pSmp->uFlags & CHN_LOOP)) + if (!(smp.uFlags & CHN_LOOP)) { rSndFile.Chn[i].dwFlags &= ~(CHN_PINGPONGLOOP|CHN_LOOP); } @@ -219,7 +217,7 @@ } -void ResetSamples(CSoundFile& rSndFile, ResetFlag resetflag) +void ResetSamples(CSoundFile &rSndFile, ResetFlag resetflag) //---------------------------------------------------------- { const UINT nSamples = rSndFile.GetNumSamples(); @@ -313,7 +311,7 @@ // Remove DC offset -float RemoveDCOffset(MODSAMPLE& smp, +float RemoveDCOffset(MODSAMPLE &smp, SmpLength iStart, SmpLength iEnd, const MODTYPE modtype, @@ -323,27 +321,25 @@ if(smp.pSample == nullptr || smp.nLength < 1) return 0; - MODSAMPLE* const pSmp = &smp; - - if (iEnd > pSmp->nLength) iEnd = pSmp->nLength; + if (iEnd > smp.nLength) iEnd = smp.nLength; if (iStart > iEnd) iStart = iEnd; if (iStart == iEnd) { iStart = 0; - iEnd = pSmp->nLength; + iEnd = smp.nLength; } - iStart *= pSmp->GetNumChannels(); - iEnd *= pSmp->GetNumChannels(); + iStart *= smp.GetNumChannels(); + iEnd *= smp.GetNumChannels(); - const double dMaxAmplitude = (pSmp->GetElementarySampleSize() == 2) ? GetMaxAmplitude<int16>() : GetMaxAmplitude<int8>(); + const double dMaxAmplitude = (smp.GetElementarySampleSize() == 2) ? GetMaxAmplitude<int16>() : GetMaxAmplitude<int8>(); // step 1: Calculate offset. OffsetData oData = {0,0,0}; - if(pSmp->GetElementarySampleSize() == 2) - oData = CalculateOffset(reinterpret_cast<int16*>(pSmp->pSample) + iStart, iEnd - iStart); - else if(pSmp->GetElementarySampleSize() == 1) - oData = CalculateOffset(reinterpret_cast<int8*>(pSmp->pSample) + iStart, iEnd - iStart); + if(smp.GetElementarySampleSize() == 2) + oData = CalculateOffset(reinterpret_cast<int16*>(smp.pSample) + iStart, iEnd - iStart); + else if(smp.GetElementarySampleSize() == 1) + oData = CalculateOffset(reinterpret_cast<int8*>(smp.pSample) + iStart, iEnd - iStart); double dMin = oData.dMin, dMax = oData.dMax, dOffset = oData.dOffset; @@ -361,22 +357,22 @@ // step 2: centralize + normalize sample dOffset *= dMaxAmplitude * dAmplify; - if(pSmp->GetElementarySampleSize() == 2) - RemoveOffsetAndNormalize( reinterpret_cast<int16*>(pSmp->pSample) + iStart, iEnd - iStart, dOffset, dAmplify); - else if(pSmp->GetElementarySampleSize() == 1) - RemoveOffsetAndNormalize( reinterpret_cast<int8*>(pSmp->pSample) + iStart, iEnd - iStart, dOffset, dAmplify); + if(smp.GetElementarySampleSize() == 2) + RemoveOffsetAndNormalize( reinterpret_cast<int16*>(smp.pSample) + iStart, iEnd - iStart, dOffset, dAmplify); + else if(smp.GetElementarySampleSize() == 1) + RemoveOffsetAndNormalize( reinterpret_cast<int8*>(smp.pSample) + iStart, iEnd - iStart, dOffset, dAmplify); // step 3: adjust global vol (if available) - if((modtype & (MOD_TYPE_IT | MOD_TYPE_MPT)) && (iStart == 0) && (iEnd == pSmp->nLength * pSmp->GetNumChannels())) + if((modtype & (MOD_TYPE_IT | MOD_TYPE_MPT)) && (iStart == 0) && (iEnd == smp.nLength * smp.GetNumChannels())) { CriticalSection cs; - pSmp->nGlobalVol = min((WORD)(pSmp->nGlobalVol / dAmplify), 64); + smp.nGlobalVol = min((WORD)(smp.nGlobalVol / dAmplify), 64); for (CHANNELINDEX i = 0; i < MAX_CHANNELS; i++) { - if(pSndFile->Chn[i].pSample == pSmp->pSample) + if(pSndFile->Chn[i].pSample == smp.pSample) { - pSndFile->Chn[i].nGlobalVol = pSmp->nGlobalVol; + pSndFile->Chn[i].nGlobalVol = smp.nGlobalVol; } } } @@ -398,30 +394,30 @@ } // Reverse sample data -bool ReverseSample(MODSAMPLE *pSmp, SmpLength iStart, SmpLength iEnd, CSoundFile *pSndFile) -//----------------------------------------------------------------------------------------- +bool ReverseSample(MODSAMPLE &smp, SmpLength iStart, SmpLength iEnd, CSoundFile *pSndFile) +//---------------------------------------------------------------------------------------- { - if(pSmp->pSample == nullptr) return false; - if(iEnd == 0 || iStart > pSmp->nLength || iEnd > pSmp->nLength) + if(smp.pSample == nullptr) return false; + if(iEnd == 0 || iStart > smp.nLength || iEnd > smp.nLength) { iStart = 0; - iEnd = pSmp->nLength; + iEnd = smp.nLength; } if(iEnd - iStart < 2) return false; - if(pSmp->GetBytesPerSample() == 8) // unused (yet) - ReverseSampleImpl(reinterpret_cast<int64*>(pSmp->pSample) + iStart, iEnd - iStart); - else if(pSmp->GetBytesPerSample() == 4) // 16 bit stereo - ReverseSampleImpl(reinterpret_cast<int32*>(pSmp->pSample) + iStart, iEnd - iStart); - else if(pSmp->GetBytesPerSample() == 2) // 16 bit mono / 8 bit stereo - ReverseSampleImpl(reinterpret_cast<int16*>(pSmp->pSample) + iStart, iEnd - iStart); - else if(pSmp->GetBytesPerSample() == 1) // 8 bit mono - ReverseSampleImpl(reinterpret_cast<int8*>(pSmp->pSample) + iStart, iEnd - iStart); + if(smp.GetBytesPerSample() == 8) // unused (yet) + ReverseSampleImpl(reinterpret_cast<int64*>(smp.pSample) + iStart, iEnd - iStart); + else if(smp.GetBytesPerSample() == 4) // 16 bit stereo + ReverseSampleImpl(reinterpret_cast<int32*>(smp.pSample) + iStart, iEnd - iStart); + else if(smp.GetBytesPerSample() == 2) // 16 bit mono / 8 bit stereo + ReverseSampleImpl(reinterpret_cast<int16*>(smp.pSample) + iStart, iEnd - iStart); + else if(smp.GetBytesPerSample() == 1) // 8 bit mono + ReverseSampleImpl(reinterpret_cast<int8*>(smp.pSample) + iStart, iEnd - iStart); else return false; - AdjustEndOfSample(*pSmp, pSndFile); + AdjustEndOfSample(smp, pSndFile); return true; } @@ -438,25 +434,25 @@ } // Virtually unsign sample data -bool UnsignSample(MODSAMPLE *pSmp, SmpLength iStart, SmpLength iEnd, CSoundFile *pSndFile) -//---------------------------------------------------------------------------------------- +bool UnsignSample(MODSAMPLE &smp, SmpLength iStart, SmpLength iEnd, CSoundFile *pSndFile) +//--------------------------------------------------------------------------------------- { - if(pSmp->pSample == nullptr) return false; - if(iEnd == 0 || iStart > pSmp->nLength || iEnd > pSmp->nLength) + if(smp.pSample == nullptr) return false; + if(iEnd == 0 || iStart > smp.nLength || iEnd > smp.nLength) { iStart = 0; - iEnd = pSmp->nLength; + iEnd = smp.nLength; } - iStart *= pSmp->GetNumChannels(); - iEnd *= pSmp->GetNumChannels(); - if(pSmp->GetElementarySampleSize() == 2) - UnsignSampleImpl(reinterpret_cast<int16*>(pSmp->pSample) + iStart, iEnd - iStart); - else if(pSmp->GetElementarySampleSize() == 1) - UnsignSampleImpl(reinterpret_cast<int8*>(pSmp->pSample) + iStart, iEnd - iStart); + iStart *= smp.GetNumChannels(); + iEnd *= smp.GetNumChannels(); + if(smp.GetElementarySampleSize() == 2) + UnsignSampleImpl(reinterpret_cast<int16*>(smp.pSample) + iStart, iEnd - iStart); + else if(smp.GetElementarySampleSize() == 1) + UnsignSampleImpl(reinterpret_cast<int8*>(smp.pSample) + iStart, iEnd - iStart); else return false; - AdjustEndOfSample(*pSmp, pSndFile); + AdjustEndOfSample(smp, pSndFile); return true; } @@ -472,25 +468,25 @@ } // Invert sample data (flip by 180 degrees) -bool InvertSample(MODSAMPLE *pSmp, SmpLength iStart, SmpLength iEnd, CSoundFile *pSndFile) -//---------------------------------------------------------------------------------------- +bool InvertSample(MODSAMPLE &smp, SmpLength iStart, SmpLength iEnd, CSoundFile *pSndFile) +//--------------------------------------------------------------------------------------- { - if(pSmp->pSample == nullptr) return false; - if(iEnd == 0 || iStart > pSmp->nLength || iEnd > pSmp->nLength) + if(smp.pSample == nullptr) return false; + if(iEnd == 0 || iStart > smp.nLength || iEnd > smp.nLength) { iStart = 0; - iEnd = pSmp->nLength; + iEnd = smp.nLength; } - iStart *= pSmp->GetNumChannels(); - iEnd *= pSmp->GetNumChannels(); - if(pSmp->GetElementarySampleSize() == 2) - InvertSampleImpl(reinterpret_cast<int16*>(pSmp->pSample) + iStart, iEnd - iStart); - else if(pSmp->GetElementarySampleSize() == 1) - InvertSampleImpl(reinterpret_cast<int8*>(pSmp->pSample) + iStart, iEnd - iStart); + iStart *= smp.GetNumChannels(); + iEnd *= smp.GetNumChannels(); + if(smp.GetElementarySampleSize() == 2) + InvertSampleImpl(reinterpret_cast<int16*>(smp.pSample) + iStart, iEnd - iStart); + else if(smp.GetElementarySampleSize() == 1) + InvertSampleImpl(reinterpret_cast<int8*>(smp.pSample) + iStart, iEnd - iStart); else return false; - AdjustEndOfSample(*pSmp, pSndFile); + AdjustEndOfSample(smp, pSndFile); return true; } @@ -507,27 +503,27 @@ } // X-Fade sample data to create smooth loop transitions -bool XFadeSample(MODSAMPLE *pSmp, SmpLength iFadeLength, CSoundFile *pSndFile) -//---------------------------------------------------------------------------- +bool XFadeSample(MODSAMPLE &smp, SmpLength iFadeLength, CSoundFile *pSndFile) +//--------------------------------------------------------------------------- { - if(pSmp->pSample == nullptr) return false; - if(pSmp->nLoopEnd <= pSmp->nLoopStart || pSmp->nLoopEnd > pSmp->nLength) return false; - if(pSmp->nLoopStart < iFadeLength) return false; + if(smp.pSample == nullptr) return false; + if(smp.nLoopEnd <= smp.nLoopStart || smp.nLoopEnd > smp.nLength) return false; + if(smp.nLoopStart < iFadeLength) return false; - SmpLength iStart = pSmp->nLoopStart - iFadeLength; - SmpLength iEnd = pSmp->nLoopEnd - iFadeLength; - iStart *= pSmp->GetNumChannels(); - iEnd *= pSmp->GetNumChannels(); - iFadeLength *= pSmp->GetNumChannels(); + SmpLength iStart = smp.nLoopStart - iFadeLength; + SmpLength iEnd = smp.nLoopEnd - iFadeLength; + iStart *= smp.GetNumChannels(); + iEnd *= smp.GetNumChannels(); + iFadeLength *= smp.GetNumChannels(); - if(pSmp->GetElementarySampleSize() == 2) - XFadeSampleImpl(reinterpret_cast<int16*>(pSmp->pSample) + iStart, iEnd - iStart, iFadeLength); - else if(pSmp->GetElementarySampleSize() == 1) - XFadeSampleImpl(reinterpret_cast<int8*>(pSmp->pSample) + iStart, iEnd - iStart, iFadeLength); + if(smp.GetElementarySampleSize() == 2) + XFadeSampleImpl(reinterpret_cast<int16*>(smp.pSample) + iStart, iEnd - iStart, iFadeLength); + else if(smp.GetElementarySampleSize() == 1) + XFadeSampleImpl(reinterpret_cast<int8*>(smp.pSample) + iStart, iEnd - iStart, iFadeLength); else return false; - AdjustEndOfSample(*pSmp, pSndFile); + AdjustEndOfSample(smp, pSndFile); return true; } @@ -545,30 +541,30 @@ // Convert a multichannel sample to mono (currently only implemented for stereo) -bool ConvertToMono(MODSAMPLE *pSmp, CSoundFile *pSndFile) -//------------------------------------------------------- +bool ConvertToMono(MODSAMPLE &smp, CSoundFile *pSndFile) +//------------------------------------------------------ { - if(pSmp->pSample == nullptr || pSmp->nLength == 0 || pSmp->GetNumChannels() != 2) return false; + if(smp.pSample == nullptr || smp.nLength == 0 || smp.GetNumChannels() != 2) return false; // Note: Sample is overwritten in-place! Unused data is not deallocated! - if(pSmp->GetElementarySampleSize() == 2) - ConvertStereoToMonoImpl(reinterpret_cast<int16*>(pSmp->pSample), pSmp->nLength); - else if(pSmp->GetElementarySampleSize() == 1) - ConvertStereoToMonoImpl(reinterpret_cast<int8*>(pSmp->pSample), pSmp->nLength); + if(smp.GetElementarySampleSize() == 2) + ConvertStereoToMonoImpl(reinterpret_cast<int16*>(smp.pSample), smp.nLength); + else if(smp.GetElementarySampleSize() == 1) + ConvertStereoToMonoImpl(reinterpret_cast<int8*>(smp.pSample), smp.nLength); else return false; CriticalSection cs; - pSmp->uFlags &= ~(CHN_STEREO); + smp.uFlags &= ~(CHN_STEREO); for (CHANNELINDEX i = 0; i < MAX_CHANNELS; i++) { - if(pSndFile->Chn[i].pSample == pSmp->pSample) + if(pSndFile->Chn[i].pSample == smp.pSample) { pSndFile->Chn[i].dwFlags &= ~CHN_STEREO; } } - AdjustEndOfSample(*pSmp, pSndFile); + AdjustEndOfSample(smp, pSndFile); return true; } Modified: trunk/OpenMPT/soundlib/modsmp_ctrl.h =================================================================== --- trunk/OpenMPT/soundlib/modsmp_ctrl.h 2011-09-03 00:55:03 UTC (rev 1009) +++ trunk/OpenMPT/soundlib/modsmp_ctrl.h 2011-09-03 01:34:39 UTC (rev 1010) @@ -22,30 +22,30 @@ // Insert silence to given location. // Note: Is currently implemented only for inserting silence to the beginning and to the end of the sample. // Return: Length of the new sample. -SmpLength InsertSilence(MODSAMPLE& smp, const SmpLength nSilenceLength, const SmpLength nStartFrom, CSoundFile* pSndFile); +SmpLength InsertSilence(MODSAMPLE &smp, const SmpLength nSilenceLength, const SmpLength nStartFrom, CSoundFile* pSndFile); // Change sample size. // Note: If resized sample is bigger, silence will be added to the sample's tail. // Return: Length of the new sample. -SmpLength ResizeSample(MODSAMPLE& smp, const SmpLength nNewLength, CSoundFile* pSndFile); +SmpLength ResizeSample(MODSAMPLE &smp, const SmpLength nNewLength, CSoundFile* pSndFile); // Replaces sample in 'smp' with given sample and frees the old sample. // If valid CSoundFile pointer is given, the sample will be replaced also from the sounds channels. -void ReplaceSample(MODSAMPLE& smp, const LPSTR pNewSample, const SmpLength nNewLength, CSoundFile* pSndFile); +void ReplaceSample(MODSAMPLE &smp, const LPSTR pNewSample, const SmpLength nNewLength, CSoundFile* pSndFile); -bool AdjustEndOfSample(MODSAMPLE& smp, CSoundFile* pSndFile = 0); +bool AdjustEndOfSample(MODSAMPLE &smp, CSoundFile* pSndFile = 0); // Returns the number of bytes allocated(at least) for sample data. // Note: Currently the return value is based on the sample length and the actual // allocation may be more than what this function returns. -inline SmpLength GetSampleCapacity(MODSAMPLE& smp) {return smp.GetSampleSizeInBytes();} +inline SmpLength GetSampleCapacity(MODSAMPLE &smp) {return smp.GetSampleSizeInBytes();} // Resets samples. -void ResetSamples(CSoundFile& rSndFile, ResetFlag resetflag); +void ResetSamples(CSoundFile &rSndFile, ResetFlag resetflag); // Remove DC offset and normalize. // Return: If DC offset was removed, returns original offset value, zero otherwise. -float RemoveDCOffset(MODSAMPLE& smp, +float RemoveDCOffset(MODSAMPLE &smp, SmpLength iStart, // Start position (for partial DC offset removal). SmpLength iEnd, // End position (for partial DC offset removal). const MODTYPE modtype, // Used to determine whether to adjust global or default volume @@ -54,19 +54,19 @@ CSoundFile* const pSndFile); // Passed to AdjustEndOfSample. // Reverse sample data -bool ReverseSample(MODSAMPLE *pSmp, SmpLength iStart, SmpLength iEnd, CSoundFile *pSndFile); +bool ReverseSample(MODSAMPLE &smp, SmpLength iStart, SmpLength iEnd, CSoundFile *pSndFile); // Virtually unsign sample data -bool UnsignSample(MODSAMPLE *pSmp, SmpLength iStart, SmpLength iEnd, CSoundFile *pSndFile); +bool UnsignSample(MODSAMPLE &smp, SmpLength iStart, SmpLength iEnd, CSoundFile *pSndFile); // Invert sample data (flip by 180 degrees) -bool InvertSample(MODSAMPLE *pSmp, SmpLength iStart, SmpLength iEnd, CSoundFile *pSndFile); +bool InvertSample(MODSAMPLE &smp, SmpLength iStart, SmpLength iEnd, CSoundFile *pSndFile); // Crossfade sample data to create smooth loops -bool XFadeSample(MODSAMPLE *pSmp, SmpLength iFadeLength, CSoundFile *pSndFile); +bool XFadeSample(MODSAMPLE &smp, SmpLength iFadeLength, CSoundFile *pSndFile); // Convert a sample with any number of channels to mono -bool ConvertToMono(MODSAMPLE *pSmp, CSoundFile *pSndFile); +bool ConvertToMono(MODSAMPLE &smp, CSoundFile *pSndFile); } // Namespace ctrlSmp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-03 18:52:32
|
Revision: 1012 http://modplug.svn.sourceforge.net/modplug/?rev=1012&view=rev Author: saga-games Date: 2011-09-03 18:52:21 +0000 (Sat, 03 Sep 2011) Log Message: ----------- [Ref] Moved some code that is common between tracker and player library to ./common/ [Ref] Unified calls to ::MessageBox / AfxMessageBox into Reporting::Notification Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/AutoSaver.cpp trunk/OpenMPT/mptrack/CleanupSong.cpp trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/Ctrl_gen.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/DefaultVstEditor.cpp trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/EffectVis.cpp trunk/OpenMPT/mptrack/ExceptionHandler.cpp trunk/OpenMPT/mptrack/Globals.cpp trunk/OpenMPT/mptrack/KeyConfigDlg.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/ModConvert.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/PSRatioCalc.cpp trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp trunk/OpenMPT/mptrack/Stdafx.h trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TuningDialog.cpp trunk/OpenMPT/mptrack/UpdateCheck.cpp trunk/OpenMPT/mptrack/View_gen.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_pat.h trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/mptrack/dlg_misc.h trunk/OpenMPT/mptrack/fxp.cpp trunk/OpenMPT/mptrack/mod2midi.cpp trunk/OpenMPT/mptrack/mptrack.vcproj trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/mptrack/serialization_utils.h trunk/OpenMPT/mptrack/test/test.cpp trunk/OpenMPT/mptrack/view_com.cpp trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_xm.cpp trunk/OpenMPT/soundlib/Loaders.h trunk/OpenMPT/soundlib/Message.cpp trunk/OpenMPT/soundlib/Mmx_mix.cpp trunk/OpenMPT/soundlib/ModSequence.cpp trunk/OpenMPT/soundlib/Sampleio.cpp trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Snd_rvb.cpp trunk/OpenMPT/soundlib/Snddev.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp trunk/OpenMPT/soundlib/mod_specifications.cpp trunk/OpenMPT/soundlib/modcommand.h trunk/OpenMPT/soundlib/modsmp_ctrl.cpp trunk/OpenMPT/soundlib/tuningbase.h trunk/OpenMPT/ungzip/ungzip.h Added Paths: ----------- trunk/OpenMPT/common/ trunk/OpenMPT/common/Reporting.cpp trunk/OpenMPT/common/Reporting.h trunk/OpenMPT/common/StringFixer.h trunk/OpenMPT/common/misc_util.cpp trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/common/typedefs.h Removed Paths: ------------- trunk/OpenMPT/mptrack/misc_util.cpp trunk/OpenMPT/mptrack/misc_util.h trunk/OpenMPT/mptrack/typedefs.h trunk/OpenMPT/soundlib/StringFixer.h Property changes on: trunk/OpenMPT/common ___________________________________________________________________ Added: tsvn:logminsize + 10 Added: bugtraq:number + true Added: trunk/OpenMPT/common/Reporting.cpp =================================================================== --- trunk/OpenMPT/common/Reporting.cpp (rev 0) +++ trunk/OpenMPT/common/Reporting.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -0,0 +1,21 @@ +#include "Stdafx.h" +#include "Reporting.h" +#include "../mptrack/Mainfrm.h" + +UINT Reporting::Notification(CString text, UINT flags /* = MB_OK*/, HWND parent /* = NULL*/) +//------------------------------------------------------------------------------------------ +{ + return ::MessageBox(parent, text, MAINFRAME_TITLE, flags); +}; + + +UINT Reporting::Notification(CString text, CString caption, UINT flags /* = MB_OK*/, HWND parent /* = NULL*/) +//----------------------------------------------------------------------------------------------------------- +{ + if(parent == NULL && CMainFrame::GetMainFrame() != nullptr) + { + parent = CMainFrame::GetMainFrame()->m_hWnd; + } + + return ::MessageBox(parent, text, caption, flags); +}; Added: trunk/OpenMPT/common/Reporting.h =================================================================== --- trunk/OpenMPT/common/Reporting.h (rev 0) +++ trunk/OpenMPT/common/Reporting.h 2011-09-03 18:52:21 UTC (rev 1012) @@ -0,0 +1,17 @@ +#pragma once +#ifndef REPORTING_H +#define REPORTING_H + +//============= +class Reporting +//============= +{ + +public: + + static UINT Notification(CString text, UINT flags = MB_OK, HWND parent = NULL); + static UINT Notification(CString text, CString caption, UINT flags = MB_OK, HWND parent = NULL); + +}; + +#endif // REPORTING_H Added: trunk/OpenMPT/common/StringFixer.h =================================================================== --- trunk/OpenMPT/common/StringFixer.h (rev 0) +++ trunk/OpenMPT/common/StringFixer.h 2011-09-03 18:52:21 UTC (rev 1012) @@ -0,0 +1,124 @@ +/* + * StringFixer.h + * ------------- + * Purpose: Various functions for "fixing" char array strings for writing to or + * reading from module files, or for securing char arrays in general. + * Notes : (currently none) + * Authors: OpenMPT Devs + */ + + +#ifndef STRINGFIXER_H +#define STRINGFIXER_H +#pragma once + + +namespace StringFixer +{ + + // Sets last character to null in given char array. + // Size of the array must be known at compile time. + template <size_t size> + void SetNullTerminator(char (&buffer)[size]) + //------------------------------------------ + { + STATIC_ASSERT(size > 0); + buffer[size-1] = 0; + } + + + // Convert a 0-terminated string to a space-padded string + template <size_t size> + void NullToSpaceString(char (&buffer)[size]) + //------------------------------------------ + { + STATIC_ASSERT(size > 0); + size_t pos = size; + while (pos-- > 0) + if (buffer[pos] == 0) + buffer[pos] = 32; + buffer[size - 1] = 0; + } + + + // Convert a space-padded string to a 0-terminated string + template <size_t size> + void SpaceToNullString(char (&buffer)[size]) + //------------------------------------------ + { + STATIC_ASSERT(size > 0); + // First, remove any Nulls + NullToSpaceString(buffer); + size_t pos = size; + while (pos-- > 0) + { + if (buffer[pos] == 32) + buffer[pos] = 0; + else if(buffer[pos] != 0) + break; + } + buffer[size - 1] = 0; + } + + + // Remove any chars after the first null char + template <size_t size> + void FixNullString(char (&buffer)[size]) + //-------------------------------------- + { + STATIC_ASSERT(size > 0); + SetNullTerminator(buffer); + size_t pos = 0; + // Find the first null char. + while(buffer[pos] != '\0' && pos < size) + { + pos++; + } + // Remove everything after the null char. + while(pos < size) + { + buffer[pos++] = '\0'; + } + } + + + // Convert a space-padded string to a 0-terminated string. STATIC VERSION! (use this if the maximum string length is known) + // Additional template parameter to specifify the max length of the final string, + // not including null char (useful for e.g. mod loaders) + template <size_t length, size_t size> + void SpaceToNullStringFixed(char (&buffer)[size]) + //------------------------------------------------ + { + STATIC_ASSERT(size > 0); + STATIC_ASSERT(length < size); + // Remove Nulls in string + SpaceToNullString(buffer); + // Overwrite trailing chars + for(size_t pos = length; pos < size; pos++) + { + buffer[pos] = 0; + } + } + + + // Convert a space-padded string to a 0-terminated string. DYNAMIC VERSION! + // Additional function parameter to specifify the max length of the final string, + // not including null char (useful for e.g. mod loaders) + template <size_t size> + void SpaceToNullStringFixed(char (&buffer)[size], size_t length) + //-------------------------------------------------------------- + { + STATIC_ASSERT(size > 0); + ASSERT(length < size); + // Remove Nulls in string + SpaceToNullString(buffer); + // Overwrite trailing chars + for(size_t pos = length; pos < size; pos++) + { + buffer[pos] = 0; + } + } + +}; + +#endif // STRINGFIXER_H Added: trunk/OpenMPT/common/misc_util.cpp =================================================================== --- trunk/OpenMPT/common/misc_util.cpp (rev 0) +++ trunk/OpenMPT/common/misc_util.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -0,0 +1,75 @@ +#include "stdafx.h" +#include "misc_util.h" +#include <ctime> + +/* + * Loads resource. + * [in] lpName and lpType: parameters passed to FindResource(). + * [out] pData: Pointer to loaded resource data, nullptr if load not successful. + * [out] nSize: Size of the data in bytes, zero if load not succesfull. + * [out] hglob: HGLOBAL returned by LoadResource-function. + * Return: pData. + */ +LPCCH LoadResource(LPCTSTR lpName, LPCTSTR lpType, LPCCH& pData, size_t& nSize, HGLOBAL& hglob) +//--------------------------------------------------------------------------------------------- +{ + pData = nullptr; + nSize = 0; + hglob = nullptr; + HINSTANCE hInstance = AfxGetInstanceHandle(); + HRSRC hrsrc = FindResource(hInstance, lpName, lpType); + if (hrsrc != NULL) + { + hglob = LoadResource(hInstance, hrsrc); + if (hglob != NULL) + { + pData = reinterpret_cast<const char*>(LockResource(hglob)); + nSize = SizeofResource(hInstance, hrsrc); + } + } + return pData; +} + + +// Returns WinAPI error message corresponding to error code returned by GetLastError(). +CString GetErrorMessage(DWORD nErrorCode) +//--------------------------------------- +{ + LPVOID lpMsgBuf; + + FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + nErrorCode, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR)&lpMsgBuf, + 0, + NULL ); + + CString msg = (LPTSTR)lpMsgBuf; + LocalFree(lpMsgBuf); + + return msg; +} + + +std::basic_string<TCHAR> Util::sdTime::GetDateTimeStr() +{ + time_t t; + std::time(&t); + return _tctime(&t); +} + +time_t Util::sdTime::MakeGmTime(tm& timeUtc) +{ +#if (_MSC_VER < MSVC_VER_2005) + // VC++ 2003 doesn't have _mkgmtime + // This does not seem to work properly with DST time zones sometimes - if that's of any concern for you, please upgrade your compiler :) + TIME_ZONE_INFORMATION tzi; + GetTimeZoneInformation(&tzi); + const time_t timeUtcTimeT = mktime(&timeUtc) - tzi.Bias * 60; +#else + const time_t timeUtcTimeT = _mkgmtime(&timeUtc); +#endif + return timeUtcTimeT; +} + Added: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h (rev 0) +++ trunk/OpenMPT/common/misc_util.h 2011-09-03 18:52:21 UTC (rev 1012) @@ -0,0 +1,316 @@ +#ifndef MISC_UTIL_H +#define MISC_UTIL_H +#pragma once + +#include <sstream> +#include <string> +#include <limits> +#include "typedefs.h" +#if _HAS_TR1 + #include <type_traits> +#endif +#include <io.h> // for _taccess + +//Convert object(typically number) to string +template<class T> +inline std::string Stringify(const T& x) +//-------------------------------------- +{ + std::ostringstream o; + if(!(o << x)) return "FAILURE"; + else return o.str(); +} + +//Convert string to number. +template<class T> +inline T ConvertStrTo(LPCSTR psz) +//------------------------------- +{ + #if _HAS_TR1 + static_assert(std::tr1::is_const<T>::value == false && std::tr1::is_volatile<T>::value == false, "Const and volatile types are not handled correctly."); + #endif + if(std::numeric_limits<T>::is_integer) + return static_cast<T>(atoi(psz)); + else + 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);} + + +// Memset given object to zero. +template <class T> +inline void MemsetZero(T &a) +//-------------------------- +{ +#if _HAS_TR1 + static_assert(std::tr1::is_pointer<T>::value == false, "Won't memset pointers."); + static_assert(std::tr1::is_pod<T>::value == true, "Won't memset non-pods."); +#endif + memset(&a, 0, sizeof(T)); +} + + +// Copy given object to other location. +template <class T> +inline void MemCopy(T &destination, T &source) +//-------------------------------------------- +{ +#if _HAS_TR1 + static_assert(std::tr1::is_pointer<T>::value == false, "Won't copy pointers."); + static_assert(std::tr1::is_pod<T>::value == true, "Won't copy non-pods."); +#endif + memcpy(&destination, &source, sizeof(T)); +} + +template <class T> +inline void MemCopy(T &destination, const T &source) +//-------------------------------------------------- +{ +#if _HAS_TR1 + static_assert(std::tr1::is_pointer<T>::value == false, "Won't copy pointers."); + static_assert(std::tr1::is_pod<T>::value == true, "Won't copy non-pods."); +#endif + memcpy(&destination, &source, 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. +template<class T, class C> +inline void Limit(T& val, const C lowerLimit, const C upperLimit) +//--------------------------------------------------------------- +{ + if(lowerLimit > upperLimit) return; + if(val < lowerLimit) val = lowerLimit; + else if(val > upperLimit) val = upperLimit; +} + + +// Like Limit, but returns value +template<class T, class C> +inline T Clamp(T val, const C lowerLimit, const C upperLimit) +//----------------------------------------------------------- +{ + if(lowerLimit > upperLimit) return val; + if(val < lowerLimit) return lowerLimit; + else if(val > upperLimit) return upperLimit; + else return val; +} + + +// Like Limit, but with upperlimit only. +template<class T, class C> +inline void LimitMax(T& val, const C upperLimit) +//---------------------------------------------- +{ + if(val > upperLimit) + val = upperLimit; +} + + +// Like Limit, but returns value +#ifndef CLAMP +#define CLAMP(number, low, high) min(high, max(low, number)) +#endif + + +LPCCH LoadResource(LPCTSTR lpName, LPCTSTR lpType, LPCCH& pData, size_t& nSize, HGLOBAL& hglob); +CString GetErrorMessage(DWORD nErrorCode); + +namespace utilImpl +{ + template <bool bMemcpy> + struct ArrayCopyImpl {}; + + template <> + struct ArrayCopyImpl<true> + { + template <class T> + static void Do(T* pDst, const T* pSrc, const size_t n) {memcpy(pDst, pSrc, sizeof(T) * n);} + }; + + template <> + struct ArrayCopyImpl<false> + { + template <class T> + static void Do(T* pDst, const T* pSrc, const size_t n) {std::copy(pSrc, pSrc + n, pDst);} + }; +} // namespace utilImpl + + +// Copies n elements from array pSrc to array pDst. +// If the source and destination arrays overlap, behaviour is undefined. +template <class T> +void ArrayCopy(T* pDst, const T* pSrc, const size_t n) +//---------------------------------------------------- +{ + utilImpl::ArrayCopyImpl<std::tr1::has_trivial_assign<T>::value>::Do(pDst, pSrc, n); +} + + +// Sanitize a filename (remove special chars) +template <size_t size> +void SanitizeFilename(char (&buffer)[size]) +//----------------------------------------- +{ + STATIC_ASSERT(size > 0); + for(size_t i = 0; i < size; i++) + { + if( buffer[i] == '\\' || + buffer[i] == '\"' || + buffer[i] == '/' || + buffer[i] == ':' || + buffer[i] == '?' || + buffer[i] == '<' || + buffer[i] == '>' || + buffer[i] == '*') + { + for(size_t j = i + 1; j < size; j++) + { + buffer[j - 1] = buffer[j]; + } + buffer[size - 1] = 0; + } + } +} + + +// Greatest Common Divisor. +template <class T> +T gcd(T a, T b) +//------------- +{ + if(a < 0) + a = -a; + if(b < 0) + b = -b; + do + { + if(a == 0) + return b; + b %= a; + if(b == 0) + return a; + a %= b; + } +} + + +// Convert a variable-length MIDI integer <value> to a normal integer <result>. +// Function returns how many bytes have been read. +template <class TIn, class TOut> +size_t ConvertMIDI2Int(TOut &result, TIn value) +//--------------------------------------------- +{ + return ConvertMIDI2Int(result, (uint8 *)(&value), sizeof(TIn)); +} + + +// Convert a variable-length MIDI integer held in the byte buffer <value> to a normal integer <result>. +// maxLength bytes are read from the byte buffer at max. +// Function returns how many bytes have been read. +// TODO This should report overflow errors if TOut is too small! +template <class TOut> +size_t ConvertMIDI2Int(TOut &result, uint8 *value, size_t maxLength) +//------------------------------------------------------------------ +{ + static_assert(std::numeric_limits<TOut>::is_integer == true, "Output type is a not an integer"); + + if(maxLength <= 0) + { + result = 0; + return 0; + } + size_t bytesUsed = 0; + result = 0; + uint8 b; + do + { + b = *value; + result <<= 7; + result |= (b & 0x7F); + value++; + } while (++bytesUsed < maxLength && (b & 0x80) != 0); + return bytesUsed; +} + + +// Convert an integer <value> to a variable-length MIDI integer, held in the byte buffer <result>. +// maxLength bytes are written to the byte buffer at max. +// Function returns how many bytes have been written. +template <class TIn> +size_t ConvertInt2MIDI(uint8 *result, size_t maxLength, TIn value) +//---------------------------------------------------------------- +{ + static_assert(std::numeric_limits<TIn>::is_integer == true, "Input type is a not an integer"); + + if(maxLength <= 0) + { + *result = 0; + return 0; + } + size_t bytesUsed = 0; + do + { + *result = (value & 0x7F); + value >>= 7; + if(value != 0) + { + *result |= 0x80; + } + result++; + } while (++bytesUsed < maxLength && value != 0) + return bytesUsed; +} + + +namespace Util +{ + // Like std::max, but avoids conflict with max-macro. + template <class T> inline const T& Max(const T& a, const T& b) {return (std::max)(a, b);} + + // Like std::min, but avoids conflict with min-macro. + template <class T> inline const T& Min(const T& a, const T& b) {return (std::min)(a, b);} + + // Returns maximum value of given integer type. + template <class T> inline T MaxValueOfType(const T&) {static_assert(std::numeric_limits<T>::is_integer == true, "Only integer types are allowed."); return (std::numeric_limits<T>::max)();} + + /// Returns value rounded to nearest integer. + inline double Round(const double& val) {return std::floor(val + 0.5);} + + /// Rounds given double value to nearest integer value of type T. + template <class T> inline T Round(const double& val) + { + static_assert(std::numeric_limits<T>::is_integer == true, "Type is a not an integer"); + static_assert(sizeof(T) <= 4, "Revise the implementation for integers > 32-bits."); + const double valRounded = Round(val); + ASSERT(valRounded >= (std::numeric_limits<T>::min)() && valRounded <= (std::numeric_limits<T>::max)()); + const T intval = static_cast<T>(valRounded); + return intval; + } + + +}; + +namespace Util { namespace sdTime +{ + // Returns string containing date and time ended with newline. + std::basic_string<TCHAR> GetDateTimeStr(); + + time_t MakeGmTime(tm& timeUtc); + +}}; // namespace Util::sdTime + +namespace Util { namespace sdOs +{ + /// Checks whether file or folder exists and whether it has the given mode. + enum FileMode {FileModeExists = 0, FileModeRead = 4, FileModeWrite = 2, FileModeReadWrite = 6}; + inline bool IsPathFileAvailable(LPCTSTR pszFilePath, FileMode fm) {return (_taccess(pszFilePath, fm) == 0);} + +} } // namespace Util::sdOs + +#endif Added: trunk/OpenMPT/common/typedefs.h =================================================================== --- trunk/OpenMPT/common/typedefs.h (rev 0) +++ trunk/OpenMPT/common/typedefs.h 2011-09-03 18:52:21 UTC (rev 1012) @@ -0,0 +1,70 @@ +#ifndef TYPEDEFS_H +#define TYPEDEFS_H + +#define nullptr 0 + +// CountOf macro computes the number of elements in a statically-allocated array. +#if _MSC_VER >= 1400 + #define CountOf(x) _countof(x) +#else + #define CountOf(x) (sizeof(x)/sizeof(x[0])) +#endif + +#define ARRAYELEMCOUNT(x) CountOf(x) + +//Compile time assert. +#define STATIC_ASSERT(expr) C_ASSERT(expr) +#define static_assert(expr, msg) C_ASSERT(expr) + + +typedef __int8 int8; +typedef __int16 int16; +typedef __int32 int32; +typedef __int64 int64; + +typedef unsigned __int8 uint8; +typedef unsigned __int16 uint16; +typedef unsigned __int32 uint32; +typedef unsigned __int64 uint64; + +const int8 int8_min = -127-1; +const int16 int16_min = -32767-1; +const int32 int32_min = -2147483647-1; +const int64 int64_min = -9223372036854775807-1; + +const int8 int8_max = 127; +const int16 int16_max = 32767; +const int32 int32_max = 2147483647; +const int64 int64_max = 9223372036854775807; + +const uint8 uint8_max = 255; +const uint16 uint16_max = 65535; +const uint32 uint32_max = 4294967295; +const uint64 uint64_max = 18446744073709551615; + +typedef float float32; + + +#if !_HAS_TR1 + namespace std + { + namespace tr1 + { + template <class T> struct has_trivial_assign {static const bool value = false;}; + + #define SPECIALIZE_TRIVIAL_ASSIGN(type) template <> struct has_trivial_assign<type> {static const bool value = true;} + SPECIALIZE_TRIVIAL_ASSIGN(int8); + SPECIALIZE_TRIVIAL_ASSIGN(uint8); + SPECIALIZE_TRIVIAL_ASSIGN(int16); + SPECIALIZE_TRIVIAL_ASSIGN(uint16); + SPECIALIZE_TRIVIAL_ASSIGN(int32); + SPECIALIZE_TRIVIAL_ASSIGN(uint32); + SPECIALIZE_TRIVIAL_ASSIGN(int64); + SPECIALIZE_TRIVIAL_ASSIGN(uint64); + #undef SPECIALIZE_TRIVIAL_ASSIGN + }; + }; +#endif + + +#endif Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -9,7 +9,7 @@ #include "fxp.h" #include "dlg_misc.h" #include "AbstractVstEditor.h" -#include "../soundlib/StringFixer.h" +#include "../common/StringFixer.h" #ifndef NO_VST @@ -29,10 +29,10 @@ ON_COMMAND(ID_VSTPRESETBACKWARDJUMP,OnVSTPresetBackwardJump) ON_COMMAND(ID_VSTPRESETFORWARDJUMP, OnVSTPresetForwardJump) ON_COMMAND(ID_PLUGINTOINSTRUMENT, OnCreateInstrument) - ON_COMMAND_RANGE(ID_PRESET_SET, ID_PRESET_SET+MAX_PLUGPRESETS, OnSetPreset) + ON_COMMAND_RANGE(ID_PRESET_SET, ID_PRESET_SET + MAX_PLUGPRESETS, OnSetPreset) ON_MESSAGE(WM_MOD_KEYCOMMAND, OnCustomKeyMsg) //rewbs.customKeys - ON_COMMAND_RANGE(ID_PLUGSELECT, ID_PLUGSELECT+MAX_MIXPLUGINS, OnToggleEditor) //rewbs.patPlugName - ON_COMMAND_RANGE(ID_SELECTINST, ID_SELECTINST+MAX_INSTRUMENTS, OnSetInputInstrument) //rewbs.patPlugName + ON_COMMAND_RANGE(ID_PLUGSELECT, ID_PLUGSELECT + MAX_MIXPLUGINS, OnToggleEditor) //rewbs.patPlugName + ON_COMMAND_RANGE(ID_SELECTINST, ID_SELECTINST + MAX_INSTRUMENTS, OnSetInputInstrument) //rewbs.patPlugName ON_COMMAND_RANGE(ID_LEARN_MACRO_FROM_PLUGGUI, ID_LEARN_MACRO_FROM_PLUGGUI + NUM_MACROS, PrepareToLearnMacro) END_MESSAGE_MAP() @@ -111,7 +111,7 @@ m_pVstPlugin->GetModDoc()->SetModified(); } else { - ::AfxMessageBox("Error loading preset. Are you sure it is for this plugin?"); + Reporting::Notification("Error loading preset. Are you sure it is for this plugin?"); } } @@ -129,7 +129,7 @@ //TODO: exception handling if (!(m_pVstPlugin->SaveProgram(files.first_file.c_str()))) - ::AfxMessageBox("Error saving preset."); + Reporting::Notification("Error saving preset."); } @@ -138,7 +138,7 @@ { if (m_pVstPlugin) { - if (::AfxMessageBox("Are you sure you want to randomize parameters?\nYou will lose current parameter values.", MB_YESNO|MB_ICONEXCLAMATION) == IDYES) + if (Reporting::Notification("Are you sure you want to randomize parameters?\nYou will lose current parameter values.", MB_YESNO | MB_ICONEXCLAMATION) == IDYES) m_pVstPlugin->RandomizeParams(); UpdateParamDisplays(); } @@ -355,7 +355,7 @@ return false; if(!m_pVstPlugin->isInstrument() || pModDoc->GetSoundFile()->GetModSpecifications().instrumentsMax == 0 || - AfxMessageBox(_T("You need to assign an instrument to this plugin before you can play notes from here.\nCreate a new instrument and assign this plugin to the instrument?"), MB_YESNO | MB_ICONQUESTION) == IDNO) + Reporting::Notification(_T("You need to assign an instrument to this plugin before you can play notes from here.\nCreate a new instrument and assign this plugin to the instrument?"), MB_YESNO | MB_ICONQUESTION) == IDNO) { return false; } else Modified: trunk/OpenMPT/mptrack/AutoSaver.cpp =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/AutoSaver.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -85,7 +85,7 @@ } else { m_bEnabled = false; - AfxMessageBox("Warning: Autosave failed and has been disabled. Please:\n- Review your autosave paths\n- Check available diskspace & filesystem access rights\n- If you are using the ITP format, ensure all instruments exist as independant .iti files"); + Reporting::Notification("Warning: Autosave failed and has been disabled. Please:\n- Review your autosave paths\n- Check available diskspace & filesystem access rights\n- If you are using the ITP format, ensure all instruments exist as independant .iti files"); success = false; } } @@ -475,8 +475,9 @@ } bool pathIsOK = !_access(path, 0); - if (!pathIsOK && IsDlgButtonChecked(IDC_AUTOSAVE_ENABLE) && !IsDlgButtonChecked(IDC_AUTOSAVE_USEORIGDIR)) { - ::AfxMessageBox("Error: backup path does not exist.", MB_OK|MB_ICONEXCLAMATION); + if (!pathIsOK && IsDlgButtonChecked(IDC_AUTOSAVE_ENABLE) && !IsDlgButtonChecked(IDC_AUTOSAVE_USEORIGDIR)) + { + Reporting::Notification("Error: backup path does not exist.", MB_OK | MB_ICONEXCLAMATION); ::SetFocus(::GetDlgItem(m_hWnd, IDC_AUTOSAVE_PATH)); return 0; } Modified: trunk/OpenMPT/mptrack/CleanupSong.cpp =================================================================== --- trunk/OpenMPT/mptrack/CleanupSong.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/CleanupSong.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -546,7 +546,7 @@ { //We don't remove an instrument's unused samples in an ITP. wsprintf(s, "OpenMPT detected %d sample%s referenced by an instrument,\n" "but not used in the song. Do you want to remove them?", nExt, (nExt == 1) ? "" : "s"); - if (::MessageBox(NULL, s, "Sample Cleanup", MB_YESNO | MB_ICONQUESTION) == IDYES) + if (Reporting::Notification(s, "Sample Cleanup", MB_YESNO | MB_ICONQUESTION) == IDYES) { CriticalSection cs; for (SAMPLEINDEX nSmp = 1; nSmp <= pSndFile->GetNumSamples(); nSmp++) @@ -588,7 +588,7 @@ CHAR s[512]; wsprintf(s, "%d sample%s unused data after the loop end point,\n" "Do you want to optimize %s and remove this unused data?", nLoopOpt, (nLoopOpt == 1) ? " has" : "s have", (nLoopOpt == 1) ? "it" : "them"); - if (::MessageBox(NULL, s, "Sample Optimization", MB_YESNO | MB_ICONQUESTION) == IDYES) + if (Reporting::Notification(s, "Sample Optimization", MB_YESNO | MB_ICONQUESTION) == IDYES) { for (SAMPLEINDEX nSmp = 1; nSmp <= pSndFile->m_nSamples; nSmp++) { @@ -712,13 +712,13 @@ char removeSamples = -1; if ( !((pSndFile->GetType() == MOD_TYPE_IT) && (pSndFile->m_dwSongFlags & SONG_ITPROJECT))) //never remove an instrument's samples in ITP. { - if(::MessageBox(NULL, "Remove samples associated with an instrument if they are unused?", "Removing unused instruments", MB_YESNO | MB_ICONQUESTION) == IDYES) + if(Reporting::Notification("Remove samples associated with an instrument if they are unused?", "Removing unused instruments", MB_YESNO | MB_ICONQUESTION) == IDYES) { removeSamples = 1; } } else { - ::MessageBox(NULL, "This is an IT project file, so no samples associated with an used instrument will be removed.", "Removing unused instruments", MB_OK | MB_ICONINFORMATION); + Reporting::Notification("This is an IT project file, so no samples associated with an used instrument will be removed.", "Removing unused instruments", MB_OK | MB_ICONINFORMATION); } BeginWaitCursor(); @@ -746,7 +746,7 @@ } EndWaitCursor(); if ((bReorg) && (pSndFile->m_nInstruments > 1) - && (::MessageBox(NULL, "Do you want to reorganize the remaining instruments?", "Removing unused instruments", MB_YESNO | MB_ICONQUESTION) == IDYES)) + && (Reporting::Notification("Do you want to reorganize the remaining instruments?", "Removing unused instruments", MB_YESNO | MB_ICONQUESTION) == IDYES)) { BeginWaitCursor(); CriticalSection cs; @@ -870,7 +870,7 @@ if(pSndFile == nullptr) return false; //jojo.compocleanup - if(::MessageBox(NULL, TEXT("WARNING: OpenMPT will convert the module to IT format and reset all song, sample and instrument attributes to default values. Continue?"), TEXT("Resetting variables"), MB_YESNO | MB_ICONWARNING) == IDNO) + if(Reporting::Notification(TEXT("WARNING: OpenMPT will convert the module to IT format and reset all song, sample and instrument attributes to default values. Continue?"), TEXT("Resetting variables"), MB_YESNO | MB_ICONWARNING) == IDNO) return false; // Stop play. Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -1,8 +1,9 @@ //rewbs.customKeys #include "stdafx.h" -#include ".\commandset.h" +#include "commandset.h" #include "resource.h" +#include "../common/Reporting.h" #include <stdio.h> #include <stdlib.h> #include <fstream> @@ -43,7 +44,7 @@ { //CHAR s[64]; //wsprintf(s, "pointer = %lX",plocalCmdSet); - //::MessageBox(NULL, "about to remove all", NULL, MB_OK|MB_ICONEXCLAMATION); //disabled by rewbs + //Reporting::Notification("about to remove all", NULL, MB_OK|MB_ICONEXCLAMATION); //disabled by rewbs //commands.RemoveAll(); } @@ -1479,7 +1480,7 @@ while(iStrm.getline(s, sizeof(s))) { - //::MessageBox(NULL, s, "", MB_ICONEXCLAMATION|MB_OK); + //Reporting::Notification(s, MB_ICONEXCLAMATION|MB_OK); curLine = s; @@ -1583,7 +1584,7 @@ CString err; err.Format("The following problems have been encountered while trying to load the key binding file %s:\n", szFilename); err += errText; - ::MessageBox(NULL, err, "", MB_ICONEXCLAMATION|MB_OK); + Reporting::Notification(err, MB_ICONEXCLAMATION | MB_OK); } if(fileVersion < KEYMAP_VERSION) UpgradeKeymap(pTempCS, fileVersion); @@ -1601,7 +1602,7 @@ { CString strMsg; AfxFormatString1(strMsg, IDS_CANT_OPEN_KEYBINDING_FILE, fileName); - AfxMessageBox(strMsg, MB_ICONEXCLAMATION|MB_OK); + Reporting::Notification(strMsg, MB_ICONEXCLAMATION | MB_OK); return false; } else Modified: trunk/OpenMPT/mptrack/Ctrl_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -7,7 +7,7 @@ #include "ctrl_gen.h" #include "view_gen.h" #include "math.h" -#include "misc_util.h" +#include "../common/misc_util.h" // -> CODE#0015 // -> DESC="channels management dlg" Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -8,8 +8,8 @@ #include "view_ins.h" #include "dlg_misc.h" #include "tuningDialog.h" -#include "misc_util.h" -#include "../soundlib/StringFixer.h" +#include "../common/misc_util.h" +#include "../common/StringFixer.h" #include "SelectPluginDialog.h" #pragma warning(disable:4244) //conversion from 'type1' to 'type2', possible loss of data Modified: trunk/OpenMPT/mptrack/Ctrl_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -8,7 +8,7 @@ #include "ctrl_pat.h" #include "view_pat.h" #include "ChannelManagerDlg.h" -#include "../soundlib/StringFixer.h" +#include "../common/StringFixer.h" ////////////////////////////////////////////////////////////// @@ -1128,7 +1128,7 @@ // If this macro is not the default IT macro, display a warning. if(!m_pModDoc->IsMacroDefaultSetupUsed()) { - if(AfxMessageBox(_T("You have chosen not to embed MIDI macros. However, the current macro configuration differs from the default macro configuration that is assumed when loading a file that has no macros embedded. This can result in data loss and broken playback.\nWould you like to embed MIDI macros now?"), MB_YESNO) == IDYES) + if(Reporting::Notification(_T("You have chosen not to embed MIDI macros. However, the current macro configuration differs from the default macro configuration that is assumed when loading a file that has no macros embedded. This can result in data loss and broken playback.\nWould you like to embed MIDI macros now?"), MB_YESNO) == IDYES) { m_pSndFile->m_dwSongFlags |= SONG_EMBEDMIDICFG; m_pModDoc->SetModified(); Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -1399,7 +1399,7 @@ CString strParam; strParam.Format(TEXT("%u: %s"), rSf.Order.GetCurrentSequenceIndex(), (LPCTSTR)rSf.Order.m_sName); CString str; AfxFormatString1(str, IDS_CONFIRM_SEQUENCE_DELETE, strParam); - if (AfxMessageBox(str, MB_YESNO | MB_ICONQUESTION) == IDYES) + if (Reporting::Notification(str, MB_YESNO | MB_ICONQUESTION) == IDYES) rSf.Order.RemoveSequence(); else { Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -16,7 +16,7 @@ #include "smbPitchShift.cpp" #pragma warning(default:4244) //"conversion from 'type1' to 'type2', possible loss of data" #include "modsmp_ctrl.h" -#include "../soundlib/StringFixer.h" +#include "../common/StringFixer.h" #include <Shlwapi.h> #ifdef _DEBUG @@ -1826,7 +1826,7 @@ default: wsprintf(str, _T("Unknown Error...")); break; } - AfxMessageBox(str, MB_ICONERROR); + Reporting::Notification(str, MB_ICONERROR); return; } @@ -1897,7 +1897,7 @@ { CString str; str.Format(TEXT(GetStrI18N("Current samplerate, %u Hz, is not in the supported samplerate range 8000 Hz - 48000 Hz. Continue?")), nSampleRate); - if(AfxMessageBox(str, MB_ICONQUESTION|MB_YESNO) != IDYES) + if(Reporting::Notification(str, MB_ICONQUESTION|MB_YESNO) != IDYES) return -1; } Modified: trunk/OpenMPT/mptrack/DefaultVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/DefaultVstEditor.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/DefaultVstEditor.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -42,14 +42,15 @@ //-------------------------------------------------------------------------------- { CSliderCtrl* pScrolledSlider = reinterpret_cast<CSliderCtrl*>(pScrollBar); - if ((pScrolledSlider == &m_slParam) && (nSBCode != SB_ENDSCROLL) ) { + if ((pScrolledSlider == &m_slParam) && (nSBCode != SB_ENDSCROLL)) + { OnParamSliderChanged(); } CAbstractVstEditor::OnVScroll(nSBCode, nPos, pScrollBar); } BOOL CDefaultVstEditor::OpenEditor(CWnd *parent) -//--------------------------------------- +//---------------------------------------------- { Create(IDD_DEFAULTPLUGINEDITOR, parent); SetTitle(); @@ -59,12 +60,14 @@ ShowWindow(SW_SHOW); // Fill param listbox - if (m_pVstPlugin) { + if (m_pVstPlugin) + { char s[128]; long nParams = m_pVstPlugin->GetNumParameters(); m_lbParameters.SetRedraw(FALSE); //disable lisbox refreshes during fill to avoid flicker m_lbParameters.ResetContent(); - for (long i=0; i<nParams; i++) { + for (long i=0; i<nParams; i++) + { CHAR sname[64]; m_pVstPlugin->GetParamName(i, sname, sizeof(sname)); wsprintf(s, "%02X: %s", i|0x80, sname); Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -8,7 +8,7 @@ #include "EffectVis.h" //rewbs.fxvis #include "ChannelManagerDlg.h" #include "../soundlib/tuningbase.h" -#include "../soundlib/StringFixer.h" +#include "../common/StringFixer.h" #include <string> using std::string; @@ -610,7 +610,7 @@ { UINT nSkip = m_nMidRow - yofs; UINT nPrevPat = m_nPattern; - BOOL bPrevPatFound = FALSE; + bool bPrevPatFound = false; // Display previous pattern if (CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_SHOWPREVIOUS) @@ -625,14 +625,14 @@ if(startOrder < pSndFile->Order.size() && pSndFile->Order[startOrder] == m_nPattern) { nPrevPat = pSndFile->Order[prevOrder]; - bPrevPatFound = TRUE; + bPrevPatFound = true; } } } if ((bPrevPatFound) && (nPrevPat < pSndFile->Patterns.Size()) && (pSndFile->Patterns[nPrevPat])) { UINT nPrevRows = pSndFile->Patterns[nPrevPat].GetNumRows(); - UINT n = (nSkip < nPrevRows) ? nSkip : nPrevRows; + UINT n = min(nSkip, nPrevRows); ypaint += (nSkip-n)*m_szCell.cy; rect.SetRect(0, m_szHeader.cy, nColumnWidth * ncols + m_szHeader.cx, ypaint - 1); @@ -664,7 +664,7 @@ if ((nVisRows > 0) && (m_nMidRow)) { UINT nNextPat = m_nPattern; - BOOL bNextPatFound = FALSE; + bool bNextPatFound = false; const ORDERINDEX startOrder= static_cast<ORDERINDEX>(SendCtrlMessage(CTRLMSG_GETCURRENTORDER)); ORDERINDEX nNextOrder; nNextOrder = pSndFile->Order.GetNextOrderIgnoringSkips(startOrder); @@ -675,12 +675,12 @@ if ((nNextOrder < ordCount) && (pSndFile->Order[startOrder] == m_nPattern)) { nNextPat = pSndFile->Order[nNextOrder]; - bNextPatFound = TRUE; + bNextPatFound = true; } if ((bNextPatFound) && (nNextPat < pSndFile->Patterns.Size()) && (pSndFile->Patterns[nNextPat])) { UINT nNextRows = pSndFile->Patterns[nNextPat].GetNumRows(); - UINT n = ((UINT)nVisRows < nNextRows) ? nVisRows : nNextRows; + UINT n = min((UINT)nVisRows, nNextRows); m_Dib.SetBlendMode(0x80); DrawPatternData(hdc, pSndFile, nNextPat, FALSE, FALSE, @@ -1322,6 +1322,7 @@ void CViewPattern::OnSize(UINT nType, int cx, int cy) //--------------------------------------------------- { + // TODO: Switching between modules (when MDI childs are maximized) first calls this with the windowed size, then with the maximized size, which makes the scrollbars move. Eww! CScrollView::OnSize(nType, cx, cy); if (((nType == SIZE_RESTORED) || (nType == SIZE_MAXIMIZED)) && (cx > 0) && (cy > 0)) { Modified: trunk/OpenMPT/mptrack/EffectVis.cpp =================================================================== --- trunk/OpenMPT/mptrack/EffectVis.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/EffectVis.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -686,7 +686,7 @@ MakeChange(m_nDragItem, point.y); } else if ((m_dwStatus & FXVSTATUS_LDRAGGING)) - { + { // Interpolate if we detect that rows have been skipped but the left mouse button was not released. // This ensures we produce a smooth curve even when we are not notified of mouse movements at a high frequency (e.g. if CPU usage is high) if ((m_nLastDrawnRow>(int)m_startRow) && ((int)row != m_nLastDrawnRow) && ((int)row != m_nLastDrawnRow+1) && ((int)row != m_nLastDrawnRow-1)) @@ -728,7 +728,7 @@ if (IsPcNote(row)) { paramValue = ScreenYToPCParam(point.y); - wsprintf(effectName, "%s", "Param Control"); //TODO - show smooth & plug+param + wsprintf(effectName, "%s", "Param Control"); // TODO - show smooth & plug+param } else { @@ -765,14 +765,16 @@ void CEffectVis::OnEditUndo() +//--------------------------- { - CHAR s[64]; - wsprintf(s, "Undo Through!"); - ::MessageBox(NULL, s, NULL, MB_OK|MB_ICONEXCLAMATION); + CHAR s[64]; + strcpy(s, "Undo Through!"); + Reporting::Notification(s, MB_OK | MB_ICONEXCLAMATION); } + BOOL CEffectVis::OnInitDialog() -//-------------------------------- +//----------------------------- { CModControlDlg::OnInitDialog(); if (m_pModDoc->GetModType() == MOD_TYPE_MPT && IsPcNote(m_startRow)) @@ -828,13 +830,15 @@ } void CEffectVis::MakeChange(int row, long y) +//------------------------------------------ { MODCOMMAND *pcmd = m_pSndFile->Patterns[m_nPattern]; - if (!pcmd) { + if (!pcmd) + { return; } - int offset = row*m_pSndFile->m_nChannels + m_nChan; + int offset = row * m_pSndFile->GetNumChannels() + m_nChan; switch (m_nAction) { @@ -871,7 +875,8 @@ break; case kAction_Preserve: - if (GetCommand(row) || IsPcNote(row)) { + if (GetCommand(row) || IsPcNote(row)) + { // Only set param if we have an effect type or if this is a PC note. // Never change the effect type. SetParamFromY(row, y); Modified: trunk/OpenMPT/mptrack/ExceptionHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -137,7 +137,7 @@ } } - ::MessageBox(window, errorMessage, "OpenMPT Crash", MB_ICONERROR); + Reporting::Notification(errorMessage, "OpenMPT Crash", MB_ICONERROR, window); // Let Windows handle the exception... return EXCEPTION_CONTINUE_SEARCH; Modified: trunk/OpenMPT/mptrack/Globals.cpp =================================================================== --- trunk/OpenMPT/mptrack/Globals.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Globals.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -203,7 +203,7 @@ CModControlView::CModControlView() //-------------------------------- { - memset(m_Pages, 0, sizeof(m_Pages)); + MemsetZero(m_Pages); m_nActiveDlg = -1; m_nInstrumentChanged = -1; m_hWndView = NULL; Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -531,7 +531,7 @@ if (cmd<0 || m_nCurKeyChoice<0 || m_nCurKeyChoice>=ih->GetKeyListSize(cmd)) { CString error = "Nothing to restore for this slot."; - ::MessageBox(NULL, error, "Invalid key data", MB_ICONEXCLAMATION|MB_OK); + Reporting::Notification(error, "Invalid key data", MB_ICONEXCLAMATION|MB_OK); return; } @@ -552,7 +552,7 @@ if (m_nCurHotKey<0 || m_nCurKeyChoice<0 || m_nCurKeyChoice>=plocalCmdSet->GetKeyListSize(cmd)) { CString error = "No key currently set for this slot."; - ::MessageBox(NULL, error, "Invalid key data", MB_ICONEXCLAMATION|MB_OK); + Reporting::Notification(error, "Invalid key data", MB_ICONEXCLAMATION|MB_OK); return; } @@ -573,7 +573,7 @@ if (cmd<0) { CString error = "Invalid slot."; - ::MessageBox(NULL, error, "Invalid key data", MB_ICONEXCLAMATION|MB_OK); + Reporting::Notification(error, "Invalid key data", MB_ICONEXCLAMATION|MB_OK); return; } @@ -589,13 +589,13 @@ if (!kc.code) { CString error = "You need to say to which key you'd like to map this command."; - ::MessageBox(NULL, error, "Invalid key data", MB_ICONEXCLAMATION|MB_OK); + Reporting::Notification(error, "Invalid key data", MB_ICONEXCLAMATION|MB_OK); return; } if (!kc.event) { /* CString error = "You need to select at least one key event type (up, down or hold)."; - ::MessageBox(NULL, error, "Invalid key data", MB_ICONEXCLAMATION|MB_OK); + Reporting::Notification(error, "Invalid key data", MB_ICONEXCLAMATION|MB_OK); return; */ kc.event = kKeyEventDown; Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -2193,7 +2193,7 @@ AfxFormatString1(str, IDS_FILE_EXISTS_BUT_IS_NOT_READABLE, (LPCTSTR)sPath); else AfxFormatString1(str, IDS_FILE_DOES_NOT_EXIST, (LPCTSTR)sPath); - AfxMessageBox(str); + Reporting::Notification(str); } } else Modified: trunk/OpenMPT/mptrack/ModConvert.cpp =================================================================== --- trunk/OpenMPT/mptrack/ModConvert.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/ModConvert.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -121,10 +121,10 @@ if((m_SndFile.GetNumInstruments() || nResizedPatterns) && (nNewType & (MOD_TYPE_MOD|MOD_TYPE_S3M))) { - if(::MessageBox(NULL, - "This operation will convert all instruments to samples,\n" - "and resize all patterns to 64 rows.\n" - "Do you want to continue?", "Warning", MB_YESNO | MB_ICONQUESTION) != IDYES) return false; + if(Reporting::Notification( + "This operation will convert all instruments to samples,\n" + "and resize all patterns to 64 rows.\n" + "Do you want to continue?", "Warning", MB_YESNO | MB_ICONQUESTION) != IDYES) return false; BeginWaitCursor(); CriticalSection cs; Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -15,7 +15,7 @@ #include "version.h" #include "modsmp_ctrl.h" #include "CleanupSong.h" -#include "../soundlib/StringFixer.h" +#include "../common/StringFixer.h" #include <shlwapi.h> extern WORD S3MFineTuneTable[16]; @@ -232,7 +232,7 @@ { CString sTemp; sTemp.Format("File: %s\nLast saved with: %s, current version is %s\n\n%s", lpszPathName, (LPCTSTR)MptVersion::ToStr(m_SndFile.m_dwLastSavedWithVersion), MptVersion::str, GetLog()); - AfxMessageBox(sTemp, MB_ICONINFORMATION); + Reporting::Notification(sTemp, MB_ICONINFORMATION); ClearLog(); } @@ -423,7 +423,7 @@ wsprintf(s, "Warning: this song was last saved with a more recent version of OpenMPT.\r\nSong saved with: v%s. Current version: v%s.\r\n", (LPCTSTR)MptVersion::ToStr(m_SndFile.m_dwLastSavedWithVersion), MptVersion::str); - ::AfxMessageBox(s); + Reporting::Notification(s); } SetModifiedFlag(FALSE); // (bModified); @@ -481,7 +481,7 @@ } else { if(type == MOD_TYPE_IT && m_SndFile.m_dwSongFlags & SONG_ITPROJECT) - AfxMessageBox(_T("ITP projects need to have a path set for each instrument..."), MB_ICONERROR | MB_OK); + Reporting::Notification(_T("ITP projects need to have a path set for each instrument..."), MB_ICONERROR | MB_OK); else ErrorBox(IDS_ERR_SAVESONG, CMainFrame::GetMainFrame()); } @@ -508,7 +508,8 @@ } } - if(unsavedInstrument && ::MessageBox(NULL,"Do you want to save modified instruments?",NULL,MB_ICONQUESTION | MB_YESNO | MB_APPLMODAL) == IDYES){ + if(unsavedInstrument && Reporting::Notification("Do you want to save modified instruments?", MB_ICONQUESTION | MB_YESNO | MB_APPLMODAL) == IDYES) + { for(INSTRUMENTINDEX i = 0 ; i < m_SndFile.m_nInstruments ; i++) { @@ -853,7 +854,7 @@ CShowLogDlg dlg(parent); return dlg.ShowLog(m_lpszLog, lpszTitle); #else - return ::MessageBox((parent) ? parent->m_hWnd : NULL, m_lpszLog, lpszTitle, MB_OK|MB_ICONINFORMATION); + return Reporting::Notification(m_lpszLog, lpszTitle, MB_OK | MB_ICONINFORMATION, (parent) ? parent->m_hWnd : nullptr); #endif } return IDCANCEL; @@ -1801,24 +1802,24 @@ { case MOD_TYPE_MOD: pattern = FileFilterMOD; - if( AfxMessageBox(GetStrI18N(TEXT( + if(Reporting::Notification(GetStrI18N(TEXT( "Compared to regular MOD save, compatibility export adjusts the beginning of oneshot samples " "in order to make the file compatible with ProTracker and other Amiga-based trackers. " "Note that this feature does not remove effects \"invented\" by other PC-based trackers (f.e. panning commands)." - "\n\n Proceed?")), MB_ICONINFORMATION|MB_YESNO) != IDYES + "\n\n Proceed?")), MB_ICONINFORMATION | MB_YESNO) != IDYES ) return; break; case MOD_TYPE_IT: pattern = FileFilterIT; - ::MessageBox(NULL,"Warning: the exported file will not contain any of MPT's file-format hacks.", "Compatibility export warning.",MB_ICONINFORMATION | MB_OK); + Reporting::Notification("Warning: the exported file will not contain any of MPT's file-format hacks.", "Compatibility export warning.", MB_ICONINFORMATION | MB_OK); break; case MOD_TYPE_XM: pattern = FileFilterXM; - ::MessageBox(NULL,"Warning: the exported file will not contain any of MPT's file-format hacks.", "Compatibility export warning.",MB_ICONINFORMATION | MB_OK); + Reporting::Notification("Warning: the exported file will not contain any of MPT's file-format hacks.", "Compatibility export warning.", MB_ICONINFORMATION | MB_OK); break; default: - ::MessageBox(NULL,"Compatibility export is currently only available for MOD, XM and IT modules.", "Can't do compatibility export.",MB_ICONINFORMATION | MB_OK); + Reporting::Notification("Compatibility export is currently only available for MOD, XM and IT modules.", "Can't do compatibility export.", MB_ICONINFORMATION | MB_OK); return; } ext = m_SndFile.GetModSpecifications().fileExtension; @@ -3811,13 +3812,13 @@ { CString message; message.Format("Param %d beyond controllable range.", paramToUse); - ::MessageBox(NULL,message, "Macro not assigned for this param",MB_ICONINFORMATION | MB_OK); + Reporting::Notification(message, "Macro not assigned for this param", MB_ICONINFORMATION | MB_OK); return; } CString message; message.Format("Param %d can now be controlled with macro %X", paramToUse, macroToSet); - ::MessageBox(NULL, message, "Macro assigned for this param",MB_ICONINFORMATION | MB_OK); + Reporting::Notification(message, "Macro assigned for this param", MB_ICONINFORMATION | MB_OK); return; } @@ -3986,7 +3987,7 @@ { CString sErrMsg; AfxFormatString1(sErrMsg, IDS_UNABLE_TO_CREATE_USER_TEMPLATE_FOLDER, pszTemplateFolder); - AfxMessageBox(sErrMsg); + Reporting::Notification(sErrMsg); return; } } Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Moddoc.h 2011-09-03 18:52:21 UTC (rev 1012) @@ -10,7 +10,7 @@ #endif // _MSC_VER >= 1000 #include "sndfile.h" -#include "misc_util.h" +#include "../common/misc_util.h" #include "Undo.h" #include <time.h> Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -8,7 +8,7 @@ #include "dlg_misc.h" #include "dlsbank.h" #include "modsmp_ctrl.h" -#include "misc_util.h" +#include "../common/misc_util.h" #pragma warning(disable:4244) //"conversion from 'type1' to 'type2', possible loss of data" @@ -43,7 +43,7 @@ { CString error; error.Format("Error: Max number of channels for this file type is %d", maxChans); - ::AfxMessageBox(error, MB_OK|MB_ICONEXCLAMATION); + Reporting::Notification(error, MB_OK | MB_ICONEXCLAMATION); return false; } Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -288,7 +288,7 @@ else { m_PreAmpNoteShowed = true; - AfxMessageBox(str_preampChangeNote, MB_ICONINFORMATION); + Reporting::Notification(str_preampChangeNote, MB_ICONINFORMATION); SetPreAmpSliderPosition(); } } Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -18,7 +18,7 @@ #include <afxadv.h> #include <shlwapi.h> #include "UpdateCheck.h" -#include "../soundlib/StringFixer.h" +#include "../common/StringFixer.h" #include "ExceptionHandler.h" // rewbs.memLeak @@ -97,7 +97,7 @@ { CString str; str.Format(GetStrI18N(_TEXT("Unable to open \"%s\": file does not exist.")), path); - AfxMessageBox(str); + Reporting::Notification(str); } else //Case: Valid path but opening fails. { @@ -109,7 +109,7 @@ "recommended to close some documents as otherwise crash is likely" "(currently there %s %d document%s open).")), path, (nOdc == 1) ? "is" : "are", nOdc, (nOdc == 1) ? "" : "s"); - AfxMessageBox(str); + Reporting::Notification(str); } } } @@ -2177,7 +2177,7 @@ if(nonFoundPlugs.GetLength() > 0) { nonFoundPlugs.Insert(0, "Problems were encountered with plugins:\n"); - MessageBox(NULL, nonFoundPlugs, "", MB_OK); + Reporting::Notification(nonFoundPlugs); } return FALSE; } Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Mptrack.h 2011-09-03 18:52:21 UTC (rev 1012) @@ -16,6 +16,7 @@ #include "../soundlib/Sndfile.h" #include "ACMConvert.h" #include <windows.h> +#include "../common/Reporting.h" class CModDoc; class CVstPluginManager; Modified: trunk/OpenMPT/mptrack/PSRatioCalc.cpp =================================================================== --- trunk/OpenMPT/mptrack/PSRatioCalc.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/PSRatioCalc.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -162,7 +162,7 @@ { if (m_dRatio<50.0 || m_dRatio>200.0) { - ::MessageBox(NULL, "Error: ratio must be between 50% and 200%.", + Reporting::Notification("Error: ratio must be between 50% and 200%.", "Error", MB_ICONERROR | MB_OK); return; } Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -711,7 +711,7 @@ || (m_nRow >= pSndFile->Patterns[m_nPattern].GetNumRows()) || (m_nChannel >= pSndFile->m_nChannels) || (!pSndFile->Patterns[m_nPattern])) return; - MODCOMMAND *m = pSndFile->Patterns[m_nPattern]+m_nRow*pSndFile->m_nChannels+m_nChannel; + MODCOMMAND *m = pSndFile->Patterns[m_nPattern].GetpModCommand(m_nRow, m_nChannel); if ((m->note != note) || (m->instr != instr)) { if(!m_bModified) // let's create just one undo step. @@ -740,7 +740,7 @@ || (m_nRow >= pSndFile->Patterns[m_nPattern].GetNumRows()) || (m_nChannel >= pSndFile->m_nChannels) || (!pSndFile->Patterns[m_nPattern])) return; - MODCOMMAND *m = pSndFile->Patterns[m_nPattern]+m_nRow*pSndFile->m_nChannels+m_nChannel; + MODCOMMAND *m = pSndFile->Patterns[m_nPattern].GetpModCommand(m_nRow, m_nChannel); if ((m->volcmd != volcmd) || (m->vol != vol)) { if(!m_bModified) // let's create just one undo step. @@ -768,7 +768,7 @@ || (m_nRow >= pSndFile->Patterns[m_nPattern].GetNumRows()) || (m_nChannel >= pSndFile->m_nChannels) || (!pSndFile->Patterns[m_nPattern])) return; - MODCOMMAND *m = pSndFile->Patterns[m_nPattern]+m_nRow*pSndFile->m_nChannels+m_nChannel; + MODCOMMAND *m = pSndFile->Patterns[m_nPattern].GetpModCommand(m_nRow, m_nChannel); // -> CODE#0010 // -> DESC="add extended parameter mechanism to pattern effects" Modified: trunk/OpenMPT/mptrack/Stdafx.h =================================================================== --- trunk/OpenMPT/mptrack/Stdafx.h 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/Stdafx.h 2011-09-03 18:52:21 UTC (rev 1012) @@ -94,7 +94,7 @@ void Log(LPCSTR format,...); -#include "typedefs.h" +#include "../common/typedefs.h" //To mark string that should be translated in case of multilingual version. #define GetStrI18N(x) (x) Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -19,9 +19,9 @@ #include "UpdateCheck.h" #include "Mpdlgs.h" #include "AutoSaver.h" -#include "../soundlib/StringFixer.h" +#include "../common/StringFixer.h" #include "TrackerSettings.h" -#include "misc_util.h" +#include "../common/misc_util.h" const TCHAR *TrackerSettings::m_szDirectoryToSettingsName[NUM_DIRS] = { _T("Songs_Directory"), _T("Samples_Directory"), _T("Instruments_Directory"), _T("Plugins_Directory"), _T("Plugin_Presets_Directory"), _T("Export_Directory"), _T(""), _T("") }; @@ -412,6 +412,11 @@ GetPrivateProfileStruct("Effects", "EQ_User2", &CEQSetupDlg::gUserPresets[1], sizeof(EQPRESET), iniFile); GetPrivateProfileStruct("Effects", "EQ_User3", &CEQSetupDlg::gUserPresets[2], sizeof(EQPRESET), iniFile); GetPrivateProfileStruct("Effects", "EQ_User4", &CEQSetupDlg::gUserPresets[3], sizeof(EQPRESET), iniFile); + StringFixer::SetNullTerminator(m_EqSettings.szName); + StringFixer::SetNullTerminator(CEQSetupDlg::gUserPresets[0].szName); + StringFixer::SetNullTerminator(CEQSetupDlg::gUserPresets[1].szName); + StringFixer::SetNullTerminator(CEQSetupDlg::gUserPresets[2].szName); + StringFixer::SetNullTerminator(CEQSetupDlg::gUserPresets[3].szName); // Auto saver settings @@ -458,7 +463,7 @@ if (pEqSettings->Gains[i] > 32) pEqSettings->Gains[i] = 16; if ((pEqSettings->Freqs[i] < 100) || (pEqSettings->Freqs[i] > 10000)) pEqSettings->Freqs[i] = CEQSetupDlg::gEQPresets[0].Freqs[i]; } - pEqSettings->szName[sizeof(pEqSettings->szName)-1] = 0; + StringFixer::SetNullTerminator(pEqSettings->szName); } Modified: trunk/OpenMPT/mptrack/TuningDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/TuningDialog.cpp 2011-09-03 15:01:03 UTC (rev 1011) +++ trunk/OpenMPT/mptrack/TuningDialog.cpp 2011-09-03 18:52:21 UTC (rev 1012) @@ -3,8 +3,8 @@ #include "TuningDialog.h" #include "MainFrm.h" #include <algorithm> -#include "misc_util.h" -#include ".\tuningdialog.h" +#include "../common/misc_util.h" +#include "tuningdialog.h" const CTuningDialog::TUNINGTREEITEM CTuningDialog::s_notFoundItemTuning = TUNINGTREEITEM(); const HTREEITEM CTuningDialog::s_notFoundItemTree = NULL; @@ -458,7 +458,7 @@ TUNINGTYPE newType = GetTuningTypeFromStr(strNewType); if(!m_pActiveTuning->IsOfType(newType)) { - if(MessageBox("This action may change the ratio values; continue?", 0, MB_YESNO) == IDYES) + if(Reporting::Notification("This action may change the ratio values; continue?", MB_YESNO) == IDYES) { m_ModifiedTCs[GetpTuningCollection(m_pActiveTuning)] = true; @@ ... [truncated message content] |
From: <sag...@us...> - 2011-09-03 19:42:35
|
Revision: 1014 http://modplug.svn.sourceforge.net/modplug/?rev=1014&view=rev Author: saga-games Date: 2011-09-03 19:42:29 +0000 (Sat, 03 Sep 2011) Log Message: ----------- [Imp] Shortcuts are not processed anymore when a message box is shown. [Mod] OpenMPT: Version is now 1.20.00.17 Modified Paths: -------------- trunk/OpenMPT/common/Reporting.cpp trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/version.h Modified: trunk/OpenMPT/common/Reporting.cpp =================================================================== --- trunk/OpenMPT/common/Reporting.cpp 2011-09-03 19:18:19 UTC (rev 1013) +++ trunk/OpenMPT/common/Reporting.cpp 2011-09-03 19:42:29 UTC (rev 1014) @@ -22,10 +22,17 @@ UINT Reporting::Notification(CString text, CString caption, UINT flags /* = MB_OK*/, HWND parent /* = NULL*/) //----------------------------------------------------------------------------------------------------------- { - if(parent == NULL && CMainFrame::GetMainFrame() != nullptr) + CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); + + if(pMainFrm != nullptr && pMainFrm->GetInputHandler() != nullptr) { - parent = CMainFrame::GetMainFrame()->m_hWnd; + pMainFrm->GetInputHandler()->Bypass(true); } return ::MessageBox(parent, text, caption, flags); + + if(pMainFrm != nullptr && pMainFrm->GetInputHandler() != nullptr) + { + pMainFrm->GetInputHandler()->Bypass(false); + } }; Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2011-09-03 19:18:19 UTC (rev 1013) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2011-09-03 19:42:29 UTC (rev 1014) @@ -355,7 +355,7 @@ return false; if(!m_pVstPlugin->isInstrument() || pModDoc->GetSoundFile()->GetModSpecifications().instrumentsMax == 0 || - Reporting::Notification(_T("You need to assign an instrument to this plugin before you can play notes from here.\nCreate a new instrument and assign this plugin to the instrument?"), MB_YESNO | MB_ICONQUESTION) == IDNO) + Reporting::Notification(_T("You need to assign an instrument to this plugin before you can play notes from here.\nCreate a new instrument and assign this plugin to the instrument?"), MB_YESNO | MB_ICONQUESTION, this->m_hWnd) == IDNO) { return false; } else Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-09-03 19:18:19 UTC (rev 1013) +++ trunk/OpenMPT/mptrack/version.h 2011-09-03 19:42:29 UTC (rev 1014) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 16 +#define VER_MINORMINOR 17 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-03 21:47:01
|
Revision: 1015 http://modplug.svn.sourceforge.net/modplug/?rev=1015&view=rev Author: saga-games Date: 2011-09-03 21:46:53 +0000 (Sat, 03 Sep 2011) Log Message: ----------- [Fix] After a messagebox was shown, shortcuts didn't work anymore [Ref] More messagebox related refactoring. Modified Paths: -------------- trunk/OpenMPT/common/Reporting.cpp trunk/OpenMPT/common/Reporting.h trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/Childfrm.h trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/CreditStatic.h trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/ExceptionHandler.cpp trunk/OpenMPT/mptrack/Globals.h trunk/OpenMPT/mptrack/InputHandler.cpp trunk/OpenMPT/mptrack/KeyConfigDlg.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/mptrack/Moptions.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/SampleEditorDialogs.cpp trunk/OpenMPT/mptrack/SelectPluginDialog.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/soundlib/Sampleio.cpp Modified: trunk/OpenMPT/common/Reporting.cpp =================================================================== --- trunk/OpenMPT/common/Reporting.cpp 2011-09-03 19:42:29 UTC (rev 1014) +++ trunk/OpenMPT/common/Reporting.cpp 2011-09-03 21:46:53 UTC (rev 1015) @@ -12,15 +12,16 @@ #include "Reporting.h" #include "../mptrack/Mainfrm.h" -UINT Reporting::Notification(CString text, UINT flags /* = MB_OK*/, HWND parent /* = NULL*/) -//------------------------------------------------------------------------------------------ + +UINT Reporting::Notification(CString text, UINT flags, CWnd *parent) +//------------------------------------------------------------------ { return Notification(text, MAINFRAME_TITLE, flags, parent); -}; +} -UINT Reporting::Notification(CString text, CString caption, UINT flags /* = MB_OK*/, HWND parent /* = NULL*/) -//----------------------------------------------------------------------------------------------------------- +UINT Reporting::Notification(CString text, CString caption, UINT flags, CWnd *parent) +//----------------------------------------------------------------------------------- { CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); @@ -29,10 +30,12 @@ pMainFrm->GetInputHandler()->Bypass(true); } - return ::MessageBox(parent, text, caption, flags); + UINT result = ::MessageBox((parent ? parent->m_hWnd : NULL), text, caption, flags); if(pMainFrm != nullptr && pMainFrm->GetInputHandler() != nullptr) { pMainFrm->GetInputHandler()->Bypass(false); } -}; + + return result; +} Modified: trunk/OpenMPT/common/Reporting.h =================================================================== --- trunk/OpenMPT/common/Reporting.h 2011-09-03 19:42:29 UTC (rev 1014) +++ trunk/OpenMPT/common/Reporting.h 2011-09-03 21:46:53 UTC (rev 1015) @@ -19,8 +19,8 @@ public: - static UINT Notification(CString text, UINT flags = MB_OK, HWND parent = NULL); - static UINT Notification(CString text, CString caption, UINT flags = MB_OK, HWND parent = NULL); + static UINT Notification(CString text, UINT flags = MB_OK, CWnd *parent = nullptr); + static UINT Notification(CString text, CString caption, UINT flags = MB_OK, CWnd *parent = nullptr); }; Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2011-09-03 19:42:29 UTC (rev 1014) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2011-09-03 21:46:53 UTC (rev 1015) @@ -355,7 +355,7 @@ return false; if(!m_pVstPlugin->isInstrument() || pModDoc->GetSoundFile()->GetModSpecifications().instrumentsMax == 0 || - Reporting::Notification(_T("You need to assign an instrument to this plugin before you can play notes from here.\nCreate a new instrument and assign this plugin to the instrument?"), MB_YESNO | MB_ICONQUESTION, this->m_hWnd) == IDNO) + Reporting::Notification(_T("You need to assign an instrument to this plugin before you can play notes from here.\nCreate a new instrument and assign this plugin to the instrument?"), MB_YESNO | MB_ICONQUESTION, this) == IDNO) { return false; } else @@ -655,7 +655,6 @@ void CAbstractVstEditor::OnInitMenu(CMenu* /*pMenu*/) //--------------------------------------------------- { - //AfxMessageBox(""); SetupMenu(); } Modified: trunk/OpenMPT/mptrack/Childfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Childfrm.h 2011-09-03 19:42:29 UTC (rev 1014) +++ trunk/OpenMPT/mptrack/Childfrm.h 2011-09-03 21:46:53 UTC (rev 1015) @@ -2,12 +2,9 @@ // ///////////////////////////////////////////////////////////////////////////// -#if !defined(AFX_CHILDFRM_H__AE144DCA_DD0B_11D1_AF24_444553540000__INCLUDED_) -#define AFX_CHILDFRM_H__AE144DCA_DD0B_11D1_AF24_444553540000__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 +#ifndef CHILDFRM_H +#define CHILDFRM_H class CModControlDlg; @@ -155,4 +152,4 @@ //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. -#endif // !defined(AFX_CHILDFRM_H__AE144DCA_DD0B_11D1_AF24_444553540000__INCLUDED_) +#endif // CHILDFRM_H Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2011-09-03 19:42:29 UTC (rev 1014) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2011-09-03 21:46:53 UTC (rev 1015) @@ -3,6 +3,7 @@ #include "stdafx.h" #include "commandset.h" #include "resource.h" +#include "Mptrack.h" // For MsgBox #include "../common/Reporting.h" #include <stdio.h> #include <stdlib.h> @@ -1423,7 +1424,7 @@ if( (outStream = fopen( fileName, "w" )) == NULL ) { - AfxMessageBox(IDS_CANT_OPEN_FILE_FOR_WRITING, MB_ICONEXCLAMATION|MB_OK); + MsgBox(IDS_CANT_OPEN_FILE_FOR_WRITING, NULL, NULL, MB_ICONEXCLAMATION | MB_OK); return false; } fprintf(outStream, "//-------- OpenMPT key binding definition file -------\n"); Modified: trunk/OpenMPT/mptrack/CreditStatic.h =================================================================== --- trunk/OpenMPT/mptrack/CreditStatic.h 2011-09-03 19:42:29 UTC (rev 1014) +++ trunk/OpenMPT/mptrack/CreditStatic.h 2011-09-03 21:46:53 UTC (rev 1015) @@ -1,9 +1,7 @@ -#if !defined(AFX_CREDITSTATIC_H__4ABD7701_49F5_11D1_9E3C_00A0245800CF__INCLUDED_) -#define AFX_CREDITSTATIC_H__4ABD7701_49F5_11D1_9E3C_00A0245800CF__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 +#ifndef CREDITSTATIC_H +#define CREDITSTATIC_H + // CreditStatic.h : header file // @@ -117,4 +115,4 @@ //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. -#endif // !defined(AFX_CREDITSTATIC_H__4ABD7701_49F5_11D1_9E3C_00A0245800CF__INCLUDED_) +#endif // CREDITSTATIC_H Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-09-03 19:42:29 UTC (rev 1014) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-09-03 21:46:53 UTC (rev 1015) @@ -623,6 +623,10 @@ // Updating Values if (dwHintMask & (HINT_MODTYPE|HINT_SAMPLEINFO)) { + if(m_nSample > m_pSndFile->GetNumSamples()) + { + SetCurrentSample(m_pSndFile->GetNumSamples()); + } const MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); CHAR s[128]; DWORD d; @@ -1873,7 +1877,7 @@ } if (handleSt == NULL) { - AfxMessageBox(IDS_SOUNDTOUCH_LOADFAILURE); + MsgBox(IDS_SOUNDTOUCH_LOADFAILURE); return -1; } Modified: trunk/OpenMPT/mptrack/ExceptionHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2011-09-03 19:42:29 UTC (rev 1014) +++ trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2011-09-03 21:46:53 UTC (rev 1015) @@ -49,7 +49,6 @@ //------------------------------------------------------------------------------------------------------------ { CMainFrame* pMainFrame = CMainFrame::GetMainFrame(); - const HWND window = (pMainFrame ? pMainFrame->m_hWnd : NULL); // Shut down audio device... if(pMainFrame) @@ -137,7 +136,7 @@ } } - Reporting::Notification(errorMessage, "OpenMPT Crash", MB_ICONERROR, window); + Reporting::Notification(errorMessage, "OpenMPT Crash", MB_ICONERROR, pMainFrame); // Let Windows handle the exception... return EXCEPTION_CONTINUE_SEARCH; Modified: trunk/OpenMPT/mptrack/Globals.h =================================================================== --- trunk/OpenMPT/mptrack/Globals.h 2011-09-03 19:42:29 UTC (rev 1014) +++ trunk/OpenMPT/mptrack/Globals.h 2011-09-03 21:46:53 UTC (rev 1015) @@ -2,14 +2,11 @@ // ///////////////////////////////////////////////////////////////////////////// +#pragma once #ifndef _MODGLOBALS_H_ #define _MODGLOBALS_H_ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - #ifndef WM_HELPHITTEST #define WM_HELPHITTEST 0x366 #endif Modified: trunk/OpenMPT/mptrack/InputHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/InputHandler.cpp 2011-09-03 19:42:29 UTC (rev 1014) +++ trunk/OpenMPT/mptrack/InputHandler.cpp 2011-09-03 21:46:53 UTC (rev 1015) @@ -58,7 +58,7 @@ } } if (bSuccess == false) - AfxMessageBox(IDS_UNABLE_TO_LOAD_KEYBINDINGS, MB_ICONERROR); + MsgBox(IDS_UNABLE_TO_LOAD_KEYBINDINGS, NULL, MAINFRAME_TITLE, MB_ICONERROR); } // We will only overwrite the default Keybindings.mkb file from now on. _tcscpy(CMainFrame::GetSettings().m_szKbdFile, sDefaultPath); Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2011-09-03 19:42:29 UTC (rev 1014) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2011-09-03 21:46:53 UTC (rev 1015) @@ -665,7 +665,7 @@ { if (m_sFullPathName.Compare(CMainFrame::GetSettings().m_szKbdFile)) { - if (AfxMessageBox("Load this keyboard config file when MPT starts up?", MB_YESNO) == IDYES) + if (Reporting::Notification("Load this keyboard config file when MPT starts up?", MB_YESNO) == IDYES) { strcpy(CMainFrame::GetSettings().m_szKbdFile,m_sFullPathName); OnSettingsChanged(); // Enable "apply" button Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2011-09-03 19:42:29 UTC (rev 1014) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2011-09-03 21:46:53 UTC (rev 1015) @@ -1,13 +1,12 @@ // MainFrm.h : interface of the CMainFrame class // ///////////////////////////////////////////////////////////////////////////// -#if !defined(AFX_MAINFRM_H__AE144DC8_DD0B_11D1_AF24_444553540000__INCLUDED_) -#define AFX_MAINFRM_H__AE144DC8_DD0B_11D1_AF24_444553540000__INCLUDED_ -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 +#ifndef MAINFRM_H +#define MAINFRM_H + #include "sndfile.h" #include "CommandSet.h" #include "inputhandler.h" @@ -682,10 +681,9 @@ const CHAR gszBuildDate[] = __DATE__ " " __TIME__; - ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. -#endif // !defined(AFX_MAINFRM_H__AE144DC8_DD0B_11D1_AF24_444553540000__INCLUDED_) +#endif // MAINFRM_H Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2011-09-03 19:42:29 UTC (rev 1014) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2011-09-03 21:46:53 UTC (rev 1015) @@ -613,7 +613,7 @@ if ((!m_pSndFile) || (!m_lpszFileName) || ((f = fopen(m_lpszFileName, "w+b")) == NULL)) { - ::AfxMessageBox("Could not open file for writing. Is it open in another application?"); + Reporting::Notification("Could not open file for writing. Is it open in another application?"); EndDialog(IDCANCEL); return; } @@ -1001,7 +1001,7 @@ // Creating the output file if ((f = fopen(m_lpszFileName, "wb")) == NULL) { - ::AfxMessageBox("Could not open file for writing. Is it open in another application?"); + Reporting::Notification("Could not open file for writing. Is it open in another application?"); goto OnError; } wfh.id_RIFF = IFFID_RIFF; Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2011-09-03 19:42:29 UTC (rev 1014) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2011-09-03 21:46:53 UTC (rev 1015) @@ -854,7 +854,7 @@ CShowLogDlg dlg(parent); return dlg.ShowLog(m_lpszLog, lpszTitle); #else - return Reporting::Notification(m_lpszLog, lpszTitle, MB_OK | MB_ICONINFORMATION, (parent) ? parent->m_hWnd : nullptr); + return Reporting::Notification(m_lpszLog, lpszTitle, MB_OK | MB_ICONINFORMATION, parent); #endif } return IDCANCEL; @@ -3887,7 +3887,7 @@ { const SAMPLEINDEX nSmp = m_SndFile.Instruments[nInstr]->Keyboard[NOTE_MIDDLEC - 1]; if (nSmp <= m_SndFile.GetNumSamples() && m_SndFile.GetSample(nSmp).pSample) - instrumentName.Format(TEXT("s: %s"), m_SndFile.GetSampleName(nSmp)); //60 is C-5 + instrumentName.Format(TEXT("s: %s"), m_SndFile.GetSampleName(nSmp)); } // Get plugin name. Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2011-09-03 19:42:29 UTC (rev 1014) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2011-09-03 21:46:53 UTC (rev 1015) @@ -689,9 +689,10 @@ if ((nIns) && (nIns <= m_SndFile.GetNumInstruments()) && (m_SndFile.Instruments[nIns])) { bool instrumentsLeft = false; - CriticalSection cs; m_SndFile.DestroyInstrument(nIns); + + CriticalSection cs; if (nIns == m_SndFile.m_nInstruments) m_SndFile.m_nInstruments--; for (UINT i=1; i<MAX_INSTRUMENTS; i++) if (m_SndFile.Instruments[i]) instrumentsLeft = true; if (!instrumentsLeft) m_SndFile.m_nInstruments = 0; Modified: trunk/OpenMPT/mptrack/Moptions.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moptions.cpp 2011-09-03 19:42:29 UTC (rev 1014) +++ trunk/OpenMPT/mptrack/Moptions.cpp 2011-09-03 21:46:53 UTC (rev 1015) @@ -108,7 +108,7 @@ if ((temp_nRowSpacing2 > temp_nRowSpacing)) { - ::AfxMessageBox("Error: Primary highlight must be greater than or equal secondary highlight.", MB_OK|MB_ICONEXCLAMATION); + Reporting::Notification("Error: Primary highlight must be greater than or equal secondary highlight.", MB_OK | MB_ICONEXCLAMATION); ::SetFocus(::GetDlgItem(m_hWnd, IDC_PRIMARYHILITE)); return 0; } Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2011-09-03 19:42:29 UTC (rev 1014) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2011-09-03 21:46:53 UTC (rev 1015) @@ -1854,15 +1854,14 @@ { CString str; str.LoadString(nStringID); - HWND hwnd = (p) ? p->m_hWnd : NULL; - return ::MessageBox(hwnd, str, lpszTitle, n); + return Reporting::Notification(str, CString(lpszTitle), n, p); } void ErrorBox(UINT nStringID, CWnd*p) //----------------------------------- { - MsgBox(nStringID, p, "Error!", MB_OK|MB_ICONSTOP); + MsgBox(nStringID, p, "Error!", MB_OK | MB_ICONSTOP); } Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2011-09-03 19:42:29 UTC (rev 1014) +++ trunk/OpenMPT/mptrack/Mptrack.h 2011-09-03 21:46:53 UTC (rev 1015) @@ -1,13 +1,11 @@ // mptrack.h : main header file for the MPTRACK application // -#if !defined(AFX_MPTRACK_H__AE144DC4_DD0B_11D1_AF24_444553540000__INCLUDED_) -#define AFX_MPTRACK_H__AE144DC4_DD0B_11D1_AF24_444553540000__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 +#ifndef MPTRACK_H +#define MPTRACK_H + #ifndef __AFXWIN_H__ #error include 'stdafx.h' before including this file for PCH #endif @@ -381,4 +379,4 @@ //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. -#endif // !defined(AFX_MPTRACK_H__AE144DC4_DD0B_11D1_AF24_444553540000__INCLUDED_) +#endif // MPTRACK_H Modified: trunk/OpenMPT/mptrack/SampleEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/SampleEditorDialogs.cpp 2011-09-03 19:42:29 UTC (rev 1014) +++ trunk/OpenMPT/mptrack/SampleEditorDialogs.cpp 2011-09-03 21:46:53 UTC (rev 1015) @@ -46,7 +46,7 @@ if(nVal < m_nFactorMin || nVal > m_nFactorMax) { CString str; str.Format(GetStrI18N(__TEXT("Value should be within [%d, %d]")), m_nFactorMin, m_nFactorMax); - AfxMessageBox(str, MB_ICONINFORMATION); + Reporting::Notification(str, MB_ICONINFORMATION); return; } m_nFactor = static_cast<int16>(nVal); Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2011-09-03 19:42:29 UTC (rev 1014) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2011-09-03 21:46:53 UTC (rev 1015) @@ -391,7 +391,7 @@ /*&& (gProblemPlugs[p].id1 == plug->dwPluginId1)*/) { s.Format("WARNING: This plugin has been identified as %s,\nwhich is known to have the following problem with OpenMPT:\n\n%s\n\nWould you still like to add this plugin to the library?", gProblemPlugs[p].name, gProblemPlugs[p].problem); - return (AfxMessageBox(s, MB_YESNO) == IDYES); + return (Reporting::Notification(s, MB_YESNO) == IDYES); } } Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2011-09-03 19:42:29 UTC (rev 1014) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2011-09-03 21:46:53 UTC (rev 1015) @@ -1116,8 +1116,13 @@ switch(cLeftBarButtons[i]) { case ID_SAMPLE_DRAW: - if(m_bDrawingEnabled) dwStyle |= NCBTNS_CHECKED; - if(pSndFile->GetSample(m_nSample).GetNumChannels() > 1 || pSndFile->GetSample(m_nSample).pSample == nullptr) dwStyle |= NCBTNS_DISABLED; + if(m_bDrawingEnabled) dwStyle |= NCBTNS_CHECKED; + if(m_nSample > pSndFile->GetNumSamples() || + pSndFile->GetSample(m_nSample).GetNumChannels() > 1 || + pSndFile->GetSample(m_nSample).pSample == nullptr) + { + dwStyle |= NCBTNS_DISABLED; + } break; } Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2011-09-03 19:42:29 UTC (rev 1014) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2011-09-03 21:46:53 UTC (rev 1015) @@ -1400,7 +1400,7 @@ if (pModDoc && pSndFile) { wsprintf(s, _T("Remove sequence %d?"), modItemID); - if(MessageBox(s, _T("Confirmation"), MB_YESNO | MB_DEFBUTTON2) == IDNO) break; + if(Reporting::Notification(s, _T("Confirmation"), MB_YESNO | MB_DEFBUTTON2) == IDNO) break; pSndFile->Order.RemoveSequence((SEQUENCEINDEX)(modItemID)); pModDoc->UpdateAllViews(NULL, HINT_MODSEQUENCE, NULL); } @@ -1416,7 +1416,7 @@ case MODITEM_PATTERN: wsprintf(s, _T("Remove pattern %d?"), modItemID); - if (pModDoc == nullptr || MessageBox(s, _T("Confirmation"), MB_YESNO | MB_DEFBUTTON2) == IDNO) break; + if (pModDoc == nullptr || Reporting::Notification(s, _T("Confirmation"), MB_YESNO | MB_DEFBUTTON2) == IDNO) break; if (pModDoc->RemovePattern((PATTERNINDEX)modItemID)) { pModDoc->UpdateAllViews(NULL, (UINT(modItemID) << HINT_SHIFT_PAT) | HINT_PATTERNDATA|HINT_PATNAMES); @@ -1425,7 +1425,7 @@ case MODITEM_SAMPLE: wsprintf(s, _T("Remove sample %d?"), modItemID); - if (pModDoc == nullptr || MessageBox(s, _T("Confirmation"), MB_YESNO | MB_DEFBUTTON2) == IDNO) break; + if (pModDoc == nullptr || Reporting::Notification(s, _T("Confirmation"), MB_YESNO | MB_DEFBUTTON2) == IDNO) break; pModDoc->GetSampleUndo()->PrepareUndo((SAMPLEINDEX)modItemID, sundo_replace); if (pModDoc->RemoveSample((SAMPLEINDEX)modItemID)) { @@ -1435,7 +1435,7 @@ case MODITEM_INSTRUMENT: wsprintf(s, _T("Remove instrument %d?"), modItemID); - if (pModDoc == nullptr || MessageBox(s, _T("Confirmation"), MB_YESNO | MB_DEFBUTTON2) == IDNO) break; + if (pModDoc == nullptr || Reporting::Notification(s, _T("Confirmation"), MB_YESNO | MB_DEFBUTTON2) == IDNO) break; if (pModDoc->RemoveInstrument((INSTRUMENTINDEX)modItemID)) { pModDoc->UpdateAllViews(NULL, (UINT(modItemID) << HINT_SHIFT_INS) | HINT_MODTYPE|HINT_ENVELOPE|HINT_INSTRUMENT); Modified: trunk/OpenMPT/soundlib/Sampleio.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sampleio.cpp 2011-09-03 19:42:29 UTC (rev 1014) +++ trunk/OpenMPT/soundlib/Sampleio.cpp 2011-09-03 21:46:53 UTC (rev 1015) @@ -14,6 +14,7 @@ #ifdef MODPLUG_TRACKER #include "../mptrack/Moddoc.h" #endif //MODPLUG_TRACKER +#include "../mptrack/Mainfrm.h" // For CriticalSection #include "Wav.h" #include "../common/StringFixer.h" #include "../common/Reporting.h" @@ -132,6 +133,8 @@ #endif // MODPLUG_TRACKER // -! NEW_FEATURE#0023 + CriticalSection cs; + MODINSTRUMENT *pIns = Instruments[nInstr]; Instruments[nInstr] = nullptr; for(CHANNELINDEX i = 0; i < MAX_CHANNELS; i++) @@ -171,6 +174,8 @@ } for (SAMPLEINDEX nSmp = 1; nSmp <= GetNumSamples(); nSmp++) if (sampleused[nSmp]) { + CriticalSection cs; + DestroySample(nSmp); strcpy(m_szNames[nSmp], ""); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-04 00:10:06
|
Revision: 1016 http://modplug.svn.sourceforge.net/modplug/?rev=1016&view=rev Author: saga-games Date: 2011-09-04 00:09:56 +0000 (Sun, 04 Sep 2011) Log Message: ----------- [Imp] Compatibility export menu item is now greyed out for S3M and MPTM modules. [Ref] Even more messagebox refactoring. Slowly getting it to where I want it to be... Modified Paths: -------------- trunk/OpenMPT/common/Reporting.cpp trunk/OpenMPT/common/Reporting.h trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/AutoSaver.cpp trunk/OpenMPT/mptrack/ChannelManagerDlg.cpp trunk/OpenMPT/mptrack/CleanupSong.cpp trunk/OpenMPT/mptrack/CommandSet.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/ExceptionHandler.cpp trunk/OpenMPT/mptrack/KeyConfigDlg.cpp trunk/OpenMPT/mptrack/KeyConfigDlg.h trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/ModConvert.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp trunk/OpenMPT/mptrack/SampleEditorDialogs.cpp trunk/OpenMPT/mptrack/SelectPluginDialog.cpp trunk/OpenMPT/mptrack/TuningDialog.cpp trunk/OpenMPT/mptrack/UpdateCheck.cpp trunk/OpenMPT/mptrack/View_gen.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/mptrack/fxp.cpp trunk/OpenMPT/mptrack/mod2midi.cpp trunk/OpenMPT/mptrack/test/test.cpp trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/Mmx_mix.cpp trunk/OpenMPT/soundlib/ModSequence.cpp trunk/OpenMPT/soundlib/Sampleio.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/pattern.cpp Modified: trunk/OpenMPT/common/Reporting.cpp =================================================================== --- trunk/OpenMPT/common/Reporting.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/common/Reporting.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -13,16 +13,9 @@ #include "../mptrack/Mainfrm.h" -UINT Reporting::Notification(CString text, UINT flags, CWnd *parent) -//------------------------------------------------------------------ +UINT Reporting::ShowNotification(const char *text, const char *caption, UINT flags, const CWnd *parent) +//----------------------------------------------------------------------------------------------------- { - return Notification(text, MAINFRAME_TITLE, flags, parent); -} - - -UINT Reporting::Notification(CString text, CString caption, UINT flags, CWnd *parent) -//----------------------------------------------------------------------------------- -{ CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); if(pMainFrm != nullptr && pMainFrm->GetInputHandler() != nullptr) @@ -39,3 +32,83 @@ return result; } + + +void Reporting::Notification(const char *text, UINT flags, const CWnd *parent) +//---------------------------------------------------------------------------- +{ + Notification(text, MAINFRAME_TITLE, flags, parent); +} + + +void Reporting::Notification(const char *text, const char *caption, UINT flags, const CWnd *parent) +//------------------------------------------------------------------------------------------------- +{ + ShowNotification(text, caption, flags, parent); +} + + +void Reporting::Information(const char *text, const CWnd *parent) +//--------------------------------------------------------------- +{ + Information(text, MAINFRAME_TITLE, parent); +} + + +void Reporting::Information(const char *text, const char *caption, const CWnd *parent) +//------------------------------------------------------------------------------------ +{ + ShowNotification(text, caption, MB_OK | MB_ICONINFORMATION, parent); +} + + +void Reporting::Warning(const char *text, const CWnd *parent) +//----------------------------------------------------------- +{ + Warning(text, MAINFRAME_TITLE " - Error", parent); +} + + +void Reporting::Warning(const char *text, const char *caption, const CWnd *parent) +//-------------------------------------------------------------------------------- +{ + ShowNotification(text, caption, MB_OK | MB_ICONWARNING, parent); +} + + +void Reporting::Error(const char *text, const CWnd *parent) +//--------------------------------------------------------- +{ + Error(text, MAINFRAME_TITLE " - Error", parent); +} + + +void Reporting::Error(const char *text, const char *caption, const CWnd *parent) +//------------------------------------------------------------------------------ +{ + ShowNotification(text, caption, MB_OK | MB_ICONERROR, parent); +} + + +ConfirmAnswer Reporting::Confirm(const char *text, bool showCancel, bool defaultNo, const CWnd *parent) +//----------------------------------------------------------------------------------------------------- +{ + return Confirm(text, MAINFRAME_TITLE " - Confirmation", showCancel, defaultNo, parent); +} + + +ConfirmAnswer Reporting::Confirm(const char *text, const char *caption, bool showCancel, bool defaultNo, const CWnd *parent) +//-------------------------------------------------------------------------------------------------------------------------- +{ + UINT result = ShowNotification(text, caption, (showCancel ? MB_YESNOCANCEL : MB_YESNO) | MB_ICONQUESTION | (defaultNo ? MB_DEFBUTTON2 : 0), parent); + switch(result) + { + case IDYES: + return cnfYes; + case IDNO: + return cnfNo; + default: + case IDCANCEL: + return cnfCancel; + } +} Modified: trunk/OpenMPT/common/Reporting.h =================================================================== --- trunk/OpenMPT/common/Reporting.h 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/common/Reporting.h 2011-09-04 00:09:56 UTC (rev 1016) @@ -12,16 +12,47 @@ #ifndef REPORTING_H #define REPORTING_H +enum ConfirmAnswer +{ + cnfYes, + cnfNo, + cnfCancel, +}; + //============= class Reporting //============= { +protected: + + static UINT ShowNotification(const char *text, const char *caption, UINT flags, const CWnd *parent); + public: - static UINT Notification(CString text, UINT flags = MB_OK, CWnd *parent = nullptr); - static UINT Notification(CString text, CString caption, UINT flags = MB_OK, CWnd *parent = nullptr); + // TODO Quick'n'dirty workaround for MsgBox(). Shouldn't be public. + static UINT CustomNotification(const char *text, const char *caption, UINT flags, const CWnd *parent) { return ShowNotification(text, caption, flags, parent); }; + // Show a simple notification + static void Notification(const char *text, UINT flags = MB_OK, const CWnd *parent = nullptr); + static void Notification(const char *text, const char *caption, UINT flags = MB_OK, const CWnd *parent = nullptr); + + // Show a simple information + static void Information(const char *text, const CWnd *parent = nullptr); + static void Information(const char *text, const char *caption, const CWnd *parent = nullptr); + + // Show a simple warning + static void Warning(const char *text, const CWnd *parent = nullptr); + static void Warning(const char *text, const char *caption, const CWnd *parent = nullptr); + + // Show an error box. + static void Error(const char *text, const CWnd *parent = nullptr); + static void Error(const char *text, const char *caption, const CWnd *parent = nullptr); + + // Show a confirmation dialog. + static ConfirmAnswer Confirm(const char *text, bool showCancel = false, bool defaultNo = false, const CWnd *parent = nullptr); + static ConfirmAnswer Confirm(const char *text, const char *caption, bool showCancel = false, bool defaultNo = false, const CWnd *parent = nullptr); + }; #endif // REPORTING_H Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -111,7 +111,7 @@ m_pVstPlugin->GetModDoc()->SetModified(); } else { - Reporting::Notification("Error loading preset. Are you sure it is for this plugin?"); + Reporting::Error("Error loading preset. Are you sure it is for this plugin?"); } } @@ -129,7 +129,7 @@ //TODO: exception handling if (!(m_pVstPlugin->SaveProgram(files.first_file.c_str()))) - Reporting::Notification("Error saving preset."); + Reporting::Error("Error saving preset."); } @@ -138,7 +138,7 @@ { if (m_pVstPlugin) { - if (Reporting::Notification("Are you sure you want to randomize parameters?\nYou will lose current parameter values.", MB_YESNO | MB_ICONEXCLAMATION) == IDYES) + if (Reporting::Confirm("Are you sure you want to randomize parameters?\nYou will lose current parameter values.") == cnfYes) m_pVstPlugin->RandomizeParams(); UpdateParamDisplays(); } @@ -355,7 +355,7 @@ return false; if(!m_pVstPlugin->isInstrument() || pModDoc->GetSoundFile()->GetModSpecifications().instrumentsMax == 0 || - Reporting::Notification(_T("You need to assign an instrument to this plugin before you can play notes from here.\nCreate a new instrument and assign this plugin to the instrument?"), MB_YESNO | MB_ICONQUESTION, this) == IDNO) + Reporting::Confirm(_T("You need to assign an instrument to this plugin before you can play notes from here.\nCreate a new instrument and assign this plugin to the instrument?"), false, false, this) == cnfYes) { return false; } else Modified: trunk/OpenMPT/mptrack/AutoSaver.cpp =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/AutoSaver.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -85,7 +85,7 @@ } else { m_bEnabled = false; - Reporting::Notification("Warning: Autosave failed and has been disabled. Please:\n- Review your autosave paths\n- Check available diskspace & filesystem access rights\n- If you are using the ITP format, ensure all instruments exist as independant .iti files"); + Reporting::Warning("Warning: Autosave failed and has been disabled. Please:\n- Review your autosave paths\n- Check available diskspace & filesystem access rights\n- If you are using the ITP format, ensure all instruments exist as independant .iti files"); success = false; } } @@ -477,7 +477,7 @@ if (!pathIsOK && IsDlgButtonChecked(IDC_AUTOSAVE_ENABLE) && !IsDlgButtonChecked(IDC_AUTOSAVE_USEORIGDIR)) { - Reporting::Notification("Error: backup path does not exist.", MB_OK | MB_ICONEXCLAMATION); + Reporting::Error("Error: backup path does not exist."); ::SetFocus(::GetDlgItem(m_hWnd, IDC_AUTOSAVE_PATH)); return 0; } Modified: trunk/OpenMPT/mptrack/ChannelManagerDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/ChannelManagerDlg.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/ChannelManagerDlg.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -204,7 +204,7 @@ { cs.Leave(); EndWaitCursor(); - MessageBox("Rearranging channels failed"); + Reporting::Error("Rearranging channels failed"); ResetState(true, true, true, true, true); LeaveCriticalSection(&applying); Modified: trunk/OpenMPT/mptrack/CleanupSong.cpp =================================================================== --- trunk/OpenMPT/mptrack/CleanupSong.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/CleanupSong.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -422,7 +422,7 @@ { EndWaitCursor(); wsprintf(s, "%d pattern%s present in file, but not used in the song\nDo you want to reorder the sequence list and remove these patterns?", nWaste, (nWaste == 1) ? "" : "s"); - if (m_wParent->MessageBox(s, "Pattern Cleanup", MB_YESNO) != IDYES) return false; + if (Reporting::Confirm(s, "Pattern Cleanup") != cnfYes) return false; BeginWaitCursor(); } @@ -546,7 +546,7 @@ { //We don't remove an instrument's unused samples in an ITP. wsprintf(s, "OpenMPT detected %d sample%s referenced by an instrument,\n" "but not used in the song. Do you want to remove them?", nExt, (nExt == 1) ? "" : "s"); - if (Reporting::Notification(s, "Sample Cleanup", MB_YESNO | MB_ICONQUESTION) == IDYES) + if (Reporting::Confirm(s, "Sample Cleanup") == cnfYes) { CriticalSection cs; for (SAMPLEINDEX nSmp = 1; nSmp <= pSndFile->GetNumSamples(); nSmp++) @@ -588,7 +588,7 @@ CHAR s[512]; wsprintf(s, "%d sample%s unused data after the loop end point,\n" "Do you want to optimize %s and remove this unused data?", nLoopOpt, (nLoopOpt == 1) ? " has" : "s have", (nLoopOpt == 1) ? "it" : "them"); - if (Reporting::Notification(s, "Sample Optimization", MB_YESNO | MB_ICONQUESTION) == IDYES) + if (Reporting::Confirm(s, "Sample Optimization") == cnfYes) { for (SAMPLEINDEX nSmp = 1; nSmp <= pSndFile->m_nSamples; nSmp++) { @@ -709,16 +709,16 @@ if (!pSndFile->GetNumInstruments()) return false; - char removeSamples = -1; + deleteInstrumentSamples removeSamples = doNoDeleteAssociatedSamples; if ( !((pSndFile->GetType() == MOD_TYPE_IT) && (pSndFile->m_dwSongFlags & SONG_ITPROJECT))) //never remove an instrument's samples in ITP. { - if(Reporting::Notification("Remove samples associated with an instrument if they are unused?", "Removing unused instruments", MB_YESNO | MB_ICONQUESTION) == IDYES) + if(Reporting::Confirm("Remove samples associated with an instrument if they are unused?", "Removing unused instruments") == cnfYes) { - removeSamples = 1; + removeSamples = deleteAssociatedSamples; } } else { - Reporting::Notification("This is an IT project file, so no samples associated with an used instrument will be removed.", "Removing unused instruments", MB_OK | MB_ICONINFORMATION); + Reporting::Information("This is an IT project file, so no samples associated with an used instrument will be removed.", "Removing unused instruments"); } BeginWaitCursor(); @@ -729,16 +729,15 @@ if (!pSndFile->IsInstrumentUsed(i)) { CriticalSection cs; - // -> CODE#0003 - // -> DESC="remove instrument's samples" - // pSndFile->DestroyInstrument(i); - pSndFile->DestroyInstrument(i, removeSamples); - // -! BEHAVIOUR_CHANGE#0003 - if ((i == pSndFile->GetNumInstruments()) && (i >1)) - pSndFile->m_nInstruments--; - else - bReorg = true; - nRemoved++; + + if(pSndFile->DestroyInstrument(i, removeSamples)) + { + if ((i == pSndFile->GetNumInstruments()) && (i > 1)) + pSndFile->m_nInstruments--; + else + bReorg = true; + nRemoved++; + } } else { usedmap[i] = true; @@ -746,7 +745,7 @@ } EndWaitCursor(); if ((bReorg) && (pSndFile->m_nInstruments > 1) - && (Reporting::Notification("Do you want to reorganize the remaining instruments?", "Removing unused instruments", MB_YESNO | MB_ICONQUESTION) == IDYES)) + && (Reporting::Confirm("Do you want to reorganize the remaining instruments?", "Removing unused instruments") == cnfYes)) { BeginWaitCursor(); CriticalSection cs; @@ -870,7 +869,7 @@ if(pSndFile == nullptr) return false; //jojo.compocleanup - if(Reporting::Notification(TEXT("WARNING: OpenMPT will convert the module to IT format and reset all song, sample and instrument attributes to default values. Continue?"), TEXT("Resetting variables"), MB_YESNO | MB_ICONWARNING) == IDNO) + if(Reporting::Confirm(TEXT("WARNING: OpenMPT will convert the module to IT format and reset all song, sample and instrument attributes to default values. Continue?"), TEXT("Resetting variables")) == cnfNo) return false; // Stop play. @@ -987,8 +986,7 @@ if(bConfirm) { - if (CMainFrame::GetMainFrame()->MessageBox("Do you want to convert all instruments to samples?", - "Removing all instruments", MB_YESNO | MB_ICONQUESTION) == IDYES) + if (Reporting::Confirm("Do you want to convert all instruments to samples?", "Removing all instruments") == cnfYes) { m_pModDoc->ConvertInstrumentsToSamples(); } @@ -996,7 +994,7 @@ for (INSTRUMENTINDEX i = 1; i <= pSndFile->GetNumInstruments(); i++) { - pSndFile->DestroyInstrument(i, -1); + pSndFile->DestroyInstrument(i, doNoDeleteAssociatedSamples); } pSndFile->m_nInstruments = 0; Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -45,7 +45,7 @@ { //CHAR s[64]; //wsprintf(s, "pointer = %lX",plocalCmdSet); - //Reporting::Notification("about to remove all", NULL, MB_OK|MB_ICONEXCLAMATION); //disabled by rewbs + //Reporting::Notification("about to remove all", MB_OK | MB_ICONEXCLAMATION); //disabled by rewbs //commands.RemoveAll(); } Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -1889,12 +1889,10 @@ } if(smpPanningInUse) { - if(MessageBox(_T("Some of the samples used in the instrument have \"Set Pan\" enabled. " + if(Reporting::Confirm(_T("Some of the samples used in the instrument have \"Set Pan\" enabled. " "When instrument is played with such sample, sample pan setting overrides instrument pan. " "Do you wish to disable panning from those samples so that instrument pan setting is effective " - "for the whole instrument?"), - _T(""), - MB_YESNO) == IDYES) + "for the whole instrument?")) == cnfYes) { for(BYTE i = 0; i < CountOf(pIns->Keyboard); i++) { @@ -2649,7 +2647,7 @@ CString str; str.Format(TEXT("Tuning %s was not found. Setting to default tuning."), m_pSndFile->Instruments[m_nInstrument]->pTuning->GetName().c_str()); - MessageBox(str); + Reporting::Notification(str); CriticalSection cs; pIns->SetTuning(pIns->s_DefaultTuning); Modified: trunk/OpenMPT/mptrack/Ctrl_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -1128,7 +1128,7 @@ // If this macro is not the default IT macro, display a warning. if(!m_pModDoc->IsMacroDefaultSetupUsed()) { - if(Reporting::Notification(_T("You have chosen not to embed MIDI macros. However, the current macro configuration differs from the default macro configuration that is assumed when loading a file that has no macros embedded. This can result in data loss and broken playback.\nWould you like to embed MIDI macros now?"), MB_YESNO) == IDYES) + if(Reporting::Confirm(_T("You have chosen not to embed MIDI macros. However, the current macro configuration differs from the default macro configuration that is assumed when loading a file that has no macros embedded. This can result in data loss and broken playback.\nWould you like to embed MIDI macros now?")) == cnfYes) { m_pSndFile->m_dwSongFlags |= SONG_EMBEDMIDICFG; m_pModDoc->SetModified(); Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -1399,7 +1399,7 @@ CString strParam; strParam.Format(TEXT("%u: %s"), rSf.Order.GetCurrentSequenceIndex(), (LPCTSTR)rSf.Order.m_sName); CString str; AfxFormatString1(str, IDS_CONFIRM_SEQUENCE_DELETE, strParam); - if (Reporting::Notification(str, MB_YESNO | MB_ICONQUESTION) == IDYES) + if (Reporting::Confirm(str) == cnfYes) rSf.Order.RemoveSequence(); else { Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -941,8 +941,7 @@ m_pModDoc->UpdateAllViews(NULL, (smp << HINT_SHIFT_SMP) | HINT_SAMPLEINFO | HINT_SAMPLEDATA | HINT_SMPNAMES); if ((pSndFile->m_nInstruments) && (!m_pModDoc->FindSampleParent(smp))) { - if (MessageBox("This sample is not used by any instrument. Do you want to create a new instrument using this sample?", - NULL, MB_YESNO|MB_ICONQUESTION) == IDYES) + if (Reporting::Confirm("This sample is not used by any instrument. Do you want to create a new instrument using this sample?") == cnfYes) { UINT nins = m_pModDoc->InsertInstrument(smp); m_pModDoc->UpdateAllViews(NULL, (nins << HINT_SHIFT_INS) | HINT_INSTRUMENT | HINT_INSNAMES | HINT_ENVELOPE); @@ -1133,7 +1132,7 @@ //Shift -> Normalize all samples if(CMainFrame::GetInputHandler()->ShiftPressed()) { - if(MessageBox(GetStrI18N(TEXT("This will normalize all samples independently. Continue?")), GetStrI18N(TEXT("Normalize")), MB_YESNO | MB_ICONQUESTION) == IDNO) + if(Reporting::Confirm(GetStrI18N(TEXT("This will normalize all samples independently. Continue?")), GetStrI18N(TEXT("Normalize"))) == cnfNo) return; iMinSample = 1; iMaxSample = m_pSndFile->m_nSamples; @@ -1295,7 +1294,7 @@ //Shift -> Process all samples if(CMainFrame::GetInputHandler()->ShiftPressed()) { - if(MessageBox(GetStrI18N(TEXT("This will process all samples independently. Continue?")), GetStrI18N(TEXT("DC Offset Removal")), MB_YESNO | MB_ICONQUESTION) == IDNO) + if(Reporting::Confirm(GetStrI18N(TEXT("This will process all samples independently. Continue?")), GetStrI18N(TEXT("DC Offset Removal"))) == cnfNo) return; iMinSample = 1; iMaxSample = m_pSndFile->m_nSamples; @@ -1830,7 +1829,7 @@ default: wsprintf(str, _T("Unknown Error...")); break; } - Reporting::Notification(str, MB_ICONERROR); + Reporting::Error(str); return; } @@ -1901,7 +1900,7 @@ { CString str; str.Format(TEXT(GetStrI18N("Current samplerate, %u Hz, is not in the supported samplerate range 8000 Hz - 48000 Hz. Continue?")), nSampleRate); - if(Reporting::Notification(str, MB_ICONQUESTION|MB_YESNO) != IDYES) + if(Reporting::Confirm(str) != cnfYes) return -1; } Modified: trunk/OpenMPT/mptrack/ExceptionHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -136,7 +136,7 @@ } } - Reporting::Notification(errorMessage, "OpenMPT Crash", MB_ICONERROR, pMainFrame); + Reporting::Error(errorMessage, "OpenMPT Crash", pMainFrame); // Let Windows handle the exception... return EXCEPTION_CONTINUE_SEARCH; Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -531,7 +531,7 @@ if (cmd<0 || m_nCurKeyChoice<0 || m_nCurKeyChoice>=ih->GetKeyListSize(cmd)) { CString error = "Nothing to restore for this slot."; - Reporting::Notification(error, "Invalid key data", MB_ICONEXCLAMATION|MB_OK); + Reporting::Error(error, "Invalid key data"); return; } @@ -661,22 +661,6 @@ //TentativeSetToDefaultFile(m_sFullPathName); } -bool COptionsKeyboard::TentativeSetToDefaultFile(CString m_sFullPathName) -{ - if (m_sFullPathName.Compare(CMainFrame::GetSettings().m_szKbdFile)) - { - if (Reporting::Notification("Load this keyboard config file when MPT starts up?", MB_YESNO) == IDYES) - { - strcpy(CMainFrame::GetSettings().m_szKbdFile,m_sFullPathName); - OnSettingsChanged(); // Enable "apply" button - UpdateDialog(); - return true; - } - } - - return false; -} - void COptionsKeyboard::OnNotesRepeat() { plocalCmdSet->QuickChange_NotesRepeat(); Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.h =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.h 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.h 2011-09-04 00:09:56 UTC (rev 1016) @@ -101,7 +101,6 @@ CButton m_bDebugSave; void ForceUpdateGUI(); - bool TentativeSetToDefaultFile(CString); public: COptionsKeyboard():CPropertyPage(IDD_OPTIONS_KEYBOARD) { m_nKeyboardCfg = 0; } Modified: trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -247,7 +247,7 @@ { if(m_rSndFile.GetModSpecifications().MIDIMappingDirectivesMax <= m_rMIDIMapper.GetCount()) { - MessageBox("Max limit reached", 0, MB_ICONINFORMATION); + Reporting::Information("Maximum amount of MIDI Mapping directives reached."); } else { Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -103,7 +103,7 @@ ON_MESSAGE(WM_MOD_UPDATEPOSITION, OnUpdatePosition) ON_MESSAGE(WM_MOD_INVALIDATEPATTERNS, OnInvalidatePatterns) ON_MESSAGE(WM_MOD_SPECIALKEY, OnSpecialKey) - ON_MESSAGE(WM_MOD_KEYCOMMAND, OnCustomKeyMsg) //rewbs.customKeys + ON_MESSAGE(WM_MOD_KEYCOMMAND, OnCustomKeyMsg) //rewbs.customKeys ON_COMMAND(ID_INTERNETUPDATE, OnInternetUpdate) //}}AFX_MSG_MAP ON_WM_INITMENU() @@ -963,7 +963,7 @@ // Display error message box if (err != 0) { - MessageBox("Unable to open sound device!", NULL, MB_OK|MB_ICONERROR); + Reporting::Error("Unable to open sound device!"); return FALSE; } // Device is ready Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -261,8 +261,8 @@ m_bGivePlugsIdleTime = IsDlgButtonChecked(IDC_GIVEPLUGSIDLETIME) ? true : false; if (m_bGivePlugsIdleTime) { - if (MessageBox("You only need slow render if you are experiencing dropped notes with a Kontakt based sampler with Direct-From-Disk enabled.\nIt will make rendering *very* slow.\n\nAre you sure you want to enable slow render?", - "Really enable slow render?", MB_YESNO) == IDNO ) + if (Reporting::Confirm("You only need slow render if you are experiencing dropped notes with a Kontakt based sampler with Direct-From-Disk enabled.\nIt will make rendering *very* slow.\n\nAre you sure you want to enable slow render?", + "Really enable slow render?") == cnfNo) { CheckDlgButton(IDC_GIVEPLUGSIDLETIME, BST_UNCHECKED); return; Modified: trunk/OpenMPT/mptrack/ModConvert.cpp =================================================================== --- trunk/OpenMPT/mptrack/ModConvert.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/ModConvert.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -121,10 +121,10 @@ if((m_SndFile.GetNumInstruments() || nResizedPatterns) && (nNewType & (MOD_TYPE_MOD|MOD_TYPE_S3M))) { - if(Reporting::Notification( + if(Reporting::Confirm( "This operation will convert all instruments to samples,\n" "and resize all patterns to 64 rows.\n" - "Do you want to continue?", "Warning", MB_YESNO | MB_ICONQUESTION) != IDYES) return false; + "Do you want to continue?", "Warning") != cnfYes) return false; BeginWaitCursor(); CriticalSection cs; Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -89,6 +89,7 @@ ON_UPDATE_COMMAND_UI(ID_VIEW_MIDIMAPPING, OnUpdateHasMIDIMappings) ON_UPDATE_COMMAND_UI(ID_FILE_SAVEASMP3, OnUpdateMP3Encode) ON_UPDATE_COMMAND_UI(ID_VIEW_EDITHISTORY, OnUpdateITMPTOnly) + ON_UPDATE_COMMAND_UI(ID_FILE_SAVECOMPAT, OnUpdateCompatExportableOnly) //}}AFX_MSG_MAP END_MESSAGE_MAP() @@ -232,7 +233,7 @@ { CString sTemp; sTemp.Format("File: %s\nLast saved with: %s, current version is %s\n\n%s", lpszPathName, (LPCTSTR)MptVersion::ToStr(m_SndFile.m_dwLastSavedWithVersion), MptVersion::str, GetLog()); - Reporting::Notification(sTemp, MB_ICONINFORMATION); + Reporting::Information(sTemp); ClearLog(); } @@ -481,7 +482,7 @@ } else { if(type == MOD_TYPE_IT && m_SndFile.m_dwSongFlags & SONG_ITPROJECT) - Reporting::Notification(_T("ITP projects need to have a path set for each instrument..."), MB_ICONERROR | MB_OK); + Reporting::Error(_T("ITP projects need to have a path set for each instrument...")); else ErrorBox(IDS_ERR_SAVESONG, CMainFrame::GetMainFrame()); } @@ -508,7 +509,7 @@ } } - if(unsavedInstrument && Reporting::Notification("Do you want to save modified instruments?", MB_ICONQUESTION | MB_YESNO | MB_APPLMODAL) == IDYES) + if(unsavedInstrument && Reporting::Confirm("Do you want to save modified instruments?") == cnfYes) { for(INSTRUMENTINDEX i = 0 ; i < m_SndFile.m_nInstruments ; i++) @@ -854,7 +855,8 @@ CShowLogDlg dlg(parent); return dlg.ShowLog(m_lpszLog, lpszTitle); #else - return Reporting::Notification(m_lpszLog, lpszTitle, MB_OK | MB_ICONINFORMATION, parent); + Reporting::Information(m_lpszLog, lpszTitle, parent); + return IDOK; #endif } return IDCANCEL; @@ -1802,24 +1804,24 @@ { case MOD_TYPE_MOD: pattern = FileFilterMOD; - if(Reporting::Notification(GetStrI18N(TEXT( + if(Reporting::Confirm(GetStrI18N(TEXT( "Compared to regular MOD save, compatibility export adjusts the beginning of oneshot samples " "in order to make the file compatible with ProTracker and other Amiga-based trackers. " "Note that this feature does not remove effects \"invented\" by other PC-based trackers (f.e. panning commands)." - "\n\n Proceed?")), MB_ICONINFORMATION | MB_YESNO) != IDYES + "\n\n Proceed?"))) != cnfYes ) return; break; case MOD_TYPE_IT: pattern = FileFilterIT; - Reporting::Notification("Warning: the exported file will not contain any of MPT's file-format hacks.", "Compatibility export warning.", MB_ICONINFORMATION | MB_OK); + Reporting::Information("Warning: the exported file will not contain any of MPT's file-format hacks.", "Compatibility export warning."); break; case MOD_TYPE_XM: pattern = FileFilterXM; - Reporting::Notification("Warning: the exported file will not contain any of MPT's file-format hacks.", "Compatibility export warning.", MB_ICONINFORMATION | MB_OK); + Reporting::Information("Warning: the exported file will not contain any of MPT's file-format hacks.", "Compatibility export warning."); break; default: - Reporting::Notification("Compatibility export is currently only available for MOD, XM and IT modules.", "Can't do compatibility export.", MB_ICONINFORMATION | MB_OK); + Reporting::Information("Compatibility export is currently only available for MOD, XM and IT modules.", "Can't do compatibility export."); return; } ext = m_SndFile.GetModSpecifications().fileExtension; @@ -2086,6 +2088,14 @@ } +void CModDoc::OnUpdateCompatExportableOnly(CCmdUI *p) +//--------------------------------------------------- +{ + if (p) + p->Enable((m_SndFile.GetType() & (MOD_TYPE_XM|MOD_TYPE_IT|MOD_TYPE_MOD)) ? TRUE : FALSE); +} + + void CModDoc::OnInsertPattern() //----------------------------- { @@ -2123,14 +2133,14 @@ void CModDoc::OnEstimateSongLength() //---------------------------------- { - CHAR s[256]; + CHAR s[64]; DWORD dwSongLength = m_SndFile.GetSongTime(); - wsprintf(s, "Approximate song length: %dmn%02ds", dwSongLength/60, dwSongLength%60); - CMainFrame::GetMainFrame()->MessageBox(s, NULL, MB_OK|MB_ICONINFORMATION); + wsprintf(s, "Approximate song length: %dmn%02ds", dwSongLength / 60, dwSongLength % 60); + Reporting::Information(s); } void CModDoc::OnApproximateBPM() -//---------------------------------- +//------------------------------ { //Convert BPM to string: CString Message; @@ -2155,7 +2165,7 @@ break; } - CMainFrame::GetMainFrame()->MessageBox(Message, NULL, MB_OK|MB_ICONINFORMATION); + Reporting::Information(Message); } @@ -3795,7 +3805,7 @@ { CString message; message.Format("Param %d can already be controlled with macro %X", paramToUse, checkMacro); - CMainFrame::GetMainFrame()->MessageBox(message, "Macro exists for this param",MB_ICONINFORMATION | MB_OK); + Reporting::Information(message, "Macro exists for this param"); return; } } @@ -3812,13 +3822,13 @@ { CString message; message.Format("Param %d beyond controllable range.", paramToUse); - Reporting::Notification(message, "Macro not assigned for this param", MB_ICONINFORMATION | MB_OK); + Reporting::Information(message, "Macro not assigned for this param"); return; } CString message; message.Format("Param %d can now be controlled with macro %X", paramToUse, macroToSet); - Reporting::Notification(message, "Macro assigned for this param", MB_ICONINFORMATION | MB_OK); + Reporting::Information(message, "Macro assigned for this param"); return; } Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/Moddoc.h 2011-09-04 00:09:56 UTC (rev 1016) @@ -438,6 +438,7 @@ afx_msg void OnUpdateITMPTOnly(CCmdUI *p); afx_msg void OnUpdateHasMIDIMappings(CCmdUI *p); afx_msg void OnUpdateMP3Encode(CCmdUI *pCmdUI); + afx_msg void OnUpdateCompatExportableOnly(CCmdUI *p); afx_msg void OnPatternRestart(); //rewbs.customKeys afx_msg void OnPatternPlay(); //rewbs.customKeys afx_msg void OnPatternPlayNoLoop(); //rewbs.customKeys Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -109,7 +109,7 @@ CString str; if(nRemainingChannels == GetNumChannels()) str.Format("No channels chosen to be removed."); else str.Format("No removal done - channel number is already at minimum."); - CMainFrame::GetMainFrame()->MessageBox(str, "Remove channel", MB_OK | MB_ICONINFORMATION); + Reporting::Information(str, "Remove channel"); return false; } @@ -152,7 +152,7 @@ { CString str; str.Format(GetStrI18N(_TEXT("Can't apply change: Number of channels should be within [%u,%u]")), m_SndFile.GetModSpecifications().channelsMin, m_SndFile.GetModSpecifications().channelsMax); - CMainFrame::GetMainFrame()->MessageBox(str , "ReArrangeChannels", MB_OK | MB_ICONINFORMATION); + Reporting::Error(str , "ReArrangeChannels"); return CHANNELINDEX_INVALID; } @@ -190,7 +190,7 @@ if(!newp) { cs.Leave(); - CMainFrame::GetMainFrame()->MessageBox("ERROR: Pattern allocation failed in ReArrangechannels(...)" , "ReArrangeChannels", MB_OK | MB_ICONINFORMATION); + Reporting::Error("ERROR: Pattern allocation failed in ReArrangechannels(...)"); return CHANNELINDEX_INVALID; } MODCOMMAND *tmpsrc = p, *tmpdest = newp; @@ -264,8 +264,7 @@ if(chnFrom == chnTo) return false; if(chnFrom >= GetNumChannels() || chnTo >= GetNumChannels()) { - CString str = "Error: Bad move indexes in CSoundFile::MoveChannel(...)"; - CMainFrame::GetMainFrame()->MessageBox(str , "MoveChannel(...)", MB_OK | MB_ICONINFORMATION); + Reporting::Error("Error: Bad move indexes in CSoundFile::MoveChannel(...)" , "MoveChannel(...)"); return true; } vector<CHANNELINDEX> newOrder; @@ -296,7 +295,7 @@ if(newOrder.size() != ReArrangeChannels(newOrder)) { - CMainFrame::GetMainFrame()->MessageBox("BUG: Channel number changed in MoveChannel()" , "", MB_OK | MB_ICONINFORMATION); + Reporting::Error("BUG: Channel number changed in MoveChannel()"); } return false; } @@ -485,9 +484,13 @@ if ((!m_SndFile.GetNumInstruments()) && ((m_SndFile.GetNumSamples() > 1) || (m_SndFile.GetSample(1).pSample))) { if (pDup) return INSTRUMENTINDEX_INVALID; - UINT n = CMainFrame::GetMainFrame()->MessageBox("Convert existing samples to instruments first?", NULL, MB_YESNOCANCEL|MB_ICONQUESTION); - if (n == IDYES) + ConfirmAnswer result = Reporting::Confirm("Convert existing samples to instruments first?", true); + if (result == cnfCancel) { + return INSTRUMENTINDEX_INVALID; + } + if (result == cnfYes) + { SAMPLEINDEX nInstruments = m_SndFile.m_nSamples; if (nInstruments > nInstrumentMax) nInstruments = nInstrumentMax; for (SAMPLEINDEX smp = 1; smp <= nInstruments; smp++) @@ -509,8 +512,7 @@ } } m_SndFile.m_nInstruments = nInstruments; - } else - if (n != IDNO) return INSTRUMENTINDEX_INVALID; + } } UINT newins = 0; for (INSTRUMENTINDEX i = 1; i <= m_SndFile.m_nInstruments; i++) @@ -690,15 +692,16 @@ { bool instrumentsLeft = false; - m_SndFile.DestroyInstrument(nIns); + if(m_SndFile.DestroyInstrument(nIns, askdeleteAssociatedSamples)) + { + CriticalSection cs; + if (nIns == m_SndFile.m_nInstruments) m_SndFile.m_nInstruments--; + for (UINT i=1; i<MAX_INSTRUMENTS; i++) if (m_SndFile.Instruments[i]) instrumentsLeft = true; + if (!instrumentsLeft) m_SndFile.m_nInstruments = 0; + SetModified(); - CriticalSection cs; - if (nIns == m_SndFile.m_nInstruments) m_SndFile.m_nInstruments--; - for (UINT i=1; i<MAX_INSTRUMENTS; i++) if (m_SndFile.Instruments[i]) instrumentsLeft = true; - if (!instrumentsLeft) m_SndFile.m_nInstruments = 0; - SetModified(); - - return true; + return true; + } } return false; } Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -288,7 +288,7 @@ else { m_PreAmpNoteShowed = true; - Reporting::Notification(str_preampChangeNote, MB_ICONINFORMATION); + Reporting::Information(str_preampChangeNote); SetPreAmpSliderPosition(); } } Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -292,15 +292,15 @@ } if (CDLSBank::IsDLSBank(lpszConfigFile)) { - UINT id = IDYES; + ConfirmAnswer result = cnfYes; if (!bNoWarn) { - id = CMainFrame::GetMainFrame()->MessageBox("You are about to replace the current MIDI library:\n" - "Do you want to replace only the missing instruments? (recommended)", - "Warning", MB_YESNOCANCEL|MB_ICONQUESTION ); + result = Reporting::Confirm("You are about to replace the current MIDI library:\n" + "Do you want to replace only the missing instruments? (recommended)", + "Warning", true); } - if (id == IDCANCEL) return FALSE; - const bool bReplaceAll = (id == IDNO); + if (result == cnfCancel) return FALSE; + const bool bReplaceAll = (result == cnfNo); CDLSBank dlsbank; if (dlsbank.Open(lpszConfigFile)) { @@ -933,7 +933,6 @@ int CTrackApp::ExitInstance() //--------------------------- { - //::MessageBox("Exiting/Crashing"); SndDevUninitialize(); if (glpMidiLibrary) { @@ -1849,19 +1848,19 @@ // Misc functions -UINT MsgBox(UINT nStringID, CWnd *p, LPCSTR lpszTitle, UINT n) -//------------------------------------------------------------ +UINT MsgBox(UINT nStringID, CWnd *parent, LPCSTR lpszTitle, UINT n) +//----------------------------------------------------------------- { CString str; str.LoadString(nStringID); - return Reporting::Notification(str, CString(lpszTitle), n, p); + return Reporting::CustomNotification(str, CString(lpszTitle), n, parent); } -void ErrorBox(UINT nStringID, CWnd*p) -//----------------------------------- +void ErrorBox(UINT nStringID, CWnd *parent) +//----------------------------------------- { - MsgBox(nStringID, p, "Error!", MB_OK | MB_ICONSTOP); + MsgBox(nStringID, parent, "Error!", MB_OK | MB_ICONSTOP); } Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -554,7 +554,7 @@ { if(!pSndFile->Patterns[m_nPattern].SetSignature(nNewBeat, nNewMeasure)) { - MessageBox("Invalid time signature!", "Pattern Properties", MB_OK|MB_ICONEXCLAMATION); + Reporting::Error("Invalid time signature!", "Pattern Properties"); GetDlgItem(IDC_EDIT_ROWSPERBEAT)->SetFocus(); return; } Modified: trunk/OpenMPT/mptrack/SampleEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/SampleEditorDialogs.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/SampleEditorDialogs.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -46,7 +46,7 @@ if(nVal < m_nFactorMin || nVal > m_nFactorMax) { CString str; str.Format(GetStrI18N(__TEXT("Value should be within [%d, %d]")), m_nFactorMin, m_nFactorMax); - Reporting::Notification(str, MB_ICONINFORMATION); + Reporting::Information(str); return; } m_nFactor = static_cast<int16>(nVal); Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -391,7 +391,7 @@ /*&& (gProblemPlugs[p].id1 == plug->dwPluginId1)*/) { s.Format("WARNING: This plugin has been identified as %s,\nwhich is known to have the following problem with OpenMPT:\n\n%s\n\nWould you still like to add this plugin to the library?", gProblemPlugs[p].name, gProblemPlugs[p].problem); - return (Reporting::Notification(s, MB_YESNO) == IDYES); + return (Reporting::Confirm(s) == cnfYes); } } @@ -438,7 +438,7 @@ UpdatePluginsList(plugLib ? plugLib->dwPluginId2 : 0); } else { - MessageBox("At least one selected file was not a valid VST-Plugin.", NULL, MB_ICONERROR | MB_OK); + Reporting::Error("At least one selected file was not a valid VST-Plugin."); } } Modified: trunk/OpenMPT/mptrack/TuningDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/TuningDialog.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/TuningDialog.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -458,7 +458,7 @@ TUNINGTYPE newType = GetTuningTypeFromStr(strNewType); if(!m_pActiveTuning->IsOfType(newType)) { - if(Reporting::Notification("This action may change the ratio values; continue?", MB_YESNO) == IDYES) + if(Reporting::Confirm("This action may change the ratio values; continue?") == cnfYes) { m_ModifiedTCs[GetpTuningCollection(m_pActiveTuning)] = true; @@ -787,7 +787,7 @@ } } if (sLoadReport.GetLength() > 0) - Reporting::Notification(sLoadReport, MB_ICONINFORMATION); + Reporting::Information(sLoadReport); UpdateView(); } @@ -1170,14 +1170,14 @@ if(!pTC) { - MessageBox("No tuning collection chosen", 0, MB_OK); + Reporting::Notification("No tuning collection chosen"); return true; } CTuning* pNewTuning = new CTuningRTI(pT); if(pTC->AddTuning(pNewTuning)) { - MessageBox("Add tuning failed"); + Reporting::Notification("Add tuning failed"); delete pNewTuning; return true; } @@ -1214,7 +1214,7 @@ if(pTC) { string str = string("Remove tuning '") + pT->GetName() + string("' from ' ") + pTC->GetName() + string("'?"); - if(MessageBox(str.c_str(), 0, MB_YESNO) == IDYES) + if(Reporting::Confirm(str.c_str()) == cnfYes) { if(!pTC->Remove(pT)) { @@ -1224,7 +1224,7 @@ } else { - MessageBox("Tuning removal failed"); + Reporting::Notification("Tuning removal failed"); } } } @@ -1333,7 +1333,7 @@ } else { - MessageBox("Saving succesful."); + Reporting::Notification("Saving succesful."); m_ModifiedTCs[m_pActiveTuningCollection] = false; } } Modified: trunk/OpenMPT/mptrack/UpdateCheck.cpp =================================================================== --- trunk/OpenMPT/mptrack/UpdateCheck.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/UpdateCheck.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -83,7 +83,7 @@ { CString msg; msg.Format("OpenMPT would like to check for updates now, proceed?\n\nNote: In the future, OpenMPT will check for updates every %d days. If you do not want this, you can disable update checks in the setup.", CUpdateCheck::updateCheckPeriod); - if(Reporting::Notification(msg, "OpenMPT Internet Update", MB_YESNO | MB_ICONQUESTION) == IDNO) + if(Reporting::Confirm(msg, "OpenMPT Internet Update") == cnfNo) { CUpdateCheck::showUpdateHint = false; caller->Terminate(); @@ -165,7 +165,7 @@ { if(!caller->isAutoUpdate) { - Reporting::Notification("You already have the latest version of OpenMPT.", "OpenMPT Internet Update", MB_OK | MB_ICONINFORMATION); + Reporting::Information("You already have the latest version of OpenMPT.", "OpenMPT Internet Update"); } } else { @@ -198,7 +198,7 @@ if(parseStep >= 4) { resultData.Format("A new version is available!\nOpenMPT %s has been released on %s. Would you like to visit %s for more information?", releaseVersion, releaseDate, releaseURL); - if(Reporting::Notification(resultData, "OpenMPT Internet Update", MB_YESNO | MB_ICONINFORMATION) == IDYES) + if(Reporting::Confirm(resultData, "OpenMPT Internet Update") == cnfYes) { CTrackApp::OpenURL(releaseURL); } @@ -222,7 +222,7 @@ { if(!isAutoUpdate) { - Reporting::Notification(errorMessage, "OpenMPT Internet Update Error", MB_OK | MB_ICONERROR); + Reporting::Error(errorMessage, "OpenMPT Internet Update Error"); } Terminate(); } Modified: trunk/OpenMPT/mptrack/View_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_gen.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/View_gen.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -1034,7 +1034,7 @@ //TODO: exception handling if (!(pVstPlugin->LoadProgram(files.first_file.c_str()))) { - Reporting::Notification("Error loading preset. Are you sure it is for this plugin?"); + Reporting::Error("Error loading preset. Are you sure it is for this plugin?"); } else { if(pSndFile->GetModSpecifications().supportsPlugins) @@ -1062,7 +1062,7 @@ //TODO: exception handling if (!(pVstPlugin->SaveProgram(files.first_file.c_str()))) - Reporting::Notification("Error saving preset."); + Reporting::Error("Error saving preset."); //end rewbs.fxpPresets } @@ -1463,12 +1463,12 @@ CString prompt; CModDoc *pModDoc = GetDocument(); CSoundFile* pSndFile = pModDoc->GetSoundFile(); - prompt.Format("Insert empty slot before slot FX%d?", m_nCurrentPlugin+1); + prompt.Format("Insert empty slot before slot FX%d?", m_nCurrentPlugin + 1); if (pSndFile->m_MixPlugins[MAX_MIXPLUGINS-1].pMixPlugin) { prompt.Append("\nWarning: plugin data in last slot will be lost."); } - if (Reporting::Notification(prompt, MB_YESNO) == IDYES) + if (Reporting::Confirm(prompt) == cnfYes) { //Delete last plug... Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -2028,9 +2028,14 @@ if (!(m_findReplace.dwReplaceFlags & PATSEARCH_REPLACE)) goto EndSearch; if (!(m_findReplace.dwReplaceFlags & PATSEARCH_REPLACEALL)) { - UINT ans = MessageBox("Replace this occurrence?", "Replace", MB_YESNOCANCEL); - if (ans == IDYES) bReplace = true; else - if (ans == IDNO) bReplace = false; else goto EndSearch; + ConfirmAnswer result = Reporting::Confirm("Replace this occurrence?", "Replace", true); + if(result == cnfCancel) + { + goto EndSearch; // Yuck! + } else + { + bReplace = (result == cnfYes); + } } if (bReplace) { @@ -2162,7 +2167,7 @@ wsprintf(&szFind[strlen(szFind)], "%02X", m_findReplace.cmdFind.param); } else strcat(szFind, "??"); wsprintf(s, "Cannot find \"%s\"", szFind); - MessageBox(s, "Find/Replace", MB_OK | MB_ICONINFORMATION); + Reporting::Information(s, "Find/Replace"); } } @@ -2713,7 +2718,7 @@ if(pSndFile->m_nChannels <= pSndFile->GetModSpecifications().channelsMin) { - CMainFrame::GetMainFrame()->MessageBox("No channel removed - channel number already at minimum.", "Remove channel", MB_OK | MB_ICONINFORMATION); + Reporting::Error("No channel removed - channel number already at minimum.", "Remove channel"); return; } @@ -2722,7 +2727,7 @@ CString str; str.Format("Remove channel %d? This channel still contains note data!", nChn + 1); - if(isEmpty || CMainFrame::GetMainFrame()->MessageBox(str , "Remove channel", MB_YESNO | MB_ICONQUESTION) == IDYES) + if(isEmpty || Reporting::Confirm(str , "Remove channel") == cnfYes) { vector<bool> keepMask(pModDoc->GetNumChannels(), true); keepMask[nChn] = false; @@ -2767,7 +2772,7 @@ CModDoc *pModDoc = GetDocument(); if (pModDoc == nullptr) return; - if(Reporting::Notification(GetStrI18N(_TEXT("This affects all patterns, proceed?")), MB_YESNO) != IDYES) + if(Reporting::Confirm(GetStrI18N(_TEXT("This affects all patterns, proceed?"))) != cnfYes) return; const CHANNELINDEX nDupChn = GetChanFromCursor(m_nMenuParam); @@ -5626,7 +5631,7 @@ else msg.Format("Unable to determine the time: pattern at current order(=%d) does not correspond to pattern at pattern view(=pattern %d).", currentOrder, m_nPattern); - MessageBox(msg); + Reporting::Notification(msg); } Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -1737,7 +1737,7 @@ if ((m_dwBeginSel >= m_dwEndSel) || (m_dwEndSel - m_dwBeginSel + 4 >= len)) { - if (MessageBox("Remove this sample?", "Remove Sample", MB_YESNOCANCEL | MB_ICONQUESTION) != IDYES) return; + if (Reporting::Confirm("Remove this sample?", "Remove Sample", true) != cnfYes) return; pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_replace); CriticalSection cs; @@ -2500,7 +2500,7 @@ if( MAX_SAMPLE_LENGTH - nOldLength < dlg.m_nSamples ) { CString str; str.Format(TEXT("Can't add silence because the new sample length would exceed maximum sample length %u."), MAX_SAMPLE_LENGTH); - Reporting::Notification(str, MB_ICONINFORMATION); + Reporting::Information(str); return; } Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -1400,7 +1400,7 @@ if (pModDoc && pSndFile) { wsprintf(s, _T("Remove sequence %d?"), modItemID); - if(Reporting::Notification(s, _T("Confirmation"), MB_YESNO | MB_DEFBUTTON2) == IDNO) break; + if(Reporting::Confirm(s, false, true) == cnfNo) break; pSndFile->Order.RemoveSequence((SEQUENCEINDEX)(modItemID)); pModDoc->UpdateAllViews(NULL, HINT_MODSEQUENCE, NULL); } @@ -1416,7 +1416,7 @@ case MODITEM_PATTERN: wsprintf(s, _T("Remove pattern %d?"), modItemID); - if (pModDoc == nullptr || Reporting::Notification(s, _T("Confirmation"), MB_YESNO | MB_DEFBUTTON2) == IDNO) break; + if (pModDoc == nullptr || Reporting::Confirm(s, false, true) == cnfNo) break; if (pModDoc->RemovePattern((PATTERNINDEX)modItemID)) { pModDoc->UpdateAllViews(NULL, (UINT(modItemID) << HINT_SHIFT_PAT) | HINT_PATTERNDATA|HINT_PATNAMES); @@ -1425,7 +1425,7 @@ case MODITEM_SAMPLE: wsprintf(s, _T("Remove sample %d?"), modItemID); - if (pModDoc == nullptr || Reporting::Notification(s, _T("Confirmation"), MB_YESNO | MB_DEFBUTTON2) == IDNO) break; + if (pModDoc == nullptr || Reporting::Confirm(s, false, true) == cnfNo) break; pModDoc->GetSampleUndo()->PrepareUndo((SAMPLEINDEX)modItemID, sundo_replace); if (pModDoc->RemoveSample((SAMPLEINDEX)modItemID)) { @@ -1435,7 +1435,7 @@ case MODITEM_INSTRUMENT: wsprintf(s, _T("Remove instrument %d?"), modItemID); - if (pModDoc == nullptr || Reporting::Notification(s, _T("Confirmation"), MB_YESNO | MB_DEFBUTTON2) == IDNO) break; + if (pModDoc == nullptr || Reporting::Confirm(s, false, true) == cnfNo) break; if (pModDoc->RemoveInstrument((INSTRUMENTINDEX)modItemID)) { pModDoc->UpdateAllViews(NULL, (UINT(modItemID) << HINT_SHIFT_INS) | HINT_MODTYPE|HINT_ENVELOPE|HINT_INSTRUMENT); @@ -1916,7 +1916,7 @@ if (!bOk) { wsprintf(s, "Unable to browse to \"%s\"", lpszDir); - MessageBox(s, NULL, MB_OK|MB_ICONERROR); + Reporting::Error(s); } return TRUE; } @@ -2080,7 +2080,7 @@ } else { - if(Reporting::Notification(_T("Replace the current orderlist?"), _T("Sequence import"), MB_YESNO | MB_ICONQUESTION) == IDNO) + if(Reporting::Confirm(_T("Replace the current orderlist?"), _T("Sequence import")) == cnfNo) return false; } pSndFile->Order.resize(min(pSndFile->GetModSpecifications().ordersMax, pOrigSeq->GetLength()), pSndFile->Order.GetInvalidPatIndex()); Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -288,7 +288,7 @@ { TCHAR szBuf[256]; wsprintf(szBuf, "Warning: encountered problem when loading plugin dll. Error %d: %s", dw, (LPCTSTR)GetErrorMessage(dw)); - Reporting::Notification(szBuf, "DEBUG: Error when loading plugin dll"); + Reporting::Error(szBuf, "DEBUG: Error when loading plugin dll"); } #endif //_DEBUG //end rewbs.VSTcompliance @@ -1449,7 +1449,7 @@ m_nOutputs = 32; CString str; str.Format("Plugin has unsupported number(=%d) of outputs; plugin may malfunction.", m_pEffect->numOutputs); - Reporting::Notification(str, "Warning", MB_ICONWARNING); + Reporting::Warning(str); } //input pointer array size must be >=2 for now - the input buffer assignment might write to non allocated mem. otherwise Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -359,7 +359,7 @@ if(maxChans < m_pSndFile->GetNumChannels()) { - if(Reporting::Notification("New module type supports less channels than currently used, and reducing channel number is required. Continue?", MB_OKCANCEL) != IDOK) + if(Reporting::Confirm("New module type supports less channels than currently used, and reducing channel number is required. Continue?") != cnfYes) return false; } @@ -921,7 +921,7 @@ void CMidiMacroSetup::OnMacroHelp() //--------------------------------- { - MessageBox(_T("Valid characters in macros:\n\n" + Reporting::Information(_T("Valid characters in macros:\n\n" "0-9, A-F - Raw hex data (4-Bit value)\n" "c - MIDI channel (4-Bit value)\n" "n - Note value\n\n" @@ -934,7 +934,7 @@ "p - Program select\n\n" "z - Zxx parameter (00-7F)\n\n" "Macros can be up to 31 characters long and contain multiple MIDI messages. SysEx messages are automatically terminated if not specified by the user."), - _T("OpenMPT MIDI Macro quick reference"), MB_OK | MB_ICONINFORMATION); + _T("OpenMPT MIDI Macro quick reference")); } Modified: trunk/OpenMPT/mptrack/fxp.cpp =================================================================== --- trunk/OpenMPT/mptrack/fxp.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/fxp.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -88,7 +88,7 @@ if ( !inStream.Open(fileName, CFile::modeRead, &e) ) { //TODO: exception - Reporting::Notification("Error opening file."); + Reporting::Error("Error opening file."); return false; } @@ -105,7 +105,7 @@ ChunkMagic == 'CcnK' && (fxMagic == 'FxCk' || fxMagic == 'FPCh'))) { - Reporting::Notification("Bad Magic number: this does not look like a preset file."); + Reporting::Error("Bad Magic number: this does not look like a preset file."); inStream.Close(); return false; } @@ -117,7 +117,7 @@ { if (!ReadLE(inStream, params[p])) { - Reporting::Notification("Error reading Params."); + Reporting::Error("Error reading Params."); inStream.Close(); return false; } @@ -127,7 +127,7 @@ { if (!ReadLE(inStream, chunkSize)) { - Reporting::Notification("Error reading chunk size."); + Reporting::Error("Error reading chunk size."); inStream.Close(); return false; } @@ -136,14 +136,14 @@ if (!chunk) { - Reporting::Notification("Error allocating memory for chunk."); + Reporting::Error("Error allocating memory for chunk."); inStream.Close(); return false; } if (!ReadLE(inStream, (char*)chunk, chunkSize)) { - Reporting::Notification("Error reading chunk."); + Reporting::Error("Error reading chunk."); inStream.Close(); return false; } @@ -231,10 +231,9 @@ return false; } catch (CFileException *e) { - Reporting::Notification(e->m_strFileName); char s[256]; wsprintf(s, "%lx: %d; %d; %s;", e, e->m_cause, e->m_lOsError, (LPCTSTR)e->m_strFileName); - Reporting::Notification(s); + Reporting::Error(s); e->Delete(); } Modified: trunk/OpenMPT/mptrack/mod2midi.cpp =================================================================== --- trunk/OpenMPT/mptrack/mod2midi.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/mod2midi.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -349,13 +349,13 @@ const CHANNELINDEX chnCount = min(64, m_pSndFile->GetNumChannels()); if(chnCount < m_pSndFile->GetNumChannels()) - MessageBox("Note: Only 64 channels will be exported."); + Reporting::Information("Note: Only 64 channels will be exported."); if (!f.Open(m_szFileName, CFile::modeCreate | CFile::modeWrite)) { return FALSE; } - memset(Tracks, 0, sizeof(Tracks)); + MemsetZero(Tracks); if (!m_pSndFile->m_nDefaultTempo) m_pSndFile->m_nDefaultTempo = 125; nTickMultiplier = MOD2MIDI_TEMPOFACTOR; const uint16 wPPQN = static_cast<uint16>((m_pSndFile->m_nDefaultTempo*nTickMultiplier) / 5); Modified: trunk/OpenMPT/mptrack/test/test.cpp =================================================================== --- trunk/OpenMPT/mptrack/test/test.cpp 2011-09-03 21:46:53 UTC (rev 1015) +++ trunk/OpenMPT/mptrack/test/test.cpp 2011-09-04 00:09:56 UTC (rev 1016) @@ -33,7 +33,7 @@ { \ CString str; \ str.Format("File: " STRINGIZE(__FILE__) "\nLine: " STRINGIZE(__LINE__) "\n\nVERIFY_EQUAL failed when comparing\n" #x "\nand\n" #y); \ - Reporting::Notification(str, "VERIFY_EQUAL failed", MB_ICONERROR); \ + Reporting::Error(str, "VERIFY_EQUAL failed"); \ } // Like VERIFY_EQUAL, but throws exception if comparison fails. @@ -54,11 +54,11 @@ } \ catch(const std::exception& e) \ { \ - Reporting::Notification(CString("Test \"" STRINGIZE... [truncated message content] |
From: <sag...@us...> - 2011-09-04 15:19:47
|
Revision: 1017 http://modplug.svn.sourceforge.net/modplug/?rev=1017&view=rev Author: saga-games Date: 2011-09-04 15:19:40 +0000 (Sun, 04 Sep 2011) Log Message: ----------- [Fix] Internal: Fixed VS2008 project file (tx jmkz) [Ref] Got rid of WinApi flags in public Reporting members alltogether Modified Paths: -------------- trunk/OpenMPT/common/Reporting.cpp trunk/OpenMPT/common/Reporting.h trunk/OpenMPT/mptrack/CleanupSong.cpp trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/EffectVis.cpp trunk/OpenMPT/mptrack/KeyConfigDlg.cpp trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/mptrack/Moptions.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/PSRatioCalc.cpp trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/mptrack/mptrack_08.vcproj Modified: trunk/OpenMPT/common/Reporting.cpp =================================================================== --- trunk/OpenMPT/common/Reporting.cpp 2011-09-04 00:09:56 UTC (rev 1016) +++ trunk/OpenMPT/common/Reporting.cpp 2011-09-04 15:19:40 UTC (rev 1017) @@ -34,17 +34,17 @@ } -void Reporting::Notification(const char *text, UINT flags, const CWnd *parent) -//---------------------------------------------------------------------------- +void Reporting::Notification(const char *text, const CWnd *parent) +//---------------------------------------------------------------- { - Notification(text, MAINFRAME_TITLE, flags, parent); + Notification(text, MAINFRAME_TITLE, parent); } -void Reporting::Notification(const char *text, const char *caption, UINT flags, const CWnd *parent) -//------------------------------------------------------------------------------------------------- +void Reporting::Notification(const char *text, const char *caption, const CWnd *parent) +//------------------------------------------------------------------------------------- { - ShowNotification(text, caption, flags, parent); + ShowNotification(text, caption, MB_OK, parent); } @@ -65,7 +65,7 @@ void Reporting::Warning(const char *text, const CWnd *parent) //----------------------------------------------------------- { - Warning(text, MAINFRAME_TITLE " - Error", parent); + Warning(text, MAINFRAME_TITLE " - Warning", parent); } Modified: trunk/OpenMPT/common/Reporting.h =================================================================== --- trunk/OpenMPT/common/Reporting.h 2011-09-04 00:09:56 UTC (rev 1016) +++ trunk/OpenMPT/common/Reporting.h 2011-09-04 15:19:40 UTC (rev 1017) @@ -34,8 +34,8 @@ static UINT CustomNotification(const char *text, const char *caption, UINT flags, const CWnd *parent) { return ShowNotification(text, caption, flags, parent); }; // Show a simple notification - static void Notification(const char *text, UINT flags = MB_OK, const CWnd *parent = nullptr); - static void Notification(const char *text, const char *caption, UINT flags = MB_OK, const CWnd *parent = nullptr); + static void Notification(const char *text, const CWnd *parent = nullptr); + static void Notification(const char *text, const char *caption, const CWnd *parent = nullptr); // Show a simple information static void Information(const char *text, const CWnd *parent = nullptr); Modified: trunk/OpenMPT/mptrack/CleanupSong.cpp =================================================================== --- trunk/OpenMPT/mptrack/CleanupSong.cpp 2011-09-04 00:09:56 UTC (rev 1016) +++ trunk/OpenMPT/mptrack/CleanupSong.cpp 2011-09-04 15:19:40 UTC (rev 1017) @@ -700,17 +700,10 @@ CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); if(pSndFile == nullptr) return false; - vector<bool> usedmap; - INSTRUMENTINDEX swapmap[MAX_INSTRUMENTS]; - INSTRUMENTINDEX swapdest[MAX_INSTRUMENTS]; - UINT nRemoved = 0; - INSTRUMENTINDEX nSwap, nIndex; - bool bReorg = false; - if (!pSndFile->GetNumInstruments()) return false; deleteInstrumentSamples removeSamples = doNoDeleteAssociatedSamples; - if ( !((pSndFile->GetType() == MOD_TYPE_IT) && (pSndFile->m_dwSongFlags & SONG_ITPROJECT))) //never remove an instrument's samples in ITP. + if (!((pSndFile->GetType() == MOD_TYPE_IT) && (pSndFile->m_dwSongFlags & SONG_ITPROJECT))) // Never remove an instrument's samples in ITP. { if(Reporting::Confirm("Remove samples associated with an instrument if they are unused?", "Removing unused instruments") == cnfYes) { @@ -722,7 +715,12 @@ } BeginWaitCursor(); - usedmap.resize(pSndFile->GetNumInstruments() + 1, false); + vector<bool> usedmap(pSndFile->GetNumInstruments() + 1, false); + vector<INSTRUMENTINDEX> swapmap(pSndFile->GetNumInstruments() + 1, 0); + vector<INSTRUMENTINDEX> swapdest(pSndFile->GetNumInstruments() + 1, 0); + INSTRUMENTINDEX nRemoved = 0; + INSTRUMENTINDEX nSwap, nIndex; + bool bReorg = false; for(INSTRUMENTINDEX i = pSndFile->GetNumInstruments(); i >= 1; i--) { @@ -751,7 +749,7 @@ CriticalSection cs; nSwap = 0; nIndex = 1; - for (INSTRUMENTINDEX nIns = 1; nIns <= pSndFile->m_nInstruments; nIns++) + for (INSTRUMENTINDEX nIns = 1; nIns <= pSndFile->GetNumInstruments(); nIns++) { if (usedmap[nIns]) { Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2011-09-04 00:09:56 UTC (rev 1016) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2011-09-04 15:19:40 UTC (rev 1017) @@ -1585,7 +1585,7 @@ CString err; err.Format("The following problems have been encountered while trying to load the key binding file %s:\n", szFilename); err += errText; - Reporting::Notification(err, MB_ICONEXCLAMATION | MB_OK); + Reporting::Warning(err); } if(fileVersion < KEYMAP_VERSION) UpgradeKeymap(pTempCS, fileVersion); @@ -1603,7 +1603,7 @@ { CString strMsg; AfxFormatString1(strMsg, IDS_CANT_OPEN_KEYBINDING_FILE, fileName); - Reporting::Notification(strMsg, MB_ICONEXCLAMATION | MB_OK); + Reporting::Warning(strMsg); return false; } else Modified: trunk/OpenMPT/mptrack/EffectVis.cpp =================================================================== --- trunk/OpenMPT/mptrack/EffectVis.cpp 2011-09-04 00:09:56 UTC (rev 1016) +++ trunk/OpenMPT/mptrack/EffectVis.cpp 2011-09-04 15:19:40 UTC (rev 1017) @@ -767,9 +767,7 @@ void CEffectVis::OnEditUndo() //--------------------------- { - CHAR s[64]; - strcpy(s, "Undo Through!"); - Reporting::Notification(s, MB_OK | MB_ICONEXCLAMATION); + Reporting::Notification("Undo Through!"); } Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2011-09-04 00:09:56 UTC (rev 1016) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2011-09-04 15:19:40 UTC (rev 1017) @@ -552,7 +552,7 @@ if (m_nCurHotKey<0 || m_nCurKeyChoice<0 || m_nCurKeyChoice>=plocalCmdSet->GetKeyListSize(cmd)) { CString error = "No key currently set for this slot."; - Reporting::Notification(error, "Invalid key data", MB_ICONEXCLAMATION|MB_OK); + Reporting::Warning(error, "Invalid key data"); return; } @@ -573,7 +573,7 @@ if (cmd<0) { CString error = "Invalid slot."; - Reporting::Notification(error, "Invalid key data", MB_ICONEXCLAMATION|MB_OK); + Reporting::Warning(error, "Invalid key data"); return; } @@ -589,13 +589,13 @@ if (!kc.code) { CString error = "You need to say to which key you'd like to map this command."; - Reporting::Notification(error, "Invalid key data", MB_ICONEXCLAMATION|MB_OK); + Reporting::Warning(error, "Invalid key data"); return; } if (!kc.event) { /* CString error = "You need to select at least one key event type (up, down or hold)."; - Reporting::Notification(error, "Invalid key data", MB_ICONEXCLAMATION|MB_OK); + Reporting::Warning(error, "Invalid key data"); return; */ kc.event = kKeyEventDown; Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2011-09-04 00:09:56 UTC (rev 1016) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2011-09-04 15:19:40 UTC (rev 1017) @@ -43,7 +43,7 @@ { CString error; error.Format("Error: Max number of channels for this file type is %d", maxChans); - Reporting::Notification(error, MB_OK | MB_ICONEXCLAMATION); + Reporting::Warning(error); return false; } Modified: trunk/OpenMPT/mptrack/Moptions.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moptions.cpp 2011-09-04 00:09:56 UTC (rev 1016) +++ trunk/OpenMPT/mptrack/Moptions.cpp 2011-09-04 15:19:40 UTC (rev 1017) @@ -108,7 +108,7 @@ if ((temp_nRowSpacing2 > temp_nRowSpacing)) { - Reporting::Notification("Error: Primary highlight must be greater than or equal secondary highlight.", MB_OK | MB_ICONEXCLAMATION); + Reporting::Warning("Error: Primary highlight must be greater than or equal secondary highlight."); ::SetFocus(::GetDlgItem(m_hWnd, IDC_PRIMARYHILITE)); return 0; } Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2011-09-04 00:09:56 UTC (rev 1016) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2011-09-04 15:19:40 UTC (rev 1017) @@ -1860,7 +1860,7 @@ void ErrorBox(UINT nStringID, CWnd *parent) //----------------------------------------- { - MsgBox(nStringID, parent, "Error!", MB_OK | MB_ICONSTOP); + MsgBox(nStringID, parent, "Error!", MB_OK | MB_ICONERROR); } Modified: trunk/OpenMPT/mptrack/PSRatioCalc.cpp =================================================================== --- trunk/OpenMPT/mptrack/PSRatioCalc.cpp 2011-09-04 00:09:56 UTC (rev 1016) +++ trunk/OpenMPT/mptrack/PSRatioCalc.cpp 2011-09-04 15:19:40 UTC (rev 1017) @@ -162,8 +162,7 @@ { if (m_dRatio<50.0 || m_dRatio>200.0) { - Reporting::Notification("Error: ratio must be between 50% and 200%.", - "Error", MB_ICONERROR | MB_OK); + Reporting::Error("Error: ratio must be between 50% and 200%."); return; } OnOK(); Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2011-09-04 00:09:56 UTC (rev 1016) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2011-09-04 15:19:40 UTC (rev 1017) @@ -339,7 +339,7 @@ int temp_nRPM = GetDlgItemInt(IDC_ROWSPERMEASURE); if ((temp_nRPB > temp_nRPM)) { - Reporting::Notification("Error: Rows per measure must be greater than or equal rows per beat.", MB_OK|MB_ICONEXCLAMATION); + Reporting::Warning("Error: Rows per measure must be greater than or equal rows per beat."); GetDlgItem(IDC_ROWSPERMEASURE)->SetFocus(); return false; } @@ -353,7 +353,7 @@ { CString error; error.Format("Error: Max number of channels for this type is %d", maxChans); - Reporting::Notification(error, MB_OK|MB_ICONEXCLAMATION); + Reporting::Warning(error); return FALSE; } Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2011-09-04 00:09:56 UTC (rev 1016) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2011-09-04 15:19:40 UTC (rev 1017) @@ -493,7 +493,7 @@ > </File> <File - RelativePath=".\common\Reporting.cpp" + RelativePath="..\common\Reporting.cpp" > </File> <File This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-04 18:02:43
|
Revision: 1018 http://modplug.svn.sourceforge.net/modplug/?rev=1018&view=rev Author: saga-games Date: 2011-09-04 18:02:35 +0000 (Sun, 04 Sep 2011) Log Message: ----------- [Ref] The refactoring frenzy doesn't stop. Added some const modifiers here and there, plus some minor stuff. Modified Paths: -------------- trunk/OpenMPT/common/Reporting.h trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_xm.cpp trunk/OpenMPT/soundlib/ModSequence.cpp trunk/OpenMPT/soundlib/ModSequence.h trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/common/Reporting.h =================================================================== --- trunk/OpenMPT/common/Reporting.h 2011-09-04 15:19:40 UTC (rev 1017) +++ trunk/OpenMPT/common/Reporting.h 2011-09-04 18:02:35 UTC (rev 1018) @@ -30,8 +30,10 @@ public: +#ifdef MODPLUG_TRACKER // TODO Quick'n'dirty workaround for MsgBox(). Shouldn't be public. static UINT CustomNotification(const char *text, const char *caption, UINT flags, const CWnd *parent) { return ShowNotification(text, caption, flags, parent); }; +#endif // MODPLUG_TRACKER // Show a simple notification static void Notification(const char *text, const CWnd *parent = nullptr); Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2011-09-04 15:19:40 UTC (rev 1017) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2011-09-04 18:02:35 UTC (rev 1018) @@ -384,14 +384,13 @@ { DrawLetter(x, y, noteStr[0], 7, 0); DrawLetter(x + 7, y, noteStr[1], 6, 0); - DrawLetter(x + 13, y, noteStr[2], 7, 1); } else { DrawLetter(x, y, noteStr[0], 5, 0); DrawLetter(x + 5, y, noteStr[1], 5, 0); - DrawLetter(x + 10, y, noteStr[2], 6, 0); } + DrawLetter(x + pfnt->nNoteWidth, y, noteStr[2], pfnt->nOctaveWidth, 0); } else //Original { @@ -1657,7 +1656,3 @@ ::ReleaseDC(m_hWnd, hdc); } - - - - Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2011-09-04 15:19:40 UTC (rev 1017) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2011-09-04 18:02:35 UTC (rev 1018) @@ -2302,24 +2302,7 @@ return FALSE; } -//rewbs.crashHandler -LRESULT CTrackApp::ProcessWndProcException(CException* e, const MSG* pMsg) -//----------------------------------------------------------------------- -{ - // TODO: Add your specialized code here and/or call the base class - Log("Unhandled Exception\n"); - Log("Attempting to close sound device\n"); - - if (CMainFrame::gpSoundDevice) { - CMainFrame::gpSoundDevice->Reset(); - CMainFrame::gpSoundDevice->Close(); - } - return CWinApp::ProcessWndProcException(e, pMsg); -} -//end rewbs.crashHandler - - /* Open or save one or multiple files using the system's file dialog * Parameter list: * - load: true: load dialog. false: save dialog. Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2011-09-04 15:19:40 UTC (rev 1017) +++ trunk/OpenMPT/mptrack/Mptrack.h 2011-09-04 18:02:35 UTC (rev 1018) @@ -235,7 +235,6 @@ afx_msg void OnHelpSearch(); //}}AFX_MSG DECLARE_MESSAGE_MAP() - virtual LRESULT ProcessWndProcException(CException* e, const MSG* pMsg); protected: static void LoadRegistryDLS(); Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2011-09-04 15:19:40 UTC (rev 1017) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2011-09-04 18:02:35 UTC (rev 1018) @@ -1491,31 +1491,36 @@ { UINT nOldPos = 0; UINT nNewPos = 0; - BOOL bAll; + bool showAll; if ((!m_pSndFile) || (m_nInstrument >= MAX_INSTRUMENTS)) return; if (m_CbnSample.GetCount() > 0) { nOldPos = m_CbnSample.GetItemData(m_CbnSample.GetCurSel()); } m_CbnSample.ResetContent(); - bAll = IsDlgButtonChecked(IDC_CHECK1); + showAll = (IsDlgButtonChecked(IDC_CHECK1) != FALSE); UINT nInsertPos; nInsertPos = m_CbnSample.AddString("0: No sample"); m_CbnSample.SetItemData(nInsertPos, 0); - for (UINT i=1; i<=m_pSndFile->m_nSamples; i++) { - BOOL bUsed = bAll; + for (UINT i=1; i<=m_pSndFile->m_nSamples; i++) + { + bool isUsed = showAll; - if (!bUsed) { - for (UINT j=0; j<NOTE_MAX; j++) { - if (KeyboardMap[j] == i) { - bUsed = TRUE; + if (!isUsed) + { + for (UINT j=0; j<NOTE_MAX; j++) + { + if (KeyboardMap[j] == i) + { + isUsed = true; break; } } } - if (bUsed) { + if (isUsed) + { CString sampleName; sampleName.Format("%d: %s", i, m_pSndFile->GetSampleName(i)); nInsertPos = m_CbnSample.AddString(sampleName); Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2011-09-04 15:19:40 UTC (rev 1017) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2011-09-04 18:02:35 UTC (rev 1018) @@ -1730,7 +1730,7 @@ { UINT len = 0; BYTE buf[8 * MAX_BASECHANNELS]; - MODCOMMAND *m = Patterns[npat].GetRow(row); + const MODCOMMAND *m = Patterns[npat].GetRow(row); for (UINT ch = 0; ch < specs.channelsMax; ch++, m++) { @@ -1888,28 +1888,28 @@ // Writing Sample Data for (UINT nsmp=1; nsmp<=header.smpnum; nsmp++) { - MODSAMPLE *psmp = &Samples[nsmp]; + const MODSAMPLE &sample = Samples[nsmp]; MemsetZero(itss); - memcpy(itss.filename, psmp->filename, 12); + memcpy(itss.filename, sample.filename, 12); memcpy(itss.name, m_szNames[nsmp], 26); StringFixer::SetNullTerminator(itss.name); itss.id = LittleEndian(IT_IMPS); - itss.gvl = (BYTE)psmp->nGlobalVol; + itss.gvl = (BYTE)sample.nGlobalVol; UINT flags = RS_PCM8S; - if(psmp->nLength && psmp->pSample) + if(sample.nLength && sample.pSample) { itss.flags = 0x01; - if (psmp->uFlags & CHN_LOOP) itss.flags |= 0x10; - if (psmp->uFlags & CHN_SUSTAINLOOP) itss.flags |= 0x20; - if (psmp->uFlags & CHN_PINGPONGLOOP) itss.flags |= 0x40; - if (psmp->uFlags & CHN_PINGPONGSUSTAIN) itss.flags |= 0x80; + if (sample.uFlags & CHN_LOOP) itss.flags |= 0x10; + if (sample.uFlags & CHN_SUSTAINLOOP) itss.flags |= 0x20; + if (sample.uFlags & CHN_PINGPONGLOOP) itss.flags |= 0x40; + if (sample.uFlags & CHN_PINGPONGSUSTAIN) itss.flags |= 0x80; #ifndef NO_PACKING if (nPacking && !compatExport) { - if ((!(psmp->uFlags & (CHN_16BIT|CHN_STEREO))) - && (CanPackSample(psmp->pSample, psmp->nLength, nPacking))) + if ((!(sample.uFlags & (CHN_16BIT|CHN_STEREO))) + && (CanPackSample(sample.pSample, sample.nLength, nPacking))) { flags = RS_ADPCM4; itss.cvt = 0xFF; @@ -1917,15 +1917,15 @@ } else #endif // NO_PACKING { - if (psmp->uFlags & CHN_STEREO) + if (sample.uFlags & CHN_STEREO) { flags = RS_STPCM8S; itss.flags |= 0x04; } - if (psmp->uFlags & CHN_16BIT) + if (sample.uFlags & CHN_16BIT) { itss.flags |= 0x02; - flags = (psmp->uFlags & CHN_STEREO) ? RS_STPCM16S : RS_PCM16S; + flags = (sample.uFlags & CHN_STEREO) ? RS_STPCM16S : RS_PCM16S; } } itss.cvt = 0x01; @@ -1935,35 +1935,35 @@ itss.flags = 0x00; } - itss.C5Speed = psmp->nC5Speed; + itss.C5Speed = sample.nC5Speed; if (!itss.C5Speed) itss.C5Speed = 8363; - itss.length = psmp->nLength; - itss.loopbegin = psmp->nLoopStart; - itss.loopend = psmp->nLoopEnd; - itss.susloopbegin = psmp->nSustainStart; - itss.susloopend = psmp->nSustainEnd; - itss.vol = psmp->nVolume >> 2; - itss.dfp = psmp->nPan >> 2; - itss.vit = autovibxm2it[psmp->nVibType & 7]; - itss.vis = min(psmp->nVibRate, 64); - itss.vid = min(psmp->nVibDepth, 32); - itss.vir = min(psmp->nVibSweep, 255); //(psmp->nVibSweep < 64) ? psmp->nVibSweep * 4 : 255; - if (psmp->uFlags & CHN_PANNING) itss.dfp |= 0x80; + itss.length = sample.nLength; + itss.loopbegin = sample.nLoopStart; + itss.loopend = sample.nLoopEnd; + itss.susloopbegin = sample.nSustainStart; + itss.susloopend = sample.nSustainEnd; + itss.vol = sample.nVolume >> 2; + itss.dfp = sample.nPan >> 2; + itss.vit = autovibxm2it[sample.nVibType & 7]; + itss.vis = min(sample.nVibRate, 64); + itss.vid = min(sample.nVibDepth, 32); + itss.vir = min(sample.nVibSweep, 255); //(sample.nVibSweep < 64) ? sample.nVibSweep * 4 : 255; + if (sample.uFlags & CHN_PANNING) itss.dfp |= 0x80; itss.samplepointer = dwPos; fseek(f, smppos[nsmp-1], SEEK_SET); fwrite(&itss, 1, sizeof(ITSAMPLESTRUCT), f); fseek(f, dwPos, SEEK_SET); - if ((psmp->pSample) && (psmp->nLength)) + if ((sample.pSample) && (sample.nLength)) { - dwPos += WriteSample(f, psmp, flags); + dwPos += WriteSample(f, &sample, flags); } } //Save hacked-on extra info if(!compatExport) { - SaveExtendedInstrumentProperties(Instruments, header.insnum, f); + SaveExtendedInstrumentProperties(header.insnum, f); SaveExtendedSongProperties(f); } @@ -2439,13 +2439,13 @@ } -void CSoundFile::SaveExtendedInstrumentProperties(MODINSTRUMENT *instruments[], UINT nInstruments, FILE* f) -//------------------------------------------------------------------------------------------------------------ // Used only when saving IT, XM and MPTM. // ITI, ITP saves using Ericus' macros etc... // The reason is that ITs and XMs save [code][size][ins1.Value][ins2.Value]... // whereas ITP saves [code][size][ins1.Value][code][size][ins2.Value]... // too late to turn back.... +void CSoundFile::SaveExtendedInstrumentProperties(UINT nInstruments, FILE* f) const +//--------------------------------------------------------------------------------- { __int32 code=0; @@ -2459,24 +2459,24 @@ if (nInstruments == 0) return; - WriteInstrumentPropertyForAllInstruments('VR..', sizeof(m_defaultInstrument.nVolRamp), f, instruments, nInstruments); - WriteInstrumentPropertyForAllInstruments('MiP.', sizeof(m_defaultInstrument.nMixPlug), f, instruments, nInstruments); - WriteInstrumentPropertyForAllInstruments('MC..', sizeof(m_defaultInstrument.nMidiChannel),f, instruments, nInstruments); - WriteInstrumentPropertyForAllInstruments('MP..', sizeof(m_defaultInstrument.nMidiProgram),f, instruments, nInstruments); - WriteInstrumentPropertyForAllInstruments('MB..', sizeof(m_defaultInstrument.wMidiBank), f, instruments, nInstruments); - WriteInstrumentPropertyForAllInstruments('P...', sizeof(m_defaultInstrument.nPan), f, instruments, nInstruments); - WriteInstrumentPropertyForAllInstruments('GV..', sizeof(m_defaultInstrument.nGlobalVol), f, instruments, nInstruments); - WriteInstrumentPropertyForAllInstruments('FO..', sizeof(m_defaultInstrument.nFadeOut), f, instruments, nInstruments); - WriteInstrumentPropertyForAllInstruments('R...', sizeof(m_defaultInstrument.nResampling), f, instruments, nInstruments); - WriteInstrumentPropertyForAllInstruments('CS..', sizeof(m_defaultInstrument.nCutSwing), f, instruments, nInstruments); - WriteInstrumentPropertyForAllInstruments('RS..', sizeof(m_defaultInstrument.nResSwing), f, instruments, nInstruments); - WriteInstrumentPropertyForAllInstruments('FM..', sizeof(m_defaultInstrument.nFilterMode), f, instruments, nInstruments); - WriteInstrumentPropertyForAllInstruments('PERN', sizeof(m_defaultInstrument.PitchEnv.nReleaseNode ), f, instruments, nInstruments); - WriteInstrumentPropertyForAllInstruments('AERN', sizeof(m_defaultInstrument.PanEnv.nReleaseNode), f, instruments, nInstruments); - WriteInstrumentPropertyForAllInstruments('VERN', sizeof(m_defaultInstrument.VolEnv.nReleaseNode), f, instruments, nInstruments); - WriteInstrumentPropertyForAllInstruments('PTTL', sizeof(m_defaultInstrument.wPitchToTempoLock), f, instruments, nInstruments); - WriteInstrumentPropertyForAllInstruments('PVEH', sizeof(m_defaultInstrument.nPluginVelocityHandling), f, instruments, nInstruments); - WriteInstrumentPropertyForAllInstruments('PVOH', sizeof(m_defaultInstrument.nPluginVolumeHandling), f, instruments, nInstruments); + WriteInstrumentPropertyForAllInstruments('VR..', sizeof(m_defaultInstrument.nVolRamp), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('MiP.', sizeof(m_defaultInstrument.nMixPlug), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('MC..', sizeof(m_defaultInstrument.nMidiChannel),f, nInstruments); + WriteInstrumentPropertyForAllInstruments('MP..', sizeof(m_defaultInstrument.nMidiProgram),f, nInstruments); + WriteInstrumentPropertyForAllInstruments('MB..', sizeof(m_defaultInstrument.wMidiBank), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('P...', sizeof(m_defaultInstrument.nPan), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('GV..', sizeof(m_defaultInstrument.nGlobalVol), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('FO..', sizeof(m_defaultInstrument.nFadeOut), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('R...', sizeof(m_defaultInstrument.nResampling), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('CS..', sizeof(m_defaultInstrument.nCutSwing), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('RS..', sizeof(m_defaultInstrument.nResSwing), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('FM..', sizeof(m_defaultInstrument.nFilterMode), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('PERN', sizeof(m_defaultInstrument.PitchEnv.nReleaseNode ), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('AERN', sizeof(m_defaultInstrument.PanEnv.nReleaseNode), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('VERN', sizeof(m_defaultInstrument.VolEnv.nReleaseNode), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('PTTL', sizeof(m_defaultInstrument.wPitchToTempoLock), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('PVEH', sizeof(m_defaultInstrument.nPluginVelocityHandling), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('PVOH', sizeof(m_defaultInstrument.nPluginVolumeHandling), f, nInstruments); if(m_nType & MOD_TYPE_MPT) { @@ -2490,34 +2490,34 @@ // write full envelope information for MPTM files (more env points) if(maxNodes > 25) { - WriteInstrumentPropertyForAllInstruments('VE..', sizeof(m_defaultInstrument.VolEnv.nNodes), f, instruments, nInstruments); - WriteInstrumentPropertyForAllInstruments('VP[.', sizeof(m_defaultInstrument.VolEnv.Ticks ), f, instruments, nInstruments); - WriteInstrumentPropertyForAllInstruments('VE[.', sizeof(m_defaultInstrument.VolEnv.Values), f, instruments, nInstruments); + WriteInstrumentPropertyForAllInstruments('VE..', sizeof(m_defaultInstrument.VolEnv.nNodes), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('VP[.', sizeof(m_defaultInstrument.VolEnv.Ticks ), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('VE[.', sizeof(m_defaultInstrument.VolEnv.Values), f, nInstruments); - WriteInstrumentPropertyForAllInstruments('PE..', sizeof(m_defaultInstrument.PanEnv.nNodes), f, instruments, nInstruments); - WriteInstrumentPropertyForAllInstruments('PP[.', sizeof(m_defaultInstrument.PanEnv.Ticks), f, instruments, nInstruments); - WriteInstrumentPropertyForAllInstruments('PE[.', sizeof(m_defaultInstrument.PanEnv.Values), f, instruments, nInstruments); + WriteInstrumentPropertyForAllInstruments('PE..', sizeof(m_defaultInstrument.PanEnv.nNodes), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('PP[.', sizeof(m_defaultInstrument.PanEnv.Ticks), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('PE[.', sizeof(m_defaultInstrument.PanEnv.Values), f, nInstruments); - WriteInstrumentPropertyForAllInstruments('PiE.', sizeof(m_defaultInstrument.PitchEnv.nNodes), f, instruments, nInstruments); - WriteInstrumentPropertyForAllInstruments('PiP[', sizeof(m_defaultInstrument.PitchEnv.Ticks), f, instruments, nInstruments); - WriteInstrumentPropertyForAllInstruments('PiE[', sizeof(m_defaultInstrument.PitchEnv.Values), f, instruments, nInstruments); + WriteInstrumentPropertyForAllInstruments('PiE.', sizeof(m_defaultInstrument.PitchEnv.nNodes), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('PiP[', sizeof(m_defaultInstrument.PitchEnv.Ticks), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('PiE[', sizeof(m_defaultInstrument.PitchEnv.Values), f, nInstruments); } } return; } -void CSoundFile::WriteInstrumentPropertyForAllInstruments(__int32 code, __int16 size, FILE* f, MODINSTRUMENT *instruments[], UINT nInstruments) -//--------------------------------------------------------------------------------------------------------------------------------------------- +void CSoundFile::WriteInstrumentPropertyForAllInstruments(__int32 code, __int16 size, FILE* f, UINT nInstruments) const +//--------------------------------------------------------------------------------------------------------------------- { fwrite(&code, 1, sizeof(__int32), f); //write code fwrite(&size, 1, sizeof(__int16), f); //write size for(UINT nins=1; nins<=nInstruments; nins++) //for all instruments... { BYTE* pField; - if (instruments[nins]) + if (Instruments[nins]) { - pField = GetInstrumentHeaderFieldPointer(instruments[nins], code, size); //get ptr to field + pField = GetInstrumentHeaderFieldPointer(Instruments[nins], code, size); //get ptr to field } else { pField = GetInstrumentHeaderFieldPointer(&m_defaultInstrument, code, size); //get ptr to field @@ -2526,8 +2526,8 @@ } } -void CSoundFile::SaveExtendedSongProperties(FILE* f) -//-------------------------------------------------- +void CSoundFile::SaveExtendedSongProperties(FILE* f) const +//-------------------------------------------------------- { //Extra song data - Yet Another Hack. __int16 size; Modified: trunk/OpenMPT/soundlib/Load_xm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_xm.cpp 2011-09-04 15:19:40 UTC (rev 1017) +++ trunk/OpenMPT/soundlib/Load_xm.cpp 2011-09-04 18:02:35 UTC (rev 1018) @@ -936,7 +936,6 @@ // Writing instruments for (i = 1; i <= xmheader.instruments; i++) { - MODSAMPLE *pSmp; WORD smptable[32]; BYTE flags[32]; @@ -1010,11 +1009,11 @@ fwrite(&xmih, 1, sizeof(xmih), f); if (smptable[0]) { - MODSAMPLE *pvib = &Samples[smptable[0]]; - xmsh.vibtype = pvib->nVibType; - xmsh.vibsweep = min(pvib->nVibSweep, 0xFF); - xmsh.vibdepth = min(pvib->nVibDepth, 0x0F); - xmsh.vibrate = min(pvib->nVibRate, 0x3F); + const MODSAMPLE &sample = Samples[smptable[0]]; + xmsh.vibtype = sample.nVibType; + xmsh.vibsweep = min(sample.nVibSweep, 0xFF); + xmsh.vibdepth = min(sample.nVibDepth, 0x0F); + xmsh.vibrate = min(sample.nVibRate, 0x3F); } WORD samples = xmih.samples; xmih.samples = LittleEndianW(xmih.samples); @@ -1024,20 +1023,20 @@ { MemsetZero(xmss); if (smptable[ins]) memcpy(xmss.name, m_szNames[smptable[ins]], 22); - pSmp = &Samples[smptable[ins]]; - xmss.samplen = pSmp->nLength; - xmss.loopstart = pSmp->nLoopStart; - xmss.looplen = pSmp->nLoopEnd - pSmp->nLoopStart; - xmss.vol = pSmp->nVolume / 4; - xmss.finetune = (char)pSmp->nFineTune; + const MODSAMPLE &sample = Samples[smptable[ins]]; + xmss.samplen = sample.nLength; + xmss.loopstart = sample.nLoopStart; + xmss.looplen = sample.nLoopEnd - sample.nLoopStart; + xmss.vol = sample.nVolume / 4; + xmss.finetune = (char)sample.nFineTune; xmss.type = 0; - if (pSmp->uFlags & CHN_LOOP) xmss.type = (pSmp->uFlags & CHN_PINGPONGLOOP) ? 2 : 1; + if (sample.uFlags & CHN_LOOP) xmss.type = (sample.uFlags & CHN_PINGPONGLOOP) ? 2 : 1; flags[ins] = RS_PCM8D; #ifndef NO_PACKING - if (nPacking) + if (nPacking && !bCompatibilityExport) { - if ((!(pSmp->uFlags & (CHN_16BIT|CHN_STEREO))) - && (CanPackSample(pSmp->pSample, pSmp->nLength, nPacking))) + if ((!(sample.uFlags & (CHN_16BIT|CHN_STEREO))) + && (CanPackSample(sample.pSample, sample.nLength, nPacking))) { flags[ins] = RS_ADPCM4; xmss.res = 0xAD; @@ -1045,7 +1044,7 @@ } else #endif { - if (pSmp->uFlags & CHN_16BIT) + if (sample.uFlags & CHN_16BIT) { flags[ins] = RS_PCM16D; xmss.type |= 0x10; @@ -1053,9 +1052,9 @@ xmss.loopstart *= 2; xmss.samplen *= 2; } - if (pSmp->uFlags & CHN_STEREO && !bCompatibilityExport) + if (sample.uFlags & CHN_STEREO && !bCompatibilityExport) { - flags[ins] = (pSmp->uFlags & CHN_16BIT) ? RS_STPCM16D : RS_STPCM8D; + flags[ins] = (sample.uFlags & CHN_16BIT) ? RS_STPCM16D : RS_STPCM8D; xmss.type |= 0x20; xmss.looplen *= 2; xmss.loopstart *= 2; @@ -1063,8 +1062,8 @@ } } xmss.pan = 255; - if (pSmp->nPan < 256) xmss.pan = (BYTE)pSmp->nPan; - xmss.relnote = (signed char)pSmp->RelativeTone; + if (sample.nPan < 256) xmss.pan = (BYTE)sample.nPan; + xmss.relnote = (signed char)sample.RelativeTone; xmss.samplen = LittleEndianW(xmss.samplen); xmss.loopstart = LittleEndianW(xmss.loopstart); xmss.looplen = LittleEndianW(xmss.looplen); @@ -1072,13 +1071,13 @@ } for (UINT ismpd=0; ismpd<xmih.samples; ismpd++) { - pSmp = &Samples[smptable[ismpd]]; - if (pSmp->pSample) + const MODSAMPLE &sample = Samples[smptable[ismpd]]; + if (sample.pSample) { #ifndef NO_PACKING - if ((flags[ismpd] == RS_ADPCM4) && (xmih.samples>1)) CanPackSample(pSmp->pSample, pSmp->nLength, nPacking); + if ((flags[ismpd] == RS_ADPCM4) && (xmih.samples > 1)) CanPackSample(sample.pSample, sample.nLength, nPacking); #endif // NO_PACKING - WriteSample(f, pSmp, flags[ismpd]); + WriteSample(f, &sample, flags[ismpd]); } } } @@ -1143,7 +1142,7 @@ //Save hacked-on extra info SaveMixPlugins(f); - SaveExtendedInstrumentProperties(Instruments, xmheader.instruments, f); + SaveExtendedInstrumentProperties(xmheader.instruments, f); SaveExtendedSongProperties(f); } Modified: trunk/OpenMPT/soundlib/ModSequence.cpp =================================================================== --- trunk/OpenMPT/soundlib/ModSequence.cpp 2011-09-04 15:19:40 UTC (rev 1017) +++ trunk/OpenMPT/soundlib/ModSequence.cpp 2011-09-04 18:02:35 UTC (rev 1018) @@ -590,28 +590,35 @@ } -size_t ModSequence::WriteToByteArray(BYTE* dest, const UINT numOfBytes, const UINT destSize) -//----------------------------------------------------------------------------- +size_t ModSequence::WriteToByteArray(BYTE* dest, const UINT numOfBytes, const UINT destSize) const +//------------------------------------------------------------------------------------------------ { if(numOfBytes > destSize || numOfBytes > MAX_ORDERS) return true; - if(GetLength() < numOfBytes) resize(ORDERINDEX(numOfBytes), 0xFF); - UINT i = 0; - for(i = 0; i<numOfBytes; i++) + + const size_t limit = min(numOfBytes, GetLength()); + + size_t i = 0; + for(i = 0; i < limit; i++) { dest[i] = static_cast<BYTE>((*this)[i]); } + // Fill non-existing order items with stop indices + for(i = limit; i < numOfBytes; i++) + { + dest[i] = 0xFF; + } return i; //Returns the number of bytes written. } -size_t ModSequence::WriteAsByte(FILE* f, const uint16 count) -//---------------------------------------------------------- +size_t ModSequence::WriteAsByte(FILE* f, const uint16 count) const +//---------------------------------------------------------------- { - if(GetLength() < count) resize(count); + const size_t limit = min(count, GetLength()); size_t i = 0; - for(i = 0; i<count; i++) + for(i = 0; i < limit; i++) { const PATTERNINDEX pat = (*this)[i]; BYTE temp = static_cast<BYTE>((*this)[i]); @@ -623,6 +630,12 @@ } fwrite(&temp, 1, 1, f); } + // Fill non-existing order items with stop indices + for(i = limit; i < count; i++) + { + BYTE temp = 0xFF; + fwrite(&temp, 1, 1, f); + } return i; //Returns the number of bytes written. } Modified: trunk/OpenMPT/soundlib/ModSequence.h =================================================================== --- trunk/OpenMPT/soundlib/ModSequence.h 2011-09-04 15:19:40 UTC (rev 1017) +++ trunk/OpenMPT/soundlib/ModSequence.h 2011-09-04 18:02:35 UTC (rev 1018) @@ -82,8 +82,8 @@ ModSequence& operator=(const ModSequence& seq); // Read/write. - size_t WriteAsByte(FILE* f, const uint16 count); - size_t WriteToByteArray(BYTE* dest, const UINT numOfBytes, const UINT destSize); + size_t WriteAsByte(FILE* f, const uint16 count) const; + size_t WriteToByteArray(BYTE* dest, const UINT numOfBytes, const UINT destSize) const; bool ReadAsByte(const BYTE* pFrom, const int howMany, const int memLength); // Deprecated function used for MPTm's created in 1.17.02.46 - 1.17.02.48. Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2011-09-04 15:19:40 UTC (rev 1017) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2011-09-04 18:02:35 UTC (rev 1018) @@ -359,7 +359,7 @@ break; // Return a pointer on the wanted field in 'input' MODINSTRUMENT given field code & size -BYTE * GetInstrumentHeaderFieldPointer(MODINSTRUMENT * input, __int32 fcode, __int16 fsize) +BYTE * GetInstrumentHeaderFieldPointer(const MODINSTRUMENT * input, __int32 fcode, __int16 fsize) { if(input == NULL) return NULL; BYTE * pointer = NULL; @@ -1305,21 +1305,24 @@ //m_nSeqOverride = 0; } -ORDERINDEX CSoundFile::FindOrder(PATTERNINDEX nPat, UINT startFromOrder, bool direction) -//-------------------------------------------------------------------------------------- +ORDERINDEX CSoundFile::FindOrder(PATTERNINDEX nPat, ORDERINDEX startFromOrder, bool direction) +//-------------------------------------------------------------------------------------------- { + const ORDERINDEX maxOrder = Order.GetLength(); ORDERINDEX foundAtOrder = ORDERINDEX_INVALID; ORDERINDEX candidateOrder = 0; - for (ORDERINDEX p = 0; p < Order.size(); p++) + for (ORDERINDEX p = 0; p < maxOrder; p++) { if (direction) { - candidateOrder = (startFromOrder + p) % Order.size(); //wrap around MAX_ORDERS - } else { - candidateOrder = (startFromOrder - p + Order.size()) % Order.size(); //wrap around 0 and MAX_ORDERS + candidateOrder = (startFromOrder + p) % maxOrder; //wrap around MAX_ORDERS + } else + { + candidateOrder = (startFromOrder - p + maxOrder) % maxOrder; //wrap around 0 and MAX_ORDERS } - if (Order[candidateOrder] == nPat) { + if (Order[candidateOrder] == nPat) + { foundAtOrder = candidateOrder; break; } @@ -1370,9 +1373,12 @@ LPCTSTR CSoundFile::GetSampleName(UINT nSample) const //--------------------------------------------------- { - if (nSample<MAX_SAMPLES) { + ASSERT(nSample <= GetNumSamples()); + if (nSample < MAX_SAMPLES) + { return m_szNames[nSample]; - } else { + } else + { return gszEmpty; } } @@ -1384,6 +1390,7 @@ if ((nInstr >= MAX_INSTRUMENTS) || (!Instruments[nInstr])) return TEXT(""); + ASSERT(nInstr <= GetNumInstruments()); const size_t nSize = ARRAYELEMCOUNT(Instruments[nInstr]->name); CString str; LPTSTR p = str.GetBuffer(nSize + 1); @@ -1556,8 +1563,8 @@ #ifndef MODPLUG_NO_FILESAVE -UINT CSoundFile::WriteSample(FILE *f, MODSAMPLE *pSmp, UINT nFlags, UINT nMaxLen) -//------------------------------------------------------------------------------- +UINT CSoundFile::WriteSample(FILE *f, const MODSAMPLE *pSmp, UINT nFlags, UINT nMaxLen) const +//------------------------------------------------------------------------------------------- { UINT len = 0, bufcount; char buffer[4096]; Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2011-09-04 15:19:40 UTC (rev 1017) +++ trunk/OpenMPT/soundlib/Sndfile.h 2011-09-04 18:02:35 UTC (rev 1018) @@ -163,7 +163,7 @@ // MODULAR MODINSTRUMENT FIELD ACCESS : body content at the (near) top of Sndfile.cpp !!! // ----------------------------------------------------------------------------------------- extern void WriteInstrumentHeaderStruct(MODINSTRUMENT * input, FILE * file); -extern BYTE * GetInstrumentHeaderFieldPointer(MODINSTRUMENT * input, __int32 fcode, __int16 fsize); +extern BYTE * GetInstrumentHeaderFieldPointer(const MODINSTRUMENT * input, __int32 fcode, __int16 fsize); // -! NEW_FEATURE#0027 @@ -721,7 +721,7 @@ static const CModSpecifications& GetModSpecifications(const MODTYPE type); double GetCurrentBPM() const; - ORDERINDEX FindOrder(PATTERNINDEX nPat, UINT startFromOrder=0, bool direction = true); //rewbs.playSongFromCursor + ORDERINDEX FindOrder(PATTERNINDEX nPat, ORDERINDEX startFromOrder = 0, bool direction = true); //rewbs.playSongFromCursor void DontLoopPattern(PATTERNINDEX nPat, ROWINDEX nRow = 0); //rewbs.playSongFromCursor void SetCurrentPos(UINT nPos); void SetCurrentOrder(ORDERINDEX nOrder); @@ -789,16 +789,16 @@ // Save Functions #ifndef MODPLUG_NO_FILESAVE - UINT WriteSample(FILE *f, MODSAMPLE *pSmp, UINT nFlags, UINT nMaxLen=0); + UINT WriteSample(FILE *f, const MODSAMPLE *pSmp, UINT nFlags, UINT nMaxLen=0) const; bool SaveXM(LPCSTR lpszFileName, UINT nPacking=0, const bool bCompatibilityExport = false); bool SaveS3M(LPCSTR lpszFileName, UINT nPacking=0); bool SaveMod(LPCSTR lpszFileName, UINT nPacking=0, const bool bCompatibilityExport = false); bool SaveIT(LPCSTR lpszFileName, UINT nPacking=0, const bool compatExport = false); bool SaveITProject(LPCSTR lpszFileName); // -> CODE#0023 -> DESC="IT project files (.itp)" -! NEW_FEATURE#0023 UINT SaveMixPlugins(FILE *f=NULL, BOOL bUpdate=TRUE); - void WriteInstrumentPropertyForAllInstruments(__int32 code, __int16 size, FILE* f, MODINSTRUMENT* instruments[], UINT nInstruments); - void SaveExtendedInstrumentProperties(MODINSTRUMENT *instruments[], UINT nInstruments, FILE* f); - void SaveExtendedSongProperties(FILE* f); + void WriteInstrumentPropertyForAllInstruments(__int32 code, __int16 size, FILE* f, UINT nInstruments) const; + void SaveExtendedInstrumentProperties(UINT nInstruments, FILE* f) const; + void SaveExtendedSongProperties(FILE* f) const; void LoadExtendedSongProperties(const MODTYPE modtype, LPCBYTE ptr, const LPCBYTE startpos, const size_t seachlimit, bool* pInterpretMptMade = nullptr); #endif // MODPLUG_NO_FILESAVE This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-05 01:07:48
|
Revision: 1022 http://modplug.svn.sourceforge.net/modplug/?rev=1022&view=rev Author: saga-games Date: 2011-09-05 01:07:40 +0000 (Mon, 05 Sep 2011) Log Message: ----------- [Ref] MODINSTRUMENT has a constructor now, so no memsetting / etc. is necessary anymore. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/LOAD_DBM.CPP trunk/OpenMPT/soundlib/Load_ams.cpp trunk/OpenMPT/soundlib/Load_imf.cpp trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_mdl.cpp trunk/OpenMPT/soundlib/Load_mid.cpp trunk/OpenMPT/soundlib/Load_mt2.cpp trunk/OpenMPT/soundlib/Load_xm.cpp trunk/OpenMPT/soundlib/Sampleio.cpp trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp trunk/OpenMPT/soundlib/load_j2b.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-09-04 19:12:08 UTC (rev 1021) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-09-05 01:07:40 UTC (rev 1022) @@ -111,7 +111,7 @@ CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); if(m_nInstrument > 0 && pSndFile && m_nInstrument <= pSndFile->GetNumInstruments() && pSndFile->Instruments[m_nInstrument] == nullptr) { - pSndFile->Instruments[m_nInstrument] = new MODINSTRUMENT; + pSndFile->Instruments[m_nInstrument] = new MODINSTRUMENT(); m_pModDoc->InitializeInstrument(pSndFile->Instruments[m_nInstrument]); } @@ -1444,16 +1444,14 @@ if (!pIns->name[0]) { - szName[31] = 0; - memset(pIns->name, 0, 32); + szName[m_pSndFile->GetModSpecifications().instrNameLengthMax - 1] = 0; strcpy(pIns->name, szName); } if (!pIns->filename[0]) { strcat(szName, szExt); - szName[11] = 0; + szName[m_pSndFile->GetModSpecifications().instrFilenameLengthMax - 1] = 0; strcpy(pIns->filename, szName); - pIns->filename[11] = 0; } SetCurrentInstrument(m_nInstrument); if (m_pModDoc) Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2011-09-04 19:12:08 UTC (rev 1021) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2011-09-05 01:07:40 UTC (rev 1022) @@ -237,7 +237,7 @@ ClearLog(); } - if ((m_SndFile.m_nType == MOD_TYPE_NONE) || (!m_SndFile.m_nChannels)) return FALSE; + if ((m_SndFile.m_nType == MOD_TYPE_NONE) || (!m_SndFile.GetNumChannels())) return FALSE; // Midi Import if (m_SndFile.m_nType == MOD_TYPE_MID) { @@ -516,9 +516,9 @@ { if(m_SndFile.m_szInstrumentPath[i][0] != '\0') { - int size = strlen(m_SndFile.m_szInstrumentPath[i]); - bool iti = _stricmp(&m_SndFile.m_szInstrumentPath[i][size-3],"iti") == 0; - bool xi = _stricmp(&m_SndFile.m_szInstrumentPath[i][size-2],"xi") == 0; + const size_t len = strlen(m_SndFile.m_szInstrumentPath[i]); + const bool iti = _stricmp(&m_SndFile.m_szInstrumentPath[i][len - 3],"iti") == 0; + const bool xi = _stricmp(&m_SndFile.m_szInstrumentPath[i][len - 2],"xi") == 0; if(iti || (!iti && !xi && m_SndFile.m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT))) m_SndFile.SaveITIInstrument(i+1, m_SndFile.m_szInstrumentPath[i]); @@ -736,8 +736,8 @@ if ((!m_SndFile.m_nInstruments) && (m_SndFile.m_nType & MOD_TYPE_XM)) { m_SndFile.m_nInstruments = 1; - m_SndFile.Instruments[1] = new MODINSTRUMENT; - InitializeInstrument(m_SndFile.Instruments[1], 1); + m_SndFile.Instruments[1] = new MODINSTRUMENT(1); + InitializeInstrument(m_SndFile.Instruments[1]); } if (m_SndFile.m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT|MOD_TYPE_XM)) { @@ -1124,7 +1124,7 @@ { m_SndFile.Chn[nChn].dwFlags |= muteType; //Kill VSTi notes on muted channel. - PLUGINDEX nPlug = m_SndFile.GetBestPlugin(nChn, PRIORITISE_INSTRUMENT, EVEN_IF_MUTED); + PLUGINDEX nPlug = m_SndFile.GetBestPlugin(nChn, PrioritiseInstrument, EvenIfMuted); if ((nPlug) && (nPlug<=MAX_MIXPLUGINS)) { CVstPlugin *pPlug = (CVstPlugin*)m_SndFile.m_MixPlugins[nPlug - 1].pMixPlugin; @@ -2371,7 +2371,7 @@ int nParam = MacroToPlugParam(macroText); char paramName[128]; MemsetZero(paramName); - PLUGINDEX nPlug = m_SndFile.GetBestPlugin(nChn, PRIORITISE_CHANNEL, EVEN_IF_MUTED); + PLUGINDEX nPlug = m_SndFile.GetBestPlugin(nChn, PrioritiseChannel, EvenIfMuted); if ((nPlug) && (nPlug<=MAX_MIXPLUGINS)) { CVstPlugin *pPlug = (CVstPlugin*)m_SndFile.m_MixPlugins[nPlug-1].pMixPlugin; if (pPlug) Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2011-09-04 19:12:08 UTC (rev 1021) +++ trunk/OpenMPT/mptrack/Moddoc.h 2011-09-05 01:07:40 UTC (rev 1022) @@ -290,7 +290,7 @@ PATTERNINDEX InsertPattern(ORDERINDEX nOrd = ORDERINDEX_INVALID, ROWINDEX nRows = 64); SAMPLEINDEX InsertSample(bool bLimit = false); INSTRUMENTINDEX InsertInstrument(SAMPLEINDEX lSample = SAMPLEINDEX_INVALID, INSTRUMENTINDEX lDuplicate = INSTRUMENTINDEX_INVALID); - void InitializeInstrument(MODINSTRUMENT *pIns, UINT nsample=0); + void InitializeInstrument(MODINSTRUMENT *pIns); void InitializeSample(MODSAMPLE &sample); bool RemoveOrder(SEQUENCEINDEX nSeq, ORDERINDEX nOrd); bool RemovePattern(PATTERNINDEX nPat); Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2011-09-04 19:12:08 UTC (rev 1021) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2011-09-05 01:07:40 UTC (rev 1022) @@ -500,10 +500,10 @@ { try { - MODINSTRUMENT *p = new MODINSTRUMENT; - InitializeInstrument(p, smp); + MODINSTRUMENT *p = new MODINSTRUMENT(smp); + InitializeInstrument(p); m_SndFile.Instruments[smp] = p; - lstrcpyn(p->name, m_SndFile.m_szNames[smp], sizeof(p->name)); + lstrcpyn(p->name, m_SndFile.m_szNames[smp], CountOf(p->name)); } catch(...) { ErrorBox(IDS_ERR_OUTOFMEMORY, CMainFrame::GetMainFrame()); @@ -532,52 +532,59 @@ } newins = ++m_SndFile.m_nInstruments; } - MODINSTRUMENT *pIns = new MODINSTRUMENT; - if (pIns) + + // Determine which sample slot to use + SAMPLEINDEX newsmp = 0; + if (nSample < m_SndFile.GetModSpecifications().samplesMax) { - SAMPLEINDEX newsmp = 0; - if (nSample < m_SndFile.GetModSpecifications().samplesMax) + // Use specified slot + newsmp = nSample; + } else if (!pDup) + { + for(SAMPLEINDEX k = 1; k <= m_SndFile.m_nSamples; k++) { - newsmp = nSample; - } else - if (!pDup) - { - for(SAMPLEINDEX k = 1; k <= m_SndFile.m_nSamples; k++) + if (!m_SndFile.IsSampleUsed(k)) { - if (!m_SndFile.IsSampleUsed(k)) - { - newsmp = k; - break; - } + // Sample isn't referenced by any instrument yet, so let's use it... + newsmp = k; + break; } - if (!newsmp) - { - int inssmp = InsertSample(); - if (inssmp != SAMPLEINDEX_INVALID) newsmp = inssmp; - } } - - CriticalSection cs; - if (pDup) + if (!newsmp) { - *pIns = *pDup; -// -> CODE#0023 -// -> DESC="IT project files (.itp)" - strcpy(m_SndFile.m_szInstrumentPath[newins - 1], m_SndFile.m_szInstrumentPath[nDuplicate - 1]); - m_bsInstrumentModified.reset(newins - 1); -// -! NEW_FEATURE#0023 - } else - { - InitializeInstrument(pIns, newsmp); + // Add a new sample + int inssmp = InsertSample(); + if (inssmp != SAMPLEINDEX_INVALID) newsmp = inssmp; } - m_SndFile.Instruments[newins] = pIns; + } - SetModified(); - } else + MODINSTRUMENT *pIns; + try { + pIns = new MODINSTRUMENT(newsmp); + InitializeInstrument(pIns); + } catch(...) + { ErrorBox(IDS_ERR_OUTOFMEMORY, CMainFrame::GetMainFrame()); return INSTRUMENTINDEX_INVALID; } + + CriticalSection cs; + + if (pDup) + { + *pIns = *pDup; + // -> CODE#0023 + // -> DESC="IT project files (.itp)" + strcpy(m_SndFile.m_szInstrumentPath[newins - 1], m_SndFile.m_szInstrumentPath[nDuplicate - 1]); + m_bsInstrumentModified.reset(newins - 1); + // -! NEW_FEATURE#0023 + } + + m_SndFile.Instruments[newins] = pIns; + + SetModified(); + return newins; } @@ -603,23 +610,11 @@ } -void CModDoc::InitializeInstrument(MODINSTRUMENT *pIns, UINT nsample) -//------------------------------------------------------------------- +// Load default instrument values for inserting new instrument during editing +void CModDoc::InitializeInstrument(MODINSTRUMENT *pIns) +//----------------------------------------------------- { - if(pIns == nullptr) - return; - MemsetZero(*pIns); - pIns->nFadeOut = 256; - pIns->nGlobalVol = 64; - pIns->nPan = 128; - pIns->nPPC = NOTE_MIDDLEC - 1; - m_SndFile.SetDefaultInstrumentValues(pIns); - for (UINT n=0; n<128; n++) - { - pIns->Keyboard[n] = nsample; - pIns->NoteMap[n] = n+1; - } - pIns->pTuning = pIns->s_DefaultTuning; + pIns->nPluginVolumeHandling = CSoundFile::s_DefaultPlugVolumeHandling; } Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.cpp 2011-09-04 19:12:08 UTC (rev 1021) +++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2011-09-05 01:07:40 UTC (rev 1022) @@ -1641,10 +1641,15 @@ Log(" usVolume = %3d, Unity Note = %d\n", prgn->usVolume, prgn->uUnityNote); } #endif - pIns = new MODINSTRUMENT; - if (!pIns) return FALSE; - MemsetZero(*pIns); - pIns->pTuning = pIns->s_DefaultTuning; + + try + { + pIns = new MODINSTRUMENT(); + } catch(...) + { + return FALSE; + } + if (pSndFile->Instruments[nInstr]) { pSndFile->DestroyInstrument(nInstr, deleteAssociatedSamples); @@ -1691,22 +1696,14 @@ } } pIns->nFadeOut = 1024; - pIns->nGlobalVol = 64; // Maximum - pIns->nPan = 128; // Center Pan pIns->nMidiProgram = (BYTE)(pDlsIns->ulInstrument & 0x7F); pIns->nMidiChannel = (BYTE)((pDlsIns->ulBank & F_INSTRUMENT_DRUMS) ? 10 : 0); pIns->wMidiBank = (WORD)(((pDlsIns->ulBank & 0x7F00) >> 1) | (pDlsIns->ulBank & 0x7F)); - pIns->nPPC = 60; // C-5 pIns->nNNA = NNA_NOTEOFF; pIns->nDCT = DCT_NOTE; pIns->nDNA = DNA_NOTEFADE; - pIns->nResampling = SRCMODE_DEFAULT; - pIns->nFilterMode = FLTMODE_UNCHANGED; - pIns->PanEnv.nReleaseNode=ENV_RELEASE_NODE_UNSET; - pIns->PitchEnv.nReleaseNode=ENV_RELEASE_NODE_UNSET; - pIns->VolEnv.nReleaseNode=ENV_RELEASE_NODE_UNSET; pSndFile->Instruments[nInstr] = pIns; - nSample = 1; + nSample = 0; UINT nLoadedSmp = 0; // Extract Samples for (UINT nRgn=nRgnMin; nRgn<nRgnMax; nRgn++) @@ -1741,9 +1738,13 @@ nSmp = RgnToSmp[nRgn-1]; } else { - while ((nSample < MAX_SAMPLES) && ((pSndFile->GetSample(nSample).pSample) || (pSndFile->m_szNames[nSample][0]))) nSample++; + // Find a nice sample slot + do + { + nSample++; + } while (nSample < pSndFile->GetNumSamples() && (pSndFile->GetSample(nSample).pSample != nullptr || pSndFile->m_szNames[nSample][0])); if (nSample >= MAX_SAMPLES) break; - if (nSample > pSndFile->m_nSamples) pSndFile->m_nSamples = nSample; + if (nSample > pSndFile->GetNumSamples()) pSndFile->m_nSamples = nSample; nSmp = nSample; nLoadedSmp++; } @@ -1900,6 +1901,3 @@ } return TRUE; } - - - Modified: trunk/OpenMPT/soundlib/Fastmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Fastmix.cpp 2011-09-04 19:12:08 UTC (rev 1021) +++ trunk/OpenMPT/soundlib/Fastmix.cpp 2011-09-05 01:07:40 UTC (rev 1022) @@ -1608,7 +1608,7 @@ #endif //Look for plugins associated with this implicit tracker channel. - PLUGINDEX nMixPlugin = GetBestPlugin(ChnMix[nChn], PRIORITISE_INSTRUMENT, RESPECT_MUTES); + PLUGINDEX nMixPlugin = GetBestPlugin(ChnMix[nChn], PrioritiseInstrument, RespectMutes); //rewbs.instroVSTi /* UINT nMixPlugin=0; @@ -2492,6 +2492,3 @@ #endif // NO_AGC - - - Modified: trunk/OpenMPT/soundlib/LOAD_DBM.CPP =================================================================== --- trunk/OpenMPT/soundlib/LOAD_DBM.CPP 2011-09-04 19:12:08 UTC (rev 1021) +++ trunk/OpenMPT/soundlib/LOAD_DBM.CPP 2011-09-05 01:07:40 UTC (rev 1022) @@ -231,14 +231,14 @@ WORD nsmp; if (chunk_pos + sizeof(DBMINSTRUMENT) > dwMemPos) break; - if ((pIns = new MODINSTRUMENT) == nullptr) break; - memset(pIns, 0, sizeof(MODINSTRUMENT)); - SetDefaultInstrumentValues(pIns); - Instruments[iIns + 1] = pIns; pih = (DBMINSTRUMENT *)(lpStream + chunk_pos); nsmp = BigEndianW(pih->sampleno); psmp = ((nsmp) && (nsmp < MAX_SAMPLES)) ? &Samples[nsmp] : nullptr; + + if ((pIns = new MODINSTRUMENT(nsmp)) == nullptr) break; + Instruments[iIns + 1] = pIns; + memcpy(pIns->name, pih->name, 30); StringFixer::SpaceToNullStringFixed<30>(pIns->name); if (psmp) @@ -248,19 +248,12 @@ } pIns->nFadeOut = 1024; // ??? - pIns->nGlobalVol = 64; pIns->nPan = BigEndianW(pih->panning); if ((pIns->nPan) && (pIns->nPan < 256)) pIns->dwFlags = INS_SETPANNING; else pIns->nPan = 128; - pIns->nPPC = 5 * 12; - for (BYTE i = 0; i < NOTE_MAX; i++) - { - pIns->Keyboard[i] = nsmp; - pIns->NoteMap[i] = i + 1; - } // Sample Info if (psmp) { Modified: trunk/OpenMPT/soundlib/Load_ams.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ams.cpp 2011-09-04 19:12:08 UTC (rev 1021) +++ trunk/OpenMPT/soundlib/Load_ams.cpp 2011-09-05 01:07:40 UTC (rev 1022) @@ -395,20 +395,17 @@ dwMemPos += 5 + panenv->points*3; pitchenv = (AMS2ENVELOPE *)(lpStream+dwMemPos); dwMemPos += 5 + pitchenv->points*3; - MODINSTRUMENT *pIns = new MODINSTRUMENT; + MODINSTRUMENT *pIns = new MODINSTRUMENT(); if (!pIns) return TRUE; memset(smpmap, 0, sizeof(smpmap)); - memset(pIns, 0, sizeof(MODINSTRUMENT)); + for (UINT ismpmap=0; ismpmap<pSmp->samples; ismpmap++) { if ((ismpmap >= 16) || (m_nSamples+1 >= MAX_SAMPLES)) break; m_nSamples++; smpmap[ismpmap] = m_nSamples; } - pIns->nGlobalVol = 64; - pIns->nPan = 128; - pIns->nPPC = 60; - SetDefaultInstrumentValues(pIns); + Instruments[nIns] = pIns; if (insnamelen) { Modified: trunk/OpenMPT/soundlib/Load_imf.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_imf.cpp 2011-09-04 19:12:08 UTC (rev 1021) +++ trunk/OpenMPT/soundlib/Load_imf.cpp 2011-09-05 01:07:40 UTC (rev 1022) @@ -253,7 +253,6 @@ env->nLoopStart = imfins->env[e].loop_start; env->nLoopEnd = imfins->env[e].loop_end; env->nSustainStart = env->nSustainEnd = imfins->env[e].sustain; - env->nReleaseNode = ENV_RELEASE_NODE_UNSET; for(UINT n = 0; n < env->nNodes; n++) { @@ -497,13 +496,16 @@ //if(memcmp(imfins.ii10, "II10", 4) != 0) // return false; - pIns = new MODINSTRUMENT; - if(!pIns) + try + { + pIns = new MODINSTRUMENT(); + } + catch(...) + { continue; + } + Instruments[nIns + 1] = pIns; - memset(pIns, 0, sizeof(MODINSTRUMENT)); - pIns->nPPC = 5 * 12; - SetDefaultInstrumentValues(pIns); memcpy(pIns->name, imfins.name, 31); StringFixer::SpaceToNullStringFixed<31>(pIns->name); @@ -518,7 +520,6 @@ } pIns->nFadeOut = imfins.fadeout; - pIns->nGlobalVol = 64; load_imf_envelope(&pIns->VolEnv, &imfins, IMF_ENV_VOL); load_imf_envelope(&pIns->PanEnv, &imfins, IMF_ENV_PAN); Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2011-09-04 19:12:08 UTC (rev 1021) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2011-09-05 01:07:40 UTC (rev 1022) @@ -305,9 +305,6 @@ const int iEnvMax = (m_nType & MOD_TYPE_MPT) ? MAX_ENVPOINTS : 25; long returnVal=0; - pIns->pTuning = m_defaultInstrument.pTuning; - pIns->nPluginVelocityHandling = PLUGIN_VELOCITYHANDLING_CHANNEL; - pIns->nPluginVolumeHandling = PLUGIN_VOLUMEHANDLING_IGNORE; if (trkvers < 0x0200) { const ITOLDINSTRUMENT *pis = (const ITOLDINSTRUMENT *)p; @@ -346,10 +343,6 @@ pIns->nNNA = pis->nna; pIns->nDCT = pis->dnc; pIns->nPan = 0x80; - - pIns->VolEnv.nReleaseNode = ENV_RELEASE_NODE_UNSET; - pIns->PanEnv.nReleaseNode = ENV_RELEASE_NODE_UNSET; - pIns->PitchEnv.nReleaseNode = ENV_RELEASE_NODE_UNSET; } else { const ITINSTRUMENT *pis = (const ITINSTRUMENT *)p; @@ -453,9 +446,6 @@ pIns->nVolSwing = pis->rv; pIns->nPanSwing = pis->rp; pIns->nPan = (pis->dfp & 0x7F) << 2; - SetDefaultInstrumentValues(pIns); - pIns->nPluginVelocityHandling = PLUGIN_VELOCITYHANDLING_CHANNEL; - pIns->nPluginVolumeHandling = PLUGIN_VOLUMEHANDLING_IGNORE; if (pIns->nPan > 256) pIns->nPan = 128; if (pis->dfp < 0x80) pIns->dwFlags |= INS_SETPANNING; } @@ -944,10 +934,9 @@ { if ((inspos[nins] > 0) && (inspos[nins] < dwMemLength - (pifh->cmwt < 0x200 ? sizeof(ITOLDINSTRUMENT) : sizeof(ITINSTRUMENT)))) { - MODINSTRUMENT *pIns = new MODINSTRUMENT; + MODINSTRUMENT *pIns = new MODINSTRUMENT(); if (!pIns) continue; - Instruments[nins+1] = pIns; - memset(pIns, 0, sizeof(MODINSTRUMENT)); + Instruments[nins + 1] = pIns; ITInstrToMPT(lpStream + inspos[nins], pIns, pifh->cmwt); } } @@ -2458,25 +2447,27 @@ if (nInstruments == 0) return; + + MODINSTRUMENT *sizeIns = new MODINSTRUMENT(); - WriteInstrumentPropertyForAllInstruments('VR..', sizeof(m_defaultInstrument.nVolRamp), f, nInstruments); - WriteInstrumentPropertyForAllInstruments('MiP.', sizeof(m_defaultInstrument.nMixPlug), f, nInstruments); - WriteInstrumentPropertyForAllInstruments('MC..', sizeof(m_defaultInstrument.nMidiChannel),f, nInstruments); - WriteInstrumentPropertyForAllInstruments('MP..', sizeof(m_defaultInstrument.nMidiProgram),f, nInstruments); - WriteInstrumentPropertyForAllInstruments('MB..', sizeof(m_defaultInstrument.wMidiBank), f, nInstruments); - WriteInstrumentPropertyForAllInstruments('P...', sizeof(m_defaultInstrument.nPan), f, nInstruments); - WriteInstrumentPropertyForAllInstruments('GV..', sizeof(m_defaultInstrument.nGlobalVol), f, nInstruments); - WriteInstrumentPropertyForAllInstruments('FO..', sizeof(m_defaultInstrument.nFadeOut), f, nInstruments); - WriteInstrumentPropertyForAllInstruments('R...', sizeof(m_defaultInstrument.nResampling), f, nInstruments); - WriteInstrumentPropertyForAllInstruments('CS..', sizeof(m_defaultInstrument.nCutSwing), f, nInstruments); - WriteInstrumentPropertyForAllInstruments('RS..', sizeof(m_defaultInstrument.nResSwing), f, nInstruments); - WriteInstrumentPropertyForAllInstruments('FM..', sizeof(m_defaultInstrument.nFilterMode), f, nInstruments); - WriteInstrumentPropertyForAllInstruments('PERN', sizeof(m_defaultInstrument.PitchEnv.nReleaseNode ), f, nInstruments); - WriteInstrumentPropertyForAllInstruments('AERN', sizeof(m_defaultInstrument.PanEnv.nReleaseNode), f, nInstruments); - WriteInstrumentPropertyForAllInstruments('VERN', sizeof(m_defaultInstrument.VolEnv.nReleaseNode), f, nInstruments); - WriteInstrumentPropertyForAllInstruments('PTTL', sizeof(m_defaultInstrument.wPitchToTempoLock), f, nInstruments); - WriteInstrumentPropertyForAllInstruments('PVEH', sizeof(m_defaultInstrument.nPluginVelocityHandling), f, nInstruments); - WriteInstrumentPropertyForAllInstruments('PVOH', sizeof(m_defaultInstrument.nPluginVolumeHandling), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('VR..', sizeof(sizeIns->nVolRamp), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('MiP.', sizeof(sizeIns->nMixPlug), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('MC..', sizeof(sizeIns->nMidiChannel),f, nInstruments); + WriteInstrumentPropertyForAllInstruments('MP..', sizeof(sizeIns->nMidiProgram),f, nInstruments); + WriteInstrumentPropertyForAllInstruments('MB..', sizeof(sizeIns->wMidiBank), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('P...', sizeof(sizeIns->nPan), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('GV..', sizeof(sizeIns->nGlobalVol), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('FO..', sizeof(sizeIns->nFadeOut), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('R...', sizeof(sizeIns->nResampling), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('CS..', sizeof(sizeIns->nCutSwing), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('RS..', sizeof(sizeIns->nResSwing), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('FM..', sizeof(sizeIns->nFilterMode), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('PERN', sizeof(sizeIns->PitchEnv.nReleaseNode ), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('AERN', sizeof(sizeIns->PanEnv.nReleaseNode), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('VERN', sizeof(sizeIns->VolEnv.nReleaseNode), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('PTTL', sizeof(sizeIns->wPitchToTempoLock), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('PVEH', sizeof(sizeIns->nPluginVelocityHandling), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('PVOH', sizeof(sizeIns->nPluginVolumeHandling), f, nInstruments); if(m_nType & MOD_TYPE_MPT) { @@ -2490,20 +2481,22 @@ // write full envelope information for MPTM files (more env points) if(maxNodes > 25) { - WriteInstrumentPropertyForAllInstruments('VE..', sizeof(m_defaultInstrument.VolEnv.nNodes), f, nInstruments); - WriteInstrumentPropertyForAllInstruments('VP[.', sizeof(m_defaultInstrument.VolEnv.Ticks ), f, nInstruments); - WriteInstrumentPropertyForAllInstruments('VE[.', sizeof(m_defaultInstrument.VolEnv.Values), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('VE..', sizeof(sizeIns->VolEnv.nNodes), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('VP[.', sizeof(sizeIns->VolEnv.Ticks ), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('VE[.', sizeof(sizeIns->VolEnv.Values), f, nInstruments); - WriteInstrumentPropertyForAllInstruments('PE..', sizeof(m_defaultInstrument.PanEnv.nNodes), f, nInstruments); - WriteInstrumentPropertyForAllInstruments('PP[.', sizeof(m_defaultInstrument.PanEnv.Ticks), f, nInstruments); - WriteInstrumentPropertyForAllInstruments('PE[.', sizeof(m_defaultInstrument.PanEnv.Values), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('PE..', sizeof(sizeIns->PanEnv.nNodes), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('PP[.', sizeof(sizeIns->PanEnv.Ticks), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('PE[.', sizeof(sizeIns->PanEnv.Values), f, nInstruments); - WriteInstrumentPropertyForAllInstruments('PiE.', sizeof(m_defaultInstrument.PitchEnv.nNodes), f, nInstruments); - WriteInstrumentPropertyForAllInstruments('PiP[', sizeof(m_defaultInstrument.PitchEnv.Ticks), f, nInstruments); - WriteInstrumentPropertyForAllInstruments('PiE[', sizeof(m_defaultInstrument.PitchEnv.Values), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('PiE.', sizeof(sizeIns->PitchEnv.nNodes), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('PiP[', sizeof(sizeIns->PitchEnv.Ticks), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('PiE[', sizeof(sizeIns->PitchEnv.Values), f, nInstruments); } } + delete sizeIns; + return; } @@ -2520,7 +2513,9 @@ pField = GetInstrumentHeaderFieldPointer(Instruments[nins], code, size); //get ptr to field } else { - pField = GetInstrumentHeaderFieldPointer(&m_defaultInstrument, code, size); //get ptr to field + MODINSTRUMENT *emptyInstrument = new MODINSTRUMENT(); + pField = GetInstrumentHeaderFieldPointer(emptyInstrument, code, size); //get ptr to field + delete emptyInstrument; } fwrite(pField, 1, size, f); //write field data } Modified: trunk/OpenMPT/soundlib/Load_mdl.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mdl.cpp 2011-09-04 19:12:08 UTC (rev 1021) +++ trunk/OpenMPT/soundlib/Load_mdl.cpp 2011-09-05 01:07:40 UTC (rev 1022) @@ -370,21 +370,16 @@ if (!Instruments[nins]) { UINT note = 12; - if ((Instruments[nins] = new MODINSTRUMENT) == NULL) break; + if ((Instruments[nins] = new MODINSTRUMENT()) == nullptr) break; MODINSTRUMENT *pIns = Instruments[nins]; - memset(pIns, 0, sizeof(MODINSTRUMENT)); memcpy(pIns->name, lpStream+dwPos+2, 32); StringFixer::SpaceToNullStringFixed<31>(pIns->name); - pIns->nGlobalVol = 64; - pIns->nPPC = 5*12; - SetDefaultInstrumentValues(pIns); for (j=0; j<lpStream[dwPos+1]; j++) { const BYTE *ps = lpStream+dwPos+34+14*j; while ((note < (UINT)(ps[1]+12)) && (note < NOTE_MAX)) { - pIns->NoteMap[note] = note+1; if (ps[0] < MAX_SAMPLES) { int ismp = ps[0]; @@ -422,8 +417,7 @@ } for (j=1; j<=m_nInstruments; j++) if (!Instruments[j]) { - Instruments[j] = new MODINSTRUMENT; - if (Instruments[j]) memset(Instruments[j], 0, sizeof(MODINSTRUMENT)); + Instruments[j] = new MODINSTRUMENT(); } break; // VE: Volume Envelope Modified: trunk/OpenMPT/soundlib/Load_mid.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mid.cpp 2011-09-04 19:12:08 UTC (rev 1021) +++ trunk/OpenMPT/soundlib/Load_mid.cpp 2011-09-05 01:07:40 UTC (rev 1022) @@ -412,10 +412,15 @@ } } if ((m_nInstruments + 1 >= MAX_INSTRUMENTS) || (m_nSamples + 1 >= MAX_SAMPLES)) return 0; - pIns = new MODINSTRUMENT; - if (!pIns) return 0; - memset(pIns, 0, sizeof(MODINSTRUMENT)); - pIns->pTuning = pIns->s_DefaultTuning; + + try + { + pIns = new MODINSTRUMENT(); + } catch(...) + { + return 0; + } + m_nSamples++; m_nInstruments++; Instruments[m_nInstruments] = pIns; @@ -423,14 +428,10 @@ pIns->nMidiProgram = nProgram; pIns->nMidiChannel = nChannel; if (nChannel == MIDI_DRUMCHANNEL) pIns->nMidiDrumKey = nNote; - pIns->nGlobalVol = 64; pIns->nFadeOut = 1024; - pIns->nPan = 128; - pIns->nPPC = 5*12; pIns->nNNA = NNA_NOTEOFF; pIns->nDCT = (nChannel == MIDI_DRUMCHANNEL) ? DCT_SAMPLE : DCT_NOTE; pIns->nDNA = DNA_NOTEFADE; - SetDefaultInstrumentValues(pIns); for (UINT j=0; j<NOTE_MAX; j++) { int mapnote = j+1; Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mt2.cpp 2011-09-04 19:12:08 UTC (rev 1021) +++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2011-09-05 01:07:40 UTC (rev 1022) @@ -401,19 +401,12 @@ MODINSTRUMENT *pIns = NULL; if (iIns <= m_nInstruments) { - pIns = new MODINSTRUMENT; + pIns = new MODINSTRUMENT(); Instruments[iIns] = pIns; if (pIns) { - memcpy(Instruments[iIns], &m_defaultInstrument, sizeof(MODINSTRUMENT)); memcpy(pIns->name, pmi->szName, 32); StringFixer::SpaceToNullStringFixed<31>(pIns->name); - pIns->nGlobalVol = 64; - pIns->nPan = 128; - for (BYTE i = 0; i < NOTE_MAX; i++) - { - pIns->NoteMap[i] = i+1; - } } } #ifdef MT2DEBUG Modified: trunk/OpenMPT/soundlib/Load_xm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_xm.cpp 2011-09-04 19:12:08 UTC (rev 1021) +++ trunk/OpenMPT/soundlib/Load_xm.cpp 2011-09-05 01:07:40 UTC (rev 1022) @@ -317,10 +317,7 @@ MemsetZero(pih); memcpy(&pih, lpStream + dwMemPos, min(sizeof(pih), ihsize)); - if ((Instruments[iIns] = new MODINSTRUMENT) == nullptr) continue; - memcpy(Instruments[iIns], &m_defaultInstrument, sizeof(MODINSTRUMENT)); - Instruments[iIns]->nPluginVelocityHandling = PLUGIN_VELOCITYHANDLING_CHANNEL; - Instruments[iIns]->nPluginVolumeHandling = PLUGIN_VOLUMEHANDLING_IGNORE; + if ((Instruments[iIns] = new MODINSTRUMENT()) == nullptr) continue; memcpy(Instruments[iIns]->name, pih.name, 22); StringFixer::SpaceToNullStringFixed<22>(Instruments[iIns]->name); @@ -436,11 +433,6 @@ MODINSTRUMENT *pIns = Instruments[iIns]; pIns->nMidiProgram = pih.type; pIns->nFadeOut = xmsh.volfade; - pIns->nPan = 128; - pIns->nPPC = 5*12; - SetDefaultInstrumentValues(pIns); - pIns->nPluginVelocityHandling = PLUGIN_VELOCITYHANDLING_CHANNEL; - pIns->nPluginVolumeHandling = PLUGIN_VOLUMEHANDLING_IGNORE; if (xmsh.vtype & 1) pIns->VolEnv.dwFlags |= ENV_ENABLED; if (xmsh.vtype & 2) pIns->VolEnv.dwFlags |= ENV_SUSTAIN; if (xmsh.vtype & 4) pIns->VolEnv.dwFlags |= ENV_LOOP; @@ -465,7 +457,6 @@ pIns->PanEnv.nLoopEnd = xmsh.ploope; if (pIns->PanEnv.nLoopEnd >= 12) pIns->PanEnv.nLoopEnd = 0; if (pIns->PanEnv.nLoopStart >= pIns->PanEnv.nLoopEnd) pIns->PanEnv.dwFlags &= ~ENV_LOOP; - pIns->nGlobalVol = 64; for (UINT ienv=0; ienv<12; ienv++) { pIns->VolEnv.Ticks[ienv] = (WORD)xmsh.venv[ienv*2]; Modified: trunk/OpenMPT/soundlib/Sampleio.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sampleio.cpp 2011-09-04 19:12:08 UTC (rev 1021) +++ trunk/OpenMPT/soundlib/Sampleio.cpp 2011-09-05 01:07:40 UTC (rev 1022) @@ -65,17 +65,10 @@ ) { // Loading Instrument - MODINSTRUMENT *pIns = new MODINSTRUMENT; - if (!pIns) return false; - MemsetZero(*pIns); - pIns->pTuning = pIns->s_DefaultTuning; - DestroyInstrument(nInstr, deleteAssociatedSamples); - - Instruments[nInstr] = pIns; // Scanning free sample - UINT nSample = 0; - for (UINT iscan=1; iscan<MAX_SAMPLES; iscan++) + SAMPLEINDEX nSample = 0; + for (SAMPLEINDEX iscan = 1; iscan < MAX_SAMPLES; iscan++) { if ((!Samples[iscan].pSample) && (!m_szNames[iscan][0])) { @@ -84,17 +77,16 @@ break; } } + + MODINSTRUMENT *pIns = new MODINSTRUMENT(nSample); + if (!pIns) return false; + + DestroyInstrument(nInstr, deleteAssociatedSamples); + + Instruments[nInstr] = pIns; + // Default values pIns->nFadeOut = 1024; - pIns->nGlobalVol = 64; - pIns->nPan = 128; - pIns->nPPC = 5*12; - SetDefaultInstrumentValues(pIns); - for (UINT iinit=0; iinit<128; iinit++) - { - pIns->Keyboard[iinit] = nSample; - pIns->NoteMap[iinit] = iinit+1; - } if (nSample) ReadSampleFromFile(nSample, lpMemFile, dwFileLength); return true; } @@ -198,7 +190,7 @@ DestroyInstrument(nInstr, deleteAssociatedSamples); - if (!Instruments[nInstr]) Instruments[nInstr] = new MODINSTRUMENT; + if (!Instruments[nInstr]) Instruments[nInstr] = new MODINSTRUMENT(); MODINSTRUMENT *pIns = Instruments[nInstr]; if (pIns) { @@ -876,21 +868,15 @@ DestroyInstrument(nInstr, deleteAssociatedSamples); - pIns = new MODINSTRUMENT; + pIns = new MODINSTRUMENT(); if (!pIns) return false; - MemsetZero(*pIns); - pIns->pTuning = pIns->s_DefaultTuning; + Instruments[nInstr] = pIns; nSamples = plh->samples; if (nSamples > 16) nSamples = 16; memcpy(pIns->name, pih->name, 16); pIns->name[16] = 0; pIns->nFadeOut = 2048; - pIns->nGlobalVol = 64; - pIns->nPan = 128; - pIns->nPPC = 60; - pIns->nResampling = SRCMODE_DEFAULT; - pIns->nFilterMode = FLTMODE_UNCHANGED; if (m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT)) { pIns->nNNA = NNA_NOTEOFF; @@ -1097,11 +1083,10 @@ DestroyInstrument(nInstr, deleteAssociatedSamples); - Instruments[nInstr] = new MODINSTRUMENT; + Instruments[nInstr] = new MODINSTRUMENT(); MODINSTRUMENT *pIns = Instruments[nInstr]; if (!pIns) return false; - memset(pIns, 0, sizeof(MODINSTRUMENT)); - pIns->pTuning = pIns->s_DefaultTuning; + memcpy(pIns->name, pxh->name, 22); nsamples = 0; for (UINT i=0; i<96; i++) @@ -1112,7 +1097,7 @@ nsamples++; if (nsamples > 32) nsamples = 32; // Allocate samples - memset(samplemap, 0, sizeof(samplemap)); + MemsetZero(samplemap); UINT nsmp = 1; for (UINT j=0; j<nsamples; j++) { @@ -1155,9 +1140,7 @@ pIns->PanEnv.nLoopEnd = pih->ploope; if (pIns->PanEnv.nLoopEnd >= 12) pIns->PanEnv.nLoopEnd = 0; if (pIns->PanEnv.nLoopStart >= pIns->PanEnv.nLoopEnd) pIns->PanEnv.dwFlags &= ~ENV_LOOP; - pIns->nGlobalVol = 64; - pIns->nPPC = 5*12; - SetDefaultInstrumentValues(pIns); + for (UINT ienv=0; ienv<12; ienv++) { pIns->VolEnv.Ticks[ienv] = (WORD)pih->venv[ienv*2]; @@ -1709,11 +1692,10 @@ DestroyInstrument(nInstr, deleteAssociatedSamples); - Instruments[nInstr] = new MODINSTRUMENT; + Instruments[nInstr] = new MODINSTRUMENT(); MODINSTRUMENT *pIns = Instruments[nInstr]; if (!pIns) return false; - MemsetZero(*pIns); - pIns->pTuning = pIns->s_DefaultTuning; + MemsetZero(samplemap); dwMemPos = 554; dwMemPos += ITInstrToMPT(pinstr, pIns, pinstr->trkvers); Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2011-09-04 19:12:08 UTC (rev 1021) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2011-09-05 01:07:40 UTC (rev 1022) @@ -371,15 +371,20 @@ STATIC_ASSERT(ENV_RELEASE_NODE_UNSET > MAX_ENVPOINTS); -enum { - CHANNEL_ONLY = 0, - INSTRUMENT_ONLY = 1, - PRIORITISE_INSTRUMENT = 2, - PRIORITISE_CHANNEL = 3, - EVEN_IF_MUTED = false, - RESPECT_MUTES = true, +enum PluginPriority +{ + ChannelOnly, + InstrumentOnly, + PrioritiseInstrument, + PrioritiseChannel, }; +enum PluginMutePriority +{ + EvenIfMuted, + RespectMutes, +}; + //Plugin velocity handling options enum PLUGVELOCITYHANDLING { Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-09-04 19:12:08 UTC (rev 1021) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-09-05 01:07:40 UTC (rev 1022) @@ -1218,7 +1218,7 @@ IMixPlugin *pPlugin = NULL; if (pChn->pModInstrument && pChn->pModInstrument->nMidiChannel > 0 && pChn->pModInstrument->nMidiChannel < 17 && pChn->nNote>0 && pChn->nNote<128) // instro sends to a midi chan { - PLUGINDEX nPlugin = GetBestPlugin(nChn, PRIORITISE_INSTRUMENT, RESPECT_MUTES); + PLUGINDEX nPlugin = GetBestPlugin(nChn, PrioritiseInstrument, RespectMutes); /* UINT nPlugin = 0; nPlugin = pChn->pModInstrument->nMixPlug; // first try intrument VST @@ -2202,8 +2202,8 @@ } -void CSoundFile::ResetChannelEnvelopes(MODCHANNEL* pChn) -//------------------------------------------------------ +void CSoundFile::ResetChannelEnvelopes(MODCHANNEL *pChn) const +//------------------------------------------------------------ { ResetChannelEnvelope(pChn->VolEnv); ResetChannelEnvelope(pChn->PanEnv); @@ -2211,8 +2211,8 @@ } -void CSoundFile::ResetChannelEnvelope(MODCHANNEL_ENVINFO &env) -//------------------------------------------------------------ +void CSoundFile::ResetChannelEnvelope(MODCHANNEL_ENVINFO &env) const +//------------------------------------------------------------------ { env.nEnvPosition = 0; env.nEnvValueAtReleaseJump = NOT_YET_RELEASED; @@ -3347,7 +3347,7 @@ } else if(macroCode == 0x03 && !isExtended) { // F0.F0.03.xx: Set plug dry/wet - const PLUGINDEX nPlug = (plugin != 0) ? plugin : GetBestPlugin(nChn, PRIORITISE_CHANNEL, EVEN_IF_MUTED); + const PLUGINDEX nPlug = (plugin != 0) ? plugin : GetBestPlugin(nChn, PrioritiseChannel, EvenIfMuted); if ((nPlug) && (nPlug <= MAX_MIXPLUGINS) && param < 0x80) { const float newRatio = 1.0 - (static_cast<float>(param & 0x7F) / 127.0f); @@ -3365,7 +3365,7 @@ } else if((macroCode & 0x80) || isExtended) { // F0.F0.{80|n}.xx / F0.F1.n.xx: Set VST effect parameter n to xx - const PLUGINDEX nPlug = (plugin != 0) ? plugin : GetBestPlugin(nChn, PRIORITISE_CHANNEL, EVEN_IF_MUTED); + const PLUGINDEX nPlug = (plugin != 0) ? plugin : GetBestPlugin(nChn, PrioritiseChannel, EvenIfMuted); const UINT plugParam = isExtended ? (0x80 + macroCode) : (macroCode & 0x7F); if((nPlug) && (nPlug <= MAX_MIXPLUGINS)) { @@ -3394,7 +3394,7 @@ const CHANNELINDEX nMasterCh = (nChn < GetNumChannels()) ? nChn + 1 : pChn->nMasterChn; if((nMasterCh) && (nMasterCh <= GetNumChannels())) { - const PLUGINDEX nPlug = (pChn->dwFlags & CHN_NOFX) ? 0 : ((plugin != 0) ? plugin : GetBestPlugin(nChn, PRIORITISE_CHANNEL, EVEN_IF_MUTED)); + const PLUGINDEX nPlug = (pChn->dwFlags & CHN_NOFX) ? 0 : ((plugin != 0) ? plugin : GetBestPlugin(nChn, PrioritiseChannel, EvenIfMuted)); if((nPlug) && (nPlug <= MAX_MIXPLUGINS)) { IMixPlugin *pPlugin = m_MixPlugins[nPlug - 1].pMixPlugin; @@ -4068,8 +4068,8 @@ } -PLUGINDEX CSoundFile::GetBestPlugin(CHANNELINDEX nChn, UINT priority, bool respectMutes) -//-------------------------------------------------------------------------------------- +PLUGINDEX CSoundFile::GetBestPlugin(CHANNELINDEX nChn, PluginPriority priority, PluginMutePriority respectMutes) const +//-------------------------------------------------------------------------------------------------------------------- { if (nChn >= MAX_CHANNELS) //Check valid channel number { @@ -4080,22 +4080,22 @@ PLUGINDEX nPlugin = 0; switch (priority) { - case CHANNEL_ONLY: + case ChannelOnly: nPlugin = GetChannelPlugin(nChn, respectMutes); break; - case INSTRUMENT_ONLY: + case InstrumentOnly: nPlugin = GetActiveInstrumentPlugin(nChn, respectMutes); break; - case PRIORITISE_INSTRUMENT: + case PrioritiseInstrument: nPlugin = GetActiveInstrumentPlugin(nChn, respectMutes); - if ((!nPlugin) || (nPlugin>MAX_MIXPLUGINS)) + if ((!nPlugin) || (nPlugin > MAX_MIXPLUGINS)) { nPlugin = GetChannelPlugin(nChn, respectMutes); } break; - case PRIORITISE_CHANNEL: + case PrioritiseChannel: nPlugin = GetChannelPlugin(nChn, respectMutes); - if ((!nPlugin) || (nPlugin>MAX_MIXPLUGINS)) + if ((!nPlugin) || (nPlugin > MAX_MIXPLUGINS)) { nPlugin = GetActiveInstrumentPlugin(nChn, respectMutes); } @@ -4106,8 +4106,8 @@ } -PLUGINDEX __cdecl CSoundFile::GetChannelPlugin(CHANNELINDEX nChn, bool respectMutes) const -//---------------------------------------------------------------------------------------- +PLUGINDEX __cdecl CSoundFile::GetChannelPlugin(CHANNELINDEX nChn, PluginMutePriority respectMutes) const +//------------------------------------------------------------------------------------------------------ { const MODCHANNEL *pChn = &Chn[nChn]; @@ -4120,7 +4120,7 @@ } UINT nPlugin; - if ( (respectMutes && (pChn->dwFlags & CHN_MUTE)) || (pChn->dwFlags&CHN_NOFX) ) + if ( (respectMutes == RespectMutes && (pChn->dwFlags & CHN_MUTE)) || (pChn->dwFlags&CHN_NOFX) ) { nPlugin = 0; } else @@ -4131,8 +4131,8 @@ } -PLUGINDEX CSoundFile::GetActiveInstrumentPlugin(CHANNELINDEX nChn, bool respectMutes) const -//----------------------------------------------------------------------------------------- +PLUGINDEX CSoundFile::GetActiveInstrumentPlugin(CHANNELINDEX nChn, PluginMutePriority respectMutes) const +//------------------------------------------------------------------------------------------------------- { const MODCHANNEL *pChn = &Chn[nChn]; // Unlike channel settings, pModInstrument is copied from the original chan to the NNA chan, @@ -4141,7 +4141,7 @@ UINT nPlugin=0; if (pChn && pChn->pModInstrument) { - if (respectMutes && pChn->pModSample && (pChn->pModSample->uFlags & CHN_MUTE)) + if (respectMutes == RespectMutes && pChn->pModSample && (pChn->pModSample->uFlags & CHN_MUTE)) { nPlugin = 0; } else Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2011-09-04 19:12:08 UTC (rev 1021) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2011-09-05 01:07:40 UTC (rev 1022) @@ -359,7 +359,7 @@ break; // Return a pointer on the wanted field in 'input' MODINSTRUMENT given field code & size -BYTE * GetInstrumentHeaderFieldPointer(const MODINSTRUMENT * input, __int32 fcode, __int16 fsize) +BYTE * GetInstrumentHeaderFieldPointer(const MODINSTRUMENT *input, __int32 fcode, __int16 fsize) { if(input == NULL) return NULL; BYTE * pointer = NULL; @@ -500,8 +500,6 @@ m_pConfig = new CSoundFilePlayConfig(); m_pTuningsTuneSpecific = new CTuningCollection("Tune specific tunings"); - - BuildDefaultInstrument(); } @@ -2661,28 +2659,6 @@ //end rewbs.plugDocAware -void CSoundFile::BuildDefaultInstrument() -//--------------------------------------- -{ -// m_defaultInstrument is currently only used to get default values for extented properties. -// In the future we can make better use of this. - MemsetZero(m_defaultInstrument); - m_defaultInstrument.nResampling = SRCMODE_DEFAULT; - m_defaultInstrument.nFilterMode = FLTMODE_UNCHANGED; - m_defaultInstrument.nPPC = 5 * 12; - m_defaultInstrument.nGlobalVol = 64; - m_defaultInstrument.nPan = 32 * 4; - //m_defaultInstrument.nIFC = 0xFF; - m_defaultInstrument.PanEnv.nReleaseNode=ENV_RELEASE_NODE_UNSET; - m_defaultInstrument.PitchEnv.nReleaseNode=ENV_RELEASE_NODE_UNSET; - m_defaultInstrument.VolEnv.nReleaseNode=ENV_RELEASE_NODE_UNSET; - m_defaultInstrument.wPitchToTempoLock = 0; - m_defaultInstrument.pTuning = m_defaultInstrument.s_DefaultTuning; - m_defaultInstrument.nPluginVelocityHandling = PLUGIN_VELOCITYHANDLING_CHANNEL; - m_defaultInstrument.nPluginVolumeHandling = CSoundFile::s_DefaultPlugVolumeHandling; -} - - void CSoundFile::DeleteStaticdata() //--------------------------------- { @@ -2762,22 +2738,6 @@ } - -void CSoundFile::SetDefaultInstrumentValues(MODINSTRUMENT *pIns) -//-------------------------------------------------------------- -{ - pIns->nResampling = m_defaultInstrument.nResampling; - pIns->nFilterMode = m_defaultInstrument.nFilterMode; - pIns->PitchEnv.nReleaseNode = m_defaultInstrument.PitchEnv.nReleaseNode; - pIns->PanEnv.nReleaseNode = m_defaultInstrument.PanEnv.nReleaseNode; - pIns->VolEnv.nReleaseNode = m_defaultInstrument.VolEnv.nReleaseNode; - pIns->pTuning = m_defaultInstrument.pTuning; - pIns->nPluginVelocityHandling = m_defaultInstrument.nPluginVelocityHandling; - pIns->nPluginVolumeHandling = m_defaultInstrument.nPluginVolumeHandling; - -} - - long CSoundFile::GetSampleOffset() //-------------------------------- { Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2011-09-04 19:12:08 UTC (rev 1021) +++ trunk/OpenMPT/soundlib/Sndfile.h 2011-09-05 01:07:40 UTC (rev 1022) @@ -94,6 +94,17 @@ BYTE nSustainStart; // sustain start node BYTE nSustainEnd; // sustain end node BYTE nReleaseNode; // release node + + INSTRUMENTENVELOPE() + { + dwFlags = 0; + MemsetZero(Ticks); + MemsetZero(Values); + nNodes = 0; + nLoopStart = nLoopEnd = 0; + nSustainStart = nSustainEnd = 0; + nReleaseNode = ENV_RELEASE_NODE_UNSET; + } }; // Instrument Struct @@ -123,6 +134,7 @@ BYTE nMidiProgram; // MIDI program BYTE nMidiChannel; // MIDI channel BYTE nMidiDrumKey; // Drum set note mapping (currently only used by the .MID loader) + signed char nPPS; //Pitch/Pan separation (i.e. how wide the panning spreads) unsigned char nPPC; //Pitch/Pan centre @@ -153,8 +165,52 @@ pTuning = pT; } - + MODINSTRUMENT(SAMPLEINDEX sample = 0) + { + nFadeOut = 256; + dwFlags = 0; + nGlobalVol = 64; + nPan = 32 * 4; + for(size_t n = 0; n < CountOf(Keyboard); n++) + { + Keyboard[n] = (WORD)sample; + NoteMap[n] = (BYTE)(n + 1); + } + + nNNA = NNA_NOTECUT; + nDCT = DCT_NONE; + nDNA = DNA_NOTECUT; + + nPanSwing = 0; + nVolSwing = 0; + nIFC = 0; + nIFR = 0; + + wMidiBank = 0; + nMidiProgram = 0; + nMidiChannel = 0; + nMidiDrumKey = 0; + + nPPC = NOTE_MIDDLEC - 1; + nPPS = 0; + + MemsetZero(name); + MemsetZero(filename); + + nMixPlug = 0; + nVolRamp = 0; + nResampling = SRCMODE_DEFAULT; + nCutSwing = 0; + nResSwing = 0; + nFilterMode = FLTMODE_UNCHANGED; + wPitchToTempoLock = 0; + nPluginVelocityHandling = PLUGIN_VELOCITYHANDLING_CHANNEL; + nPluginVolumeHandling = PLUGIN_VOLUMEHANDLING_IGNORE; + + pTuning = s_DefaultTuning; + } + }; //MODINSTRUMENT; @@ -673,7 +729,6 @@ MODSAMPLE Samples[MAX_SAMPLES]; // Sample Headers public: MODINSTRUMENT *Instruments[MAX_INSTRUMENTS]; // Instrument Headers - MODINSTRUMENT m_defaultInstrument; // Currently only used to get default values for extented properties. CHAR m_szNames[MAX_SAMPLES][MAX_SAMPLENAME]; // Song and sample names MODMIDICFG m_MidiCfg; // Midi macro config table SNDMIXPLUGIN m_MixPlugins[MAX_MIXPLUGINS]; // Mix plugins @@ -1083,20 +1138,18 @@ public: int GetVolEnvValueFromPosition(int position, const MODINSTRUMENT* pIns) const; - void ResetChannelEnvelopes(MODCHANNEL *pChn); - void ResetChannelEnvelope(MODCHANNEL_ENVINFO &env); - void SetDefaultInstrumentValues(MODINSTRUMENT *pIns); + void ResetChannelEnvelopes(MODCHANNEL *pChn) const; + void ResetChannelEnvelope(MODCHANNEL_ENVINFO &env) const; private: - PLUGINDEX __cdecl GetChannelPlugin(CHANNELINDEX nChn, bool respectMutes) const; - PLUGINDEX __cdecl GetActiveInstrumentPlugin(CHANNELINDEX, bool respectMutes) const; + PLUGINDEX __cdecl GetChannelPlugin(CHANNELINDEX nChn, PluginMutePriority respectMutes) const; + PLUGINDEX __cdecl GetActiveInstrumentPlugin(CHANNELINDEX, PluginMutePriority respectMutes) const; UINT GetBestMidiChan(const MODCHANNEL *pChn) const; void HandlePatternTransitionEvents(); - void BuildDefaultInstrument(); long GetSampleOffset(); public: - PLUGINDEX GetBestPlugin(CHANNELINDEX nChn, UINT priority, bool respectMutes); + PLUGINDEX GetBestPlugin(CHANNELINDEX nChn, PluginPriority priority, PluginMutePriority respectMutes) const; // A couple of functions for handling backwards jumps and stuff to prevent infinite loops when counting the mod length or rendering to wav. public: Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2011-09-04 19:12:08 UTC (rev 1021) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2011-09-05 01:07:40 UTC (rev 1022) @@ -2391,7 +2391,7 @@ // Check instrument plugins if ((pIns->nMidiChannel >= 1) && (pIns->nMidiChannel <= 16)) { - nPlugin = GetBestPlugin(nChn, PRIORITISE_INSTRUMENT, RESPECT_MUTES); + nPlugin = GetBestPlugin(nChn, PrioritiseInstrument, RespectMutes); if ((nPlugin) && (nPlugin <= MAX_MIXPLUGINS)) { pPlugin = m_MixPlugins[nPlugin-1].pMixPlugin; Modified: trunk/OpenMPT/soundlib/load_j2b.cpp =================================================================== --- trunk/OpenMPT/soundlib/load_j2b.cpp 2011-09-04 19:12:08 UTC (rev 1021) +++ trunk/OpenMPT/soundlib/load_j2b.cpp 2011-09-05 01:07:40 UTC (rev 1022) @@ -361,7 +361,6 @@ if(flags & AMENV_SUSTAIN) pMPTEnv->dwFlags |= ENV_SUSTAIN; if(flags & AMENV_LOOP) pMPTEnv->dwFlags |= ENV_LOOP; - pMPTEnv->nReleaseNode = ENV_RELEASE_NODE_UNSET; pMPTEnv->nNodes = min(numpoints, 10); // the buggy mod2j2b converter will actually NOT limit this to 10 points if the envelope is longer. pMPTEnv->nSustainStart = pMPTEnv->nSustainEnd = sustainpoint; @@ -402,7 +401,6 @@ if(flags & AMENV_SUSTAIN) pMPTEnv->dwFlags |= ENV_SUSTAIN; if(flags & AMENV_LOOP) pMPTEnv->dwFlags |= ENV_LOOP; - pMPTEnv->nReleaseNode = ENV_RELEASE_NODE_UNSET; pMPTEnv->nNodes = min(pAMEnv->numpoints + 1, 10); pMPTEnv->nSustainStart = pMPTEnv->nSustainEnd = pAMEnv->suslooppoint; @@ -551,12 +549,10 @@ if(Instruments[nIns] != nullptr) delete Instruments[nIns]; - MODINSTRUMENT *pIns = new MODINSTRUMENT; + MODINSTRUMENT *pIns = new MODINSTRUMENT(); if(pIns == nullptr) break; Instruments[nIns] = pIns; - MemsetZero(*pIns); - SetDefaultInstrumentValues(pIns); m_nInstruments = max(m_nInstruments, nIns); @@ -565,7 +561,6 @@ for(BYTE i = 0; i < 128; i++) { - pIns->NoteMap[i] = i + 1; pIns->Keyboard[i] = instheader->samplemap[i] + m_nSamples + 1; } @@ -662,12 +657,10 @@ if(Instruments[nIns] != nullptr) delete Instruments[nIns]; - MODINSTRUMENT *pIns = new MODINSTRUMENT; + MODINSTRUMENT *pIns = new MODINSTRUMENT(); if(pIns == nullptr) break; Instruments[nIns] = pIns; - MemsetZero(*pIns); - SetDefaultInstrumentValues(pIns); m_nInstruments = max(m_nInstruments, nIns); @@ -676,14 +669,10 @@ for(BYTE i = 0; i < 128; i++) { - pIns->NoteMap[i] = i + 1; pIns->Keyboard[i] = instheader->samplemap[i] + m_nSamples + 1; } - pIns->nGlobalVol = 64; - pIns->nPan = 128; pIns->nFadeOut = LittleEndianW(instheader->volenv.fadeout) << 5; - pIns->nPPC = NOTE_MIDDLEC - 1; Convert_RIFF_AM_Envelope(&instheader->volenv, &pIns->VolEnv, ENV_VOLUME); Convert_RIFF_AM_Envelope(&instheader->pitchenv, &pIns->PitchEnv, ENV_PITCH); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-05 14:39:37
|
Revision: 1023 http://modplug.svn.sourceforge.net/modplug/?rev=1023&view=rev Author: saga-games Date: 2011-09-05 14:39:30 +0000 (Mon, 05 Sep 2011) Log Message: ----------- [Fix] IT/MPTM saver broke when merging SaveIT and SaveCompatIT (tx jmkz) [Mod] OpenMPT: Version is now 1.20.00.19 Modified Paths: -------------- trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/Load_it.cpp Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-09-05 01:07:40 UTC (rev 1022) +++ trunk/OpenMPT/mptrack/version.h 2011-09-05 14:39:30 UTC (rev 1023) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 18 +#define VER_MINORMINOR 19 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2011-09-05 01:07:40 UTC (rev 1022) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2011-09-05 14:39:30 UTC (rev 1023) @@ -1360,7 +1360,6 @@ ITSAMPLESTRUCT itss; vector<bool>smpcount(GetNumSamples(), false); DWORD dwPos = 0, dwHdrPos = 0, dwExtra = 0; - WORD patinfo[4]; FILE *f; @@ -1694,11 +1693,6 @@ { DWORD dwPatPos = dwPos; if (!Patterns[npat]) continue; - patpos[npat] = dwPos; - patinfo[0] = 0; - patinfo[1] = Patterns[npat].GetNumRows(); - patinfo[2] = 0; - patinfo[3] = 0; if(Patterns[npat].GetOverrideSignature()) bNeedsMptPatSave = true; @@ -1710,18 +1704,29 @@ continue; } + patpos[npat] = dwPos; + + // Write pattern header + WORD patinfo[4]; + patinfo[0] = 0; + patinfo[1] = LittleEndianW(Patterns[npat].GetNumRows()); + patinfo[2] = 0; + patinfo[3] = 0; + fwrite(patinfo, 8, 1, f); dwPos += 8; - vector<BYTE> chnmask(specs.channelsMax, 0xFF); - vector<MODCOMMAND> lastvalue(specs.channelsMax, MODCOMMAND::Empty()); - for (UINT row = 0; row<Patterns[npat].GetNumRows(); row++) + const CHANNELINDEX maxChannels = min(specs.channelsMax, GetNumChannels()); + vector<BYTE> chnmask(maxChannels, 0xFF); + vector<MODCOMMAND> lastvalue(maxChannels, MODCOMMAND::Empty()); + + for (ROWINDEX row = 0; row<Patterns[npat].GetNumRows(); row++) { UINT len = 0; BYTE buf[8 * MAX_BASECHANNELS]; const MODCOMMAND *m = Patterns[npat].GetRow(row); - for (UINT ch = 0; ch < specs.channelsMax; ch++, m++) + for (CHANNELINDEX ch = 0; ch < maxChannels; ch++, m++) { // Skip mptm-specific notes. if(m->IsPcNote()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-06 16:04:07
|
Revision: 1025 http://modplug.svn.sourceforge.net/modplug/?rev=1025&view=rev Author: saga-games Date: 2011-09-06 16:03:56 +0000 (Tue, 06 Sep 2011) Log Message: ----------- [Ref] Moved envelope flags from channel flags to MODCHANNEL_ENVINFO. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/View_ins.cpp trunk/OpenMPT/mptrack/View_ins.h trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2011-09-06 12:23:23 UTC (rev 1024) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2011-09-06 16:03:56 UTC (rev 1025) @@ -1076,17 +1076,16 @@ && (pChn->pModInstrument) && (pChn->pModInstrument == m_pSndFile->Instruments[nIns]) && ((!(pChn->dwFlags & CHN_NOTEFADE)) || (pChn->nFadeOutVol))) { + MODCHANNEL_ENVINFO *env = &pChn->VolEnv; if (m_dwNotifyType & MPTNOTIFY_PITCHENV) { - if (pChn->dwFlags & CHN_PITCHENV) p->dwPos[k] = MPTNOTIFY_POSVALID | (DWORD)(pChn->PitchEnv.nEnvPosition); - } else - if (m_dwNotifyType & MPTNOTIFY_PANENV) + env = &pChn->PitchEnv; + } else if (m_dwNotifyType & MPTNOTIFY_PANENV) { - if (pChn->dwFlags & CHN_PANENV) p->dwPos[k] = MPTNOTIFY_POSVALID | (DWORD)(pChn->PanEnv.nEnvPosition); - } else - { - if (pChn->dwFlags & CHN_VOLENV) p->dwPos[k] = MPTNOTIFY_POSVALID | (DWORD)(pChn->VolEnv.nEnvPosition); + env = &pChn->PanEnv; } + + if (env->flags & ENV_ENABLED) p->dwPos[k] = MPTNOTIFY_POSVALID | (DWORD)(env->nEnvPosition); } } } else Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2011-09-06 12:23:23 UTC (rev 1024) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2011-09-06 16:03:56 UTC (rev 1025) @@ -945,7 +945,7 @@ pChn->nPos = pChn->nPosLo = pChn->nLength = 0; pChn->nLoopStart = sample.nLoopStart; pChn->nLoopEnd = sample.nLoopEnd; - pChn->dwFlags = sample.uFlags & (0xFF & ~CHN_MUTE); + pChn->dwFlags = sample.uFlags & (CHN_SAMPLEFLAGS & ~CHN_MUTE); pChn->nPan = 128; if (sample.uFlags & CHN_PANNING) pChn->nPan = sample.nPan; pChn->nInsVol = sample.nGlobalVol; Modified: trunk/OpenMPT/mptrack/View_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_ins.cpp 2011-09-06 12:23:23 UTC (rev 1024) +++ trunk/OpenMPT/mptrack/View_ins.cpp 2011-09-06 16:03:56 UTC (rev 1025) @@ -540,31 +540,81 @@ } -bool CViewInstrument::EnvToggleEnv(INSTRUMENTENVELOPE *pEnv, CSoundFile *pSndFile, MODINSTRUMENT *pIns, bool bEnable, BYTE cDefaultValue, DWORD dwChanFlag, DWORD dwExtraFlags) -//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +bool CViewInstrument::EnvToggleEnv(enmEnvelopeTypes envelope, CSoundFile *pSndFile, MODINSTRUMENT *pIns, bool enable, BYTE defaultValue, DWORD extraFlags) +//-------------------------------------------------------------------------------------------------------------------------------------------------------- { - if(pEnv == nullptr) return false; + if(pIns == nullptr || pSndFile == nullptr) + { + return false; + } - if (bEnable) + INSTRUMENTENVELOPE *env; + + switch(envelope) { - pEnv->dwFlags |= (ENV_ENABLED|dwExtraFlags); - if (!pEnv->nNodes) + case ENV_VOLUME: + default: + env = &pIns->VolEnv; + break; + case ENV_PANNING: + env = &pIns->PanEnv; + break; + case ENV_PITCH: + env = &pIns->PitchEnv; + break; + } + + const DWORD flags = (ENV_ENABLED | extraFlags); + + if (enable) + { + env->dwFlags |= flags; + if(!env->nNodes) { - pEnv->Values[0] = pEnv->Values[1] = cDefaultValue; - pEnv->Ticks[0] = 0; - pEnv->Ticks[1] = 10; - pEnv->nNodes = 2; + env->Values[0] = env->Values[1] = defaultValue; + env->Ticks[0] = 0; + env->Ticks[1] = 10; + env->nNodes = 2; InvalidateRect(NULL, FALSE); } } else { - pEnv->dwFlags &= ~(ENV_ENABLED|dwExtraFlags); - for(CHANNELINDEX nChn = 0; nChn < MAX_CHANNELS; nChn++) + env->dwFlags &= ~flags; + } + + CriticalSection cs; + + // Update mixing flags... + for(CHANNELINDEX nChn = 0; nChn < MAX_CHANNELS; nChn++) + { + if(pSndFile->Chn[nChn].pModInstrument == pIns) { - if(pSndFile->Chn[nChn].pModInstrument == pIns) - pSndFile->Chn[nChn].dwFlags &= ~dwChanFlag; + MODCHANNEL_ENVINFO *envInfo; + + switch(envelope) + { + case ENV_VOLUME: + default: + envInfo = &pSndFile->Chn[nChn].VolEnv; + break; + case ENV_PANNING: + envInfo = &pSndFile->Chn[nChn].PanEnv; + break; + case ENV_PITCH: + envInfo = &pSndFile->Chn[nChn].PitchEnv; + break; + } + + if(enable) + { + envInfo->flags |= flags; + } else + { + envInfo->flags &= ~flags; + } } } + return true; } @@ -576,7 +626,7 @@ if(pIns == nullptr) return false; CSoundFile *pSndFile = GetDocument()->GetSoundFile(); // security checks are done in GetInstrumentPtr() - return EnvToggleEnv(&pIns->VolEnv, pSndFile, pIns, bEnable, 64, CHN_VOLENV); + return EnvToggleEnv(ENV_VOLUME, pSndFile, pIns, bEnable, 64); } @@ -587,7 +637,7 @@ if(pIns == nullptr) return false; CSoundFile *pSndFile = GetDocument()->GetSoundFile(); // security checks are done in GetInstrumentPtr() - return EnvToggleEnv(&pIns->PanEnv, pSndFile, pIns, bEnable, 32, CHN_PANENV); + return EnvToggleEnv(ENV_PANNING, pSndFile, pIns, bEnable, 32); } @@ -599,7 +649,7 @@ CSoundFile *pSndFile = GetDocument()->GetSoundFile(); // security checks are done in GetInstrumentPtr() pIns->PitchEnv.dwFlags &= ~ENV_FILTER; - return EnvToggleEnv(&pIns->PitchEnv, pSndFile, pIns, bEnable, 32, CHN_PITCHENV); + return EnvToggleEnv(ENV_PITCH, pSndFile, pIns, bEnable, 32); } @@ -610,8 +660,7 @@ if(pIns == nullptr) return false; CSoundFile *pSndFile = GetDocument()->GetSoundFile(); // security checks are done in GetInstrumentPtr() - pIns->PitchEnv.dwFlags &= ~ENV_FILTER; - return EnvToggleEnv(&pIns->PitchEnv, pSndFile, pIns, bEnable, 64, CHN_PITCHENV, ENV_FILTER); + return EnvToggleEnv(ENV_PITCH, pSndFile, pIns, bEnable, 64, ENV_FILTER); } @@ -1135,11 +1184,11 @@ { if (m_dwNotifyPos[i]) { - memset(m_dwNotifyPos, 0, sizeof(m_dwNotifyPos)); + MemsetZero(m_dwNotifyPos); InvalidateEnvelope(); break; } - memset(m_baPlayingNote, 0, sizeof(bool)*NOTE_MAX); //rewbs.instViewNNA + MemsetZero(m_baPlayingNote); //rewbs.instViewNNA m_nPlayingChannel = CHANNELINDEX_INVALID; //rewbs.instViewNNA } } else Modified: trunk/OpenMPT/mptrack/View_ins.h =================================================================== --- trunk/OpenMPT/mptrack/View_ins.h 2011-09-06 12:23:23 UTC (rev 1024) +++ trunk/OpenMPT/mptrack/View_ins.h 2011-09-06 16:03:56 UTC (rev 1025) @@ -91,7 +91,7 @@ bool EnvToggleReleaseNode(int nPoint); // Set envelope status - bool EnvToggleEnv(INSTRUMENTENVELOPE *pEnv, CSoundFile *pSndFile, MODINSTRUMENT *pIns, bool bEnable, BYTE cDefaultValue, DWORD dwChanFlag, DWORD dwExtraFlags = 0); + bool EnvToggleEnv(enmEnvelopeTypes envelope, CSoundFile *pSndFile, MODINSTRUMENT *pIns, bool enable, BYTE defaultValue, DWORD extraFlags = 0); bool EnvSetVolEnv(bool bEnable); bool EnvSetPanEnv(bool bEnable); bool EnvSetPitchEnv(bool bEnable); Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2011-09-06 12:23:23 UTC (rev 1024) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2011-09-06 16:03:56 UTC (rev 1025) @@ -151,17 +151,13 @@ #define CHN_PANBRELLO 0x40000 // apply panbrello #define CHN_PORTAMENTO 0x80000 // apply portamento #define CHN_GLISSANDO 0x100000 // glissando mode -#define CHN_VOLENV 0x200000 // volume envelope is active -#define CHN_PANENV 0x400000 // pan envelope is active -#define CHN_PITCHENV 0x800000 // pitch envelope is active -#define CHN_FASTVOLRAMP 0x1000000 // ramp volume very fast -#define CHN_EXTRALOUD 0x2000000 // force master volume to 0x100 -#define CHN_REVERB 0x4000000 // apply reverb -#define CHN_NOREVERB 0x8000000 // forbid reverb -#define CHN_SOLO 0x10000000 // solo channel -> CODE#0012 -> DESC="midi keyboard split" -! NEW_FEATURE#0012 -#define CHN_NOFX 0x20000000 // dry channel -> CODE#0015 -> DESC="channels management dlg" -! NEW_FEATURE#0015 -#define CHN_SYNCMUTE 0x40000000 // keep sample sync on mute -#define CHN_FILTERENV 0x80000000 // force pitch envelope to act as filter envelope +#define CHN_FASTVOLRAMP 0x200000 // ramp volume very fast +#define CHN_EXTRALOUD 0x400000 // force master volume to 0x100 +#define CHN_REVERB 0x800000 // apply reverb +#define CHN_NOREVERB 0x1000000 // forbid reverb +#define CHN_SOLO 0x2000000 // solo channel -> CODE#0012 -> DESC="midi keyboard split" -! NEW_FEATURE#0012 +#define CHN_NOFX 0x4000000 // dry channel -> CODE#0015 -> DESC="channels management dlg" -! NEW_FEATURE#0015 +#define CHN_SYNCMUTE 0x8000000 // keep sample sync on mute #define CHN_SAMPLEFLAGS (CHN_16BIT|CHN_LOOP|CHN_PINGPONGLOOP|CHN_SUSTAINLOOP|CHN_PINGPONGSUSTAIN|CHN_PANNING|CHN_STEREO|CHN_PINGPONGFLAG) #define CHN_CHANNELFLAGS (~CHN_SAMPLEFLAGS) Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-09-06 12:23:23 UTC (rev 1024) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-09-06 16:03:56 UTC (rev 1025) @@ -667,7 +667,7 @@ pChn->dwFlags = (pChn->dwFlags & (CHN_CHANNELFLAGS | CHN_PINGPONGFLAG)) | (pSmp->uFlags & CHN_SAMPLEFLAGS); } else { - pChn->dwFlags &= ~(CHN_KEYOFF|CHN_NOTEFADE|CHN_VOLENV|CHN_PANENV|CHN_PITCHENV); + pChn->dwFlags &= ~(CHN_KEYOFF|CHN_NOTEFADE); //IT compatibility tentative fix: Don't change bidi loop direction when //no sample nor instrument is changed. @@ -679,18 +679,13 @@ if (pIns) { - if (pIns->VolEnv.dwFlags & ENV_ENABLED) pChn->dwFlags |= CHN_VOLENV; - if (pIns->PanEnv.dwFlags & ENV_ENABLED) pChn->dwFlags |= CHN_PANENV; - if (pIns->PitchEnv.dwFlags & ENV_ENABLED) pChn->dwFlags |= CHN_PITCHENV; + // Copy envelope flags (we actually only need the "enabled" and "pitch" flag) + pChn->VolEnv.flags = pIns->VolEnv.dwFlags; + pChn->PanEnv.flags = pIns->PanEnv.dwFlags; + pChn->PitchEnv.flags = pIns->PitchEnv.dwFlags; if ((pIns->PitchEnv.dwFlags & ENV_ENABLED) && (pIns->PitchEnv.dwFlags & ENV_FILTER)) { - pChn->dwFlags |= CHN_FILTERENV; if (!pChn->nCutOff) pChn->nCutOff = 0x7F; - } else - { - // Special case: Reset filter envelope flag manually (because of S7D/S7E effects). - // This way, the S7x effects can be applied to several notes, as long as they don't come with an instrument number. - pChn->dwFlags &= ~CHN_FILTERENV; } if (pIns->nIFC & 0x80) pChn->nCutOff = pIns->nIFC & 0x7F; if (pIns->nIFR & 0x80) pChn->nResonance = pIns->nIFR & 0x7F; @@ -2072,9 +2067,9 @@ if (pChn->pModInstrument) { MODINSTRUMENT *pIns = pChn->pModInstrument; - if ((pChn->dwFlags & CHN_PANENV) && (pIns->PanEnv.nNodes) && (param > pIns->PanEnv.Ticks[pIns->PanEnv.nNodes-1])) + if ((pChn->PanEnv.flags & ENV_ENABLED) && (pIns->PanEnv.nNodes) && (param > pIns->PanEnv.Ticks[pIns->PanEnv.nNodes - 1])) { - pChn->dwFlags &= ~CHN_PANENV; + pChn->PanEnv.flags &= ~ENV_ENABLED; } } } @@ -2924,23 +2919,23 @@ case 4: pChn->nNNA = NNA_CONTINUE; break; case 5: pChn->nNNA = NNA_NOTEOFF; break; case 6: pChn->nNNA = NNA_NOTEFADE; break; - case 7: pChn->dwFlags &= ~CHN_VOLENV; break; - case 8: pChn->dwFlags |= CHN_VOLENV; break; - case 9: pChn->dwFlags &= ~CHN_PANENV; break; - case 10: pChn->dwFlags |= CHN_PANENV; break; - case 11: pChn->dwFlags &= ~CHN_PITCHENV; break; - case 12: pChn->dwFlags |= CHN_PITCHENV; break; + case 7: pChn->VolEnv.flags &= ~ENV_ENABLED; break; + case 8: pChn->VolEnv.flags |= ENV_ENABLED; break; + case 9: pChn->PanEnv.flags &= ~ENV_ENABLED; break; + case 10: pChn->PanEnv.flags |= ENV_ENABLED; break; + case 11: pChn->PitchEnv.flags &= ~ENV_ENABLED; break; + case 12: pChn->PitchEnv.flags |= ENV_ENABLED; break; case 13: case 14: if(GetType() == MOD_TYPE_MPT) { - pChn->dwFlags |= CHN_PITCHENV; + pChn->PitchEnv.flags |= ENV_ENABLED; if(param == 13) // pitch env on, filter env off { - pChn->dwFlags &= ~CHN_FILTERENV; + pChn->PitchEnv.flags &= ~ENV_FILTER; } else // filter env on { - pChn->dwFlags |= CHN_FILTERENV; + pChn->PitchEnv.flags |= ENV_FILTER; } } break; @@ -3723,7 +3718,7 @@ const bool bKeyOn = (pChn->dwFlags & CHN_KEYOFF) ? false : true; pChn->dwFlags |= CHN_KEYOFF; //if ((!pChn->pModInstrument) || (!(pChn->dwFlags & CHN_VOLENV))) - if ((pChn->pModInstrument) && (!(pChn->dwFlags & CHN_VOLENV))) + if ((pChn->pModInstrument) && (!(pChn->VolEnv.flags & ENV_ENABLED))) { pChn->dwFlags |= CHN_NOTEFADE; } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2011-09-06 12:23:23 UTC (rev 1024) +++ trunk/OpenMPT/soundlib/Sndfile.h 2011-09-06 16:03:56 UTC (rev 1025) @@ -231,6 +231,7 @@ struct MODCHANNEL_ENVINFO { DWORD nEnvPosition; + DWORD flags; LONG nEnvValueAtReleaseJump; }; Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2011-09-06 12:23:23 UTC (rev 1024) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2011-09-06 16:03:56 UTC (rev 1025) @@ -1014,7 +1014,7 @@ // IT Compatibility: S77 does not disable the volume envelope, it just pauses the counter // Problem: This pauses on the wrong tick at the moment... - if (((pChn->dwFlags & CHN_VOLENV) || ((pIns->VolEnv.dwFlags & ENV_ENABLED) && IsCompatibleMode(TRK_IMPULSETRACKER))) && (pIns->VolEnv.nNodes)) + if (((pChn->VolEnv.flags & ENV_ENABLED) || ((pIns->VolEnv.dwFlags & ENV_ENABLED) && IsCompatibleMode(TRK_IMPULSETRACKER))) && (pIns->VolEnv.nNodes)) { int envvol = GetVolEnvValueFromPosition(pChn->VolEnv.nEnvPosition, pIns); @@ -1050,7 +1050,7 @@ // IT Compatibility: S79 does not disable the panning envelope, it just pauses the counter // Problem: This pauses on the wrong tick at the moment... - if (((pChn->dwFlags & CHN_PANENV) || ((pIns->PanEnv.dwFlags & ENV_ENABLED) && IsCompatibleMode(TRK_IMPULSETRACKER))) && (pIns->PanEnv.nNodes)) + if (((pChn->PanEnv.flags & ENV_ENABLED) || ((pIns->PanEnv.dwFlags & ENV_ENABLED) && IsCompatibleMode(TRK_IMPULSETRACKER))) && (pIns->PanEnv.nNodes)) { int envpos = pChn->PanEnv.nEnvPosition; UINT pt = pIns->PanEnv.nNodes - 1; @@ -1104,7 +1104,7 @@ // IT Compatibility: S7B does not disable the pitch envelope, it just pauses the counter // Problem: This pauses on the wrong tick at the moment... - if ((pIns) && ((pChn->dwFlags & CHN_PITCHENV) || ((pIns->PitchEnv.dwFlags & ENV_ENABLED) && IsCompatibleMode(TRK_IMPULSETRACKER))) && (pChn->pModInstrument->PitchEnv.nNodes)) + if ((pIns) && ((pChn->PitchEnv.flags & ENV_ENABLED) || ((pIns->PitchEnv.dwFlags & ENV_ENABLED) && IsCompatibleMode(TRK_IMPULSETRACKER))) && (pChn->pModInstrument->PitchEnv.nNodes)) { int envpos = pChn->PitchEnv.nEnvPosition; UINT pt = pIns->PitchEnv.nNodes - 1; @@ -1140,7 +1140,7 @@ envpitch = CLAMP(envpitch, -256, 256); //if (pIns->PitchEnv.dwFlags & ENV_FILTER) - if (pChn->dwFlags & CHN_FILTERENV) + if (pChn->PitchEnv.flags & ENV_FILTER) { // Filter Envelope: controls cutoff frequency #ifndef NO_FILTER @@ -1184,7 +1184,7 @@ { const MODINSTRUMENT *pIns = pChn->pModInstrument; - if (pChn->dwFlags & CHN_VOLENV) + if (pChn->VolEnv.flags & ENV_ENABLED) { // Increase position pChn->VolEnv.nEnvPosition++; @@ -1232,7 +1232,7 @@ { const MODINSTRUMENT *pIns = pChn->pModInstrument; - if (pChn->dwFlags & CHN_PANENV) + if (pChn->PanEnv.flags & ENV_ENABLED) { pChn->PanEnv.nEnvPosition++; if (pIns->PanEnv.dwFlags & ENV_LOOP) @@ -1262,7 +1262,7 @@ { const MODINSTRUMENT *pIns = pChn->pModInstrument; - if (pChn->dwFlags & CHN_PITCHENV) + if (pChn->PitchEnv.flags & ENV_ENABLED) { // Increase position pChn->PitchEnv.nEnvPosition++; @@ -2426,7 +2426,7 @@ //If new note, determine notevelocity to use. - if(note) + if(note != NOTE_NONE) { UINT velocity = 4*defaultVolume; switch(pIns->nPluginVelocityHandling) @@ -2437,7 +2437,7 @@ } MODCOMMAND::NOTE realNote = note; - if((note >= NOTE_MIN) && (note <= NOTE_MAX)) + if(NOTE_IS_VALID(note)) realNote = pIns->NoteMap[note - 1]; // Experimental VST panning //ProcessMIDIMacro(nChn, false, m_MidiCfg.szMidiGlb[MIDIOUT_PAN], 0, nPlugin); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-08 20:16:01
|
Revision: 1029 http://modplug.svn.sourceforge.net/modplug/?rev=1029&view=rev Author: saga-games Date: 2011-09-08 20:15:53 +0000 (Thu, 08 Sep 2011) Log Message: ----------- [Fix] IT Loader: Envelope points with the high byte missing are now loaded correctly. [Imp] IT Loader: Most files saved with early "compatiblity export" are not detected as MPT 1.16 files anymore. [Mod] OpenMPT: Version is now 1.20.00.20 Modified Paths: -------------- trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_xm.cpp Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-09-07 22:48:23 UTC (rev 1028) +++ trunk/OpenMPT/mptrack/version.h 2011-09-08 20:15:53 UTC (rev 1029) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 19 +#define VER_MINORMINOR 20 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2011-09-07 22:48:23 UTC (rev 1028) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2011-09-08 20:15:53 UTC (rev 1029) @@ -33,7 +33,7 @@ MPTM version history for cwtv-field in "IT" header (only for MPTM files!): 0x890(1.18.02.00) -> 0x891(1.19.00.00): Pattern-specific time signatures Fixed behaviour of Pattern Loop command for rows > 255 (r617) -0x88F(1.18.01.00) -> 0x890(1.18.02.00): Removed volume command velocity :xy, added delay-cut command :xy. +0x88F(1.18.01.00) -> 0x890(1.18.02.00): Removed volume command velocity :xy, added delay-cut command :xy. 0x88E(1.17.02.50) -> 0x88F(1.18.01.00): Numerous changes 0x88D(1.17.02.49) -> 0x88E(1.17.02.50): Changed ID to that of IT and undone the orderlist change done in 0x88A->0x88B. Now extended orderlist is saved as extension. @@ -67,7 +67,7 @@ //tuning name <-> tuning id number map, //and then writing the tuning id for every instrument. //For example if there are 6 instruments and - //first half use tuning 'T1', and the other half + //first half use tuning 'T1', and the other half //tuning 'T2', the output would be something like //T1 1 T2 2 1 1 1 2 2 2 @@ -75,14 +75,14 @@ typedef map<CTuning*, uint16> TNTS_MAP; typedef TNTS_MAP::iterator TNTS_MAP_ITER; TNTS_MAP tNameToShort_Map; - + unsigned short figMap = 0; for(UINT i = 1; i <= sf.GetNumInstruments(); i++) if (sf.Instruments[i] != nullptr) { TNTS_MAP_ITER iter = tNameToShort_Map.find(sf.Instruments[i]->pTuning); if(iter != tNameToShort_Map.end()) continue; //Tuning already mapped. - + tNameToShort_Map[sf.Instruments[i]->pTuning] = figMap; figMap++; } @@ -202,7 +202,7 @@ csf.GetpModDoc()->SetModified(); //The tuning is changed so the modified flag is set. } #endif // MODPLUG_TRACKER - + } csf.Instruments[i]->pTuning = csf.Instruments[i]->s_DefaultTuning; @@ -231,10 +231,10 @@ // Impulse Tracker IT file support -static inline UINT ConvertVolParam(UINT value) -//-------------------------------------------- +UINT ConvertVolParam(const MODCOMMAND *m) +//--------------------------------------- { - return (value > 9) ? 9 : value; + return min(m->vol, 9); } @@ -291,6 +291,19 @@ { mptEnv->Values[ev] = itEnv->data[ev * 3] + envOffset; mptEnv->Ticks[ev] = (itEnv->data[ev * 3 + 2] << 8) | (itEnv->data[ev * 3 + 1]); + if(ev > 0 && ev < itEnv->num && mptEnv->Ticks[ev] < mptEnv->Ticks[ev - 1]) + { + // Fix broken envelopes... Instruments 2 and 3 in NoGap.it by Werewolf have envelope points where the high byte of envelope nodes is missing. + // NoGap.it was saved with MPT 1.07 or MPT 1.09, which *normally* doesn't do this in IT files. + // However... It turns out that MPT 1.07 omitted the high byte of envelope nodes when saving an XI instrument file, and it looks like + // Instrument 2 and 3 in NoGap.it were loaded from XI files. + mptEnv->Ticks[ev] &= 0xFF; + mptEnv->Ticks[ev] |= (mptEnv->Ticks[ev] & ~0xFF); + if(mptEnv->Ticks[ev] < mptEnv->Ticks[ev - 1]) + { + mptEnv->Ticks[ev] += 0x100; + } + } } // Sanitize envelope mptEnv->Ticks[0] = 0; @@ -300,7 +313,7 @@ //BOOL CSoundFile::ITInstrToMPT(const void *p, MODINSTRUMENT *pIns, UINT trkvers) long CSoundFile::ITInstrToMPT(const void *p, MODINSTRUMENT *pIns, UINT trkvers) //rewbs.modularInstData //----------------------------------------------------------------------------- -{ +{ // Envelope point count. Limited to 25 in IT format. const int iEnvMax = (m_nType & MOD_TYPE_MPT) ? MAX_ENVPOINTS : 25; @@ -357,7 +370,7 @@ { //(handle old format where midichan // and mixplug are 1 value) pIns->nMixPlug = pIns->nMidiChannel-128; - pIns->nMidiChannel = 0; + pIns->nMidiChannel = 0; } if (pis->mbank<=128) pIns->wMidiBank = pis->mbank; @@ -381,7 +394,7 @@ pIns->Keyboard[k] |= ((UINT)pisex->keyboardhi[k] << 8); } } - //rewbs.modularInstData + //rewbs.modularInstData //find end of standard header BYTE* pEndInstHeader; if (*((int *)pis->dummy) == 'MPTX') @@ -394,7 +407,7 @@ { //...the next piece of data must be the total size of the modular data long modularInstSize = *((long *)(pEndInstHeader+4)); - + //handle chunks BYTE* pModularInst = (BYTE*)(pEndInstHeader+4+sizeof(modularInstSize)); //4 is for 'INSM' pEndInstHeader+=4+sizeof(modularInstSize)+modularInstSize; @@ -427,12 +440,12 @@ } //end rewbs.modularInstData - - // Volume Envelope + + // Volume Envelope ITEnvToMPT(&pis->volenv, &pIns->VolEnv, 0, iEnvMax); - // Panning Envelope + // Panning Envelope ITEnvToMPT(&pis->panenv, &pIns->PanEnv, 32, iEnvMax); - // Pitch Envelope + // Pitch Envelope ITEnvToMPT(&pis->pitchenv, &pIns->PitchEnv, 32, iEnvMax); if (pis->pitchenv.flags & 0x80) pIns->PitchEnv.dwFlags |= ENV_FILTER; @@ -536,8 +549,16 @@ m_dwLastSavedWithVersion = MAKE_VERSION_NUMERIC(1, 17, 00, 00); } else if(pifh->cwtv == 0x0217 && pifh->cmwt == 0x0200 && pifh->reserved == 0) { - // ModPlug Tracker 1.16 (semi-raped IT format) - m_dwLastSavedWithVersion = MAKE_VERSION_NUMERIC(1, 16, 00, 00); + if(memchr(pifh->chnpan, 0xFF, sizeof(pifh->chnpan)) != NULL) + { + // ModPlug Tracker 1.16 (semi-raped IT format) + m_dwLastSavedWithVersion = MAKE_VERSION_NUMERIC(1, 16, 00, 00); + } else + { + // OpenMPT 1.17 disguised as this in compatible mode, + // but never writes 0xFF in the pan map for unused channels (which is an invalid value). + m_dwLastSavedWithVersion = MAKE_VERSION_NUMERIC(1, 17, 00, 00); + } interpretModPlugMade = true; } else if(pifh->cwtv == 0x0214 && pifh->cmwt == 0x0202 && pifh->reserved == 0) { @@ -559,7 +580,7 @@ if (GetpModDoc()) GetpModDoc()->AddToLog(str_LoadingIncompatibleVersion); return false; - } + } else if (pifh->cwtv > verMptFileVer) { if (GetpModDoc()) @@ -567,7 +588,7 @@ } } } - + if(GetType() == MOD_TYPE_IT) mptStartPos = dwMemLength; // Read row highlights @@ -606,7 +627,7 @@ m_nSamplePreAmp = min(pifh->mv, 128); // Reading Channels Pan Positions - for (int ipan=0; ipan</*MAX_BASECHANNELS*/64; ipan++) if (pifh->chnpan[ipan] != 0xFF) //Header only has room for settings for 64 chans... + for (int ipan=0; ipan< 64; ipan++) if (pifh->chnpan[ipan] != 0xFF) { ChnSettings[ipan].nVolume = pifh->chnvol[ipan]; ChnSettings[ipan].nPan = 128; @@ -648,7 +669,7 @@ if(pifh->cwtv > 0x88A && pifh->cwtv <= 0x88D) dwMemPos += Order.Deserialize(lpStream+dwMemPos, dwMemLength-dwMemPos); else - { + { Order.ReadAsByte(lpStream + dwMemPos, nordsize, dwMemLength - dwMemPos); dwMemPos += pifh->ordnum; //Replacing 0xFF and 0xFE with new corresponding indexes @@ -845,15 +866,15 @@ } } // Read mix plugins information - if (dwMemPos + 8 < dwMemLength) + if (dwMemPos + 8 < dwMemLength) { dwMemPos += LoadMixPlugins(lpStream+dwMemPos, dwMemLength-dwMemPos); } - + //UINT npatterns = pifh->patnum; UINT npatterns = patpos.size(); - - if (npatterns > GetModSpecifications().patternsMax) + + if (npatterns > GetModSpecifications().patternsMax) npatterns = GetModSpecifications().patternsMax; // Checking for unused channels @@ -861,7 +882,7 @@ { memset(chnmask, 0, sizeof(chnmask)); - if ((!patpos[patchk]) || ((DWORD)patpos[patchk] >= dwMemLength - 4)) + if ((!patpos[patchk]) || ((DWORD)patpos[patchk] >= dwMemLength - 4)) continue; UINT len = *((WORD *)(lpStream+patpos[patchk])); @@ -873,16 +894,16 @@ hasModPlugExtensions = true; } - if ((rows < GetModSpecifications().patternRowsMin) || (rows > GetModSpecifications().patternRowsMax)) + if ((rows < GetModSpecifications().patternRowsMin) || (rows > GetModSpecifications().patternRowsMax)) continue; - if (patpos[patchk]+8+len > dwMemLength) + if (patpos[patchk]+8+len > dwMemLength) continue; UINT i = 0; const BYTE *p = lpStream+patpos[patchk]+8; UINT nrow = 0; - + while (nrow<rows) { if (i >= len) break; @@ -894,13 +915,13 @@ } UINT ch = b & IT_bitmask_patternChanField_c; // 0x7f We have some data grab a byte keeping only 7 bits - if (ch) + if (ch) ch = (ch - 1);// & IT_bitmask_patternChanMask_c; // 0x3f mask of the byte again, keeping only 6 bits if (b & IT_bitmask_patternChanEnabled_c) // 0x80 check if the upper bit is enabled. { - if (i >= len) - break; + if (i >= len) + break; chnmask[ch] = p[i++]; // set the channel mask for this channel. } // Channel used @@ -913,7 +934,7 @@ // -! BEHAVIOUR_CHANGE#0006 } // Now we actually update the pattern-row entry the note,instrument etc. - // Note + // Note if (chnmask[ch] & 1) i++; // Instrument if (chnmask[ch] & 2) i++; @@ -1044,7 +1065,7 @@ LPCBYTE ptr = LoadExtendedInstrumentProperties(lpStream + dwMemPos, lpStream + mptStartPos, &interpretModPlugMade); LoadExtendedSongProperties(GetType(), ptr, lpStream, mptStartPos, &interpretModPlugMade); } - + // -! NEW_FEATURE#0027 @@ -1054,7 +1075,7 @@ { if ((!patpos[npat]) || ((DWORD)patpos[npat] >= dwMemLength - 4)) { - if(Patterns.Insert(npat, 64)) + if(Patterns.Insert(npat, 64)) { #ifdef MODPLUG_TRACKER CString s; @@ -1093,21 +1114,21 @@ m+=m_nChannels; continue; } - + UINT ch = b & IT_bitmask_patternChanField_c; // 0x7f - + if (ch) ch = (ch - 1); //& IT_bitmask_patternChanMask_c; // 0x3f - + if (b & IT_bitmask_patternChanEnabled_c) // 0x80 { - if (i >= len) + if (i >= len) break; chnmask[ch] = p[i++]; } // Now we grab the data for this particular row/channel. - + if ((chnmask[ch] & 0x10) && (ch < m_nChannels)) { m[ch].note = lastvalue[ch].note; @@ -1178,7 +1199,7 @@ if ((vol >= 193) && (vol <= 202)) { m[ch].volcmd = VOLCMD_TONEPORTAMENTO; m[ch].vol = vol - 193; } else // 203-212: Vibrato depth if ((vol >= 203) && (vol <= 212)) - { + { m[ch].volcmd = VOLCMD_VIBRATODEPTH; m[ch].vol = vol - 203; // Old versions of ModPlug saved this as vibrato speed instead, so let's fix that if(m_dwLastSavedWithVersion && m_dwLastSavedWithVersion <= MAKE_VERSION_NUMERIC(1, 17, 02, 54)) @@ -1291,7 +1312,7 @@ uint16 fnum = 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 - + if(f == nullptr) return bytes_written; @@ -1418,7 +1439,7 @@ break; } } - + if(!compatExport) { // This way, we indicate that the file will most likely contain OpenMPT hacks. Compatibility export puts 0 here. @@ -1443,7 +1464,7 @@ memset(header.chnpan, 0xA0, 64); memset(header.chnvol, 64, 64); - for (size_t ich = 0; ich < 64; ich++) //Header only has room for settings for 64 chans... + for (size_t ich = 0; ich < min(m_nChannels, 64); ich++) // Header only has room for settings for 64 chans... { header.chnpan[ich] = ChnSettings[ich].nPan >> 2; if (ChnSettings[ich].dwFlags & CHN_SURROUND) header.chnpan[ich] = 100; @@ -1583,7 +1604,7 @@ iti.mch = pIns->nMixPlug + 128; } iti.nna = pIns->nNNA; - iti.dct = (pIns->nDCT < DCT_PLUGIN || !compatExport) ? pIns->nDCT : 0; + iti.dct = (pIns->nDCT < DCT_PLUGIN || !compatExport) ? pIns->nDCT : 0; iti.dca = pIns->nDNA; iti.fadeout = min(pIns->nFadeOut >> 5, 256); iti.pps = pIns->nPPS; @@ -1645,7 +1666,7 @@ fwrite(&ModInstID, 1, sizeof(ModInstID), f); // mark this as an instrument with modular extensions long sizePos = ftell(f); // we will want to write the modular data's total size here fwrite(&modularInstSize, 1, sizeof(modularInstSize), f); // write a DUMMY size, just to move file pointer by a long - + //Write chunks UINT ID; { //VST Slot chunk: @@ -1660,7 +1681,7 @@ ID='MYID'; fwrite(&ID, 1, sizeof(int), f); instModularDataSize+=sizeof(int); - + //You can save your chunk size somwhere here if you need variable chunk size. fwrite(myData, 1, myDataSize, f); instModularDataSize+=myDataSize; @@ -1671,8 +1692,8 @@ fseek(f, sizePos, SEEK_SET); // go back to sizePos fwrite(&modularInstSize, 1, sizeof(modularInstSize), f); // write data fseek(f, curPos, SEEK_SET); // go back to where we were. - - //move forward + + //move forward dwPos+=sizeof(ModInstID)+sizeof(modularInstSize)+modularInstSize; } //------------ end rewbs.modularInstData @@ -1751,25 +1772,25 @@ { case VOLCMD_VOLUME: vol = m->vol; if (vol > 64) vol = 64; break; case VOLCMD_PANNING: vol = m->vol + 128; if (vol > 192) vol = 192; break; - case VOLCMD_VOLSLIDEUP: vol = 85 + ConvertVolParam(m->vol); break; - case VOLCMD_VOLSLIDEDOWN: vol = 95 + ConvertVolParam(m->vol); break; - case VOLCMD_FINEVOLUP: vol = 65 + ConvertVolParam(m->vol); break; - case VOLCMD_FINEVOLDOWN: vol = 75 + ConvertVolParam(m->vol); break; - case VOLCMD_VIBRATODEPTH: vol = 203 + ConvertVolParam(m->vol); break; + case VOLCMD_VOLSLIDEUP: vol = 85 + ConvertVolParam(m); break; + case VOLCMD_VOLSLIDEDOWN: vol = 95 + ConvertVolParam(m); break; + case VOLCMD_FINEVOLUP: vol = 65 + ConvertVolParam(m); break; + case VOLCMD_FINEVOLDOWN: vol = 75 + ConvertVolParam(m); break; + case VOLCMD_VIBRATODEPTH: vol = 203 + ConvertVolParam(m); break; case VOLCMD_VIBRATOSPEED: if(command == CMD_NONE) { // illegal command -> move if possible command = CMD_VIBRATO; - param = ConvertVolParam(m->vol) << 4; + param = ConvertVolParam(m) << 4; } else { vol = 203; } break; - case VOLCMD_TONEPORTAMENTO: vol = 193 + ConvertVolParam(m->vol); break; - case VOLCMD_PORTADOWN: vol = 105 + ConvertVolParam(m->vol); break; - case VOLCMD_PORTAUP: vol = 115 + ConvertVolParam(m->vol); break; - case VOLCMD_OFFSET: if(!compatExport) vol = 223 + ConvertVolParam(m->vol); //rewbs.volOff + case VOLCMD_TONEPORTAMENTO: vol = 193 + ConvertVolParam(m); break; + case VOLCMD_PORTADOWN: vol = 105 + ConvertVolParam(m); break; + case VOLCMD_PORTAUP: vol = 115 + ConvertVolParam(m); break; + case VOLCMD_OFFSET: if(!compatExport) vol = 223 + ConvertVolParam(m); //rewbs.volOff break; default: vol = 0xFF; } @@ -1792,7 +1813,7 @@ b |= 0x10; } else { - lastvalue[ch].note = note; + lastvalue[ch].note = note; lastvalue[ch].volcmd |= 1; } } @@ -1890,7 +1911,7 @@ itss.id = LittleEndian(IT_IMPS); itss.gvl = (BYTE)sample.nGlobalVol; - + UINT flags = RS_PCM8S; if(sample.nLength && sample.pSample) { @@ -1972,7 +1993,7 @@ fclose(f); return true; } - + //hack //BEGIN: MPT SPECIFIC: //-------------------- @@ -2252,13 +2273,13 @@ { nPluginSize += p->nPluginDataSize; } - + // rewbs.modularPlugData DWORD MPTxPlugDataSize = 4 + (sizeof(m_MixPlugins[i].fDryRatio)) + //4 for ID and size of dryRatio 4 + (sizeof(m_MixPlugins[i].defaultProgram)); //rewbs.plugDefaultProgram // for each extra entity, add 4 for ID, plus size of entity, plus optionally 4 for size of entity. - nPluginSize += MPTxPlugDataSize+4; //+4 is for size itself: sizeof(DWORD) is 4 + nPluginSize += MPTxPlugDataSize+4; //+4 is for size itself: sizeof(DWORD) is 4 // rewbs.modularPlugData if (f) { @@ -2268,7 +2289,7 @@ s[2] = '0' + (i/10); s[3] = '0' + (i%10); fwrite(s, 1, 4, f); - + // write plugin size: fwrite(&nPluginSize, 1, 4, f); fwrite(&p->Info, 1, sizeof(SNDMIXPLUGININFO), f); @@ -2276,7 +2297,7 @@ if (m_MixPlugins[i].pPluginData) { fwrite(m_MixPlugins[i].pPluginData, 1, m_MixPlugins[i].nPluginDataSize, f); } - + //rewbs.dryRatio fwrite(&MPTxPlugDataSize, 1, 4, f); @@ -2344,7 +2365,7 @@ nPluginSize = *(DWORD *)(p + nPos + 4); if (nPluginSize > nLen - nPos - 8) break; - + // Channel FX if (!memcmp(p + nPos, "CHFX", 4)) { @@ -2366,7 +2387,7 @@ //data for VST setchunk? size lies just after standard plugin data. DWORD dwExtra = *(DWORD *)(p+nPos+8+sizeof(SNDMIXPLUGININFO)); - + if ((dwExtra) && (dwExtra <= nPluginSize-sizeof(SNDMIXPLUGININFO)-4)) { m_MixPlugins[nPlugin].nPluginDataSize = 0; @@ -2380,7 +2401,7 @@ //rewbs.modularPlugData DWORD dwXPlugData = *(DWORD *)(p+nPos+8+sizeof(SNDMIXPLUGININFO)+dwExtra+4); //read next DWORD into dwMPTExtra - + //if dwMPTExtra is positive and there are dwMPTExtra bytes left in nPluginSize, we have some more data! if ((dwXPlugData) && ((int)dwXPlugData <= (int)nPluginSize-(int)(sizeof(SNDMIXPLUGININFO)+dwExtra+8))) { @@ -2433,7 +2454,7 @@ } -// Used only when saving IT, XM and MPTM. +// Used only when saving IT, XM and MPTM. // ITI, ITP saves using Ericus' macros etc... // The reason is that ITs and XMs save [code][size][ins1.Value][ins2.Value]... // whereas ITP saves [code][size][ins1.Value][code][size][ins2.Value]... @@ -2448,13 +2469,13 @@ }*/ code = 'MPTX'; // write extension header code - fwrite(&code, 1, sizeof(__int32), f); + fwrite(&code, 1, sizeof(__int32), f); if (nInstruments == 0) return; MODINSTRUMENT *sizeIns = new MODINSTRUMENT(); - + WriteInstrumentPropertyForAllInstruments('VR..', sizeof(sizeIns->nVolRamp), f, nInstruments); WriteInstrumentPropertyForAllInstruments('MiP.', sizeof(sizeIns->nMixPlug), f, nInstruments); WriteInstrumentPropertyForAllInstruments('MC..', sizeof(sizeIns->nMidiChannel),f, nInstruments); @@ -2517,7 +2538,7 @@ { pField = GetInstrumentHeaderFieldPointer(Instruments[nins], code, size); //get ptr to field } else - { + { MODINSTRUMENT *emptyInstrument = new MODINSTRUMENT(); pField = GetInstrumentHeaderFieldPointer(emptyInstrument, code, size); //get ptr to field delete emptyInstrument; @@ -2533,32 +2554,32 @@ __int16 size; __int32 code = 'MPTS'; //Extra song file data fwrite(&code, 1, sizeof(__int32), f); - + code = 'DT..'; //write m_nDefaultTempo field code - fwrite(&code, 1, sizeof(__int32), f); + fwrite(&code, 1, sizeof(__int32), f); size = sizeof(m_nDefaultTempo); //write m_nDefaultTempo field size fwrite(&size, 1, sizeof(__int16), f); fwrite(&m_nDefaultTempo, 1, size, f); //write m_nDefaultTempo code = 'RPB.'; //write m_nRowsPerBeat - fwrite(&code, 1, sizeof(__int32), f); + fwrite(&code, 1, sizeof(__int32), f); size = sizeof(m_nDefaultRowsPerBeat); fwrite(&size, 1, sizeof(__int16), f); fwrite(&m_nDefaultRowsPerBeat, 1, size, f); code = 'RPM.'; //write m_nRowsPerMeasure - fwrite(&code, 1, sizeof(__int32), f); + fwrite(&code, 1, sizeof(__int32), f); size = sizeof(m_nDefaultRowsPerMeasure); fwrite(&size, 1, sizeof(__int16), f); fwrite(&m_nDefaultRowsPerMeasure, 1, size, f); - code = 'C...'; //write m_nChannels - fwrite(&code, 1, sizeof(__int32), f); - size = sizeof(m_nChannels); + code = 'C...'; //write m_nChannels + fwrite(&code, 1, sizeof(__int32), f); + size = sizeof(m_nChannels); fwrite(&size, 1, sizeof(__int16), f); - fwrite(&m_nChannels, 1, size, f); + fwrite(&m_nChannels, 1, size, f); - if(TypeIsIT_MPT() && m_nChannels > 64) //IT header has room only for 64 channels. Save the + if(TypeIsIT_MPT() && m_nChannels > 64) //IT header has room only for 64 channels. Save the { //settings that do not fit to the header here as an extension. code = 'ChnS'; fwrite(&code, 1, sizeof(__int32), f); @@ -2574,64 +2595,64 @@ fwrite(&panvol, sizeof(panvol), 1, f); } } - + code = 'TM..'; //write m_nTempoMode - fwrite(&code, 1, sizeof(__int32), f); - size = sizeof(m_nTempoMode); + fwrite(&code, 1, sizeof(__int32), f); + size = sizeof(m_nTempoMode); fwrite(&size, 1, sizeof(__int16), f); - fwrite(&m_nTempoMode, 1, size, f); + fwrite(&m_nTempoMode, 1, size, f); code = 'PMM.'; //write m_nMixLevels - fwrite(&code, 1, sizeof(__int32), f); - size = sizeof(m_nMixLevels); + fwrite(&code, 1, sizeof(__int32), f); + size = sizeof(m_nMixLevels); fwrite(&size, 1, sizeof(__int16), f); - fwrite(&m_nMixLevels, 1, size, f); + fwrite(&m_nMixLevels, 1, size, f); code = 'CWV.'; //write m_dwCreatedWithVersion - fwrite(&code, 1, sizeof(__int32), f); - size = sizeof(m_dwCreatedWithVersion); + fwrite(&code, 1, sizeof(__int32), f); + size = sizeof(m_dwCreatedWithVersion); fwrite(&size, 1, sizeof(__int16), f); - fwrite(&m_dwCreatedWithVersion, 1, size, f); + fwrite(&m_dwCreatedWithVersion, 1, size, f); code = 'LSWV'; //write m_dwLastSavedWithVersion - fwrite(&code, 1, sizeof(__int32), f); - size = sizeof(m_dwLastSavedWithVersion); + fwrite(&code, 1, sizeof(__int32), f); + size = sizeof(m_dwLastSavedWithVersion); fwrite(&size, 1, sizeof(__int16), f); - fwrite(&m_dwLastSavedWithVersion, 1, size, f); + fwrite(&m_dwLastSavedWithVersion, 1, size, f); code = 'SPA.'; //write m_nSamplePreAmp - fwrite(&code, 1, sizeof(__int32), f); - size = sizeof(m_nSamplePreAmp); + fwrite(&code, 1, sizeof(__int32), f); + size = sizeof(m_nSamplePreAmp); fwrite(&size, 1, sizeof(__int16), f); - fwrite(&m_nSamplePreAmp, 1, size, f); + fwrite(&m_nSamplePreAmp, 1, size, f); code = 'VSTV'; //write m_nVSTiVolume - fwrite(&code, 1, sizeof(__int32), f); - size = sizeof(m_nVSTiVolume); + fwrite(&code, 1, sizeof(__int32), f); + size = sizeof(m_nVSTiVolume); fwrite(&size, 1, sizeof(__int16), f); - fwrite(&m_nVSTiVolume, 1, size, f); + fwrite(&m_nVSTiVolume, 1, size, f); code = 'DGV.'; //write m_nDefaultGlobalVolume - fwrite(&code, 1, sizeof(__int32), f); - size = sizeof(m_nDefaultGlobalVolume); + fwrite(&code, 1, sizeof(__int32), f); + size = sizeof(m_nDefaultGlobalVolume); fwrite(&size, 1, sizeof(__int16), f); - fwrite(&m_nDefaultGlobalVolume, 1, size, f); + fwrite(&m_nDefaultGlobalVolume, 1, size, f); code = 'RP..'; //write m_nRestartPos - fwrite(&code, 1, sizeof(__int32), f); - size = sizeof(m_nRestartPos); + fwrite(&code, 1, sizeof(__int32), f); + size = sizeof(m_nRestartPos); fwrite(&size, 1, sizeof(__int16), f); fwrite(&m_nRestartPos, 1, size, f); //Additional flags for XM/IT/MPTM - if(m_ModFlags) + if(m_ModFlags) { code = 'MSF.'; - fwrite(&code, 1, sizeof(__int32), f); - size = sizeof(m_ModFlags); + fwrite(&code, 1, sizeof(__int32), f); + size = sizeof(m_ModFlags); fwrite(&size, 1, sizeof(__int16), f); - fwrite(&m_ModFlags, 1, size, f); + fwrite(&m_ModFlags, 1, size, f); } //MIMA, MIDI mapping directives @@ -2654,8 +2675,8 @@ GetMIDIMapper().Serialize(f); } } - + return; } @@ -2682,11 +2703,11 @@ ptr += sizeof(int32); // jump extension header code while( ptr < pEnd && uintptr_t(pEnd-ptr) >= 4) //Loop 'till beginning of end of file/mpt specific looking for inst. extensions - { + { memcpy(&code, ptr, sizeof(code)); // read field code if (code == 'MPTS') //Reached song extensions, break out of this loop return ptr; - + ptr += sizeof(code); // jump field code if((uintptr_t)(pEnd - ptr) < 2) @@ -2723,9 +2744,9 @@ int32 code = 0; int16 size = 0; - + memcpy(&code, ptr, sizeof(code)); - + if(code != 'MPTS') return; @@ -2736,7 +2757,7 @@ // HACK: Reset mod flags to default values here, as they are not always written. m_ModFlags = 0; - // Case macros. + // Case macros. #define CASE(id, data) \ case id: fadr = reinterpret_cast<BYTE*>(&data); nMaxReadCount = min(size, sizeof(data)); break; #define CASE_NOTXM(id, data) \ @@ -2744,7 +2765,7 @@ ptr += sizeof(code); // jump extension header code while( uintptr_t(ptr - lpStream) <= searchlimit-6 ) //Loop until given limit. - { + { code = (*((int32 *)ptr)); // read field code ptr += sizeof(int32); // jump field code size = (*((int16 *)ptr)); // read field size @@ -2772,7 +2793,7 @@ CASE_NOTXM('RP..', m_nRestartPos); CASE('MSF.', m_ModFlags); case 'MIMA': GetMIDIMapper().Deserialize(ptr, size); break; - case 'ChnS': + case 'ChnS': if( (size <= 63*2) && (size % 2 == 0) ) { const BYTE* pData = ptr; @@ -2817,4 +2838,3 @@ #undef CASE #undef CASE_NOTXM } - Modified: trunk/OpenMPT/soundlib/Load_xm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_xm.cpp 2011-09-07 22:48:23 UTC (rev 1028) +++ trunk/OpenMPT/soundlib/Load_xm.cpp 2011-09-08 20:15:53 UTC (rev 1029) @@ -463,17 +463,19 @@ pIns->VolEnv.Values[ienv] = (BYTE)xmsh.venv[ienv*2+1]; pIns->PanEnv.Ticks[ienv] = (WORD)xmsh.penv[ienv*2]; pIns->PanEnv.Values[ienv] = (BYTE)xmsh.penv[ienv*2+1]; - if (ienv) + if (ienv > 0) { // libmikmod code says: "Some broken XM editing program will only save the low byte of the position // value. Try to compensate by adding the missing high byte" - I guess that's what this code is for. - if (pIns->VolEnv.Ticks[ienv] < pIns->VolEnv.Ticks[ienv-1]) + // Note: It appears that MPT 1.07's XI instrument saver omitted the high byte of envelope nodes. + // This might be the source for some broken envelopes in IT and XM files. + if (pIns->VolEnv.Ticks[ienv] < pIns->VolEnv.Ticks[ienv - 1]) { pIns->VolEnv.Ticks[ienv] &= 0xFF; pIns->VolEnv.Ticks[ienv] += pIns->VolEnv.Ticks[ienv - 1] & 0xFF00; if (pIns->VolEnv.Ticks[ienv] < pIns->VolEnv.Ticks[ienv - 1]) pIns->VolEnv.Ticks[ienv] += 0x100; } - if (pIns->PanEnv.Ticks[ienv] < pIns->PanEnv.Ticks[ienv-1]) + if (pIns->PanEnv.Ticks[ienv] < pIns->PanEnv.Ticks[ienv - 1]) { pIns->PanEnv.Ticks[ienv] &= 0xFF; pIns->PanEnv.Ticks[ienv] += pIns->PanEnv.Ticks[ienv - 1] & 0xFF00; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-17 15:42:45
|
Revision: 1034 http://modplug.svn.sourceforge.net/modplug/?rev=1034&view=rev Author: saga-games Date: 2011-09-17 15:42:37 +0000 (Sat, 17 Sep 2011) Log Message: ----------- [Mod] Volume ramp up and ramp down are now two different settings (patch by xaimus) Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/MPTHacks.cpp trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/Mpdlgs.h trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/resource.h trunk/OpenMPT/mptrack/test/test.cpp trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-09-11 18:52:20 UTC (rev 1033) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-09-17 15:42:37 UTC (rev 1034) @@ -1304,7 +1304,7 @@ // -> CODE#0027 // -> DESC="per-instrument volume ramping setup (refered as attack)" // Volume ramping (attack) - int n = pIns->nVolRamp; //? MAX_ATTACK_LENGTH - pIns->nVolRamp : 0; + int n = pIns->nVolRampUp; //? MAX_ATTACK_LENGTH - pIns->nVolRampUp : 0; m_SliderAttack.SetPos(n); if(n == 0) SetDlgItemText(IDC_EDIT2,"default"); else SetDlgItemInt(IDC_EDIT2,n); @@ -2160,9 +2160,9 @@ if(n > MAX_ATTACK_VALUE) n = MAX_ATTACK_VALUE; int newRamp = n; //? MAX_ATTACK_LENGTH - n : 0; - if(pIns->nVolRamp != newRamp) + if(pIns->nVolRampUp != newRamp) { - pIns->nVolRamp = newRamp; + pIns->nVolRampUp = newRamp; SetInstrumentModified(true); } @@ -2343,12 +2343,13 @@ // -> CODE#0027 // -> DESC="per-instrument volume ramping setup (refered as attack)" // Volume ramping (attack) - if (pSlider==&m_SliderAttack) { + if (pSlider==&m_SliderAttack) + { n = m_SliderAttack.GetPos(); int newRamp = n; //? MAX_ATTACK_LENGTH - n : 0; - if(pIns->nVolRamp != newRamp) + if(pIns->nVolRampUp != newRamp) { - pIns->nVolRamp = newRamp; + pIns->nVolRampUp = newRamp; SetDlgItemInt(IDC_EDIT2,n); SetInstrumentModified(true); } Modified: trunk/OpenMPT/mptrack/MPTHacks.cpp =================================================================== --- trunk/OpenMPT/mptrack/MPTHacks.cpp 2011-09-11 18:52:20 UTC (rev 1033) +++ trunk/OpenMPT/mptrack/MPTHacks.cpp 2011-09-17 15:42:37 UTC (rev 1034) @@ -293,7 +293,7 @@ if(instr == nullptr) continue; // Extended instrument attributes - if(instr->nFilterMode != FLTMODE_UNCHANGED || instr->nVolRamp != 0 || instr->nResampling != SRCMODE_DEFAULT || + if(instr->nFilterMode != FLTMODE_UNCHANGED || instr->nVolRampUp != 0 || instr->nResampling != SRCMODE_DEFAULT || instr->nCutSwing != 0 || instr->nResSwing != 0 || instr->nMixPlug != 0 || instr->wPitchToTempoLock != 0 || instr->nDCT == DCT_PLUGIN || instr->VolEnv.nReleaseNode != ENV_RELEASE_NODE_UNSET || @@ -305,7 +305,7 @@ if(autofix) { instr->nFilterMode = FLTMODE_UNCHANGED; - instr->nVolRamp = 0; + instr->nVolRampUp = 0; instr->nResampling = SRCMODE_DEFAULT; instr->nCutSwing = 0; instr->nResSwing = 0; Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2011-09-11 18:52:20 UTC (rev 1033) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2011-09-17 15:42:37 UTC (rev 1034) @@ -430,20 +430,21 @@ BEGIN_MESSAGE_MAP(COptionsPlayer, CPropertyPage) ON_WM_HSCROLL() - ON_CBN_SELCHANGE(IDC_COMBO1,OnResamplerChanged) - ON_CBN_SELCHANGE(IDC_COMBO2,OnSettingsChanged) + ON_CBN_SELCHANGE(IDC_COMBO1, OnResamplerChanged) + ON_CBN_SELCHANGE(IDC_COMBO2, OnSettingsChanged) //rewbs.resamplerConf - ON_CBN_SELCHANGE(IDC_WFIRTYPE,OnWFIRTypeChanged) - ON_EN_UPDATE(IDC_WFIRCUTOFF,OnSettingsChanged) - ON_EN_UPDATE(IDC_RAMPING, OnSettingsChanged) + ON_CBN_SELCHANGE(IDC_WFIRTYPE, OnWFIRTypeChanged) + ON_EN_UPDATE(IDC_WFIRCUTOFF, OnSettingsChanged) + ON_EN_UPDATE(IDC_RAMPING_IN, OnSettingsChanged) + ON_EN_UPDATE(IDC_RAMPING_OUT, OnSettingsChanged) //end rewbs.resamplerConf - ON_COMMAND(IDC_CHECK1, OnSettingsChanged) - ON_COMMAND(IDC_CHECK2, OnSettingsChanged) - ON_COMMAND(IDC_CHECK3, OnSettingsChanged) - ON_COMMAND(IDC_CHECK4, OnSettingsChanged) - ON_COMMAND(IDC_CHECK5, OnSettingsChanged) - ON_COMMAND(IDC_CHECK6, OnSettingsChanged) - ON_COMMAND(IDC_CHECK7, OnSettingsChanged) + ON_COMMAND(IDC_CHECK1, OnSettingsChanged) + ON_COMMAND(IDC_CHECK2, OnSettingsChanged) + ON_COMMAND(IDC_CHECK3, OnSettingsChanged) + ON_COMMAND(IDC_CHECK4, OnSettingsChanged) + ON_COMMAND(IDC_CHECK5, OnSettingsChanged) + ON_COMMAND(IDC_CHECK6, OnSettingsChanged) + ON_COMMAND(IDC_CHECK7, OnSettingsChanged) ON_COMMAND(IDC_BUTTON_DEFAULT_RESAMPLING, OnDefaultResampling) END_MESSAGE_MAP() @@ -457,7 +458,8 @@ //rewbs.resamplerConf DDX_Control(pDX, IDC_WFIRTYPE, m_CbnWFIRType); DDX_Control(pDX, IDC_WFIRCUTOFF, m_CEditWFIRCutoff); - DDX_Control(pDX, IDC_RAMPING, m_CEditRamping); + DDX_Control(pDX, IDC_RAMPING_IN, m_CEditRampUp); + DDX_Control(pDX, IDC_RAMPING_OUT, m_CEditRampDown); //end rewbs.resamplerConf DDX_Control(pDX, IDC_COMBO2, m_CbnReverbPreset); DDX_Control(pDX, IDC_SLIDER1, m_SbXBassDepth); @@ -537,9 +539,14 @@ } //rewbs.resamplerConf OnResamplerChanged(); - char s[20] = ""; - _ltoa(CMainFrame::GetSettings().glVolumeRampSamples,s, 10); - m_CEditRamping.SetWindowText(s); + + char s[16] = ""; + _ltoa(CMainFrame::GetSettings().glVolumeRampUpSamples, s, 10); + m_CEditRampUp.SetWindowText(s); + + _ltoa(CMainFrame::GetSettings().glVolumeRampDownSamples, s, 10); + m_CEditRampDown.SetWindowText(s); + //end rewbs.resamplerConf return TRUE; } @@ -625,7 +632,8 @@ m_CbnResampling.SetCurSel(SRCMODE_POLYPHASE); OnResamplerChanged(); m_CEditWFIRCutoff.SetWindowText("97"); - m_CEditRamping.SetWindowText("42"); + m_CEditRampUp.SetWindowText("42"); + m_CEditRampDown.SetWindowText("42"); } @@ -677,8 +685,12 @@ if (s != "") CMainFrame::GetSettings().gdWFIRCutoff = atoi(s)/100.0; //CMainFrame::GetSettings().gbWFIRType set in OnWFIRTypeChange - m_CEditRamping.GetWindowText(s); - CMainFrame::GetSettings().glVolumeRampSamples = atol(s); + + m_CEditRampUp.GetWindowText(s); + CMainFrame::GetSettings().glVolumeRampUpSamples = atol(s); + m_CEditRampDown.GetWindowText(s); + CMainFrame::GetSettings().glVolumeRampDownSamples = atol(s); + SndMixInitializeTables(); //regenerate resampling tables //end rewbs.resamplerConf if (pParent) pParent->SetupPlayer(dwQuality, dwSrcMode, TRUE); Modified: trunk/OpenMPT/mptrack/Mpdlgs.h =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.h 2011-09-11 18:52:20 UTC (rev 1033) +++ trunk/OpenMPT/mptrack/Mpdlgs.h 2011-09-17 15:42:37 UTC (rev 1034) @@ -51,7 +51,8 @@ CSliderCtrl m_SbXBassDepth, m_SbXBassRange; CSliderCtrl m_SbSurroundDepth, m_SbSurroundDelay; CSliderCtrl m_SbReverbDepth; - CEdit m_CEditWFIRCutoff, m_CEditRamping; //rewbs.resamplerConf: added m_CEditRamping + CEdit m_CEditWFIRCutoff; + CEdit m_CEditRampUp, m_CEditRampDown; public: COptionsPlayer():CPropertyPage(IDD_OPTIONS_PLAYER) {} Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2011-09-11 18:52:20 UTC (rev 1033) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2011-09-17 15:42:37 UTC (rev 1034) @@ -51,7 +51,8 @@ gcsInstallGUID = ""; // Audio Setup //rewbs.resamplerConf - glVolumeRampSamples = 42; + glVolumeRampUpSamples = 42; + glVolumeRampDownSamples = 42; gdWFIRCutoff = 0.97; gbWFIRType = 7; //WFIR_KAISER4T; //end rewbs.resamplerConf @@ -343,7 +344,11 @@ gbWFIRType = static_cast<BYTE>(CMainFrame::GetPrivateProfileDWord("Sound Settings", "XMMSModplugResamplerWFIRType", gbWFIRType, iniFile)); //gdWFIRCutoff = static_cast<double>(CMainFrame::GetPrivateProfileLong("Sound Settings", "ResamplerWFIRCutoff", gdWFIRCutoff * 100.0, iniFile)) / 100.0; gdWFIRCutoff = static_cast<double>(CMainFrame::GetPrivateProfileLong("Sound Settings", "ResamplerWFIRCutoff", Util::Round<long>(gdWFIRCutoff * 100.0), iniFile)) / 100.0; - glVolumeRampSamples = CMainFrame::GetPrivateProfileLong("Sound Settings", "VolumeRampSamples", glVolumeRampSamples, iniFile); + + // Ramping... first try to read the old setting, then the new ones + glVolumeRampUpSamples = glVolumeRampDownSamples = CMainFrame::GetPrivateProfileLong("Sound Settings", "VolumeRampSamples", glVolumeRampUpSamples, iniFile); + glVolumeRampUpSamples = CMainFrame::GetPrivateProfileLong("Sound Settings", "VolumeRampUpSamples", glVolumeRampUpSamples, iniFile); + glVolumeRampDownSamples = CMainFrame::GetPrivateProfileLong("Sound Settings", "VolumeRampDownSamples", glVolumeRampDownSamples, iniFile); m_dwMidiSetup = CMainFrame::GetPrivateProfileDWord("MIDI Settings", "MidiSetup", m_dwMidiSetup, iniFile); m_nMidiDevice = CMainFrame::GetPrivateProfileDWord("MIDI Settings", "MidiDevice", m_nMidiDevice, iniFile); @@ -577,8 +582,9 @@ RegQueryValueEx(key, "XMMSModplugResamplerWFIRType", NULL, &dwREG_DWORD, (LPBYTE)&gbWFIRType, &dwDWORDSize); dwDWORDSize = sizeof(gdWFIRCutoff); RegQueryValueEx(key, "ResamplerWFIRCutoff", NULL, &dwREG_DWORD, (LPBYTE)&gdWFIRCutoff, &dwDWORDSize); - dwDWORDSize = sizeof(glVolumeRampSamples); - RegQueryValueEx(key, "VolumeRampSamples", NULL, &dwREG_DWORD, (LPBYTE)&glVolumeRampSamples, &dwDWORDSize); + dwDWORDSize = sizeof(glVolumeRampUpSamples); + RegQueryValueEx(key, "VolumeRampSamples", NULL, &dwREG_DWORD, (LPBYTE)&glVolumeRampUpSamples, &dwDWORDSize); + glVolumeRampDownSamples = glVolumeRampUpSamples; //end rewbs.resamplerConf //rewbs.autochord @@ -709,7 +715,9 @@ CMainFrame::WritePrivateProfileLong("Sound Settings", "MixChannels", CSoundFile::m_nMaxMixChannels, iniFile); CMainFrame::WritePrivateProfileDWord("Sound Settings", "XMMSModplugResamplerWFIRType", gbWFIRType, iniFile); CMainFrame::WritePrivateProfileLong("Sound Settings", "ResamplerWFIRCutoff", static_cast<int>(gdWFIRCutoff*100+0.5), iniFile); - CMainFrame::WritePrivateProfileLong("Sound Settings", "VolumeRampSamples", glVolumeRampSamples, iniFile); + WritePrivateProfileString("Sound Settings", "VolumeRampSamples", NULL, iniFile); // deprecated + CMainFrame::WritePrivateProfileLong("Sound Settings", "VolumeRampUpSamples", glVolumeRampUpSamples, iniFile); + CMainFrame::WritePrivateProfileLong("Sound Settings", "VolumeRampDownSamples", glVolumeRampDownSamples, iniFile); CMainFrame::WritePrivateProfileDWord("MIDI Settings", "MidiSetup", m_dwMidiSetup, iniFile); CMainFrame::WritePrivateProfileDWord("MIDI Settings", "MidiDevice", m_nMidiDevice, iniFile); Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2011-09-11 18:52:20 UTC (rev 1033) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2011-09-17 15:42:37 UTC (rev 1034) @@ -69,7 +69,7 @@ //rewbs.resamplerConf double gdWFIRCutoff; BYTE gbWFIRType; - long glVolumeRampSamples; + long glVolumeRampUpSamples, glVolumeRampDownSamples; //end rewbs.resamplerConf UINT gnAutoChordWaitTime; Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2011-09-11 18:52:20 UTC (rev 1033) +++ trunk/OpenMPT/mptrack/mptrack.rc 2011-09-17 15:42:37 UTC (rev 1034) @@ -13,13 +13,11 @@ #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// -// Deutsch (Deutschland) resources +// German (Germany) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) -#ifdef _WIN32 LANGUAGE LANG_GERMAN, SUBLANG_GERMAN #pragma code_page(1252) -#endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // @@ -208,7 +206,6 @@ LTEXT "",IDC_LASTUPDATE,6,228,258,24 END - IDD_CLOSEDOCUMENTS DIALOGEX 0, 0, 370, 197 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Save modified files" @@ -228,7 +225,7 @@ // #ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO +GUIDELINES DESIGNINFO BEGIN IDD_MODLOADING_WARNINGS, DIALOG BEGIN @@ -320,18 +317,16 @@ END #endif // APSTUDIO_INVOKED -#endif // Deutsch (Deutschland) resources +#endif // German (Germany) resources ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// -// Englisch (USA) resources +// English (United States) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) -#endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // @@ -382,7 +377,7 @@ CONTROL "Slider2",IDC_SLIDER6,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,149,128,62,15 LTEXT "5ms",IDC_STATIC,131,131,18,8 LTEXT "50ms",IDC_STATIC,211,131,23,8 - GROUPBOX "Sound Quality",IDC_STATIC,6,162,256,108 + GROUPBOX "Sound Quality",IDC_STATIC,6,162,256,114 LTEXT "Resampling:",IDC_STATIC,18,182,42,8 COMBOBOX IDC_COMBO1,66,180,114,56,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "WFIR type:",IDC_STATIC,18,200,42,8 @@ -392,9 +387,11 @@ LTEXT "%",IDC_STATIC,186,219,8,8 LTEXT "Sample ramping (click avoidance):",IDC_STATIC,18,238,109,8 LTEXT "(can be overridden by instrument setting)",IDC_STATIC,18,248,138,8 - EDITTEXT IDC_RAMPING,156,235,24,14,ES_AUTOHSCROLL | ES_NUMBER - LTEXT "Samples",IDC_STATIC,182,238,29,8 + EDITTEXT IDC_RAMPING_IN,156,235,24,14,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "Samples (Ramp In)",IDC_STATIC,182,238,70,8 PUSHBUTTON "Default Settings",IDC_BUTTON_DEFAULT_RESAMPLING,186,180,66,12 + EDITTEXT IDC_RAMPING_OUT,156,252,24,14,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "Samples (Ramp Out)",IDC_STATIC,182,255,70,8 END IDD_WAVECONVERT DIALOGEX 0, 0, 262, 221 @@ -428,7 +425,7 @@ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,66,168,12 END -IDD_PROGRESS DIALOG 0, 0, 186, 55 +IDD_PROGRESS DIALOG 0, 0, 186, 55 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Saving Wave File" FONT 8, "MS Shell Dlg" @@ -842,7 +839,7 @@ RTEXT "IDC_TEXT_SAVEDWITH",IDC_TEXT_SAVEDWITH,18,283,54,8 END -IDD_SHOWLOG DIALOG 0, 0, 300, 106 +IDD_SHOWLOG DIALOG 0, 0, 300, 106 STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_CONTEXTHELP | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Information" FONT 8, "MS Shell Dlg" @@ -1042,7 +1039,7 @@ BEGIN END -IDD_PAGEEDITNOTE DIALOG 0, 0, 220, 34 +IDD_PAGEEDITNOTE DIALOG 0, 0, 220, 34 STYLE DS_SETFONT | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CAPTION CAPTION "Note" FONT 8, "MS Shell Dlg" @@ -1053,7 +1050,7 @@ COMBOBOX IDC_COMBO2,74,15,137,70,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP END -IDD_PAGEEDITVOLUME DIALOG 0, 0, 220, 34 +IDD_PAGEEDITVOLUME DIALOG 0, 0, 220, 34 STYLE DS_SETFONT | DS_SETFOREGROUND | WS_CHILD | WS_VISIBLE | WS_CAPTION CAPTION "Volume" FONT 8, "MS Shell Dlg" @@ -1303,14 +1300,14 @@ EDITTEXT IDC_EDIT6,174,180,31,12,ES_AUTOHSCROLL | ES_NUMBER END -IDD_SPLASHSCREEN DIALOG 0, 0, 188, 95 +IDD_SPLASHSCREEN DIALOG 0, 0, 188, 95 STYLE DS_SETFONT | DS_SETFOREGROUND | DS_CENTER | WS_POPUP FONT 8, "MS Shell Dlg" BEGIN CONTROL "",IDC_SPLASH,"Static",SS_WHITERECT,0,0,187,94 END -IDD_TREEVIEW DIALOG 0, 0, 85, 266 +IDD_TREEVIEW DIALOG 0, 0, 85, 266 STYLE DS_SETFONT | WS_CHILD FONT 8, "MS Shell Dlg" BEGIN @@ -1389,7 +1386,7 @@ BEGIN END -IDD_SETUP_REVERB DIALOG 0, 0, 240, 156 +IDD_SETUP_REVERB DIALOG 0, 0, 240, 156 STYLE DS_SETFONT | WS_CHILD | WS_CAPTION CAPTION "Reverb" FONT 8, "MS Shell Dlg" @@ -1633,7 +1630,7 @@ // #ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO +GUIDELINES DESIGNINFO BEGIN IDD_ABOUTBOX, DIALOG BEGIN @@ -1990,7 +1987,7 @@ // Menu // -IDR_MAINFRAME MENU +IDR_MAINFRAME MENU BEGIN POPUP "&File" BEGIN @@ -2103,7 +2100,7 @@ END END -IDR_TOOLBARS MENU +IDR_TOOLBARS MENU BEGIN POPUP "&ToolBars" BEGIN @@ -2112,7 +2109,7 @@ END END -IDR_ENVELOPES MENU +IDR_ENVELOPES MENU BEGIN POPUP "&Envelope" BEGIN @@ -2145,7 +2142,7 @@ // String Table // -STRINGTABLE +STRINGTABLE BEGIN IDR_MAINFRAME "OpenMPT" IDR_MODULETYPE "\nModule\nuntitled\nMusic Modules (*.mod;*.s3m;*.it;*.xm)\n.mod\nModplugTracker.Document\nMusic Module" @@ -2158,20 +2155,20 @@ IDS_APPLY_TUNING_MODIFICATIONS "Apply local tuning modifications to file?" END -STRINGTABLE +STRINGTABLE BEGIN ID_ENVELOPE_VIEWGRID "Show/hide row guidelines" ID_REPORT_BUG "Report a bug!\nReport a bug!" IDS_ERR_DIALOG "Dialog encountered an error and needs to close" END -STRINGTABLE +STRINGTABLE BEGIN AFX_IDS_APP_TITLE "OpenMPT" AFX_IDS_IDLEMESSAGE "Ready" END -STRINGTABLE +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 @@ -2197,14 +2194,14 @@ IDS_ERR_SAVESONG "Unable to save song!" END -STRINGTABLE +STRINGTABLE BEGIN IDS_ERR_TOOMANYPAT "Too many patterns!" IDS_ERR_TOOMANYSMP "Too many samples!" IDS_ERR_SAVESMP "Unable to save sample" END -STRINGTABLE +STRINGTABLE BEGIN ID_INDICATOR_EXT "EXT" ID_INDICATOR_CAPS "CAP" @@ -2214,20 +2211,20 @@ ID_INDICATOR_REC "REC" END -STRINGTABLE +STRINGTABLE BEGIN ID_INDICATOR_TIME "00:00:00 [100] 200ch" -END - -STRINGTABLE -BEGIN ID_INDICATOR_USER "Row 000, Col 000" ID_INDICATOR_INFO "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ID_INDICATOR_XINFO "123456789|123456789|123456789|123456789|" +END + +STRINGTABLE +BEGIN ID_VIEW_MIDIMAPPING "Configure the MIDI Mapping" END -STRINGTABLE +STRINGTABLE BEGIN ID_FILE_NEW "Create a new document\nNew" ID_FILE_OPEN "Open an existing document\nOpen" @@ -2236,7 +2233,7 @@ ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" END -STRINGTABLE +STRINGTABLE BEGIN ID_APP_ABOUT "About OpenMPT\nAbout" ID_APP_EXIT "Exit OpenMPT\nExit" @@ -2247,7 +2244,7 @@ ID_HELP "Display help for current task or command\nHelp" END -STRINGTABLE +STRINGTABLE BEGIN ID_FILE_MRU_FILE1 "Open this document" ID_FILE_MRU_FILE2 "Open this document" @@ -2267,13 +2264,13 @@ ID_FILE_MRU_FILE16 "Open this document" END -STRINGTABLE +STRINGTABLE BEGIN ID_NEXT_PANE "Switch to the next window pane\nNext Pane" ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" END -STRINGTABLE +STRINGTABLE BEGIN ID_WINDOW_NEW "Open another window for the active song\nNew Window" ID_WINDOW_ARRANGE "Arrange icons at the bottom of the window\nArrange Icons" @@ -2283,7 +2280,7 @@ ID_WINDOW_SPLIT "Split the active window into panes\nSplit" END -STRINGTABLE +STRINGTABLE BEGIN ID_EDIT_CLEAR "Erase the selection\nErase" ID_EDIT_CLEAR_ALL "Erase everything\nErase All" @@ -2299,13 +2296,13 @@ ID_EDIT_REDO "Redo the previously undone action\nRedo" END -STRINGTABLE +STRINGTABLE BEGIN ID_VIEW_TOOLBAR "Show or hide the main toolbar\nToggle ToolBar" ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" END -STRINGTABLE +STRINGTABLE BEGIN AFX_IDS_SCSIZE "Change the window size" AFX_IDS_SCMOVE "Change the window position" @@ -2316,14 +2313,14 @@ AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents" END -STRINGTABLE +STRINGTABLE BEGIN AFX_IDS_SCRESTORE "Restore the window to normal size" AFX_IDS_SCTASKLIST "Activate Task List" AFX_IDS_MDICHILD "Activate this window" END -STRINGTABLE +STRINGTABLE BEGIN ID_FILE_NEWMOD "Create a new ProTracker (MOD) music module\nNew MOD" ID_FILE_NEWXM "Create a new FastTracker II (XM) music module\nNew XM" @@ -2337,7 +2334,7 @@ ID_PLAYER_SETUP "Configure the sound device and player options" END -STRINGTABLE +STRINGTABLE BEGIN ID_VIEW_OPTIONS "Configure the audio device, keyboard layout, colors etc...\nSetup" ID_INSERT_PATTERN "Create a new pattern" @@ -2351,12 +2348,12 @@ ID_EDIT_FINDNEXT "Continue search\nFind Next" END -STRINGTABLE +STRINGTABLE BEGIN IDC_COMBO_INSTRUMENT "Change the current instrument for entering notes\nActive Instrument" END -STRINGTABLE +STRINGTABLE BEGIN IDC_SAMPLE_NEW "Create a new sample\nNew Sample" IDC_SAMPLE_OPEN "Load sample from disk\nImport sample" @@ -2369,12 +2366,12 @@ IDC_SAMPLE_PLAY "Play a middle C using the current sample\nPlay sample" END -STRINGTABLE +STRINGTABLE BEGIN IDC_SAMPLE_DOWNSAMPLE "Shrink selection\nDownsample" END -STRINGTABLE +STRINGTABLE BEGIN IDC_PATTERN_PLAY "Play the curent pattern from the current position\nPlay Pattern" IDC_PATTERN_PLAYFROMSTART @@ -2384,7 +2381,7 @@ IDC_PATTERN_NEW "Create a new pattern\nInsert Pattern" END -STRINGTABLE +STRINGTABLE BEGIN IDC_SAMPLE_SILENCE "Silence Sample\nSilence" IDC_SAMPLE_INVERT "Invert phase\nInvert phase" @@ -2395,12 +2392,12 @@ IDC_INSTRUMENT_PLAY "Play the current instrument\nPlay instrument" END -STRINGTABLE +STRINGTABLE BEGIN IDC_SAMPLE_DCOFFSET "Remove DC Offset\nRemove DC Offset and normalize (hold shift to process all samples)" END -STRINGTABLE +STRINGTABLE BEGIN ID_ENVELOPE_SETLOOP "Enable or disable the envelope loop" ID_ENVELOPE_SUSTAIN "Enable or disable the envelope sustain" @@ -2409,21 +2406,21 @@ ID_MODTREE_REFRESH "Refresh the display\nRefresh" END -STRINGTABLE +STRINGTABLE BEGIN ID_PATTERN_PLAYROW "Play current row\nPlay Row" ID_IMPORT_MIDILIB "Defines the default MIDI library used when importing MIDI files" ID_CLEANUP_REARRANGE "Rearrange all patterns so that they are sorted in the order list\nRearrange Patterns" END -STRINGTABLE +STRINGTABLE BEGIN ID_EDIT_GOTO_MENU "Go to row / channel / pattern / order" ID_CLEANUP_COMPO "Reset attributes to defaults (useful for creating sample packs)\nCompo Cleanup" ID_OVERFLOWPASTE "Toggle overflow paste\nToggle overflow paste" END -STRINGTABLE +STRINGTABLE BEGIN ID_VIEW_COMMENTS "Activates the song text editor" ID_ADD_SOUNDBANK "Add a new DLS sound bank" @@ -2432,7 +2429,7 @@ ID_MIDI_RECORD "Record from an external MIDI keyboard\nMIDI Record" END -STRINGTABLE +STRINGTABLE BEGIN ID_PATTERN_PROPERTIES "Pattern Properties\nPattern Properties" ID_PATTERN_VUMETERS "Show or hide channel VU-Meters\nVU-Meters" @@ -2444,7 +2441,7 @@ ID_ENVSEL_PANNING "Show Panning Envelope" END -STRINGTABLE +STRINGTABLE BEGIN ID_ENVSEL_PITCH "Show Pitch/Filter Envelope" ID_ENVELOPE_VOLUME "Enable or disable the volume envelope" @@ -2458,12 +2455,12 @@ ID_NETLINK_TOP_PICKS "Visit our list of free web resources!" END -STRINGTABLE +STRINGTABLE BEGIN IDD_TREEVIEW "Show or hide the tree view" END -STRINGTABLE +STRINGTABLE BEGIN ID_SAMPLE_TRIM "Delete everything except the current selection\nTrim Sample" ID_FILE_SAVEMIDI "Export the current song to a standard MIDI file" @@ -2474,27 +2471,27 @@ ID_PATTERN_AMPLIFY "Amplify selection\nAmplify" END -STRINGTABLE +STRINGTABLE BEGIN ID_ESTIMATESONGLENGTH "Displays the approximate song length" END -STRINGTABLE +STRINGTABLE BEGIN ID_VIEWPLUGNAMES "Displays the channel plugins in channel headers\nShow Plugins" END -STRINGTABLE +STRINGTABLE BEGIN ID_EDIT_GOTO "Go to row, channel, pattern...\nGo to row" END -STRINGTABLE +STRINGTABLE BEGIN IDS_ERR_TUNING_SERIALISATION "Static tuning serialisation failed" END -STRINGTABLE +STRINGTABLE BEGIN IDS_ERR_NO_TUNING_SELECTION "Operation failed - No tuning file selected." IDS_UNSUPPORTED_TUNING_DnD @@ -2518,50 +2515,44 @@ IDS_SCL_IMPORT_FAIL_8 "OpenMPT supports importing scl-files with at most %1 notes" END -STRINGTABLE +STRINGTABLE BEGIN ID_PANIC "Kill all VSTi and sample voices\nStop all hanging VSTi and sample voices" ID_VIEW_EDITHISTORY "View the edit history of this module" -END - -STRINGTABLE -BEGIN ID_FILE_SAVEASTEMPLATE "Save the active document as template module\nSave as Template" END -STRINGTABLE +STRINGTABLE BEGIN ID_FILE_OPENTEMPLATE "Open a template document\nOpen template document" END -STRINGTABLE +STRINGTABLE BEGIN ID_CHANNEL_MANAGER "Add, remove, mute and manage channels" ID_PLUGIN_SETUP "Register plugins and add them to the current module" END -STRINGTABLE +STRINGTABLE BEGIN ID_VIEW_SONGPROPERTIES "Edit global song properties or convert the module to another format" END -STRINGTABLE +STRINGTABLE BEGIN IDC_SAMPLE_XFADE "Crossfade Loop Points\nCrossfade between loop start and loop end to create seamless sample loops." END -#endif // Englisch (USA) resources +#endif // English (United States) resources ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// -// Englisch (GB) resources +// English (United Kingdom) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG) -#ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK #pragma code_page(1252) -#endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // @@ -2740,7 +2731,7 @@ // #ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO +GUIDELINES DESIGNINFO BEGIN IDD_MSGBOX_HIDABLE, DIALOG BEGIN @@ -2823,7 +2814,7 @@ // Menu // -IDR_VSTMENU MENU +IDR_VSTMENU MENU BEGIN POPUP "&File" BEGIN @@ -2846,7 +2837,7 @@ END END -IDR_PLUGINMENU MENU +IDR_PLUGINMENU MENU BEGIN POPUP "File" BEGIN @@ -2928,7 +2919,7 @@ // IDR_BUILTIN_TUNINGS TUNING "res\\built-inTunings.tc" -#endif // Englisch (GB) resources +#endif // English (United Kingdom) resources ///////////////////////////////////////////////////////////////////////////// Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2011-09-11 18:52:20 UTC (rev 1033) +++ trunk/OpenMPT/mptrack/resource.h 2011-09-17 15:42:37 UTC (rev 1034) @@ -716,8 +716,9 @@ #define IDC_PATINSTROPLUGGUI 2201 #define IDC_WFIRCUTOFF 2202 #define IDC_WFIRTYPE 2203 -#define IDC_RAMPING 2204 +#define IDC_RAMPING_IN 2204 #define IDC_PLAYEROPTIONS 2205 +#define IDC_RAMPING_OUT 2205 #define IDC_CHORDDETECTWAITTIME 2206 #define IDC_STATIC2 2207 #define IDC_STATIC1 2208 Modified: trunk/OpenMPT/mptrack/test/test.cpp =================================================================== --- trunk/OpenMPT/mptrack/test/test.cpp 2011-09-11 18:52:20 UTC (rev 1033) +++ trunk/OpenMPT/mptrack/test/test.cpp 2011-09-17 15:42:37 UTC (rev 1034) @@ -325,7 +325,7 @@ VERIFY_EQUAL_NONCONT(pIns->nPPS, 0); VERIFY_EQUAL_NONCONT(pIns->nPPC, NOTE_MIDDLEC - 1); - VERIFY_EQUAL_NONCONT(pIns->nVolRamp, 1200); + VERIFY_EQUAL_NONCONT(pIns->nVolRampUp, 1200); VERIFY_EQUAL_NONCONT(pIns->nResampling, SRCMODE_POLYPHASE); VERIFY_EQUAL_NONCONT(pIns->nIFC, 0); @@ -520,7 +520,7 @@ VERIFY_EQUAL_NONCONT(pIns->nPPS, 16); VERIFY_EQUAL_NONCONT(pIns->nPPC, (NOTE_MIDDLEC - 1) + 6); // F#5 - VERIFY_EQUAL_NONCONT(pIns->nVolRamp, 1200); + VERIFY_EQUAL_NONCONT(pIns->nVolRampUp, 1200); VERIFY_EQUAL_NONCONT(pIns->nResampling, SRCMODE_POLYPHASE); VERIFY_EQUAL_NONCONT(pIns->nIFC, 0x80 | 0x32); Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2011-09-11 18:52:20 UTC (rev 1033) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2011-09-17 15:42:37 UTC (rev 1034) @@ -2476,7 +2476,7 @@ MODINSTRUMENT *sizeIns = new MODINSTRUMENT(); - WriteInstrumentPropertyForAllInstruments('VR..', sizeof(sizeIns->nVolRamp), f, nInstruments); + WriteInstrumentPropertyForAllInstruments('VR..', sizeof(sizeIns->nVolRampUp), f, nInstruments); WriteInstrumentPropertyForAllInstruments('MiP.', sizeof(sizeIns->nMixPlug), f, nInstruments); WriteInstrumentPropertyForAllInstruments('MC..', sizeof(sizeIns->nMidiChannel),f, nInstruments); WriteInstrumentPropertyForAllInstruments('MP..', sizeof(sizeIns->nMidiProgram),f, nInstruments); Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2011-09-11 18:52:20 UTC (rev 1033) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2011-09-17 15:42:37 UTC (rev 1034) @@ -207,7 +207,7 @@ VLE. VolEnv.nLoopEnd; VLS. VolEnv.nLoopStart; VP[. VolEnv.Ticks[MAX_ENVPOINTS]; -VR.. nVolRamp; +VR.. nVolRampUp; VS.. nVolSwing; VSB. VolEnv.nSustainStart; VSE. VolEnv.nSustainEnd; @@ -326,7 +326,7 @@ WRITE_MPTHEADER_array_member( name , CHAR , n[.. , 32 ) WRITE_MPTHEADER_array_member( filename , CHAR , fn[. , 12 ) WRITE_MPTHEADER_sized_member( nMixPlug , BYTE , MiP. ) -WRITE_MPTHEADER_sized_member( nVolRamp , USHORT , VR.. ) +WRITE_MPTHEADER_sized_member( nVolRampUp , uint16 , VR.. ) WRITE_MPTHEADER_sized_member( nResampling , USHORT , R... ) WRITE_MPTHEADER_sized_member( nCutSwing , BYTE , CS.. ) WRITE_MPTHEADER_sized_member( nResSwing , BYTE , RS.. ) @@ -408,7 +408,7 @@ GET_MPTHEADER_array_member( name , CHAR , n[.. , 32 ) GET_MPTHEADER_array_member( filename , CHAR , fn[. , 12 ) GET_MPTHEADER_sized_member( nMixPlug , BYTE , MiP. ) -GET_MPTHEADER_sized_member( nVolRamp , USHORT , VR.. ) +GET_MPTHEADER_sized_member( nVolRampUp , uint16 , VR.. ) GET_MPTHEADER_sized_member( nResampling , UINT , R... ) GET_MPTHEADER_sized_member( nCutSwing , BYTE , CS.. ) GET_MPTHEADER_sized_member( nResSwing , BYTE , RS.. ) Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2011-09-11 18:52:20 UTC (rev 1033) +++ trunk/OpenMPT/soundlib/Sndfile.h 2011-09-17 15:42:37 UTC (rev 1034) @@ -142,10 +142,7 @@ CHAR filename[32]; PLUGINDEX nMixPlug; // Plugin assigned to this instrument -// -> CODE#0027 -// -> DESC="per-instrument volume ramping setup (refered as attack)" - USHORT nVolRamp; // Default sample ramping -// -! NEW_FEATURE#0027 + uint16 nVolRampUp; // Default sample ramping up UINT nResampling; // Resampling mode BYTE nCutSwing; // Random cutoff factor BYTE nResSwing; // Random resonance factor @@ -199,7 +196,7 @@ MemsetZero(filename); nMixPlug = 0; - nVolRamp = 0; + nVolRampUp = 0; nResampling = SRCMODE_DEFAULT; nCutSwing = 0; nResSwing = 0; @@ -680,7 +677,9 @@ static UINT m_nMaxMixChannels; static LONG m_nStreamVolume; static DWORD gdwSysInfo, gdwSoundSetup, gdwMixingFreq, gnBitsPerSample, gnChannels; - static UINT gnAGC, gnVolumeRampSamples, gnCPUUsage; + static UINT gnAGC; + static UINT gnVolumeRampUpSamples, gnVolumeRampDownSamples; + static UINT gnCPUUsage; static LPSNDMIXHOOKPROC gpSndMixHook; static PMIXPLUGINCREATEPROC gpMixPluginCreateProc; static uint8 s_DefaultPlugVolumeHandling; Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2011-09-11 18:52:20 UTC (rev 1033) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2011-09-17 15:42:37 UTC (rev 1034) @@ -42,7 +42,8 @@ DWORD CSoundFile::gnBitsPerSample = 16; // Mixing data initialized in UINT CSoundFile::gnAGC = AGC_UNITY; -UINT CSoundFile::gnVolumeRampSamples = 42; //default value +UINT CSoundFile::gnVolumeRampUpSamples = 42; //default value +UINT CSoundFile::gnVolumeRampDownSamples = 42; //default value UINT CSoundFile::gnCPUUsage = 0; LPSNDMIXHOOKPROC CSoundFile::gpSndMixHook = NULL; PMIXPLUGINCREATEPROC CSoundFile::gpMixPluginCreateProc = NULL; @@ -226,7 +227,8 @@ if (gdwMixingFreq > MAX_SAMPLE_RATE) gdwMixingFreq = MAX_SAMPLE_RATE; // Start with ramping disabled to avoid clicks on first read. // Ramping is now set after the first read in CSoundFile::Read(); - gnVolumeRampSamples = 0; + gnVolumeRampUpSamples = 0; + gnVolumeRampDownSamples = CMainFrame::GetSettings().glVolumeRampDownSamples; gnDryROfsVol = gnDryLOfsVol = 0; #ifndef NO_REVERB gnRvbROfsVol = gnRvbLOfsVol = 0; @@ -425,7 +427,7 @@ m_nBufferCount -= lCount; m_lTotalSampleCount += lCount; // increase sample count for VSTTimeInfo. // Turn on ramping after first read (fix http://forum.openmpt.org/index.php?topic=523.0 ) - gnVolumeRampSamples = CMainFrame::GetSettings().glVolumeRampSamples; + gnVolumeRampUpSamples = CMainFrame::GetSettings().glVolumeRampUpSamples; } MixDone: if (lRead) memset(lpBuffer, (gnBitsPerSample == 8) ? 0x80 : 0, lRead * lSampleSize); @@ -1738,44 +1740,57 @@ //----------------------------------------------- { pChn->nRightRamp = pChn->nLeftRamp = 0; - if ((pChn->dwFlags & CHN_VOLUMERAMP) // && gnVolumeRampSamples //rewbs: this allows us to use non ramping mix functions if ramping is 0 - && ((pChn->nRightVol != pChn->nNewRightVol) || (pChn->nLeftVol != pChn->nNewLeftVol))) + if((pChn->dwFlags & CHN_VOLUMERAMP) && ((pChn->nRightVol != pChn->nNewRightVol) || (pChn->nLeftVol != pChn->nNewLeftVol))) { - LONG nRampLength = gnVolumeRampSamples; - // -> CODE#0027 - // -> DESC="per-instrument volume ramping setup" - BOOL enableCustomRamp = pChn->pModInstrument && (m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_XM)); - if(enableCustomRamp) nRampLength = pChn->pModInstrument->nVolRamp ? (gdwMixingFreq * pChn->pModInstrument->nVolRamp / 100000) : gnVolumeRampSamples; - if(!nRampLength) nRampLength = 1; - // -! NEW_FEATURE#0027 + const bool rampUp = (pChn->nNewRightVol > pChn->nRightVol) || (pChn->nNewLeftVol > pChn->nLeftVol); + LONG rampLength, globalRampLength, instrRampLength = 0; + rampLength = globalRampLength = (rampUp ? gnVolumeRampUpSamples : gnVolumeRampDownSamples); + //XXXih: add real support for bidi ramping here + + if(pChn->pModInstrument != nullptr && rampUp) + { + instrRampLength = pChn->pModInstrument->nVolRampUp; + rampLength = instrRampLength ? (gdwMixingFreq * instrRampLength / 100000) : globalRampLength; + } + const bool enableCustomRamp = (instrRampLength > 0); + + if(!rampLength) + { + rampLength = 1; + } + LONG nRightDelta = ((pChn->nNewRightVol - pChn->nRightVol) << VOLUMERAMPPRECISION); LONG nLeftDelta = ((pChn->nNewLeftVol - pChn->nLeftVol) << VOLUMERAMPPRECISION); #ifndef FASTSOUNDLIB - // -> CODE#0027 - // -> DESC="per-instrument volume ramping setup " - // if ((gdwSoundSetup & SNDMIX_DIRECTTODISK) - // || ((gdwSysInfo & (SYSMIX_ENABLEMMX|SYSMIX_FASTCPU)) - // && (gdwSoundSetup & SNDMIX_HQRESAMPLER) && (gnCPUUsage <= 50))) - if ((gdwSoundSetup & SNDMIX_DIRECTTODISK) - || ((gdwSysInfo & (SYSMIX_ENABLEMMX|SYSMIX_FASTCPU)) - && (gdwSoundSetup & SNDMIX_HQRESAMPLER) && (gnCPUUsage <= 50) && !(enableCustomRamp && pChn->pModInstrument->nVolRamp))) - // -! NEW_FEATURE#0027 +// if ((gdwSoundSetup & SNDMIX_DIRECTTODISK) +// || ((gdwSysInfo & (SYSMIX_ENABLEMMX|SYSMIX_FASTCPU)) +// && (gdwSoundSetup & SNDMIX_HQRESAMPLER) && (gnCPUUsage <= 50))) + if((gdwSoundSetup & SNDMIX_DIRECTTODISK) + || ((gdwSysInfo & (SYSMIX_ENABLEMMX | SYSMIX_FASTCPU)) && (gdwSoundSetup & SNDMIX_HQRESAMPLER) && (gnCPUUsage <= 50) && !enableCustomRamp)) { - if ((pChn->nRightVol|pChn->nLeftVol) && (pChn->nNewRightVol|pChn->nNewLeftVol) && (!(pChn->dwFlags & CHN_FASTVOLRAMP))) + if((pChn->nRightVol | pChn->nLeftVol) && (pChn->nNewRightVol | pChn->nNewLeftVol) && (!(pChn->dwFlags & CHN_FASTVOLRAMP))) { - nRampLength = m_nBufferCount; - if (nRampLength > (1 << (VOLUMERAMPPRECISION-1))) nRampLength = (1 << (VOLUMERAMPPRECISION-1)); - if (nRampLength < (LONG)gnVolumeRampSamples) nRampLength = gnVolumeRampSamples; + rampLength = m_nBufferCount; + if(rampLength > (1 << (VOLUMERAMPPRECISION-1))) + { + rampLength = (1 << (VOLUMERAMPPRECISION-1)); + } + if(rampLength < (LONG)globalRampLength) + { + rampLength = globalRampLength; + } } } #endif // FASTSOUNDLIB - pChn->nRightRamp = nRightDelta / nRampLength; - pChn->nLeftRamp = nLeftDelta / nRampLength; - pChn->nRightVol = pChn->nNewRightVol - ((pChn->nRightRamp * nRampLength) >> VOLUMERAMPPRECISION); - pChn->nLeftVol = pChn->nNewLeftVol - ((pChn->nLeftRamp * nRampLength) >> VOLUMERAMPPRECISION); + + pChn->nRightRamp = nRightDelta / rampLength; + pChn->nLeftRamp = nLeftDelta / rampLength; + pChn->nRightVol = pChn->nNewRightVol - ((pChn->nRightRamp * rampLength) >> VOLUMERAMPPRECISION); + pChn->nLeftVol = pChn->nNewLeftVol - ((pChn->nLeftRamp * rampLength) >> VOLUMERAMPPRECISION); + if (pChn->nRightRamp|pChn->nLeftRamp) { - pChn->nRampLength = nRampLength; + pChn->nRampLength = rampLength; } else { pChn->dwFlags &= ~CHN_VOLUMERAMP; @@ -2517,33 +2532,37 @@ void CSoundFile::ApplyGlobalVolume(int SoundBuffer[], long lTotalSampleCount) //--------------------------------------------------------------------------- { - long delta=0; - long step=0; + long delta = 0; + long step = 0; if (m_nGlobalVolumeDestination != m_nGlobalVolume) { //user has provided new global volume + const bool rampUp = m_nGlobalVolumeDestination > m_nGlobalVolume; m_nGlobalVolumeDestination = m_nGlobalVolume; - m_nSamplesToGlobalVolRampDest = gnVolumeRampSamples; + m_nSamplesToGlobalVolRampDest = rampUp ? gnVolumeRampUpSamples : gnVolumeRampDownSamples; } - if (m_nSamplesToGlobalVolRampDest>0) + long rampLength = m_nSamplesToGlobalVolRampDest; + + if (m_nSamplesToGlobalVolRampDest > 0) { // still some ramping left to do. long highResGlobalVolumeDestination = static_cast<long>(m_nGlobalVolumeDestination)<<VOLUMERAMPPRECISION; - delta = highResGlobalVolumeDestination-m_lHighResRampingGlobalVolume; - step = delta/static_cast<long>(m_nSamplesToGlobalVolRampDest); + delta = highResGlobalVolumeDestination - m_lHighResRampingGlobalVolume; + step = delta / static_cast<long>(m_nSamplesToGlobalVolRampDest); - UINT maxStep = max(50, (10000/gnVolumeRampSamples+1)); // define max step size as some factor of user defined ramping value: the lower the value, the more likely the click. - while (static_cast<UINT>(abs(step)) > maxStep) // if step is too big (might cause click), extend ramp length. + UINT maxStep = max(50, (10000 / (rampLength + 1))); // define max step size as some factor of user defined ramping value: the lower the value, the more likely the click. + while(abs(step) > maxStep) // if step is too big (might cause click), extend ramp length. { - m_nSamplesToGlobalVolRampDest += gnVolumeRampSamples; - step = delta/static_cast<long>(m_nSamplesToGlobalVolRampDest); + m_nSamplesToGlobalVolRampDest += rampLength; + step = delta / static_cast<long>(m_nSamplesToGlobalVolRampDest); } } - for (int pos=0; pos<lTotalSampleCount; pos++) { + for (int pos = 0; pos < lTotalSampleCount; pos++) + { if (m_nSamplesToGlobalVolRampDest > 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |