From: <sag...@us...> - 2009-07-26 21:59:51
|
Revision: 304 http://modplug.svn.sourceforge.net/modplug/?rev=304&view=rev Author: saga-games Date: 2009-07-26 21:59:23 +0000 (Sun, 26 Jul 2009) Log Message: ----------- [Fix] Wav Export / Channel Manager / Pattern Editor: Pattern names with leading space char are now accepted [Fix] MOD/XM Saver: F20 won't turn into G20 [Ref] Code refactoring: Added "CLAMP" macro - similar to Limit(), but returns a value. Changed many routines in sndmix, snd_fx and mod loaders to use CLAMP. [Fix] General tab / Main bar / Loaders / Conversion: Fixed arbitrary speed limits (64 on general tab, 127 on main bar). Added speedMin and speedMax to ModSpecs as they are different for MOD/XM and S3M/IT/MPTM. [Imp] Default dirs: Don't overwrite working directory when updating the default directory [Ref] S3M Loader: Less arbitrary value limits, code refactoring [Fix] IT / XM Compatiblity: Tempo slides won't exceed 255 BPM in compatible mode. [Fix] XM Compatiblity: In compatible mode, old retrigger routines are used again (as MPT's default retrigger algorithm actually represents FT2's retrigger algorithm). Additionally, a retrigger bug from FT2 is emulated (retrigger with vxx on the same channel would always reset the retriggered note's volume) [Fix] IT Compatibility: Allow OpenMPT's new volume colum commands (offset etc.) to be used together with Retrigger in compatible mode again Modified Paths: -------------- trunk/OpenMPT/mptrack/ChannelManagerDlg.cpp trunk/OpenMPT/mptrack/Ctrl_gen.cpp trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainbar.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/mptrack/dlg_misc.h trunk/OpenMPT/mptrack/misc_util.h trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/resource.h trunk/OpenMPT/soundlib/Load_mod.cpp trunk/OpenMPT/soundlib/Load_s3m.cpp trunk/OpenMPT/soundlib/Load_xm.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndmix.cpp trunk/OpenMPT/soundlib/mod_specifications.h Modified: trunk/OpenMPT/mptrack/ChannelManagerDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/ChannelManagerDlg.cpp 2009-07-25 15:39:19 UTC (rev 303) +++ trunk/OpenMPT/mptrack/ChannelManagerDlg.cpp 2009-07-26 21:59:23 UTC (rev 304) @@ -775,7 +775,7 @@ ii = pattern[i]; - if(m_pSndFile->ChnSettings[ii].szName[0] > 0x20) + if(m_pSndFile->ChnSettings[ii].szName[0] >= 0x20) wsprintf(s, "%d: %s", (ii+1), m_pSndFile->ChnSettings[ii].szName); else wsprintf(s, "Channel %d", ii+1); Modified: trunk/OpenMPT/mptrack/Ctrl_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2009-07-25 15:39:19 UTC (rev 303) +++ trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2009-07-26 21:59:23 UTC (rev 304) @@ -7,11 +7,12 @@ #include "ctrl_gen.h" #include "view_gen.h" #include "math.h" +#include "misc_util.h" // -> CODE#0015 // -> DESC="channels management dlg" #include "Ctrl_pat.h" -#include ".\ctrl_gen.h" +#include "ctrl_gen.h" // -! NEW_FEATURE#0015 BEGIN_MESSAGE_MAP(CCtrlGeneral, CModControlDlg) @@ -91,9 +92,8 @@ // -> CODE#0016 // -> DESC="default tempo update" // m_SpinTempo.SetRange(32, 255); // 255 bpm max - //m_SpinTempo.SetRange(32, 512); - m_SpinTempo.SetRange(specs.tempoMin, specs.tempoMax); - m_SpinSpeed.SetRange(1, 64); + m_SpinTempo.SetRange((short)specs.tempoMin, (short)specs.tempoMax); + m_SpinSpeed.SetRange((short)specs.speedMin, (short)specs.speedMax); // -! BEHAVIOUR_CHANGE#0016 m_SpinGlobalVol.SetRange(0, 128); m_SpinSamplePA.SetRange(0, 2000); @@ -341,9 +341,8 @@ m_EditTempo.GetWindowText(s, sizeof(s)); if (s[0]) { - UINT n = atoi(s); - CModSpecifications specs = m_pSndFile->GetModSpecifications(); - if ((n >= specs.tempoMin) && (n <= specs.tempoMax) && (n != m_pSndFile->m_nDefaultTempo)) + UINT n = CLAMP(atoi(s), m_pSndFile->GetModSpecifications().tempoMin, m_pSndFile->GetModSpecifications().tempoMax); + if (n != m_pSndFile->m_nDefaultTempo) { m_bEditsLocked=true; m_EditTempo.SetModify(FALSE); @@ -368,8 +367,8 @@ m_EditSpeed.GetWindowText(s, sizeof(s)); if (s[0]) { - UINT n = atoi(s); - if ((n >= 1) && (n <= 64) && (n != m_pSndFile->m_nDefaultSpeed)) { + UINT n = CLAMP(atoi(s), m_pSndFile->GetModSpecifications().speedMin, m_pSndFile->GetModSpecifications().speedMax); + if (n != m_pSndFile->m_nDefaultSpeed) { m_bEditsLocked=true; m_EditSpeed.SetModify(FALSE); m_pSndFile->m_nDefaultSpeed = n; @@ -390,8 +389,8 @@ if ((m_pSndFile) && (m_pModDoc) && (m_bInitialized)) { m_EditVSTiVol.GetWindowText(s, sizeof(s)); if (s[0]) { - int n = atoi(s); - if ((n >= 0) && (n <= 2000) && (n != m_pSndFile->m_nVSTiVolume)) { + int n = CLAMP(atoi(s), 0, 2000); + if (n != m_pSndFile->m_nVSTiVolume) { m_bEditsLocked=true; m_pSndFile->m_nVSTiVolume = n; m_pSndFile->RecalculateGainForAllPlugs(); @@ -411,8 +410,8 @@ if ((m_pSndFile) && (m_pModDoc) && (m_bInitialized)) { m_EditSamplePA.GetWindowText(s, sizeof(s)); if (s[0]) { - int n = atoi(s); - if ((n >= 0) && (n <= 2000) && (n != m_pSndFile->m_nSamplePreAmp)) { + int n = CLAMP(atoi(s), 0, 2000); + if (n != m_pSndFile->m_nSamplePreAmp) { m_bEditsLocked=true; m_pSndFile->m_nSamplePreAmp = n; m_pModDoc->SetModified(); @@ -433,21 +432,17 @@ m_EditGlobalVol.GetWindowText(s, sizeof(s)); if (s[0]) { - UINT n = atoi(s); - if (n <= 128) - { - UINT n0 = m_pSndFile->m_nDefaultGlobalVolume / 2; - if (n != n0) - { - m_bEditsLocked=true; - m_EditGlobalVol.SetModify(FALSE); - m_pSndFile->m_nDefaultGlobalVolume = n << 1; - m_pSndFile->m_nGlobalVolume = n << 1; - m_pModDoc->SetModified(); - m_pModDoc->UpdateAllViews(NULL, HINT_MODGENERAL, this); - UpdateView(HINT_MODGENERAL, NULL); - m_bEditsLocked=false; - } + UINT n = CLAMP(atoi(s), 0, 128); + if (n != (m_pSndFile->m_nDefaultGlobalVolume >> 1)) + { + m_bEditsLocked=true; + m_EditGlobalVol.SetModify(FALSE); + m_pSndFile->m_nDefaultGlobalVolume = n << 1; + m_pSndFile->m_nGlobalVolume = n << 1; + m_pModDoc->SetModified(); + m_pModDoc->UpdateAllViews(NULL, HINT_MODGENERAL, this); + UpdateView(HINT_MODGENERAL, NULL); + m_bEditsLocked=false; } } } @@ -463,17 +458,16 @@ m_EditRestartPos.GetWindowText(s, sizeof(s)); if (s[0]) { - UINT n = atoi(s); - if(n < m_pSndFile->Order.size()) + UINT n = CLAMP(atoi(s), 0, m_pSndFile->Order.size()); + for (ORDERINDEX i = 0; i <= n; i++) + if (m_pSndFile->Order[i] == m_pSndFile->Order.GetInvalidPatIndex()) return; + + if (n != m_pSndFile->m_nRestartPos) { - for (ORDERINDEX i=0; i<=n; i++) if (m_pSndFile->Order[i] == m_pSndFile->Order.GetInvalidPatIndex()) return; - if (n != m_pSndFile->m_nRestartPos) - { - m_EditRestartPos.SetModify(FALSE); - m_pSndFile->m_nRestartPos = n; - m_pModDoc->SetModified(); - m_pModDoc->UpdateAllViews(NULL, HINT_MODGENERAL, this); - } + m_EditRestartPos.SetModify(FALSE); + m_pSndFile->m_nRestartPos = n; + m_pModDoc->SetModified(); + m_pModDoc->UpdateAllViews(NULL, HINT_MODGENERAL, this); } } } @@ -490,25 +484,6 @@ //---------------------------------- { m_pModDoc->SongProperties(); - /* - CModTypeDlg dlg(m_pSndFile, this); - if (dlg.DoModal() == IDOK) - { - BOOL bShowLog = FALSE; - m_pModDoc->ClearLog(); - if(dlg.m_nType) { - if (!m_pModDoc->ChangeModType(dlg.m_nType)) return; - bShowLog = TRUE; - } - if ((dlg.m_nChannels >= 4) && (dlg.m_nChannels != m_pSndFile->m_nChannels)) { - if(m_pModDoc->ChangeNumChannels(dlg.m_nChannels)) bShowLog = TRUE; - if(CChannelManagerDlg::sharedInstance(FALSE) && CChannelManagerDlg::sharedInstance()->IsDisplayed()) - CChannelManagerDlg::sharedInstance()->Update(); - } - if (bShowLog) m_pModDoc->ShowLog("Conversion Status", this); - m_pModDoc->SetModified(); - } - */ } @@ -732,13 +707,10 @@ for (int ry=rect.bottom-1; ry>rect.top; ry-=2) { int y0 = rect.bottom - ry; - int n = (y0 * NUM_VUMETER_PENS) / cy; - if (n < 0) n = 0; - if (n >= NUM_VUMETER_PENS) n = NUM_VUMETER_PENS-1; + int n = CLAMP((y0 * NUM_VUMETER_PENS) / cy, 0, NUM_VUMETER_PENS - 1); if (vu < y0) - { n += NUM_VUMETER_PENS; - } + SelectObject(hdc, CMainFrame::gpenVuMeter[n]); MoveToEx(hdc, rect.left, ry, NULL); LineTo(hdc, rect.right, ry); Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2009-07-25 15:39:19 UTC (rev 303) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2009-07-26 21:59:23 UTC (rev 304) @@ -479,7 +479,7 @@ const char *pszfmt = pSndFile->m_bChannelMuteTogglePending[ncolhdr]? "[Channel %d]" : "Channel %d"; // const char *pszfmt = pModDoc->IsChannelRecord(ncolhdr) ? "Channel %d " : "Channel %d"; // -! NEW_FEATURE#0012 - if ((pSndFile->m_nType & (MOD_TYPE_XM|MOD_TYPE_IT|MOD_TYPE_MPT)) && ((BYTE)pSndFile->ChnSettings[ncolhdr].szName[0] > 0x20)) + if ((pSndFile->m_nType & (MOD_TYPE_XM|MOD_TYPE_IT|MOD_TYPE_MPT)) && ((BYTE)pSndFile->ChnSettings[ncolhdr].szName[0] >= 0x20)) pszfmt = pSndFile->m_bChannelMuteTogglePending[ncolhdr]?"%d: [%s]":"%d: %s"; else if (m_nDetailLevel < 2) pszfmt = pSndFile->m_bChannelMuteTogglePending[ncolhdr]?"[Ch%d]":"Ch%d"; else if (m_nDetailLevel < 3) pszfmt = pSndFile->m_bChannelMuteTogglePending[ncolhdr]?"[Chn %d]":"Chn %d"; Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2009-07-25 15:39:19 UTC (rev 303) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2009-07-26 21:59:23 UTC (rev 304) @@ -3053,8 +3053,8 @@ _tcscpy(directories[dir], szPath); - // When updating default directory, also update the working directory. - if(szPath[0] && directories == m_szDefaultDirectory) + // When updating default directory, also update the working directory (if it hasn't been set yet). + if(szPath[0] && directories == m_szDefaultDirectory && !m_szWorkingDirectory[dir][0]) SetWorkingDirectory(szPath, dir); } Modified: trunk/OpenMPT/mptrack/Mainbar.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mainbar.cpp 2009-07-25 15:39:19 UTC (rev 303) +++ trunk/OpenMPT/mptrack/Mainbar.cpp 2009-07-26 21:59:23 UTC (rev 304) @@ -495,9 +495,9 @@ if ((n = (short int)m_SpinTempo.GetPos()) != 0) { if (n < 0) - pSndFile->SetTempo(nCurrentTempo - 1, true); + pSndFile->SetTempo(max(nCurrentTempo - 1, pSndFile->GetModSpecifications().tempoMin), true); else - pSndFile->SetTempo(nCurrentTempo + 1, true); + pSndFile->SetTempo(min(nCurrentTempo + 1, pSndFile->GetModSpecifications().tempoMax), true); m_SpinTempo.SetPos(0); } @@ -505,16 +505,10 @@ { if (n < 0) { - if (nCurrentSpeed > 1) - { - pSndFile->m_nMusicSpeed = nCurrentSpeed - 1; - } + pSndFile->m_nMusicSpeed = max(nCurrentSpeed - 1, pSndFile->GetModSpecifications().speedMin); } else { - if (nCurrentSpeed < 0x7F) - { - pSndFile->m_nMusicSpeed = nCurrentSpeed + 1; - } + pSndFile->m_nMusicSpeed = min(nCurrentSpeed + 1, pSndFile->GetModSpecifications().speedMax); } m_SpinSpeed.SetPos(0); } Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2009-07-25 15:39:19 UTC (rev 303) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2009-07-26 21:59:23 UTC (rev 304) @@ -1448,7 +1448,7 @@ // Channel mode if(wsdlg.m_bChannelMode){ // Add channel number & name (if available) to path string - if(m_SndFile.ChnSettings[i].szName[0] > 0x20) + if(m_SndFile.ChnSettings[i].szName[0] >= 0x20) wsprintf(channel, "-%03d_%s.wav", i+1,m_SndFile.ChnSettings[i].szName); else wsprintf(channel, "-%03d.wav", i+1); Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2009-07-25 15:39:19 UTC (rev 303) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2009-07-26 21:59:23 UTC (rev 304) @@ -8,6 +8,7 @@ #include "dlg_misc.h" #include "dlsbank.h" #include "modsmp_ctrl.h" +#include "misc_util.h" #pragma warning(disable:4244) //"conversion from 'type1' to 'type2', possible loss of data" @@ -419,6 +420,11 @@ } //end rewbs.cutomKeys + // Check mod specifications + const CModSpecifications& specs = m_SndFile.GetModSpecifications(); + m_SndFile.m_nDefaultTempo = CLAMP(m_SndFile.m_nDefaultTempo, specs.tempoMin, specs.tempoMax); + m_SndFile.m_nDefaultSpeed = CLAMP(m_SndFile.m_nDefaultSpeed, specs.speedMin, specs.speedMax); + SetModified(); ClearUndo(); UpdateAllViews(NULL, HINT_MODTYPE); Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2009-07-25 15:39:19 UTC (rev 303) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2009-07-26 21:59:23 UTC (rev 304) @@ -571,7 +571,7 @@ CDialog::OnInitDialog(); for (UINT n = 0; n < m_nChannels; n++) { - if(m_pSndFile->ChnSettings[n].szName[0] > 0x20) + if(m_pSndFile->ChnSettings[n].szName[0] >= 0x20) wsprintf(label, "Channel %d: %s", (n + 1), m_pSndFile->ChnSettings[n].szName); else wsprintf(label, "Channel %d", n + 1); @@ -1635,11 +1635,13 @@ char cNewEditOption = GetEditMode(); if(cNewEditOption != 3 && m_nEditOption == 3) { + // switch to "add silenece" m_nLength = GetDlgItemInt(IDC_EDIT_ADDSILENCE); SetDlgItemInt(IDC_EDIT_ADDSILENCE, m_nSamples); } else if(cNewEditOption == 3 && m_nEditOption != 3) { + // "switch to "resize" m_nSamples = GetDlgItemInt(IDC_EDIT_ADDSILENCE); SetDlgItemInt(IDC_EDIT_ADDSILENCE, m_nLength); } Modified: trunk/OpenMPT/mptrack/dlg_misc.h =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.h 2009-07-25 15:39:19 UTC (rev 303) +++ trunk/OpenMPT/mptrack/dlg_misc.h 2009-07-26 21:59:23 UTC (rev 304) @@ -356,7 +356,7 @@ public: UINT m_nSamples; UINT m_nLength; - char m_nEditOption; //0 = add at beginning, 1 = add at end, 2 = resize + char m_nEditOption; // 1 = add at beginning, 2 = add at end, 3 = resize public: CAddSilenceDlg(CWnd *parent, UINT nSamples = 32, UINT nOrigLength = 1024):CDialog(IDD_ADDSILENCE, parent) { m_nSamples = nSamples; m_nLength = nOrigLength; m_nEditOption = 2; } Modified: trunk/OpenMPT/mptrack/misc_util.h =================================================================== --- trunk/OpenMPT/mptrack/misc_util.h 2009-07-25 15:39:19 UTC (rev 303) +++ trunk/OpenMPT/mptrack/misc_util.h 2009-07-26 21:59:23 UTC (rev 304) @@ -72,4 +72,10 @@ } +// Like Limit, but returns value +#ifndef CLAMP +#define CLAMP(number, low, high) min(high, max(low, number)) #endif + + +#endif Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2009-07-25 15:39:19 UTC (rev 303) +++ trunk/OpenMPT/mptrack/mptrack.rc 2009-07-26 21:59:23 UTC (rev 304) @@ -13,6 +13,53 @@ #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// +// Deutsch (Deutschland) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) +#ifdef _WIN32 +LANGUAGE LANG_GERMAN, SUBLANG_GERMAN +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_MODLOADING_WARNINGS DIALOGEX 0, 0, 316, 178 +STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "module.it - Warnings" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "OK",IDOK,258,156,50,14 + EDITTEXT IDC_EDIT_MODLOADING_WARNINGS,6,18,300,132,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY + LTEXT "The following problems have been encountered when loading this module:",IDC_STATIC,6,6,237,8 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_MODLOADING_WARNINGS, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 309 + TOPMARGIN, 7 + BOTTOMMARGIN, 171 + END +END +#endif // APSTUDIO_INVOKED + +#endif // Deutsch (Deutschland) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// // Englisch (USA) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) @@ -493,14 +540,14 @@ CTEXT "Not saved with song!",IDC_STATIC,262,73,60,17 CONTROL "",IDC_VUMETER_LEFT,"Static",SS_BLACKRECT | SS_SUNKEN,325,1,15,91 CONTROL "",IDC_VUMETER_RIGHT,"Static",SS_BLACKRECT | SS_SUNKEN,343,1,15,91 - GROUPBOX "Player Settings (not saved in song!)",IDC_STATIC,414,31,147,63,NOT WS_VISIBLE - CONTROL "Bass Expansion",IDC_CHECK_BASS,"Button",BS_AUTOCHECKBOX | BS_FLAT | NOT WS_VISIBLE | WS_TABSTOP,420,43,65,10 - CONTROL "Reverb",IDC_CHECK_REVERB,"Button",BS_AUTOCHECKBOX | BS_FLAT | NOT WS_VISIBLE | WS_TABSTOP,420,55,46,10 - CONTROL "Surround",IDC_CHECK_SURROUND,"Button",BS_AUTOCHECKBOX | BS_FLAT | NOT WS_VISIBLE | WS_TABSTOP,420,67,48,10 - COMBOBOX IDC_COMBO_RESAMPLING,490,76,67,74,CBS_DROPDOWNLIST | NOT WS_VISIBLE | WS_TABSTOP - LTEXT "Resampling:",IDC_STATIC,491,67,43,8,NOT WS_VISIBLE - CONTROL "Graphic EQ",IDC_CHECK_EQ,"Button",BS_AUTOCHECKBOX | BS_FLAT | NOT WS_VISIBLE | WS_TABSTOP,420,79,58,10 - CONTROL "AGC",IDC_CHECK_AGC,"Button",BS_AUTOCHECKBOX | BS_FLAT | NOT WS_VISIBLE | WS_TABSTOP,491,43,31,10 + GROUPBOX "Player Settings (not saved in song!)",IDC_STATIC,366,6,150,66,NOT WS_VISIBLE + CONTROL "Bass Expansion",IDC_CHECK_BASS,"Button",BS_AUTOCHECKBOX | BS_FLAT | NOT WS_VISIBLE | WS_TABSTOP,372,18,65,10 + CONTROL "Reverb",IDC_CHECK_REVERB,"Button",BS_AUTOCHECKBOX | BS_FLAT | NOT WS_VISIBLE | WS_TABSTOP,372,30,46,10 + CONTROL "Surround",IDC_CHECK_SURROUND,"Button",BS_AUTOCHECKBOX | BS_FLAT | NOT WS_VISIBLE | WS_TABSTOP,372,42,48,10 + COMBOBOX IDC_COMBO_RESAMPLING,444,54,67,74,CBS_DROPDOWNLIST | NOT WS_VISIBLE | WS_TABSTOP + LTEXT "Resampling:",IDC_STATIC,444,42,43,8,NOT WS_VISIBLE + CONTROL "Graphic EQ",IDC_CHECK_EQ,"Button",BS_AUTOCHECKBOX | BS_FLAT | NOT WS_VISIBLE | WS_TABSTOP,372,54,58,10 + CONTROL "AGC",IDC_CHECK_AGC,"Button",BS_AUTOCHECKBOX | BS_FLAT | NOT WS_VISIBLE | WS_TABSTOP,444,18,31,10 END IDD_CONTROL_COMMENTS DIALOGEX 0, 0, 435, 119 @@ -2312,10 +2359,9 @@ LTEXT "Static",IDC_TUNINGTYPE_DESC,109,134,179,20,0,WS_EX_STATICEDGE END -IDD_CHANNELMANAGER DIALOGEX 0, 0, 523, 231 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_TOOLWINDOW -CAPTION "Channel manager" +IDD_CHANNELMANAGER DIALOGEX 0, 0, 524, 231 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Channel Manager" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN CONTROL "",IDC_TAB1,"SysTabControl32",TCS_MULTILINE,0,0,523,18,WS_EX_CLIENTEDGE @@ -2422,6 +2468,11 @@ BOTTOMMARGIN, 236 END + IDD_CHANNELMANAGER, DIALOG + BEGIN + RIGHTMARGIN, 523 + END + IDD_DEFAULTPLUGINEDITOR, DIALOG BEGIN LEFTMARGIN, 7 Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2009-07-25 15:39:19 UTC (rev 303) +++ trunk/OpenMPT/mptrack/resource.h 2009-07-26 21:59:23 UTC (rev 304) @@ -106,6 +106,8 @@ #define IDD_MIDIPARAMCONTROL 515 #define IDD_MSGBOX_HIDABLE 516 #define IDD_ADDSILENCE 517 +#define IDD_DIALOG4 518 +#define IDD_MODLOADING_WARNINGS 518 #define IDC_BUTTON1 1001 #define IDC_BUTTON2 1002 #define IDC_BUTTON3 1003 @@ -875,6 +877,7 @@ #define IDC_RADIO_ADDSILENCE_END 2381 #define IDC_SPIN_ADDSILENCE 2382 #define IDC_RADIO_RESIZETO 2384 +#define IDC_EDIT_MODLOADING_WARNINGS 2385 #define ID_FILE_NEWMOD 32771 #define ID_FILE_NEWXM 32772 #define ID_FILE_NEWS3M 32773 @@ -1112,9 +1115,9 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 518 +#define _APS_NEXT_RESOURCE_VALUE 519 #define _APS_NEXT_COMMAND_VALUE 59227 -#define _APS_NEXT_CONTROL_VALUE 2385 +#define _APS_NEXT_CONTROL_VALUE 2386 #define _APS_NEXT_SYMED_VALUE 901 #endif #endif Modified: trunk/OpenMPT/soundlib/Load_mod.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mod.cpp 2009-07-25 15:39:19 UTC (rev 303) +++ trunk/OpenMPT/soundlib/Load_mod.cpp 2009-07-26 21:59:23 UTC (rev 304) @@ -116,7 +116,7 @@ case CMD_PATTERNBREAK: command = 0x0D; param = ((param / 10) << 4) | (param % 10); break; case CMD_MODCMDEX: command = 0x0E; break; case CMD_SPEED: command = 0x0F; if (param > 0x20) param = 0x20; break; - case CMD_TEMPO: if (param > 0x20) { command = 0x0F; break; } + case CMD_TEMPO: if (param >= 0x20) { command = 0x0F; break; } case CMD_GLOBALVOLUME: command = 'G' - 55; break; case CMD_GLOBALVOLSLIDE: command = 'H' - 55; break; case CMD_KEYOFF: command = 'K' - 55; break; Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_s3m.cpp 2009-07-25 15:39:19 UTC (rev 303) +++ trunk/OpenMPT/soundlib/Load_s3m.cpp 2009-07-26 21:59:23 UTC (rev 304) @@ -11,6 +11,7 @@ #include "stdafx.h" #include "sndfile.h" #include "../mptrack/moddoc.h" +#include "../mptrack/misc_util.h" #pragma warning(disable:4244) //"conversion from 'type1' to 'type2', possible loss of data" @@ -266,12 +267,10 @@ memcpy(m_szNames[0], psfh.name, 28); // Speed m_nDefaultSpeed = psfh.speed; - if (m_nDefaultSpeed < 1) m_nDefaultSpeed = 6; - if (m_nDefaultSpeed > 0x1F) m_nDefaultSpeed = 0x1F; + if (!m_nDefaultSpeed) m_nDefaultSpeed = 6; // Tempo m_nDefaultTempo = psfh.tempo; - if (m_nDefaultTempo < 40) m_nDefaultTempo = 40; - if (m_nDefaultTempo > 240) m_nDefaultTempo = 240; + m_nDefaultTempo = CLAMP(m_nDefaultTempo, 32, 255); // Global Volume m_nDefaultGlobalVolume = psfh.globalvol << 2; if ((!m_nDefaultGlobalVolume) || (m_nDefaultGlobalVolume > 256)) m_nDefaultGlobalVolume = 256; @@ -296,8 +295,7 @@ if ((psfh.cwtv < 0x1320) || (psfh.flags & 0x40)) m_dwSongFlags |= SONG_FASTVOLSLIDES; // Reading pattern order UINT iord = psfh.ordnum; - if (iord<1) iord = 1; - if (iord > MAX_ORDERS) iord = MAX_ORDERS; + iord = CLAMP(iord, 1, MAX_ORDERS); if (iord) { Order.ReadAsByte(lpStream+dwMemPos, iord, dwMemLength-dwMemPos); @@ -343,27 +341,19 @@ lstrcpy(m_szNames[iSmp], (LPCSTR)&s[0x30]); if ((s[0]==1) && (s[0x4E]=='R') && (s[0x4F]=='S')) { - UINT j = LittleEndian(*((LPDWORD)(s+0x10))); - if (j > MAX_SAMPLE_LENGTH) j = MAX_SAMPLE_LENGTH; - if (j < 4) j = 0; - Ins[iSmp].nLength = j; - j = LittleEndian(*((LPDWORD)(s+0x14))); - if (j >= Ins[iSmp].nLength) j = Ins[iSmp].nLength - 1; - Ins[iSmp].nLoopStart = j; - j = LittleEndian(*((LPDWORD)(s+0x18))); - if (j > MAX_SAMPLE_LENGTH) j = MAX_SAMPLE_LENGTH; - if (j < 4) j = 0; - if (j > Ins[iSmp].nLength) j = Ins[iSmp].nLength; - Ins[iSmp].nLoopEnd = j; - j = s[0x1C]; - if (j > 64) j = 64; - Ins[iSmp].nVolume = j << 2; + Ins[iSmp].nLength = CLAMP(LittleEndian(*((LPDWORD)(s + 0x10))), 4, MAX_SAMPLE_LENGTH); + Ins[iSmp].nLoopStart = CLAMP(LittleEndian(*((LPDWORD)(s + 0x14))), 0, Ins[iSmp].nLength - 1); + Ins[iSmp].nLoopEnd = CLAMP(LittleEndian(*((LPDWORD)(s+0x18))), 4, Ins[iSmp].nLength); + Ins[iSmp].nVolume = CLAMP(s[0x1C], 0, 64) << 2; Ins[iSmp].nGlobalVol = 64; - if (s[0x1F]&1) Ins[iSmp].uFlags |= CHN_LOOP; - j = LittleEndian(*((LPDWORD)(s+0x20))); - if (!j) j = 8363; - if (j < 1024) j = 1024; - Ins[iSmp].nC4Speed = j; + if (s[0x1F] & 1) Ins[iSmp].uFlags |= CHN_LOOP; + + UINT c4speed; + c4speed = LittleEndian(*((LPDWORD)(s+0x20))); + if (!c4speed) c4speed = 8363; + if (c4speed < 1024) c4speed = 1024; + Ins[iSmp].nC4Speed = c4speed; + insfile[iSmp] = ((DWORD)LittleEndianW(*((LPWORD)(s+0x0E)))) << 4; insfile[iSmp] += ((DWORD)(BYTE)s[0x0D]) << 20; if (insfile[iSmp] > dwMemLength) insfile[iSmp] &= 0xFFFF; @@ -528,9 +518,9 @@ header[0x2E] = 'R'; header[0x2F] = 'M'; header[0x30] = m_nDefaultGlobalVolume >> 2; - header[0x31] = m_nDefaultSpeed; - header[0x32] = m_nDefaultTempo; - header[0x33] = min(max(0x20, m_nSamplePreAmp), 0x7F); // Stereo + header[0x31] = CLAMP(m_nDefaultSpeed, 1, 255); + header[0x32] = CLAMP(m_nDefaultTempo, 32, 255); + header[0x33] = CLAMP(m_nSamplePreAmp, 0x10, 0x7F); // Stereo header[0x35] = 0xFC; for (i=0; i<32; i++) { Modified: trunk/OpenMPT/soundlib/Load_xm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_xm.cpp 2009-07-25 15:39:19 UTC (rev 303) +++ trunk/OpenMPT/soundlib/Load_xm.cpp 2009-07-26 21:59:23 UTC (rev 304) @@ -9,6 +9,7 @@ #include "stdafx.h" #include "sndfile.h" #include "../mptrack/version.h" +#include "../mptrack/misc_util.h" //////////////////////////////////////////////////////// // FastTracker II XM file support @@ -84,7 +85,7 @@ XMSAMPLESTRUCT xmss; DWORD dwMemPos, dwHdrSize; WORD norders=0, restartpos=0, channels=0, patterns=0, instruments=0; - WORD xmflags=0, deftempo=125, defspeed=6; + WORD xmflags=0; BYTE InstUsed[256]; // -> CODE#0006 // -> DESC="misc quantity changes" @@ -100,7 +101,7 @@ m_nChannels = 0; if ((!lpStream) || (dwMemLength < 0x200)) return FALSE; if (_strnicmp((LPCSTR)lpStream, "Extended Module", 15)) return FALSE; - memcpy(m_szNames[0], lpStream+17, 20); + memcpy(m_szNames[0], lpStream + 17, 20); dwHdrSize = LittleEndian(*((DWORD *)(lpStream+60))); norders = LittleEndianW(*((WORD *)(lpStream+64))); if ((!norders) || (norders > MAX_ORDERS)) return FALSE; @@ -116,23 +117,19 @@ m_nMaxPeriod = 54784; m_nChannels = channels; if (restartpos < norders) m_nRestartPos = restartpos; - patterns = LittleEndianW(*((WORD *)(lpStream+70))); - if (patterns > 256) patterns = 256; + patterns = CLAMP(LittleEndianW(*((WORD *)(lpStream+70))), 0, 256); instruments = LittleEndianW(*((WORD *)(lpStream+72))); if (instruments >= MAX_INSTRUMENTS) instruments = MAX_INSTRUMENTS-1; m_nInstruments = instruments; m_nSamples = 0; - memcpy(&xmflags, lpStream+74, 2); + memcpy(&xmflags, lpStream + 74, 2); xmflags = LittleEndianW(xmflags); if (xmflags & 1) m_dwSongFlags |= SONG_LINEARSLIDES; if (xmflags & 0x1000) m_dwSongFlags |= SONG_EXFILTERRANGE; - defspeed = LittleEndianW(*((WORD *)(lpStream+76))); - deftempo = LittleEndianW(*((WORD *)(lpStream+78))); + m_nDefaultSpeed = CLAMP(LittleEndianW(*((WORD *)(lpStream+76))), 1, 31); // -> CODE#0016 // -> DESC="default tempo update" -// if ((deftempo >= 32) && (deftempo < 256)) m_nDefaultTempo = deftempo; - if ((deftempo >= 32) && (deftempo <= 512)) m_nDefaultTempo = deftempo; - if ((defspeed > 0) && (defspeed < 40)) m_nDefaultSpeed = defspeed; + m_nDefaultTempo = CLAMP(LittleEndianW(*((WORD *)(lpStream+78))), 32, 512); // -! BEHAVIOUR_CHANGE#0016 Order.ReadAsByte(lpStream+80, norders, dwMemLength-80); memset(InstUsed, 0, sizeof(InstUsed)); Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2009-07-25 15:39:19 UTC (rev 303) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2009-07-26 21:59:23 UTC (rev 304) @@ -14,6 +14,7 @@ #include "../mptrack/mptrack.h" #include "../mptrack/moddoc.h" #include "../mptrack/MainFrm.h" +#include "../mptrack/misc_util.h" // -! NEW_FEATURE#0022 #pragma warning(disable:4244) @@ -111,6 +112,7 @@ nCurrentPattern = nNextPattern = 0; nPattern = Order[0]; nRow = nNextRow = 0; + for (;;) { UINT nSpeedCount = 0; @@ -243,16 +245,17 @@ if ((param & 0xF0) == 0x10) { nMusicTempo += (param & 0x0F) * (nMusicSpeed-1); //rewbs.tempoSlideFix -// -> CODE#0010 -// -> DESC="add extended parameter mechanism to pattern effects" -// if (nMusicTempo > 255) nMusicTempo = 255; - if (nMusicTempo > 512) nMusicTempo = 512; -// -! NEW_FEATURE#0010 } else { nMusicTempo -= (param & 0x0F) * (nMusicSpeed-1); //rewbs.tempoSlideFix - if (nMusicTempo < 32) nMusicTempo = 32; } +// -> CODE#0010 +// -> DESC="add extended parameter mechanism to pattern effects" + if(GetModFlag(MSF_COMPATIBLE_PLAY)) + nMusicTempo = CLAMP(nMusicTempo, 32, 255); + else + nMusicTempo = CLAMP(nMusicTempo, GetModSpecifications().tempoMin, GetModSpecifications().tempoMax); +// -! NEW_FEATURE#0010 break; // Pattern Delay case CMD_S3MCMDEX: @@ -344,8 +347,7 @@ if (!(m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT))) param <<= 1; nGlbVol -= param * nMusicSpeed; } - if (nGlbVol < 0) nGlbVol = 0; - if (nGlbVol > 256) nGlbVol = 256; + nGlbVol = CLAMP(nGlbVol, 0, 256); break; case CMD_CHANNELVOLUME: if (param <= 64) chnvols[nChn] = param; @@ -367,7 +369,7 @@ param = (param & 0x0F) * nMusicSpeed; param = (chnvols[nChn] > param) ? chnvols[nChn] - param : 0; } else param = ((param & 0xF0) >> 4) * nMusicSpeed + chnvols[nChn]; - if (param > 64) param = 64; + param = min(param, 64); chnvols[nChn] = param; break; } @@ -667,9 +669,8 @@ } } - if (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2|MOD_TYPE_MED)) note += pChn->nTranspose; - if (note < 1) note = 1; - if (note > 132) note = 132; + if (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2|MOD_TYPE_MED)) note += pChn->nTranspose; + note = CLAMP(note, 1, 132); pChn->nNote = note; pChn->m_CalculateFreq = true; @@ -745,9 +746,9 @@ pChn->nLeftVU = pChn->nRightVU = 0xFF; pChn->dwFlags &= ~CHN_FILTER; pChn->dwFlags |= CHN_FASTVOLRAMP; - if(!GetModFlag(MSF_COMPATIBLE_PLAY)) + if(!GetModFlag(MSF_COMPATIBLE_PLAY) && (m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT))) { - //IT compatibility 15. Retrigger (Tremor doesn't store anything here, so we just don't reset this as well) + //IT compatibility 15. Retrigger will not be reset (Tremor doesn't store anything here, so we just don't reset this as well) pChn->nRetrigCount = 0; pChn->nTremorCount = 0; } @@ -1565,25 +1566,30 @@ if (!(param & 0x0F)) param |= pChn->nRetrigParam & 0x0F; param |= 0x100; // increment retrig count on first row } - if(!GetModFlag(MSF_COMPATIBLE_PLAY)) + if(GetModFlag(MSF_COMPATIBLE_PLAY) && (m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT))) { + //IT compatibility 15. Retrigger + if (volcmd == VOLCMD_OFFSET) + RetrigNote(nChn, pChn->nRetrigParam, vol << 3); + else if (volcmd == VOLCMD_VELOCITY) + RetrigNote(nChn, pChn->nRetrigParam, 48 - (vol << 3)); + else + RetrigNote(nChn, pChn->nRetrigParam); + } + else + { + //MPT Retrig if (param) pChn->nRetrigParam = (BYTE)(param & 0xFF); else param = pChn->nRetrigParam; //rewbs.volOffset //RetrigNote(nChn, param); if (volcmd == VOLCMD_OFFSET) - RetrigNote(nChn, param, vol<<3); + RetrigNote(nChn, param, vol << 3); else if (volcmd == VOLCMD_VELOCITY) - RetrigNote(nChn, param, 48-(vol << 3)); + RetrigNote(nChn, param, 48 - (vol << 3)); else RetrigNote(nChn, param); //end rewbs.volOffset: } - else - { - //IT compatibility 15. Retrigger - if (param) pChn->nRetrigParam = (BYTE)(param & 0xFF); - RetrigNote(nChn, pChn->nRetrigParam); - } break; // Tremor @@ -2277,8 +2283,7 @@ else newvolume += (int)((param & 0xF0) >> 2); if (m_nType & MOD_TYPE_MOD) pChn->dwFlags |= CHN_FASTVOLRAMP; } - if (newvolume < 0) newvolume = 0; - if (newvolume > 256) newvolume = 256; + newvolume = CLAMP(newvolume, 0, 256); pChn->nVolume = newvolume; } @@ -2324,8 +2329,7 @@ if (nPanSlide) { nPanSlide += pChn->nPan; - if (nPanSlide < 0) nPanSlide = 0; - if (nPanSlide > 256) nPanSlide = 256; + nPanSlide = CLAMP(nPanSlide, 0, 256); pChn->nPan = nPanSlide; pChn->nRestorePanOnNewNote = 0; } @@ -2390,8 +2394,7 @@ if (nChnSlide) { nChnSlide += pChn->nGlobalVol; - if (nChnSlide < 0) nChnSlide = 0; - if (nChnSlide > 64) nChnSlide = 64; + nChnSlide = CLAMP(nChnSlide, 0, 64); pChn->nGlobalVol = nChnSlide; } } @@ -3046,12 +3049,18 @@ if (dv) { int vol = pChn->nVolume; - if (retrigTable1[dv]) - vol = (vol * retrigTable1[dv]) >> 4; - else - vol += ((int)retrigTable2[dv]) << 2; - if (vol < 0) vol = 0; - if (vol > 256) vol = 256; + + // FT2 compatibility: Retrig + volume will not change volume of retrigged notes + if(!(m_nType & MOD_TYPE_XM) || !(pChn->nRowVolCmd == VOLCMD_VOLUME) || !GetModFlag(MSF_COMPATIBLE_PLAY)) + { + if (retrigTable1[dv]) + vol = (vol * retrigTable1[dv]) >> 4; + else + vol += ((int)retrigTable2[dv]) << 2; + } + + vol = CLAMP(vol, 0, 256); + pChn->nVolume = vol; pChn->dwFlags |= CHN_FASTVOLRAMP; } @@ -3236,7 +3245,7 @@ void CSoundFile::SetTempo(UINT param, bool setAsNonModcommand) -//----------------------------------- +//------------------------------------------------------------ { const CModSpecifications& specs = GetModSpecifications(); if(setAsNonModcommand) @@ -3258,18 +3267,17 @@ else if (param < 0x20 && m_nTickCount) //rewbs.tempoSlideFix: only slide if (T0x or T1x) and tick is not 0 { if ((param & 0xF0) == 0x10) - { m_nMusicTempo += (param & 0x0F); //rewbs.tempoSlideFix: no *2 - // -> CODE#0016 - // -> DESC="default tempo update" - // if (m_nMusicTempo > 255) m_nMusicTempo = 255; - if (m_nMusicTempo > specs.tempoMax) m_nMusicTempo = specs.tempoMax; - // -! BEHAVIOUR_CHANGE#0016 - } else - { + else m_nMusicTempo -= (param & 0x0F); //rewbs.tempoSlideFix: no *2 - if ((LONG)m_nMusicTempo < specs.tempoMin) m_nMusicTempo = specs.tempoMin; - } + + // -> CODE#0016 + // -> DESC="default tempo update" + if(GetModFlag(MSF_COMPATIBLE_PLAY)) + m_nMusicTempo = CLAMP(m_nMusicTempo, 32, 255); + else + m_nMusicTempo = CLAMP(m_nMusicTempo, specs.tempoMin, specs.tempoMax); + // -! BEHAVIOUR_CHANGE#0016 } } } @@ -3339,8 +3347,7 @@ { if (!(m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT))) nGlbSlide *= 2; nGlbSlide += m_nGlobalVolume; - if (nGlbSlide < 0) nGlbSlide = 0; - if (nGlbSlide > 256) nGlbSlide = 256; + nGlbSlide = CLAMP(nGlbSlide, 0, 256); m_nGlobalVolume = nGlbSlide; } } Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2009-07-25 15:39:19 UTC (rev 303) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2009-07-26 21:59:23 UTC (rev 304) @@ -637,7 +637,7 @@ Chn[ich].nVolume = 256; Chn[ich].nCutOff = 0x7F; //IT compatibility 15. Retrigger - if(GetModFlag(MSF_COMPATIBLE_PLAY)) + if(GetModFlag(MSF_COMPATIBLE_PLAY) && (m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT))) { Chn[ich].nRetrigParam = 1; Chn[ich].nRetrigCount = 0; @@ -1188,7 +1188,7 @@ Chn[j].nPatternLoopCount = 0; Chn[j].nPatternLoop = 0; //IT compatibility 15. Retrigger - if(GetModFlag(MSF_COMPATIBLE_PLAY)) + if(GetModFlag(MSF_COMPATIBLE_PLAY) && (m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT))) { Chn[j].nRetrigCount = 0; Chn[j].nRetrigParam = 1; @@ -1454,7 +1454,7 @@ Chn[i].nFadeOutVol = 0; Chn[i].dwFlags |= CHN_KEYOFF|CHN_NOTEFADE; //IT compatibility 15. Retrigger - if(GetModFlag(MSF_COMPATIBLE_PLAY)) + if(GetModFlag(MSF_COMPATIBLE_PLAY) && (m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT))) { Chn[i].nRetrigParam = 1; Chn[i].nRetrigCount = 0; Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2009-07-25 15:39:19 UTC (rev 303) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2009-07-26 21:59:23 UTC (rev 304) @@ -14,6 +14,7 @@ #include "../mptrack/mptrack.h" #include "../mptrack/moddoc.h" #include "../mptrack/MainFrm.h" +#include "../mptrack/misc_util.h" // -! NEW_FEATURE#0022 #include "sndfile.h" #include "midi.h" @@ -954,8 +955,7 @@ } } - if (vol < 0) vol = 0; - if (vol > 256) vol = 256; + vol = CLAMP(vol, 0, 256); // Tremolo if (pChn->dwFlags & CHN_TREMOLO) @@ -994,7 +994,7 @@ { if(GetModFlag(MSF_COMPATIBLE_PLAY) && (m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT))) { - // Original IT behaviour + // IT compatibility 12: Tremor if(pChn->nTremorOn) pChn->nTremorOn--; if(!pChn->nTremorOn) { @@ -1040,10 +1040,8 @@ pChn->dwFlags |= CHN_FASTVOLRAMP; } - // Clip volume - if (vol < 0) vol = 0; - if (vol > 0x100) vol = 0x100; - vol <<= 6; + // Clip volume and multiply + vol = CLAMP(vol, 0, 256) << 6; // Process Envelopes if (pChn->pHeader) @@ -1073,10 +1071,7 @@ int relativeVolumeChange = (envvol-envValueAtReleaseNode)*2; envvol = envValueAtReleaseJump + relativeVolumeChange; } - if (envvol < 0) envvol = 0; - if (envvol > 512) - envvol = 512; - vol = (vol * envvol) >> 8; + vol = (vol * CLAMP(envvol, 0, 512)) >> 8; } // Panning Envelope if ((pChn->dwFlags & CHN_PANENV) && (penv->nPanEnv)) @@ -1111,8 +1106,8 @@ { envpan += ((envpos - x1) * (y2 - envpan)) / (x2 - x1); } - if (envpan < 0) envpan = 0; - if (envpan > 64) envpan = 64; + + envpan = CLAMP(envpan, 0, 64); int pan = pChn->nPan; if (pan >= 128) { @@ -1121,9 +1116,8 @@ { pan += ((envpan - 32) * (pan)) / 32; } - if (pan < 0) pan = 0; - if (pan > 256) pan = 256; - pChn->nRealPan = pan; + + pChn->nRealPan = CLAMP(pan, 0, 256); } // FadeOut volume if (pChn->dwFlags & CHN_NOTEFADE) @@ -1144,9 +1138,7 @@ if ((penv->nPPS) && (pChn->nRealPan) && (pChn->nNote)) { int pandelta = (int)pChn->nRealPan + (int)((int)(pChn->nNote - penv->nPPC - 1) * (int)penv->nPPS) / (int)8; - if (pandelta < 0) pandelta = 0; - if (pandelta > 256) pandelta = 256; - pChn->nRealPan = pandelta; + pChn->nRealPan = CLAMP(pandelta, 0, 256); } } else { @@ -1227,11 +1219,9 @@ } } + // Preserve Amiga freq limits if (m_dwSongFlags & SONG_AMIGALIMITS) - { - if (period < 113*4) period = 113*4; - if (period > 856*4) period = 856*4; - } + period = CLAMP(period, 113 * 4, 856 * 4); // Pitch/Filter Envelope if ((pChn->pHeader) && (pChn->dwFlags & CHN_PITCHENV) && (pChn->pHeader->nPitchEnv)) @@ -1269,8 +1259,7 @@ int envpitchdest = (((int)penv->PitchEnv[pt]) - 32) * 8; envpitch += ((envpos - x1) * (envpitchdest - envpitch)) / (x2 - x1); } - if (envpitch < -256) envpitch = -256; - if (envpitch > 256) envpitch = 256; + envpitch = CLAMP(envpitch, -256, 256); // Filter Envelope: controls cutoff frequency if (penv->dwFlags & ENV_FILTER) { @@ -1397,9 +1386,8 @@ pChn->nPanbrelloPos += pChn->nPanbrelloSpeed; pdelta = ((pdelta * (int)pChn->nPanbrelloDepth) + 2) >> 3; pdelta += pChn->nRealPan; - if (pdelta < 0) pdelta = 0; - if (pdelta > 256) pdelta = 256; - pChn->nRealPan = pdelta; + + pChn->nRealPan = CLAMP(pdelta, 0, 256); } int nPeriodFrac = 0; // Instrument Auto-Vibrato @@ -1691,8 +1679,7 @@ pan *= (int)m_nStereoSeparation; pan /= 128; pan += 128; - if (pan < 0) pan = 0; - if (pan > 256) pan = 256; + pan = CLAMP(pan, 0, 256); #ifndef FASTSOUNDLIB if (gdwSoundSetup & SNDMIX_REVERSESTEREO) pan = 256 - pan; #endif Modified: trunk/OpenMPT/soundlib/mod_specifications.h =================================================================== --- trunk/OpenMPT/soundlib/mod_specifications.h 2009-07-25 15:39:19 UTC (rev 303) +++ trunk/OpenMPT/soundlib/mod_specifications.h 2009-07-26 21:59:23 UTC (rev 304) @@ -31,6 +31,8 @@ INSTRUMENTINDEX instrumentsMax; BYTE defaultMixLevels; BYTE MIDIMappingDirectivesMax; + UINT speedMin; + UINT speedMax; }; @@ -61,7 +63,9 @@ 4000, //SamplesMax 256, //instrumentMax mixLevels_117RC3, //defaultMixLevels - 200 //Max MIDI mapping directives + 200, //Max MIDI mapping directives + 1, //Min Speed + 255, //Max Speed }; @@ -80,7 +84,7 @@ 4, //Channel min 4, //Channel max 32, //Min tempo - 256, //Max tempo + 255, //Max tempo 64, //Min pattern rows 64, //Max pattern rows 20, //Max mod name length @@ -88,6 +92,8 @@ 0, //instrumentMax mixLevels_original, //defaultMixLevels 0, //Max MIDI mapping directives + 1, //Min Speed + 31, //Max Speed }; // MOD with MPT extensions. @@ -104,14 +110,16 @@ 4, //Channel min 32, //Channel max 32, //Min tempo - 256, //Max tempo + 255, //Max tempo 64, //Min pattern rows 64, //Max pattern rows 20, //Max mod name length 31, //SamplesMax 0, //instrumentMax mixLevels_original, //defaultMixLevels - 0 //Max MIDI mapping directives + 0, //Max MIDI mapping directives + 1, //Min Speed + 31, //Max Speed }; const CModSpecifications xm = @@ -127,14 +135,16 @@ 4, //Channel min 32, //Channel max 32, //Min tempo - 256, //Max tempo + 255, //Max tempo 4, //Min pattern rows 256, //Max pattern rows 20, //Max mod name length 31, //SamplesMax 200, //instrumentMax mixLevels_original, //defaultMixLevels - 0 //Max MIDI mapping directives + 0, //Max MIDI mapping directives + 1, //Min Speed + 31, //Max Speed }; // XM with MPT extensions @@ -147,7 +157,7 @@ false, //No notecut. true, //Has noteoff. 240, //Pattern max. - 256, //Order max. + 255, //Order max. 4, //Channel min 127, //Channel max 32, //Min tempo @@ -158,7 +168,9 @@ 4000, //SamplesMax 256, //instrumentMax mixLevels_117RC3, //defaultMixLevels - 200 //Max MIDI mapping directives + 200, //Max MIDI mapping directives + 1, //Min Speed + 31, //Max Speed }; const CModSpecifications s3m = @@ -174,14 +186,16 @@ 4, //Channel min 32, //Channel max 32, //Min tempo - 256, //Max tempo + 255, //Max tempo 64, //Min pattern rows 64, //Max pattern rows 27, //Max mod name length 99, //SamplesMax 0, //instrumentMax mixLevels_original, //defaultMixLevels - 0 //Max MIDI mapping directives + 0, //Max MIDI mapping directives + 1, //Min Speed + 255, //Max Speed }; // S3M with MPT extensions @@ -198,14 +212,16 @@ 4, //Channel min 32, //Channel max 32, //Min tempo - 256, //Max tempo + 255, //Max tempo 64, //Min pattern rows 64, //Max pattern rows 27, //Max mod name length 99, //SamplesMax 0, //instrumentMax mixLevels_original, //defaultMixLevels - 0 //Max MIDI mapping directives + 0, //Max MIDI mapping directives + 1, //Min Speed + 255, //Max Speed }; const CModSpecifications it = @@ -221,14 +237,16 @@ 4, //Channel min 64, //Channel max 32, //Min tempo - 256, //Max tempo + 255, //Max tempo 4, //Min pattern rows 256, //Max pattern rows 25, //Max mod name length 256, //SamplesMax 200, //instrumentMax mixLevels_original, //defaultMixLevels - 0 //Max MIDI mapping directives + 0, //Max MIDI mapping directives + 1, //Min Speed + 255, //Max Speed }; const CModSpecifications itEx = @@ -251,7 +269,9 @@ 4000, //SamplesMax 256, //instrumentMax mixLevels_117RC3, //defaultMixLevels - 200 //Max MIDI mapping directives + 200, //Max MIDI mapping directives + 1, //Min Speed + 255, //Max Speed }; } //namespace ModSpecs This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |