From: <sag...@us...> - 2011-09-17 15:59:12
|
Revision: 1035 http://modplug.svn.sourceforge.net/modplug/?rev=1035&view=rev Author: saga-games Date: 2011-09-17 15:59:05 +0000 (Sat, 17 Sep 2011) Log Message: ----------- [Imp (?)] Reordered MODINSTRUMENT members for theoretically better caching. [Mod] Installer: Updated hashs / download locations for unmo3 2.4.0.3 [Mod] OpenMPT: Version is now 1.20.00.22 Modified Paths: -------------- trunk/OpenMPT/installer/install-unmo3-free-itd.iss trunk/OpenMPT/installer/install-unmo3-free.iss trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/installer/install-unmo3-free-itd.iss =================================================================== --- trunk/OpenMPT/installer/install-unmo3-free-itd.iss 2011-09-17 15:42:37 UTC (rev 1034) +++ trunk/OpenMPT/installer/install-unmo3-free-itd.iss 2011-09-17 15:59:05 UTC (rev 1035) @@ -21,9 +21,9 @@ begin if(IsTaskSelected('downloadmo3') And FileExists(ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp'))) then begin - if(GetSHA1OfFile(ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp')) <> 'f8ec44e0a089f17ddd6333956ecc37cd8081e7e8') then + if(GetSHA1OfFile(ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp')) <> '79de7b1476bbde064951c6946cf315a2') then begin - MsgBox('Warning: unmo3.dll has been downloaded, but its checksum is wrong! This means that either the downloaded file is corrupted or that a newer version of unmo3.dll is available. The file has thus not been installed. Please obtain unmo3.dll from http://openmpt.org/ and verify its checksum.', mbCriticalError, MB_OK) + MsgBox('Warning: unmo3.dll has been downloaded, but its checksum is wrong! This means that the downloaded file might corrupted or manipulated. The file has thus not been installed. Please obtain unmo3.dll from http://openmpt.org/ and verify its checksum.', mbCriticalError, MB_OK) end else begin FileCopy(ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp'), ExpandConstant('{app}\unmo3.dll'), true); @@ -46,7 +46,7 @@ begin if(IsTaskSelected('downloadmo3')) then begin - ITD_AddFile('http://openmpt.org/files/unmo3/2.4.0.2/unmo3.dll', ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp')); + ITD_AddFile('http://openmpt.org/files/unmo3/2.4.0.3/unmo3.dll', ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp')); ITD_AddMirror('ftp://ftp.untergrund.net/users/sagamusix/openmpt/unmo3.dll', ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp')); end else begin Modified: trunk/OpenMPT/installer/install-unmo3-free.iss =================================================================== --- trunk/OpenMPT/installer/install-unmo3-free.iss 2011-09-17 15:42:37 UTC (rev 1034) +++ trunk/OpenMPT/installer/install-unmo3-free.iss 2011-09-17 15:59:05 UTC (rev 1035) @@ -13,16 +13,16 @@ #include "install.iss" [_ISToolDownload] -Source: http://openmpt.org/files/unmo3/2.4.0.2/unmo3.dll; DestDir: {tmp}; DestName: openmpt-unmo3.dll.tmp; Tasks: downloadmo3 +Source: http://openmpt.org/files/unmo3/2.4.0.3/unmo3.dll; DestDir: {tmp}; DestName: openmpt-unmo3.dll.tmp; Tasks: downloadmo3 [Code] // Verify checksum of downloaded file, and if it is OK, copy it to the app directory. procedure VerifyUNMO3Checksum(); begin if(IsTaskSelected('downloadmo3') And FileExists(ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp'))) then begin - if(GetSHA1OfFile(ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp')) <> 'f8ec44e0a089f17ddd6333956ecc37cd8081e7e8') then + if(GetSHA1OfFile(ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp')) <> '79de7b1476bbde064951c6946cf315a2') then begin - MsgBox('Warning: unmo3.dll has been downloaded, but its checksum is wrong! This means that either the downloaded file is corrupted or that a newer version of unmo3.dll is available. The file has thus not been installed. Please obtain unmo3.dll from http://openmpt.org/ and verify its checksum.', mbCriticalError, MB_OK) + MsgBox('Warning: unmo3.dll has been downloaded, but its checksum is wrong! This means that the downloaded file might corrupted or manipulated. The file has thus not been installed. Please obtain unmo3.dll from http://openmpt.org/ and verify its checksum.', mbCriticalError, MB_OK) end else begin FileCopy(ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp'), ExpandConstant('{app}\unmo3.dll'), true); Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-09-17 15:42:37 UTC (rev 1034) +++ trunk/OpenMPT/mptrack/version.h 2011-09-17 15:59:05 UTC (rev 1035) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 21 +#define VER_MINORMINOR 22 //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_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2011-09-17 15:42:37 UTC (rev 1034) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2011-09-17 15:59:05 UTC (rev 1035) @@ -78,11 +78,14 @@ #define MAX_ENVPOINTS 240 #define MIN_PERIOD 0x0020 #define MAX_PERIOD 0xFFFF + // String lengths (including trailing null char) -#define MAX_SAMPLENAME 32 // also affects module name! -#define MAX_SAMPLEFILENAME 22 -#define MAX_PATTERNNAME 32 -#define MAX_CHANNELNAME 20 +#define MAX_SAMPLENAME 32 // also affects module name! +#define MAX_SAMPLEFILENAME 22 +#define MAX_INSTRUMENTNAME 32 +#define MAX_INSTRUMENTFILENAME 32 +#define MAX_PATTERNNAME 32 +#define MAX_CHANNELNAME 20 #define MAX_EQ_BANDS 6 Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2011-09-17 15:42:37 UTC (rev 1034) +++ trunk/OpenMPT/soundlib/Sndfile.h 2011-09-17 15:59:05 UTC (rev 1035) @@ -86,42 +86,35 @@ struct INSTRUMENTENVELOPE { DWORD dwFlags; // envelope flags - WORD Ticks[MAX_ENVPOINTS]; // envelope point position (x axis) - BYTE Values[MAX_ENVPOINTS]; // envelope point value (y axis) UINT nNodes; // amount of nodes used BYTE nLoopStart; // loop start node BYTE nLoopEnd; // loop end node BYTE nSustainStart; // sustain start node BYTE nSustainEnd; // sustain end node BYTE nReleaseNode; // release node + WORD Ticks[MAX_ENVPOINTS]; // envelope point position (x axis) + BYTE Values[MAX_ENVPOINTS]; // envelope point value (y axis) INSTRUMENTENVELOPE() { dwFlags = 0; - MemsetZero(Ticks); - MemsetZero(Values); nNodes = 0; nLoopStart = nLoopEnd = 0; nSustainStart = nSustainEnd = 0; nReleaseNode = ENV_RELEASE_NODE_UNSET; + MemsetZero(Ticks); + MemsetZero(Values); } }; // Instrument Struct struct MODINSTRUMENT { - UINT nFadeOut; // Instrument fadeout speed - DWORD dwFlags; // Instrument flags - UINT nGlobalVol; // Global volume (all sample volumes are multiplied with this) - UINT nPan; // Default pan (overrides sample panning), if the appropriate flag is set + UINT nFadeOut; // Instrument fadeout speed + DWORD dwFlags; // Instrument flags + UINT nGlobalVol; // Global volume (all sample volumes are multiplied with this) + UINT nPan; // Default pan (overrides sample panning), if the appropriate flag is set - INSTRUMENTENVELOPE VolEnv; // Volume envelope data - INSTRUMENTENVELOPE PanEnv; // Panning envelope data - INSTRUMENTENVELOPE PitchEnv; // Pitch / filter envelope data - - BYTE NoteMap[128]; // Note mapping, f.e. C-5 => D-5. - WORD Keyboard[128]; // Sample mapping, f.e. C-5 => Sample 1 - BYTE nNNA; // New note action BYTE nDCT; // Duplicate check type (i.e. which condition will trigger the duplicate note action) BYTE nDNA; // Duplicate note action @@ -138,9 +131,6 @@ signed char nPPS; //Pitch/Pan separation (i.e. how wide the panning spreads) unsigned char nPPC; //Pitch/Pan centre - CHAR name[32]; // Note: not guaranteed to be null-terminated. - CHAR filename[32]; - PLUGINDEX nMixPlug; // Plugin assigned to this instrument uint16 nVolRampUp; // Default sample ramping up UINT nResampling; // Resampling mode @@ -150,13 +140,23 @@ WORD wPitchToTempoLock; // BPM at which the samples assigned to this instrument loop correctly BYTE nPluginVelocityHandling; // How to deal with plugin velocity BYTE nPluginVolumeHandling; // How to deal with plugin volume -// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -// WHEN adding new members here, ALSO update Sndfile.cpp (instructions near the top of this file)! -// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + CTuning *pTuning; // sample tuning assigned to this instrument + static CTuning *s_DefaultTuning; - CTuning* pTuning; // sample tuning assigned to this instrument - static CTuning* s_DefaultTuning; + INSTRUMENTENVELOPE VolEnv; // Volume envelope data + INSTRUMENTENVELOPE PanEnv; // Panning envelope data + INSTRUMENTENVELOPE PitchEnv; // Pitch / filter envelope data + BYTE NoteMap[128]; // Note mapping, f.e. C-5 => D-5. + SAMPLEINDEX Keyboard[128]; // Sample mapping, f.e. C-5 => Sample 1 + + CHAR name[MAX_INSTRUMENTNAME]; // Note: not guaranteed to be null-terminated. + CHAR filename[MAX_INSTRUMENTFILENAME]; + + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + // WHEN adding new members here, ALSO update Sndfile.cpp (instructions near the top of this file)! + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + void SetTuning(CTuning* pT) { pTuning = pT; @@ -169,12 +169,6 @@ 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; @@ -192,9 +186,6 @@ nPPC = NOTE_MIDDLEC - 1; nPPS = 0; - MemsetZero(name); - MemsetZero(filename); - nMixPlug = 0; nVolRampUp = 0; nResampling = SRCMODE_DEFAULT; @@ -206,6 +197,15 @@ nPluginVolumeHandling = PLUGIN_VOLUMEHANDLING_IGNORE; pTuning = s_DefaultTuning; + + for(size_t n = 0; n < CountOf(Keyboard); n++) + { + Keyboard[n] = sample; + NoteMap[n] = (BYTE)(n + 1); + } + + MemsetZero(name); + MemsetZero(filename); } }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-17 17:20:04
|
Revision: 1036 http://modplug.svn.sourceforge.net/modplug/?rev=1036&view=rev Author: saga-games Date: 2011-09-17 17:19:58 +0000 (Sat, 17 Sep 2011) Log Message: ----------- [Fix] Updated another unmo3-related URL in the installer [Mod] Close Dialog: Added buttons "Save All" and "Save None" for quicker navigation Modified Paths: -------------- trunk/OpenMPT/installer/install-unmo3-free-itd.iss trunk/OpenMPT/mptrack/CloseMainDialog.cpp trunk/OpenMPT/mptrack/CloseMainDialog.h trunk/OpenMPT/mptrack/mptrack.rc Modified: trunk/OpenMPT/installer/install-unmo3-free-itd.iss =================================================================== --- trunk/OpenMPT/installer/install-unmo3-free-itd.iss 2011-09-17 15:59:05 UTC (rev 1035) +++ trunk/OpenMPT/installer/install-unmo3-free-itd.iss 2011-09-17 17:19:58 UTC (rev 1036) @@ -47,7 +47,7 @@ if(IsTaskSelected('downloadmo3')) then begin ITD_AddFile('http://openmpt.org/files/unmo3/2.4.0.3/unmo3.dll', ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp')); - ITD_AddMirror('ftp://ftp.untergrund.net/users/sagamusix/openmpt/unmo3.dll', ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp')); + ITD_AddMirror('ftp://ftp.untergrund.net/users/sagamusix/openmpt/archive/unmo3/2.4.0.3/unmo3.dll', ExpandConstant('{tmp}\openmpt-unmo3.dll.tmp')); end else begin ITD_ClearFiles(); Modified: trunk/OpenMPT/mptrack/CloseMainDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/CloseMainDialog.cpp 2011-09-17 15:59:05 UTC (rev 1035) +++ trunk/OpenMPT/mptrack/CloseMainDialog.cpp 2011-09-17 17:19:58 UTC (rev 1036) @@ -16,8 +16,8 @@ BEGIN_MESSAGE_MAP(CloseMainDialog, CDialog) - ON_LBN_SELCHANGE(IDC_LIST1, OnSelectionChanged) - ON_COMMAND(IDC_BUTTON1, OnSwitchSelection) + ON_COMMAND(IDC_BUTTON1, OnSaveAll) + ON_COMMAND(IDC_BUTTON2, OnSaveNone) ON_COMMAND(IDC_CHECK1, OnSwitchFullPaths) END_MESSAGE_MAP() @@ -74,9 +74,6 @@ { // No modified documents... OnOK(); - } else - { - UpdateSwitchButtonState(); } return TRUE; @@ -120,39 +117,22 @@ } -void CloseMainDialog::OnSelectionChanged() -//---------------------------------------- +void CloseMainDialog::OnSaveAll() +//------------------------------- { - UpdateSwitchButtonState(); + m_List.SelItemRange(TRUE, 0, m_List.GetCount() - 1); + OnOK(); } -// Switch between save all/none -void CloseMainDialog::OnSwitchSelection() -//--------------------------------------- +void CloseMainDialog::OnSaveNone() +//-------------------------------- { - const int count = m_List.GetCount(); - // If all items are selected, deselect them all; Else, select all items. - const BOOL action = (m_List.GetSelCount() == count) ? FALSE : TRUE; - for(int i = 0; i < count; i++) - { - m_List.SetSel(i, action); - } - UpdateSwitchButtonState(); + m_List.SelItemRange(FALSE, 0, m_List.GetCount() - 1); + OnOK(); } -// Update Select none/all button -void CloseMainDialog::UpdateSwitchButtonState() -//--------------------------------------------- -{ - CString text = (m_List.GetSelCount() == m_List.GetCount()) ? "Se&lect none" : "Se&lect all"; - ((CButton *)GetDlgItem(IDC_BUTTON1))->SetWindowText(text); - text = (m_List.GetSelCount() > 0) ? "&Save selected" : "Cl&ose"; - ((CButton *)GetDlgItem(IDOK))->SetWindowText(text); -} - - // Switch between full path / filename only display void CloseMainDialog::OnSwitchFullPaths() //--------------------------------------- Modified: trunk/OpenMPT/mptrack/CloseMainDialog.h =================================================================== --- trunk/OpenMPT/mptrack/CloseMainDialog.h 2011-09-17 15:59:05 UTC (rev 1035) +++ trunk/OpenMPT/mptrack/CloseMainDialog.h 2011-09-17 17:19:58 UTC (rev 1036) @@ -19,7 +19,6 @@ CListBox m_List; CString FormatTitle(const CModDoc *pModDoc, bool fullPath); - void UpdateSwitchButtonState(); public: CloseMainDialog() : CDialog(IDD_CLOSEDOCUMENTS) { }; @@ -31,8 +30,9 @@ virtual void OnOK(); virtual void OnCancel(); - afx_msg void OnSelectionChanged(); - afx_msg void OnSwitchSelection(); + afx_msg void OnSaveAll(); + afx_msg void OnSaveNone(); + afx_msg void OnSwitchFullPaths(); DECLARE_MESSAGE_MAP() Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2011-09-17 15:59:05 UTC (rev 1035) +++ trunk/OpenMPT/mptrack/mptrack.rc 2011-09-17 17:19:58 UTC (rev 1036) @@ -211,11 +211,12 @@ CAPTION "Save modified files" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - DEFPUSHBUTTON "&OK",IDOK,300,138,66,14 + DEFPUSHBUTTON "Save &Selected",IDOK,300,138,66,14 PUSHBUTTON "&Cancel",IDCANCEL,300,157,66,14 LISTBOX IDC_LIST1,6,6,288,168,LBS_SORT | LBS_MULTIPLESEL | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP CONTROL "Show &full paths",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,180,252,12 - PUSHBUTTON "&Select none",IDC_BUTTON1,300,12,66,14 + PUSHBUTTON "Save &All",IDC_BUTTON1,300,90,66,14 + PUSHBUTTON "Save &None",IDC_BUTTON2,300,108,66,14 END This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-17 22:37:41
|
Revision: 1037 http://modplug.svn.sourceforge.net/modplug/?rev=1037&view=rev Author: saga-games Date: 2011-09-17 22:37:34 +0000 (Sat, 17 Sep 2011) Log Message: ----------- [Ref] Misc refactoring and cleanup Modified Paths: -------------- trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/ExceptionHandler.cpp trunk/OpenMPT/mptrack/Globals.cpp trunk/OpenMPT/mptrack/Globals.h trunk/OpenMPT/mptrack/KeyConfigDlg.cpp trunk/OpenMPT/mptrack/Mpt_midi.cpp trunk/OpenMPT/mptrack/mod2midi.cpp trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/Dlsbank.h trunk/OpenMPT/soundlib/LOAD_DMF.CPP trunk/OpenMPT/soundlib/Load_gdm.cpp trunk/OpenMPT/soundlib/Load_mt2.cpp trunk/OpenMPT/soundlib/Load_psm.cpp trunk/OpenMPT/soundlib/Message.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -435,7 +435,7 @@ DefineKeyCommand(kcEditCopy, 1361, _T("Copy")); DefineKeyCommand(kcEditPaste, 1362, _T("Paste")); DefineKeyCommand(kcEditMixPaste, 1363, _T("Mix Paste")); - DefineKeyCommand(kcEditSelectAll, 1364, _T("SelectAll")); + DefineKeyCommand(kcEditSelectAll, 1364, _T("Select All")); DefineKeyCommand(kcEditFind, 1365, _T("Find / Replace")); DefineKeyCommand(kcEditFindNext, 1366, _T("Find Next")); DefineKeyCommand(kcViewMain, 1367, _T("Toggle Main View")); Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -401,7 +401,7 @@ if (pIns) { bool bModified = false; - WORD n = pIns->Keyboard[m_nNote]; + SAMPLEINDEX n = pIns->Keyboard[m_nNote]; for (NOTEINDEXTYPE i = 0; i < NOTE_MAX; i++) if (pIns->Keyboard[i] != n) { pIns->Keyboard[i] = n; @@ -577,7 +577,7 @@ { UINT n = pIns->NoteMap[m_nNote]; bool bOk = false; - if ((note > 0) && (note <= NOTE_MAX)) + if ((note >= pSndFile->GetModSpecifications().noteMin) && (note <= pSndFile->GetModSpecifications().noteMax)) { n = note; bOk = true; Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -1530,15 +1530,12 @@ sztmp[32] = 0; if ((m->note) && (m->note <= NOTE_MAX)) { - UINT nsmp = pIns->Keyboard[m->note-1]; + const SAMPLEINDEX nsmp = pIns->Keyboard[m->note-1]; if ((nsmp) && (nsmp <= pSndFile->GetNumSamples())) { - CHAR sztmp2[64] = ""; - memcpy(sztmp2, pSndFile->m_szNames[nsmp], MAX_SAMPLENAME); - sztmp2[32] = 0; - if (sztmp2[0]) + if (pSndFile->m_szNames[nsmp][0]) { - wsprintf(sztmp+strlen(sztmp), " (%d: %s)", nsmp, sztmp2); + wsprintf(sztmp+strlen(sztmp), " (%d: %s)", nsmp, pSndFile->m_szNames[nsmp]); } } } Modified: trunk/OpenMPT/mptrack/ExceptionHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -99,7 +99,7 @@ pDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &ExInfo, NULL, NULL); ::CloseHandle(hFile); - errorMessage.AppendFormat("\n\nDebug information have been saved to\n%s", baseRescuePath); + errorMessage.AppendFormat("\n\nDebug information has been saved to\n%s", baseRescuePath); } } ::FreeLibrary(hDll); Modified: trunk/OpenMPT/mptrack/Globals.cpp =================================================================== --- trunk/OpenMPT/mptrack/Globals.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/mptrack/Globals.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -13,7 +13,7 @@ #include "ctrl_ins.h" #include "ctrl_com.h" #include "ctrl_graph.h" //rewbs.graph -#include ".\globals.h" +#include "globals.h" #ifdef _DEBUG #define new DEBUG_NEW Modified: trunk/OpenMPT/mptrack/Globals.h =================================================================== --- trunk/OpenMPT/mptrack/Globals.h 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/mptrack/Globals.h 2011-09-17 22:37:34 UTC (rev 1037) @@ -111,9 +111,6 @@ //================================ { public: - CModTabCtrl() {} - -public: BOOL InsertItem(int nIndex, LPSTR pszText, LPARAM lParam=0, int iImage=-1); BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID); UINT GetItemData(int nIndex); Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -588,7 +588,7 @@ //detect invalid input if (!kc.code) { - CString error = "You need to say to which key you'd like to map this command."; + CString error = "You need to say to which key you'd like to map this command to."; Reporting::Warning(error, "Invalid key data"); return; } Modified: trunk/OpenMPT/mptrack/Mpt_midi.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpt_midi.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/mptrack/Mpt_midi.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -14,16 +14,15 @@ //Get Midi message(dwParam1), apply MIDI settings having effect on volume, and return //the volume value [0, 256]. In addition value -1 is used as 'use default value'-indicator. -int ApplyVolumeRelatedMidiSettings(const DWORD& dwParam1, const BYTE midivolume) -//---------------------------------------------------------------- +int ApplyVolumeRelatedMidiSettings(const DWORD &dwParam1, const BYTE midivolume) +//------------------------------------------------------------------------------ { int nVol = GetFromMIDIMsg_DataByte2(dwParam1); if (CMainFrame::GetSettings().m_dwMidiSetup & MIDISETUP_RECORDVELOCITY) { nVol = (CDLSBank::DLSMidiVolumeToLinear(nVol)+255) >> 8; if (CMainFrame::GetSettings().m_dwMidiSetup & MIDISETUP_AMPLIFYVELOCITY) nVol *= 2; - if (nVol < 1) nVol = 1; - if (nVol > 256) nVol = 256; + Limit(nVol, 1, 256); if(CMainFrame::GetSettings().m_dwMidiSetup & MIDISETUP_MIDIVOL_TO_NOTEVOL) nVol = static_cast<int>((midivolume / 127.0) * nVol); } @@ -38,8 +37,8 @@ return nVol; } -void ApplyTransposeKeyboardSetting(CMainFrame& rMainFrm, DWORD& dwParam1) -//------------------------------------------------------------------------ +void ApplyTransposeKeyboardSetting(CMainFrame &rMainFrm, DWORD &dwParam1) +//----------------------------------------------------------------------- { if ( (CMainFrame::GetSettings().m_dwMidiSetup & MIDISETUP_TRANSPOSEKEYBOARD) && (GetFromMIDIMsg_Channel(dwParam1) != 9) ) @@ -50,17 +49,12 @@ int note = GetFromMIDIMsg_DataByte1(dwParam1); if (note < 0x80) { - note += nTranspose*12; - if (note < 0) note = NOTE_NONE; - if (note > NOTE_MAX - 1) note = NOTE_MAX - 1; + note += nTranspose * 12; + Limit(note, 0, NOTE_MAX - NOTE_MIN); - // -> CODE#0011 - // -> DESC="bug fix about transpose midi keyboard option" - //dwParam1 &= 0xffffff00; dwParam1 &= 0xffff00ff; - // -! BUG_FIX#0011 - dwParam1 |= (note<<8); + dwParam1 |= (note << 8); } } } @@ -97,7 +91,7 @@ { DWORD dwTime = timeGetTime(); const DWORD timediff = dwTime - gdwLastMidiEvtTime; - if (timediff < 20*3) break; + if (timediff < 20 * 3) break; gdwLastMidiEvtTime = dwTime; // continue } @@ -119,7 +113,8 @@ //------------------------------- { if (shMidiIn) return TRUE; - try { + try + { if (midiInOpen(&shMidiIn, GetSettings().m_nMidiDevice, (DWORD)MidiInCallBack, 0, CALLBACK_FUNCTION) != MMSYSERR_NOERROR) { shMidiIn = NULL; @@ -186,7 +181,7 @@ size_t CMIDIMapper::GetSerializationSize() const -//--------------------------------------------- +//---------------------------------------------- { size_t s = 0; for(const_iterator citer = Begin(); citer != End(); citer++) @@ -234,7 +229,7 @@ bool CMIDIMapper::Deserialize(const BYTE* ptr, const size_t size) -//---------------------------------------------------------------------------- +//--------------------------------------------------------------- { m_Directives.clear(); const BYTE* endptr = ptr + size; @@ -278,7 +273,7 @@ bool CMIDIMapper::OnMIDImsg(const DWORD midimsg, BYTE& mappedIndex, uint32& paramindex, BYTE& paramval) -//---------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------- { bool captured = false; @@ -338,4 +333,3 @@ else return true; } - Modified: trunk/OpenMPT/mptrack/mod2midi.cpp =================================================================== --- trunk/OpenMPT/mptrack/mod2midi.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/mptrack/mod2midi.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -481,18 +481,18 @@ tmp[len+1] = (pTrk->nMidiChannel==9) ? static_cast<BYTE>(pTrk->nMidiProgram) : static_cast<BYTE>(note); UINT vol = 0x7f; UINT nsmp = pTrk->nInstrument; - if (m_pSndFile->m_nInstruments) + if (m_pSndFile->GetNumInstruments()) { - if ((nsmp < MAX_INSTRUMENTS) && (m_pSndFile->Instruments[nsmp])) + if ((nsmp <= m_pSndFile->GetNumInstruments()) && (m_pSndFile->Instruments[nsmp])) { MODINSTRUMENT *pIns = m_pSndFile->Instruments[nsmp]; nsmp = pIns->Keyboard[note]; } else nsmp = 0; } - if ((nsmp) && (nsmp < MAX_SAMPLES)) vol = m_pSndFile->GetSample(nsmp).nVolume; - if (m->volcmd == VOLCMD_VOLUME) vol = m->vol*4; - if (m->command == CMD_VOLUME) vol = m->param*4; - vol = LinearToDLSMidiVolume(vol<<8); + if (nsmp && nsmp <= m_pSndFile->GetNumSamples()) vol = m_pSndFile->GetSample(nsmp).nVolume; + if (m->command == CMD_VOLUME) vol = m->param * 4; + if (m->volcmd == VOLCMD_VOLUME) vol = m->vol * 4; + vol = LinearToDLSMidiVolume(vol << 8); if (vol > 0x7f) vol = 0x7f; tmp[len+2] = (BYTE)vol; tmp[len+3] = 0; @@ -506,7 +506,7 @@ UINT param = m->param; switch(m->command) { - case CMD_SPEED: if ((param) && (param < 32)) nSpeed = param; break; + case CMD_SPEED: if (param) nSpeed = param; break; case CMD_PATTERNBREAK: pattern_break = param; break; } } Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -873,6 +873,7 @@ for (UINT i=0; i<m_nSamplesEx; i++, pDlsSmp++, p++) { memcpy(pDlsSmp->szName, p->achSampleName, 20); + StringFixer::SetNullTerminator(pDlsSmp->szName); pDlsSmp->dwLen = 0; pDlsSmp->dwSampleRate = p->dwSampleRate; pDlsSmp->byOriginalPitch = p->byOriginalPitch; @@ -1757,7 +1758,7 @@ { if ((nRgn == nRgnMin) || ((iKey >= pRgn->uKeyMin) && (iKey <= pRgn->uKeyMax))) { - pIns->Keyboard[iKey] = (BYTE)nSmp; + pIns->Keyboard[iKey] = (SAMPLEINDEX)nSmp; } } // Load the sample @@ -1901,3 +1902,25 @@ } return TRUE; } + + +const CHAR *CDLSBank::GetRegionName(UINT nIns, UINT nRgn) const +//------------------------------------------------------------- +{ + DLSINSTRUMENT *pDlsIns; + + if ((!m_pInstruments) || (nIns >= m_nInstruments)) return nullptr; + pDlsIns = &m_pInstruments[nIns]; + if (nRgn >= pDlsIns->nRegions) return nullptr; + + if (m_nType & SOUNDBANK_TYPE_SF2) + { + UINT nWaveLink = pDlsIns->Regions[nRgn].nWaveLink; + if ((nWaveLink < m_nSamplesEx) && (m_pSamplesEx)) + { + DLSSAMPLEEX *p = &m_pSamplesEx[nWaveLink]; + return p->szName; + } + } + return nullptr; +} Modified: trunk/OpenMPT/soundlib/Dlsbank.h =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.h 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/soundlib/Dlsbank.h 2011-09-17 22:37:34 UTC (rev 1037) @@ -124,6 +124,7 @@ BOOL ExtractWaveForm(UINT nIns, UINT nRgn, LPBYTE *ppWave, DWORD *pLen); BOOL ExtractSample(CSoundFile *pSndFile, SAMPLEINDEX nSample, UINT nIns, UINT nRgn, int transpose=0); BOOL ExtractInstrument(CSoundFile *pSndFile, INSTRUMENTINDEX nInstr, UINT nIns, UINT nDrumRgn); + const CHAR *GetRegionName(UINT nIns, UINT nRgn) const; // Internal Loader Functions protected: Modified: trunk/OpenMPT/soundlib/LOAD_DMF.CPP =================================================================== --- trunk/OpenMPT/soundlib/LOAD_DMF.CPP 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/soundlib/LOAD_DMF.CPP 2011-09-17 22:37:34 UTC (rev 1037) @@ -856,7 +856,7 @@ { // Special case: Last 4 bytes should be "ENDE", without a size field (WTF) ASSERT_CAN_READ(4); - if(LittleEndian(*(uint32 *)(lpStream + dwMemPos)) == DMF_ENDE) + if(*(uint32 *)(lpStream + dwMemPos) == LittleEndian(DMF_ENDE)) { break; } Modified: trunk/OpenMPT/soundlib/Load_gdm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_gdm.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/soundlib/Load_gdm.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -20,7 +20,7 @@ #pragma pack(1) -typedef struct _GDMHEADER +struct GDMHEADER { uint32 ID; // ID: 'GDM\xFE' char SongTitle[32]; // Music's title @@ -53,9 +53,9 @@ uint16 SSLength; uint32 TGOffset; // Offset of text graphic (huh?) uint16 TGLength; -} GDMHEADER, *PGDMHEADER; +}; -typedef struct _GDMSAMPLEHEADER +struct GDMSAMPLEHEADER { char SamName[32]; // sample's name char FileName[12]; // sample's filename @@ -67,11 +67,14 @@ uint16 C4Hertz; // frequency uint8 Volume; // default volume uint8 Pan; // default pan -} GDMSAMPLEHEADER, *PGDMSAMPLEHEADER; +}; #pragma pack() -static MODTYPE GDMHeader_Origin[] = +#define GDMHEAD_GDM_ 0xFE4D4447 +#define GDMHEAD_GMFS 0x53464D47 + +static const MODTYPE GDMHeader_Origin[] = { MOD_TYPE_NONE, MOD_TYPE_MOD, MOD_TYPE_MTM, MOD_TYPE_S3M, MOD_TYPE_669, MOD_TYPE_FAR, MOD_TYPE_ULT, MOD_TYPE_STM, MOD_TYPE_MED }; @@ -81,55 +84,55 @@ { if ((!lpStream) || (dwMemLength < sizeof(GDMHEADER))) return false; - const PGDMHEADER pHeader = (PGDMHEADER)lpStream; + const GDMHEADER *pHeader = (GDMHEADER *)lpStream; - // is it a valid GDM file? - if( (LittleEndian(pHeader->ID) != 0xFE4D4447) || //GDM\xFE + // Is it a valid GDM file? + if( (pHeader->ID != LittleEndian(GDMHEAD_GDM_)) || //GDM\xFE (pHeader->DOSEOF[0] != 13 || pHeader->DOSEOF[1] != 10 || pHeader->DOSEOF[2] != 26) || //CR+LF+EOF - (LittleEndian(pHeader->ID2) != 0x53464D47)) return false; //GMFS + (pHeader->ID2 != LittleEndian(GDMHEAD_GMFS))) return false; //GMFS - // there are no other format versions... + // There are no other format versions... if(pHeader->FormMajorVer != 1 || pHeader->FormMinorVer != 0) return false; // 1-MOD, 2-MTM, 3-S3M, 4-669, 5-FAR, 6-ULT, 7-STM, 8-MED - m_nType = GDMHeader_Origin[pHeader->FormOrigin % ARRAYELEMCOUNT(GDMHeader_Origin)]; + m_nType = GDMHeader_Origin[pHeader->FormOrigin % CountOf(GDMHeader_Origin)]; if(m_nType == MOD_TYPE_NONE) return false; - // interesting question: Is TrackID, TrackMajorVer, TrackMinorVer relevant? The only TrackID should be 0 - 2GDM.exe, so the answer would be no. + // Interesting question: Is TrackID, TrackMajorVer, TrackMinorVer relevant? The only TrackID should be 0 - 2GDM.exe, so the answer would be no. - // song name + // Song name MemsetZero(m_szNames); memcpy(m_szNames[0], pHeader->SongTitle, 32); StringFixer::SpaceToNullStringFixed<31>(m_szNames[0]); - // read channel pan map... 0...15 = channel panning, 16 = surround channel, 255 = channel does not exist + // Read channel pan map... 0...15 = channel panning, 16 = surround channel, 255 = channel does not exist m_nChannels = 32; for(CHANNELINDEX i = 0; i < 32; i++) { if(pHeader->PanMap[i] < 16) { - ChnSettings[i].nPan = min((pHeader->PanMap[i] << 4) + 8, 256); + ChnSettings[i].nPan = min((pHeader->PanMap[i] * 16) + 8, 256); } else if(pHeader->PanMap[i] == 16) { ChnSettings[i].nPan = 128; ChnSettings[i].dwFlags |= CHN_SURROUND; } - else if(pHeader->PanMap[i] == 0xff) + else if(pHeader->PanMap[i] == 0xFF) { m_nChannels = i; break; } } - m_nDefaultGlobalVolume = min(pHeader->MastVol << 2, 256); + m_nDefaultGlobalVolume = min(pHeader->MastVol * 4, 256); m_nDefaultSpeed = pHeader->Tempo; m_nDefaultTempo = pHeader->BPM; - m_nRestartPos = 0; // not supported in this format, so use the default value - m_nSamplePreAmp = 48; // dito - m_nVSTiVolume = 48; // dito + m_nRestartPos = 0; // Not supported in this format, so use the default value + m_nSamplePreAmp = 48; // Dito + m_nVSTiVolume = 48; // Dito uint32 iSampleOffset = LittleEndian(pHeader->SamOffset), iPatternsOffset = LittleEndian(pHeader->PatOffset); @@ -140,7 +143,7 @@ iTGOffset = LittleEndian(pHeader->TGOffset), iTGLength = LittleEndianW(pHeader->TGLength); - // check if offsets are valid. we won't read the scrolly text or text graphics, but invalid pointers would probably indicate a broken file... + // Check if offsets are valid. we won't read the scrolly text or text graphics, but invalid pointers would probably indicate a broken file... if( dwMemLength < iOrdOffset || dwMemLength - iOrdOffset < pHeader->NOO || dwMemLength < iPatternsOffset || dwMemLength < iSamHeadOffset || dwMemLength - iSamHeadOffset < (pHeader->NOS + 1) * sizeof(GDMSAMPLEHEADER) @@ -150,17 +153,17 @@ || dwMemLength < iTGOffset || dwMemLength - iTGOffset < iTGLength) return false; - // read orders + // Read orders Order.ReadAsByte(lpStream + iOrdOffset, pHeader->NOO + 1, dwMemLength - iOrdOffset); - // read samples + // Read samples m_nSamples = pHeader->NOS + 1; for(SAMPLEINDEX iSmp = 1; iSmp <= m_nSamples; iSmp++) { - const PGDMSAMPLEHEADER pSample = (PGDMSAMPLEHEADER)(lpStream + iSamHeadOffset + (iSmp - 1) * sizeof(GDMSAMPLEHEADER)); + const GDMSAMPLEHEADER *pSample = (GDMSAMPLEHEADER *)(lpStream + iSamHeadOffset + (iSmp - 1) * sizeof(GDMSAMPLEHEADER)); - // sample header + // Sample header memcpy(m_szNames[iSmp], pSample->SamName, 32); StringFixer::SpaceToNullStringFixed<31>(m_szNames[iSmp]); @@ -174,7 +177,7 @@ Samples[iSmp].nLoopEnd = min(LittleEndian(pSample->LoopEnd) - 1, Samples[iSmp].nLength); // dito FrequencyToTranspose(&Samples[iSmp]); // set transpose + finetune for mod files - // fix transpose + finetune for some rare cases where transpose is not C-5 (e.g. sample 4 in wander2.gdm) + // Fix transpose + finetune for some rare cases where transpose is not C-5 (e.g. sample 4 in wander2.gdm) if(m_nType == MOD_TYPE_MOD) { while(Samples[iSmp].RelativeTone != 0) @@ -192,7 +195,7 @@ } } - if(pSample->Flags & 0x01) Samples[iSmp].uFlags |= CHN_LOOP; // loop sample + if(pSample->Flags & 0x01) Samples[iSmp].uFlags |= CHN_LOOP; // Loop sample if(pSample->Flags & 0x04) { @@ -200,10 +203,10 @@ } else { - Samples[iSmp].nVolume = 256; // default volume + Samples[iSmp].nVolume = 256; // Default volume } - if(pSample->Flags & 0x08) // default panning is used + if(pSample->Flags & 0x08) // Default panning is used { Samples[iSmp].uFlags |= CHN_PANNING; Samples[iSmp].nPan = (pSample->Pan > 15) ? 128 : min((pSample->Pan * 16) + 8, 256); // 0...15, 16 = surround (not supported), 255 = no default panning @@ -213,8 +216,8 @@ Samples[iSmp].nPan = 128; } - /* note: apparently (and according to zilym), 2GDM doesn't handle 16 bit or stereo samples properly. - so those flags are pretty much meaningless and we will ignore them... in fact, samples won't load as expected if we don't! */ + // Note: apparently (and according to zilym), 2GDM doesn't handle 16 bit or stereo samples properly. + // so those flags are pretty much meaningless and we will ignore them... in fact, samples won't load as expected if we don't! UINT iSampleFormat; if(pSample->Flags & 0x02) // 16 bit @@ -232,60 +235,60 @@ iSampleFormat = RS_PCM8U; } - // according to zilym, LZW support has never been finished, so this is also practically useless. Just ignore the flag. + // According to zilym, LZW support has never been finished, so this is also practically useless. Just ignore the flag. // if(pSample->Flags & 0x10) {...} - // read sample data + // Read sample data ReadSample(&Samples[iSmp], iSampleFormat, reinterpret_cast<LPCSTR>(lpStream + iSampleOffset), dwMemLength - iSampleOffset); iSampleOffset += min(LittleEndian(pSample->Length), dwMemLength - iSampleOffset); } - // read patterns + // Read patterns Patterns.ResizeArray(max(MAX_PATTERNS, pHeader->NOP + 1)); - bool bS3MCommandSet = (GetBestSaveFormat() & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT)) != 0 ? true : false; + const bool bS3MCommandSet = (GetBestSaveFormat() & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT)) != 0; - // we'll start at position iPatternsOffset and decode all patterns - for (PATTERNINDEX iPat = 0; iPat < pHeader->NOP + 1; iPat++) + // We'll start at position iPatternsOffset and decode all patterns + for(PATTERNINDEX iPat = 0; iPat < pHeader->NOP + 1; iPat++) { if(iPatternsOffset + 2 > dwMemLength) break; - uint16 iPatternLength = LittleEndianW(*(uint16 *)(lpStream + iPatternsOffset)); // pattern length including the two "length" bytes + uint16 iPatternLength = LittleEndianW(*(uint16 *)(lpStream + iPatternsOffset)); // Pattern length including the two "length" bytes if(iPatternLength > dwMemLength || iPatternsOffset > dwMemLength - iPatternLength) break; if(Patterns.Insert(iPat, 64)) break; - // position in THIS pattern + // Position in THIS pattern DWORD iPatternPos = iPatternsOffset + 2; - MODCOMMAND *p = Patterns[iPat]; + for(ROWINDEX iRow = 0; iRow < 64; iRow++) + { + MODCOMMAND *p = Patterns[iPat].GetRow(iRow); - for(UINT iRow = 0; iRow < 64; iRow++) - { - while(true) // zero byte = next row + while(true) // Zero byte = next row { if(iPatternPos + 1 > dwMemLength) break; BYTE bChannel = lpStream[iPatternPos++]; - if(bChannel == 0) break; // next row, please! + if(bChannel == 0) break; // Next row, please! - UINT channel = bChannel & 0x1f; - if(channel >= m_nChannels) break; // better safe than sorry! + const UINT channel = bChannel & 0x1F; + if(channel >= m_nChannels) break; // Better safe than sorry! - MODCOMMAND *m = &p[iRow * m_nChannels + channel]; + MODCOMMAND *m = &p[channel]; if(bChannel & 0x20) { - // note and sample follows + // Note and sample follows if(iPatternPos + 2 > dwMemLength) break; BYTE bNote = lpStream[iPatternPos++]; BYTE bSample = lpStream[iPatternPos++]; - bNote = (bNote & 0x7F) - 1; // this format doesn't have note cuts + bNote = (bNote & 0x7F) - 1; // This format doesn't have note cuts if(bNote < 0xF0) bNote = (bNote & 0x0F) + 12 * (bNote >> 4) + 13; if(bNote == 0xFF) bNote = NOTE_NONE; m->note = bNote; @@ -295,7 +298,7 @@ if(bChannel & 0x40) { - // effect(s) follow + // Effect(s) follow(s) m->command = CMD_NONE; m->volcmd = CMD_NONE; @@ -336,11 +339,11 @@ } break; case 0x0D: command = CMD_PATTERNBREAK; break; - case 0x0E: + case 0x0E: if(bS3MCommandSet) { command = CMD_S3MCMDEX; - // need to do some remapping + // Need to do some remapping switch(param >> 4) { case 0x0: @@ -473,7 +476,7 @@ if(m->command == CMD_S3MCMDEX && ((m->param >> 4) == 0x8) && volcommand == CMD_NONE) { volcommand = VOLCMD_PANNING; - volparam = ((param & 0x0F) << 2) + 2; + volparam = ((param & 0x0F) * 4) + 2; } m->command = command; Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mt2.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -561,7 +561,7 @@ if (pmi->GroupsMapping[i] == iGrp) { UINT nSmp = pmg->nSmpNo+1; - pIns->Keyboard[i+12] = (BYTE)nSmp; + pIns->Keyboard[i + 12] = (SAMPLEINDEX)nSmp; if (nSmp <= m_nSamples) { Samples[nSmp].nVibType = pmi->bVibType; Modified: trunk/OpenMPT/soundlib/Load_psm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_psm.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/soundlib/Load_psm.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -155,7 +155,7 @@ dwMemPos += 12; - memset(m_szNames, 0, sizeof(m_szNames)); + MemsetZero(m_szNames); m_nVSTiVolume = m_nSamplePreAmp = 48; // not supported in this format, so use a good default value Modified: trunk/OpenMPT/soundlib/Message.cpp =================================================================== --- trunk/OpenMPT/soundlib/Message.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/soundlib/Message.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -183,8 +183,8 @@ // [in] lineEnding: line ending formatting of the text in memory. // [in] pTextConverter: Pointer to a callback function which can be used to post-process the written characters, if necessary (nullptr otherwise). // [out] returns formatted song message. -CString CSoundFile::GetSongMessage(const enmLineEndings lineEnding, void (*pTextConverter)(char &)) -//------------------------------------------------------------------------------------------------- +CString CSoundFile::GetSongMessage(const enmLineEndings lineEnding, void (*pTextConverter)(char &)) const +//------------------------------------------------------------------------------------------------------- { CString comments; Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-09-17 22:37:34 UTC (rev 1037) @@ -1255,7 +1255,7 @@ //I'd like to copy other flags too, but this would change playback behaviour. p->dwFlags |= (pChn->dwFlags & (CHN_MUTE|CHN_NOFX)); - p->nMasterChn = nChn+1; + p->nMasterChn = nChn + 1; p->nCommand = 0; //rewbs.VSTiNNA if (applyNNAtoPlug && pPlugin) @@ -1278,10 +1278,14 @@ // Key Off the note switch(pChn->nNNA) { - case NNA_NOTEOFF: KeyOff(n); break; + case NNA_NOTEOFF: + KeyOff(n); + break; case NNA_NOTECUT: p->nFadeOutVol = 0; - case NNA_NOTEFADE: p->dwFlags |= CHN_NOTEFADE; break; + case NNA_NOTEFADE: + p->dwFlags |= CHN_NOTEFADE; + break; } if (!p->nVolume) { @@ -3754,7 +3758,7 @@ if (pIns->VolEnv.nReleaseNode != ENV_RELEASE_NODE_UNSET) { pChn->VolEnv.nEnvValueAtReleaseJump = GetVolEnvValueFromPosition(pChn->VolEnv.nEnvPosition, pIns); - pChn->VolEnv.nEnvPosition= pIns->VolEnv.Ticks[pIns->VolEnv.nReleaseNode]; + pChn->VolEnv.nEnvPosition = pIns->VolEnv.Ticks[pIns->VolEnv.nReleaseNode]; } } @@ -4353,8 +4357,8 @@ // Get the needed vector size for pattern nPat. -size_t CSoundFile::GetVisitedRowsVectorSize(const PATTERNINDEX nPat) -//------------------------------------------------------------------ +size_t CSoundFile::GetVisitedRowsVectorSize(const PATTERNINDEX nPat) const +//------------------------------------------------------------------------ { if(Patterns.IsValidPat(nPat)) { Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2011-09-17 17:19:58 UTC (rev 1036) +++ trunk/OpenMPT/soundlib/Sndfile.h 2011-09-17 22:37:34 UTC (rev 1037) @@ -1116,7 +1116,7 @@ // [in] lineEnding: line ending formatting of the text in memory. // [in] pTextConverter: Pointer to a callback function which can be used to post-process the written characters, if necessary (nullptr otherwise). // [out] returns formatted song message. - CString GetSongMessage(const enmLineEndings lineEnding, void (*pTextConverter)(char &) = nullptr); + CString GetSongMessage(const enmLineEndings lineEnding, void (*pTextConverter)(char &) = nullptr) const; protected: // Read song message from a mapped file. @@ -1157,7 +1157,7 @@ private: void SetRowVisited(const ORDERINDEX nOrd, const ROWINDEX nRow, const bool bVisited = true, VisitedRowsType *pRowVector = nullptr); bool IsRowVisited(const ORDERINDEX nOrd, const ROWINDEX nRow, const bool bAutoSet = true, VisitedRowsType *pRowVector = nullptr); - size_t GetVisitedRowsVectorSize(const PATTERNINDEX nPat); + size_t GetVisitedRowsVectorSize(const PATTERNINDEX nPat) const; public: // "importance" of every FX command. Table is used for importing from formats with multiple effect columns This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-17 22:41:48
|
Revision: 1038 http://modplug.svn.sourceforge.net/modplug/?rev=1038&view=rev Author: saga-games Date: 2011-09-17 22:41:42 +0000 (Sat, 17 Sep 2011) Log Message: ----------- [Imp] MPT Hacks: Invalid +++ / --- order items in XM / MOD files are now detected. [Mod] More VSTi resume state sanitizing (don't kill all VSTi voices if the song is already stopped) Modified Paths: -------------- trunk/OpenMPT/mptrack/MPTHacks.cpp trunk/OpenMPT/soundlib/Sndfile.cpp Modified: trunk/OpenMPT/mptrack/MPTHacks.cpp =================================================================== --- trunk/OpenMPT/mptrack/MPTHacks.cpp 2011-09-17 22:37:34 UTC (rev 1037) +++ trunk/OpenMPT/mptrack/MPTHacks.cpp 2011-09-17 22:41:42 UTC (rev 1038) @@ -11,7 +11,6 @@ #include "../soundlib/modsmp_ctrl.h" /* TODO: -stereo/16bit samples (only XM? stereo/16bit flags are defined in the S3M and IT specs...) out-of range sample pre-amp song flags and properties (just look at the song properties window) +++/--- orders in XM/MOD sequence @@ -106,6 +105,57 @@ } +// Functor for fixing jump commands to moved order items +struct FixJumpCommands +//==================== +{ + FixJumpCommands(const vector<PATTERNINDEX> &offsets) : jumpOffset(offsets) {}; + + void operator()(MODCOMMAND& m) + { + if(m.command == CMD_POSITIONJUMP && m.param < jumpOffset.size()) + { + m.param = BYTE(int(m.param) - jumpOffset[m.param]); + } + } + + const vector<PATTERNINDEX> jumpOffset; +}; + + +void RemoveFromOrder(CSoundFile &rSndFile, PATTERNINDEX which) +//------------------------------------------------------------ +{ + const ORDERINDEX orderLength = rSndFile.Order.GetLengthTailTrimmed(); + ORDERINDEX currentLength = orderLength; + + // Associate order item index with jump offset (i.e. how much it moved forwards) + vector<PATTERNINDEX> jumpOffset(orderLength, 0); + PATTERNINDEX maxJump = 0; + + for(ORDERINDEX i = 0; i < currentLength; i++) + { + if(rSndFile.Order[i] == which) + { + maxJump++; + // Move order list forwards, update jump counters + for(ORDERINDEX j = i + 1; j < orderLength; j++) + { + rSndFile.Order[j - 1] = rSndFile.Order[j]; + jumpOffset[j] = maxJump; + } + rSndFile.Order[--currentLength] = rSndFile.Order.GetInvalidPatIndex(); + } + } + + rSndFile.Patterns.ForEachModCommand(FixJumpCommands(jumpOffset)); + if(rSndFile.m_nRestartPos < jumpOffset.size()) + { + rSndFile.m_nRestartPos -= jumpOffset[rSndFile.m_nRestartPos]; + } +} + + // Go through the module to find out if it contains any hacks introduced by (Open)MPT bool CModDoc::HasMPTHacks(const bool autofix) //------------------------------------------- @@ -146,6 +196,34 @@ if(foundHere) AddToLog("Found VST plugins\n"); + // Check for invalid order items + for(ORDERINDEX i = m_SndFile.Order.GetLengthTailTrimmed(); i > 0; i--) + { + if(m_SndFile.Order[i - 1] == m_SndFile.Order.GetIgnoreIndex() && !originalSpecs->hasIgnoreIndex) + { + foundHacks = true; + AddToLog("This format does not support separator (+++) patterns\n"); + + if(autofix) + { + RemoveFromOrder(m_SndFile, m_SndFile.Order.GetIgnoreIndex()); + } + + break; + } + } + + if((m_SndFile.GetType() & (MOD_TYPE_MOD | MOD_TYPE_XM)) && m_SndFile.Order.GetLengthFirstEmpty() != m_SndFile.Order.GetLengthTailTrimmed()) + { + foundHacks = true; + AddToLog("The pattern sequence should end after the first stop (---) index in this format.\n"); + + if(autofix) + { + RemoveFromOrder(m_SndFile, m_SndFile.Order.GetInvalidPatIndex()); + } + } + // Pattern count if(m_SndFile.Patterns.GetNumPatterns() > originalSpecs->patternsMax) { @@ -448,3 +526,4 @@ return foundHacks; } + Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2011-09-17 22:37:34 UTC (rev 1037) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2011-09-17 22:41:42 UTC (rev 1038) @@ -1205,9 +1205,9 @@ if (!m_MixPlugins[iPlug].pMixPlugin) continue; //most common branch - if (m_MixPlugins[iPlug].pMixState) + IMixPlugin *pPlugin = m_MixPlugins[iPlug].pMixPlugin; + if (m_MixPlugins[iPlug].pMixState && !pPlugin->IsResumed()) { - IMixPlugin *pPlugin = m_MixPlugins[iPlug].pMixPlugin; pPlugin->NotifySongPlaying(true); pPlugin->Resume(); } @@ -1226,7 +1226,7 @@ continue; //most common branch IMixPlugin *pPlugin = m_MixPlugins[iPlug].pMixPlugin; - if (m_MixPlugins[iPlug].pMixState) + if (m_MixPlugins[iPlug].pMixState && pPlugin->IsResumed()) { pPlugin->HardAllNotesOff(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-18 19:38:20
|
Revision: 1039 http://modplug.svn.sourceforge.net/modplug/?rev=1039&view=rev Author: saga-games Date: 2011-09-18 19:38:13 +0000 (Sun, 18 Sep 2011) Log Message: ----------- [Ref] Changed catch(...) to catch(MPTMemoryException) when catching "operator new" exceptions. (Using a custom typedef is a quick workaround for MFC apps not making use of std::bad_alloc by default) Modified Paths: -------------- trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/mptrack/Stdafx.h trunk/OpenMPT/mptrack/test/test.cpp trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/Load_imf.cpp trunk/OpenMPT/soundlib/Load_mid.cpp trunk/OpenMPT/soundlib/Message.cpp trunk/OpenMPT/soundlib/pattern.cpp Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2011-09-17 22:41:42 UTC (rev 1038) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2011-09-18 19:38:13 UTC (rev 1039) @@ -501,14 +501,14 @@ try { MODINSTRUMENT *p = new MODINSTRUMENT(smp); - InitializeInstrument(p); m_SndFile.Instruments[smp] = p; - lstrcpyn(p->name, m_SndFile.m_szNames[smp], CountOf(p->name)); - } catch(...) + } catch(MPTMemoryException) { ErrorBox(IDS_ERR_OUTOFMEMORY, CMainFrame::GetMainFrame()); return INSTRUMENTINDEX_INVALID; } + InitializeInstrument(m_SndFile.Instruments[smp]); + lstrcpyn(m_SndFile.Instruments[smp]->name, m_SndFile.m_szNames[smp], MAX_INSTRUMENTNAME); } } m_SndFile.m_nInstruments = nInstruments; @@ -562,12 +562,12 @@ try { pIns = new MODINSTRUMENT(newsmp); - InitializeInstrument(pIns); - } catch(...) + } catch(MPTMemoryException) { ErrorBox(IDS_ERR_OUTOFMEMORY, CMainFrame::GetMainFrame()); return INSTRUMENTINDEX_INVALID; } + InitializeInstrument(pIns); CriticalSection cs; Modified: trunk/OpenMPT/mptrack/Stdafx.h =================================================================== --- trunk/OpenMPT/mptrack/Stdafx.h 2011-09-17 22:41:42 UTC (rev 1038) +++ trunk/OpenMPT/mptrack/Stdafx.h 2011-09-18 19:38:13 UTC (rev 1039) @@ -96,6 +96,9 @@ #include "../common/typedefs.h" +// Exception type that is used to catch "operator new" exceptions. +typedef CMemoryException * MPTMemoryException; + //To mark string that should be translated in case of multilingual version. #define GetStrI18N(x) (x) Modified: trunk/OpenMPT/mptrack/test/test.cpp =================================================================== --- trunk/OpenMPT/mptrack/test/test.cpp 2011-09-17 22:41:42 UTC (rev 1038) +++ trunk/OpenMPT/mptrack/test/test.cpp 2011-09-18 19:38:13 UTC (rev 1039) @@ -126,11 +126,11 @@ if (!dwVerInfoSize) throw std::runtime_error("!dwVerInfoSize is true"); - char* pVersionInfo; + char *pVersionInfo; try { pVersionInfo = new char[dwVerInfoSize]; - } catch(...) + } catch(MPTMemoryException) { throw std::runtime_error("Could not allocate memory for pVersionInfo"); } Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.cpp 2011-09-17 22:41:42 UTC (rev 1038) +++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2011-09-18 19:38:13 UTC (rev 1039) @@ -1646,7 +1646,7 @@ try { pIns = new MODINSTRUMENT(); - } catch(...) + } catch(MPTMemoryException) { return FALSE; } Modified: trunk/OpenMPT/soundlib/Load_imf.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_imf.cpp 2011-09-17 22:41:42 UTC (rev 1038) +++ trunk/OpenMPT/soundlib/Load_imf.cpp 2011-09-18 19:38:13 UTC (rev 1039) @@ -499,8 +499,7 @@ try { pIns = new MODINSTRUMENT(); - } - catch(...) + } catch(MPTMemoryException) { continue; } Modified: trunk/OpenMPT/soundlib/Load_mid.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mid.cpp 2011-09-17 22:41:42 UTC (rev 1038) +++ trunk/OpenMPT/soundlib/Load_mid.cpp 2011-09-18 19:38:13 UTC (rev 1039) @@ -416,7 +416,7 @@ try { pIns = new MODINSTRUMENT(); - } catch(...) + } catch(MPTMemoryException) { return 0; } Modified: trunk/OpenMPT/soundlib/Message.cpp =================================================================== --- trunk/OpenMPT/soundlib/Message.cpp 2011-09-17 22:41:42 UTC (rev 1038) +++ trunk/OpenMPT/soundlib/Message.cpp 2011-09-18 19:38:13 UTC (rev 1039) @@ -28,7 +28,7 @@ m_lpszSongComments = new char[length + 1]; // + 1 for trailing null memset(m_lpszSongComments, 0, length + 1); return true; - } catch(...) + } catch(MPTMemoryException) { m_lpszSongComments = nullptr; return false; Modified: trunk/OpenMPT/soundlib/pattern.cpp =================================================================== --- trunk/OpenMPT/soundlib/pattern.cpp 2011-09-17 22:41:42 UTC (rev 1038) +++ trunk/OpenMPT/soundlib/pattern.cpp 2011-09-18 19:38:13 UTC (rev 1039) @@ -253,10 +253,10 @@ { try { - MODCOMMAND *p = new MODCOMMAND[rows*nchns]; + MODCOMMAND *p = new MODCOMMAND[rows * nchns]; memset(p, 0, rows * nchns * sizeof(MODCOMMAND)); return p; - } catch (...) + } catch(MPTMemoryException) { 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-18 20:11:39
|
Revision: 1040 http://modplug.svn.sourceforge.net/modplug/?rev=1040&view=rev Author: saga-games Date: 2011-09-18 20:11:32 +0000 (Sun, 18 Sep 2011) Log Message: ----------- [Ref/Fix] Fixing more "new MODINSTRUMENT" stuff (exception handling). Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/soundlib/LOAD_DBM.CPP trunk/OpenMPT/soundlib/Load_ams.cpp trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_mdl.cpp trunk/OpenMPT/soundlib/Load_mt2.cpp trunk/OpenMPT/soundlib/Load_xm.cpp trunk/OpenMPT/soundlib/Sampleio.cpp trunk/OpenMPT/soundlib/load_j2b.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-09-18 19:38:13 UTC (rev 1039) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-09-18 20:11:32 UTC (rev 1040) @@ -111,7 +111,13 @@ 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(); + try + { + pSndFile->Instruments[m_nInstrument] = new MODINSTRUMENT(); + } catch(MPTMemoryException) + { + return FALSE; + } m_pModDoc->InitializeInstrument(pSndFile->Instruments[m_nInstrument]); } Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2011-09-18 19:38:13 UTC (rev 1039) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2011-09-18 20:11:32 UTC (rev 1040) @@ -735,9 +735,14 @@ if ((!m_SndFile.m_nInstruments) && (m_SndFile.m_nType & MOD_TYPE_XM)) { - m_SndFile.m_nInstruments = 1; - m_SndFile.Instruments[1] = new MODINSTRUMENT(1); - InitializeInstrument(m_SndFile.Instruments[1]); + try + { + m_SndFile.Instruments[1] = new MODINSTRUMENT(1); + m_SndFile.m_nInstruments = 1; + InitializeInstrument(m_SndFile.Instruments[1]); + } catch(MPTMemoryException) + { + } } if (m_SndFile.m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT|MOD_TYPE_XM)) { Modified: trunk/OpenMPT/soundlib/LOAD_DBM.CPP =================================================================== --- trunk/OpenMPT/soundlib/LOAD_DBM.CPP 2011-09-18 19:38:13 UTC (rev 1039) +++ trunk/OpenMPT/soundlib/LOAD_DBM.CPP 2011-09-18 20:11:32 UTC (rev 1040) @@ -236,7 +236,14 @@ nsmp = BigEndianW(pih->sampleno); psmp = ((nsmp) && (nsmp < MAX_SAMPLES)) ? &Samples[nsmp] : nullptr; - if ((pIns = new MODINSTRUMENT(nsmp)) == nullptr) break; + try + { + pIns = new MODINSTRUMENT(nsmp); + } catch(MPTMemoryException) + { + break; + } + Instruments[iIns + 1] = pIns; memcpy(pIns->name, pih->name, 30); Modified: trunk/OpenMPT/soundlib/Load_ams.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ams.cpp 2011-09-18 19:38:13 UTC (rev 1039) +++ trunk/OpenMPT/soundlib/Load_ams.cpp 2011-09-18 20:11:32 UTC (rev 1040) @@ -395,9 +395,16 @@ dwMemPos += 5 + panenv->points*3; pitchenv = (AMS2ENVELOPE *)(lpStream+dwMemPos); dwMemPos += 5 + pitchenv->points*3; - MODINSTRUMENT *pIns = new MODINSTRUMENT(); - if (!pIns) return TRUE; - memset(smpmap, 0, sizeof(smpmap)); + MODINSTRUMENT *pIns; + try + { + pIns = new MODINSTRUMENT(); + } catch(MPTMemoryException) + { + return true; + } + + MemsetZero(smpmap); for (UINT ismpmap=0; ismpmap<pSmp->samples; ismpmap++) { Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2011-09-18 19:38:13 UTC (rev 1039) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2011-09-18 20:11:32 UTC (rev 1040) @@ -491,14 +491,6 @@ vector<DWORD> inspos; vector<DWORD> smppos; vector<DWORD> patpos; -// Using eric's code here to take care of NNAs etc.. -// -> CODE#0006 -// -> DESC="misc quantity changes" -// BYTE chnmask[64], channels_used[64]; -// MODCOMMAND lastvalue[64]; - BYTE chnmask[MAX_BASECHANNELS]; - MODCOMMAND lastvalue[MAX_BASECHANNELS]; -// -! BEHAVIOUR_CHANGE#0006 bool interpretModPlugMade = false; bool hasModPlugExtensions = false; @@ -880,8 +872,6 @@ // Checking for unused channels for (UINT patchk=0; patchk<npatterns; patchk++) { - memset(chnmask, 0, sizeof(chnmask)); - if ((!patpos[patchk]) || ((DWORD)patpos[patchk] >= dwMemLength - 4)) continue; @@ -904,6 +894,8 @@ const BYTE *p = lpStream+patpos[patchk]+8; UINT nrow = 0; + vector<BYTE> chnmask; + while (nrow<rows) { if (i >= len) break; @@ -918,6 +910,11 @@ if (ch) ch = (ch - 1);// & IT_bitmask_patternChanMask_c; // 0x3f mask of the byte again, keeping only 6 bits + if(ch >= chnmask.size()) + { + chnmask.resize(ch + 1, 0); + } + if (b & IT_bitmask_patternChanEnabled_c) // 0x80 check if the upper bit is enabled. { if (i >= len) @@ -955,10 +952,14 @@ { if ((inspos[nins] > 0) && (inspos[nins] < dwMemLength - (pifh->cmwt < 0x200 ? sizeof(ITOLDINSTRUMENT) : sizeof(ITINSTRUMENT)))) { - MODINSTRUMENT *pIns = new MODINSTRUMENT(); - if (!pIns) continue; - Instruments[nins + 1] = pIns; - ITInstrToMPT(lpStream + inspos[nins], pIns, pifh->cmwt); + try + { + Instruments[nins + 1] = new MODINSTRUMENT(); + ITInstrToMPT(lpStream + inspos[nins], Instruments[nins + 1], pifh->cmwt); + } catch(MPTMemoryException) + { + continue; + } } } @@ -1098,8 +1099,9 @@ // Now (after the Insert() call), we can read the pattern name. CopyPatternName(Patterns[npat], &patNames, patNamesLen); - memset(lastvalue, 0, sizeof(lastvalue)); - memset(chnmask, 0, sizeof(chnmask)); + vector<BYTE> chnmask; + vector<MODCOMMAND> lastvalue; + MODCOMMAND *m = Patterns[npat]; UINT i = 0; const BYTE *p = lpStream+patpos[npat]+8; @@ -1120,6 +1122,13 @@ if (ch) ch = (ch - 1); //& IT_bitmask_patternChanMask_c; // 0x3f + if(ch >= chnmask.size()) + { + chnmask.resize(ch + 1, 0); + lastvalue.resize(ch + 1, MODCOMMAND::Empty()); + ASSERT(chnmask.size() <= GetNumChannels()); + } + if (b & IT_bitmask_patternChanEnabled_c) // 0x80 { if (i >= len) @@ -2474,7 +2483,7 @@ if (nInstruments == 0) return; - MODINSTRUMENT *sizeIns = new MODINSTRUMENT(); + MODINSTRUMENT *sizeIns = nullptr; WriteInstrumentPropertyForAllInstruments('VR..', sizeof(sizeIns->nVolRampUp), f, nInstruments); WriteInstrumentPropertyForAllInstruments('MiP.', sizeof(sizeIns->nMixPlug), f, nInstruments); @@ -2521,8 +2530,6 @@ } } - delete sizeIns; - return; } Modified: trunk/OpenMPT/soundlib/Load_mdl.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mdl.cpp 2011-09-18 19:38:13 UTC (rev 1039) +++ trunk/OpenMPT/soundlib/Load_mdl.cpp 2011-09-18 20:11:32 UTC (rev 1040) @@ -370,7 +370,13 @@ if (!Instruments[nins]) { UINT note = 12; - if ((Instruments[nins] = new MODINSTRUMENT()) == nullptr) break; + try + { + Instruments[nins] = new MODINSTRUMENT(); + } catch(MPTMemoryException) + { + break; + } MODINSTRUMENT *pIns = Instruments[nins]; memcpy(pIns->name, lpStream+dwPos+2, 32); StringFixer::SpaceToNullStringFixed<31>(pIns->name); @@ -417,7 +423,13 @@ } for (j=1; j<=m_nInstruments; j++) if (!Instruments[j]) { - Instruments[j] = new MODINSTRUMENT(); + try + { + Instruments[j] = new MODINSTRUMENT(); + } catch(MPTMemoryException) + { + } + } break; // VE: Volume Envelope Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mt2.cpp 2011-09-18 19:38:13 UTC (rev 1039) +++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2011-09-18 20:11:32 UTC (rev 1040) @@ -401,12 +401,14 @@ MODINSTRUMENT *pIns = NULL; if (iIns <= m_nInstruments) { - pIns = new MODINSTRUMENT(); - Instruments[iIns] = pIns; - if (pIns) + try { + pIns = new MODINSTRUMENT(); + Instruments[iIns] = pIns; memcpy(pIns->name, pmi->szName, 32); StringFixer::SpaceToNullStringFixed<31>(pIns->name); + } catch(MPTMemoryException) + { } } #ifdef MT2DEBUG Modified: trunk/OpenMPT/soundlib/Load_xm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_xm.cpp 2011-09-18 19:38:13 UTC (rev 1039) +++ trunk/OpenMPT/soundlib/Load_xm.cpp 2011-09-18 20:11:32 UTC (rev 1040) @@ -284,7 +284,7 @@ if(xmheader.flags & 1) m_dwSongFlags |= SONG_LINEARSLIDES; if(xmheader.flags & 0x1000) m_dwSongFlags |= SONG_EXFILTERRANGE; - Order.ReadAsByte(lpStream + 80, xmheader.orders, dwMemLength - 80); + Order.ReadAsByte(lpStream + 80, min(xmheader.orders, MAX_ORDERS), dwMemLength - 80); dwMemPos = xmheader.size + 60; @@ -317,7 +317,13 @@ MemsetZero(pih); memcpy(&pih, lpStream + dwMemPos, min(sizeof(pih), ihsize)); - if ((Instruments[iIns] = new MODINSTRUMENT()) == nullptr) continue; + try + { + Instruments[iIns] = new MODINSTRUMENT(); + } catch(MPTMemoryException) + { + continue; + } memcpy(Instruments[iIns]->name, pih.name, 22); StringFixer::SpaceToNullStringFixed<22>(Instruments[iIns]->name); @@ -485,7 +491,6 @@ } for (UINT j=0; j<96; j++) { - pIns->NoteMap[j+12] = j+1+12; if (xmsh.snum[j] < nsamples) pIns->Keyboard[j+12] = samplemap[xmsh.snum[j]]; } Modified: trunk/OpenMPT/soundlib/Sampleio.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sampleio.cpp 2011-09-18 19:38:13 UTC (rev 1039) +++ trunk/OpenMPT/soundlib/Sampleio.cpp 2011-09-18 20:11:32 UTC (rev 1040) @@ -78,11 +78,17 @@ } } - MODINSTRUMENT *pIns = new MODINSTRUMENT(nSample); - if (!pIns) return false; + MODINSTRUMENT *pIns; + try + { + pIns = new MODINSTRUMENT(nSample); + } catch(MPTMemoryException) + { + return false; + } + DestroyInstrument(nInstr, deleteAssociatedSamples); - Instruments[nInstr] = pIns; // Default values @@ -188,59 +194,67 @@ || (nInstr >= MAX_INSTRUMENTS) || (!pSrcSong->Instruments[nSrcInstr])) return false; if (m_nInstruments < nInstr) m_nInstruments = nInstr; + MODINSTRUMENT *pIns; + + try + { + pIns = new MODINSTRUMENT(); + } catch(MPTMemoryException) + { + return false; + } + DestroyInstrument(nInstr, deleteAssociatedSamples); - if (!Instruments[nInstr]) Instruments[nInstr] = new MODINSTRUMENT(); - MODINSTRUMENT *pIns = Instruments[nInstr]; - if (pIns) + Instruments[nInstr] = pIns; + + // TODO we want to copy ALL samples, not just 32! Use vectors here. + WORD samplemap[32]; + WORD samplesrc[32]; + UINT nSamples = 0; + UINT nsmp = 1; + *pIns = *pSrcSong->Instruments[nSrcInstr]; + for (UINT i=0; i<128; i++) { - WORD samplemap[32]; - WORD samplesrc[32]; - UINT nSamples = 0; - UINT nsmp = 1; - *pIns = *pSrcSong->Instruments[nSrcInstr]; - for (UINT i=0; i<128; i++) + UINT n = pIns->Keyboard[i]; + if ((n) && (n <= pSrcSong->m_nSamples) && (i < NOTE_MAX)) { - UINT n = pIns->Keyboard[i]; - if ((n) && (n <= pSrcSong->m_nSamples) && (i < NOTE_MAX)) + UINT j = 0; + for (j=0; j<nSamples; j++) { - UINT j = 0; - for (j=0; j<nSamples; j++) + if (samplesrc[j] == n) break; + } + if (j >= nSamples) + { + while ((nsmp < MAX_SAMPLES) && ((Samples[nsmp].pSample) || (m_szNames[nsmp][0]))) nsmp++; + if ((nSamples < 32) && (nsmp < MAX_SAMPLES)) { - if (samplesrc[j] == n) break; - } - if (j >= nSamples) - { - while ((nsmp < MAX_SAMPLES) && ((Samples[nsmp].pSample) || (m_szNames[nsmp][0]))) nsmp++; - if ((nSamples < 32) && (nsmp < MAX_SAMPLES)) - { - samplesrc[nSamples] = (WORD)n; - samplemap[nSamples] = (WORD)nsmp; - nSamples++; - pIns->Keyboard[i] = (WORD)nsmp; - if (m_nSamples < nsmp) m_nSamples = nsmp; - nsmp++; - } else - { - pIns->Keyboard[i] = 0; - } + samplesrc[nSamples] = (WORD)n; + samplemap[nSamples] = (WORD)nsmp; + nSamples++; + pIns->Keyboard[i] = (SAMPLEINDEX)nsmp; + if (m_nSamples < nsmp) m_nSamples = nsmp; + nsmp++; } else { - pIns->Keyboard[i] = samplemap[j]; + pIns->Keyboard[i] = 0; } } else { - pIns->Keyboard[i] = 0; + pIns->Keyboard[i] = samplemap[j]; } - } - // Load Samples - for (UINT k=0; k<nSamples; k++) + } else { - ReadSampleFromSong(samplemap[k], pSrcSong, samplesrc[k]); + pIns->Keyboard[i] = 0; } - return true; } - return false; + // Load Samples + for (UINT k=0; k<nSamples; k++) + { + ReadSampleFromSong(samplemap[k], pSrcSong, samplesrc[k]); + } + + return true; } @@ -866,11 +880,16 @@ || (!pih->layers) || (!plh->samples)) return false; if (nInstr > m_nInstruments) m_nInstruments = nInstr; + try + { + pIns = new MODINSTRUMENT(); + } catch(MPTMemoryException) + { + return false; + } + DestroyInstrument(nInstr, deleteAssociatedSamples); - pIns = new MODINSTRUMENT(); - if (!pIns) return false; - Instruments[nInstr] = pIns; nSamples = plh->samples; if (nSamples > 16) nSamples = 16; @@ -1081,12 +1100,19 @@ if ((dwMemPos < sizeof(XIFILEHEADER)) || (dwMemPos >= dwFileLength)) return false; if (nInstr > m_nInstruments) m_nInstruments = nInstr; - DestroyInstrument(nInstr, deleteAssociatedSamples); + MODINSTRUMENT *pIns; - Instruments[nInstr] = new MODINSTRUMENT(); - MODINSTRUMENT *pIns = Instruments[nInstr]; - if (!pIns) return false; + try + { + pIns = new MODINSTRUMENT(); + } catch(MPTMemoryException) + { + return false; + } + DestroyInstrument(nInstr, deleteAssociatedSamples); + + Instruments[nInstr] = pIns; memcpy(pIns->name, pxh->name, 22); nsamples = 0; for (UINT i=0; i<96; i++) @@ -1149,17 +1175,17 @@ pIns->PanEnv.Values[ienv] = (BYTE)pih->pIns[ienv*2+1]; if (ienv) { - if (pIns->VolEnv.Ticks[ienv] < pIns->VolEnv.Ticks[ienv-1]) + 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; + 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; - if (pIns->PanEnv.Ticks[ienv] < pIns->PanEnv.Ticks[ienv-1]) pIns->PanEnv.Ticks[ienv] += 0x100; + pIns->PanEnv.Ticks[ienv] += pIns->PanEnv.Ticks[ienv - 1] & 0xFF00; + if (pIns->PanEnv.Ticks[ienv] < pIns->PanEnv.Ticks[ienv - 1]) pIns->PanEnv.Ticks[ienv] += 0x100; } } } @@ -1690,12 +1716,19 @@ || (pinstr->id != LittleEndian(IT_IMPI))) return false; if (nInstr > m_nInstruments) m_nInstruments = nInstr; + MODINSTRUMENT *pIns; + + try + { + pIns = new MODINSTRUMENT(); + } catch(MPTMemoryException) + { + return false; + } + DestroyInstrument(nInstr, deleteAssociatedSamples); - Instruments[nInstr] = new MODINSTRUMENT(); - MODINSTRUMENT *pIns = Instruments[nInstr]; - if (!pIns) return false; - + Instruments[nInstr] = pIns; MemsetZero(samplemap); dwMemPos = 554; dwMemPos += ITInstrToMPT(pinstr, pIns, pinstr->trkvers); Modified: trunk/OpenMPT/soundlib/load_j2b.cpp =================================================================== --- trunk/OpenMPT/soundlib/load_j2b.cpp 2011-09-18 19:38:13 UTC (rev 1039) +++ trunk/OpenMPT/soundlib/load_j2b.cpp 2011-09-18 20:11:32 UTC (rev 1040) @@ -549,10 +549,14 @@ if(Instruments[nIns] != nullptr) delete Instruments[nIns]; - MODINSTRUMENT *pIns = new MODINSTRUMENT(); - if(pIns == nullptr) + try + { + Instruments[nIns] = new MODINSTRUMENT(); + } catch(MPTMemoryException) + { break; - Instruments[nIns] = pIns; + } + MODINSTRUMENT *pIns = Instruments[nIns]; m_nInstruments = max(m_nInstruments, nIns); @@ -657,10 +661,14 @@ if(Instruments[nIns] != nullptr) delete Instruments[nIns]; - MODINSTRUMENT *pIns = new MODINSTRUMENT(); - if(pIns == nullptr) + try + { + Instruments[nIns] = new MODINSTRUMENT(); + } catch(MPTMemoryException) + { break; - Instruments[nIns] = pIns; + } + MODINSTRUMENT *pIns = Instruments[nIns]; m_nInstruments = max(m_nInstruments, nIns); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-18 23:40:33
|
Revision: 1043 http://modplug.svn.sourceforge.net/modplug/?rev=1043&view=rev Author: saga-games Date: 2011-09-18 23:40:27 +0000 (Sun, 18 Sep 2011) Log Message: ----------- [Mod] Global volume is now applied before internal DSPs (http://bugs.openmpt.org/view.php?id=72). [Mod] OpenMPT: Version is now 1.20.00.24 Modified Paths: -------------- trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-09-18 21:12:51 UTC (rev 1042) +++ trunk/OpenMPT/mptrack/version.h 2011-09-18 23:40:27 UTC (rev 1043) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 23 +#define VER_MINORMINOR 24 //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/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2011-09-18 21:12:51 UTC (rev 1042) +++ trunk/OpenMPT/soundlib/Sndfile.h 2011-09-18 23:40:27 UTC (rev 1043) @@ -1088,7 +1088,7 @@ #ifdef MODPLUG_TRACKER void ProcessMidiOut(CHANNELINDEX nChn, MODCHANNEL *pChn); //rewbs.VSTdelay : added arg. #endif - void ApplyGlobalVolume(int SoundBuffer[], long lTotalSampleCount); + void ApplyGlobalVolume(int SoundBuffer[], int RearBuffer[], long lTotalSampleCount); // Static helper functions public: Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2011-09-18 21:12:51 UTC (rev 1042) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2011-09-18 23:40:27 UTC (rev 1043) @@ -287,33 +287,38 @@ LPCONVERTPROC pCvt = X86_Convert32To8; UINT lRead, lMax, lSampleSize, lCount, lSampleCount, nStat=0; UINT nMaxPlugins; - + nMaxPlugins = MAX_MIXPLUGINS; while ((nMaxPlugins > 0) && (!m_MixPlugins[nMaxPlugins-1].pMixPlugin)) nMaxPlugins--; m_nMixStat = 0; + lSampleSize = gnChannels; if (gnBitsPerSample == 16) { lSampleSize *= 2; pCvt = X86_Convert32To16; } #ifndef FASTSOUNDLIB else if (gnBitsPerSample == 24) { lSampleSize *= 3; pCvt = X86_Convert32To24; } else if (gnBitsPerSample == 32) { lSampleSize *= 4; pCvt = X86_Convert32To32; } -#endif +#endif // FASTSOUNDLIB + lMax = cbBuffer / lSampleSize; if ((!lMax) || (!lpBuffer) || (!m_nChannels)) return 0; lRead = lMax; if (m_dwSongFlags & SONG_ENDREACHED) goto MixDone; + while (lRead > 0) { // Update Channel Data if (!m_nBufferCount) { + #ifndef FASTSOUNDLIB if (m_dwSongFlags & SONG_FADINGSONG) { m_dwSongFlags |= SONG_ENDREACHED; m_nBufferCount = lRead; } else -#endif +#endif // FASTSOUNDLIB + if (ReadNote()) { // Save pattern cue points for WAV rendering here (if we reached a new pattern, that is.) @@ -334,9 +339,10 @@ break; } #endif // MODPLUG_TRACKER + #ifndef FASTSOUNDLIB if (!FadeSong(FADESONGDELAY) || m_bIsRendering) //rewbs: disable song fade when rendering. -#endif +#endif // FASTSOUNDLIB { m_dwSongFlags |= SONG_ENDREACHED; if (lRead == lMax || m_bIsRendering) //rewbs: don't complete buffer when rendering @@ -345,15 +351,19 @@ } } } + lCount = m_nBufferCount; if (lCount > MIXBUFFERSIZE) lCount = MIXBUFFERSIZE; if (lCount > lRead) lCount = lRead; if (!lCount) break; + lSampleCount = lCount; - #ifndef NO_REVERB + +#ifndef NO_REVERB gnReverbSend = 0; - #endif +#endif // NO_REVERB + // Resetting sound buffer X86_StereoFill(MixSoundBuffer, lSampleCount, &gnDryROfsVol, &gnDryLOfsVol); @@ -362,23 +372,42 @@ { lSampleCount *= 2; m_nMixStat += CreateStereoMix(lCount); - #ifndef NO_REVERB + +#ifndef NO_REVERB ProcessReverb(lCount); - #endif +#endif // NO_REVERB + if (nMaxPlugins) ProcessPlugins(lCount); + + // Apply global volume + if (m_pConfig->getGlobalVolumeAppliesToMaster()) + { + ApplyGlobalVolume(MixSoundBuffer, MixRearBuffer, lSampleCount); + } + ProcessStereoDSP(lCount); } else { m_nMixStat += CreateStereoMix(lCount); - #ifndef NO_REVERB + +#ifndef NO_REVERB ProcessReverb(lCount); - #endif +#endif // NO_REVERB + if (nMaxPlugins) ProcessPlugins(lCount); X86_MonoFromStereo(MixSoundBuffer, lCount); + + // Apply global volume + if (m_pConfig->getGlobalVolumeAppliesToMaster()) + { + ApplyGlobalVolume(MixSoundBuffer, nullptr, lSampleCount); + } + ProcessMonoDSP(lCount); } + +#ifdef ENABLE_EQ // Graphic Equalizer -#ifdef ENABLE_EQ if (gdwSoundSetup & SNDMIX_EQ) { if (gnChannels >= 2) @@ -386,13 +415,17 @@ else EQMono(MixSoundBuffer, lCount); } -#endif +#endif // ENABLE_EQ + nStat++; + #ifndef NO_AGC // Automatic Gain Control if (gdwSoundSetup & SNDMIX_AGC) ProcessAGC(lSampleCount); -#endif - UINT lTotalSampleCount = lSampleCount; +#endif // NO_AGC + + UINT lTotalSampleCount = lSampleCount; // Including rear channels + #ifndef FASTSOUNDLIB // Multichannel if (gnChannels > 2) @@ -400,6 +433,9 @@ X86_InterleaveFrontRear(MixSoundBuffer, MixRearBuffer, lSampleCount); lTotalSampleCount *= 2; } +#endif // FASTSOUNDLIB + +#ifndef FASTSOUNDLIB // Noise Shaping if (gnBitsPerSample <= 16) { @@ -408,16 +444,13 @@ X86_Dither(MixSoundBuffer, lTotalSampleCount, gnBitsPerSample); } - //Apply global volume - if (m_pConfig->getGlobalVolumeAppliesToMaster()) { - ApplyGlobalVolume(MixSoundBuffer, lTotalSampleCount); - } - // Hook Function - if (gpSndMixHook) { //Currently only used for VU Meter, so it's OK to do it after global Vol. + if (gpSndMixHook) + { + //Currently only used for VU Meter, so it's OK to do it after global Vol. gpSndMixHook(MixSoundBuffer, lTotalSampleCount, gnChannels); } -#endif +#endif // FASTSOUNDLIB // Perform clipping lpBuffer += pCvt(lpBuffer, MixSoundBuffer, lTotalSampleCount); @@ -1597,7 +1630,7 @@ */ const int vibpos = pChn->nAutoVibPos & 0xFF; int adepth = pChn->nAutoVibDepth; // (1) - adepth += pSmp->nVibSweep & 0xFF; // (2 & 3) + adepth += pSmp->nVibSweep; // (2 & 3) adepth = min(adepth, (int)(pSmp->nVibDepth << 8)); pChn->nAutoVibDepth = adepth; // (5) adepth >>= 8; // (4) @@ -2529,52 +2562,61 @@ #endif -void CSoundFile::ApplyGlobalVolume(int SoundBuffer[], long lTotalSampleCount) -//--------------------------------------------------------------------------- +void CSoundFile::ApplyGlobalVolume(int SoundBuffer[], int RearBuffer[], long lTotalSampleCount) +//--------------------------------------------------------------------------------------------- { - long delta = 0; long step = 0; if (m_nGlobalVolumeDestination != m_nGlobalVolume) { - //user has provided new global volume + // User has provided new global volume const bool rampUp = m_nGlobalVolumeDestination > m_nGlobalVolume; m_nGlobalVolumeDestination = m_nGlobalVolume; m_nSamplesToGlobalVolRampDest = rampUp ? gnVolumeRampUpSamples : gnVolumeRampDownSamples; } - long rampLength = m_nSamplesToGlobalVolRampDest; + const long rampLength = m_nSamplesToGlobalVolRampDest; if (m_nSamplesToGlobalVolRampDest > 0) { - // still some ramping left to do. - long highResGlobalVolumeDestination = static_cast<long>(m_nGlobalVolumeDestination)<<VOLUMERAMPPRECISION; + // Still some ramping left to do. + long highResGlobalVolumeDestination = static_cast<long>(m_nGlobalVolumeDestination) << VOLUMERAMPPRECISION; - delta = highResGlobalVolumeDestination - m_lHighResRampingGlobalVolume; + const long delta = highResGlobalVolumeDestination - m_lHighResRampingGlobalVolume; step = delta / static_cast<long>(m_nSamplesToGlobalVolRampDest); - 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. + 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 += rampLength; step = delta / static_cast<long>(m_nSamplesToGlobalVolRampDest); } } - for (int pos = 0; pos < lTotalSampleCount; pos++) + const long highResVolume = m_lHighResRampingGlobalVolume; + const UINT samplesToRamp = m_nSamplesToGlobalVolRampDest; + + // SoundBuffer has interleaved left/right channels for the front channels; RearBuffer has the rear left/right channels. + // So we process the pairs independently for ramping. + for (int pairs = max(gnChannels / 2, 1); pairs > 0; pairs--) { + int *sample = (pairs == 1) ? SoundBuffer : RearBuffer; + m_lHighResRampingGlobalVolume = highResVolume; + m_nSamplesToGlobalVolRampDest = samplesToRamp; - if (m_nSamplesToGlobalVolRampDest > 0) + for (int pos = lTotalSampleCount; pos > 0; pos--, sample++) { - //ramping required - m_lHighResRampingGlobalVolume += step; - SoundBuffer[pos] = _muldiv(SoundBuffer[pos], m_lHighResRampingGlobalVolume, MAX_GLOBAL_VOLUME<<VOLUMERAMPPRECISION); - m_nSamplesToGlobalVolRampDest--; - } else - { - SoundBuffer[pos] = _muldiv(SoundBuffer[pos], m_nGlobalVolume, MAX_GLOBAL_VOLUME); - m_lHighResRampingGlobalVolume = m_nGlobalVolume<<VOLUMERAMPPRECISION; + if (m_nSamplesToGlobalVolRampDest > 0) + { + // Ramping required + m_lHighResRampingGlobalVolume += step; + *sample = _muldiv(*sample, m_lHighResRampingGlobalVolume, MAX_GLOBAL_VOLUME << VOLUMERAMPPRECISION); + m_nSamplesToGlobalVolRampDest--; + } else + { + *sample = _muldiv(*sample, m_nGlobalVolume, MAX_GLOBAL_VOLUME); + m_lHighResRampingGlobalVolume = m_nGlobalVolume << VOLUMERAMPPRECISION; + } } - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-19 23:31:36
|
Revision: 1046 http://modplug.svn.sourceforge.net/modplug/?rev=1046&view=rev Author: saga-games Date: 2011-09-19 23:31:30 +0000 (Mon, 19 Sep 2011) Log Message: ----------- [Fix] Volume / Panning Swing should range from 0 to 100, not 0 to 64. [Fix] IT Compatibility: Volume / Panning Swing algorithms were wrong. [Mod] OpenMPT: Version is now 1.20.00.25 Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-09-19 16:14:07 UTC (rev 1045) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-09-19 23:31:30 UTC (rev 1046) @@ -957,8 +957,8 @@ m_CbnPluginVolumeHandling.AddString("None"); // Vol/Pan Swing - m_SliderVolSwing.SetRange(0, 64); - m_SliderPanSwing.SetRange(0, 64); + m_SliderVolSwing.SetRange(0, 100); + m_SliderPanSwing.SetRange(0, 100); m_SliderCutSwing.SetRange(0, 64); m_SliderResSwing.SetRange(0, 64); // Filter @@ -2365,7 +2365,7 @@ else if (pSlider==&m_SliderVolSwing) { n = m_SliderVolSwing.GetPos(); - if ((n >= 0) && (n <= 64) && (n != (int)pIns->nVolSwing)) + if ((n >= 0) && (n <= 100) && (n != (int)pIns->nVolSwing)) { pIns->nVolSwing = (BYTE)n; SetInstrumentModified(true); @@ -2375,7 +2375,7 @@ else if (pSlider==&m_SliderPanSwing) { n = m_SliderPanSwing.GetPos(); - if ((n >= 0) && (n <= 64) && (n != (int)pIns->nPanSwing)) + if ((n >= 0) && (n <= 100) && (n != (int)pIns->nPanSwing)) { pIns->nPanSwing = (BYTE)n; SetInstrumentModified(true); Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-09-19 16:14:07 UTC (rev 1045) +++ trunk/OpenMPT/mptrack/version.h 2011-09-19 23:31:30 UTC (rev 1046) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 24 +#define VER_MINORMINOR 25 //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-19 16:14:07 UTC (rev 1045) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2011-09-19 23:31:30 UTC (rev 1046) @@ -456,8 +456,8 @@ pIns->nPPC = pis->ppc; pIns->nIFC = pis->ifc; pIns->nIFR = pis->ifr; - pIns->nVolSwing = pis->rv; - pIns->nPanSwing = pis->rp; + pIns->nVolSwing = min(pis->rv, 100); + pIns->nPanSwing = min(pis->rp, 100); pIns->nPan = (pis->dfp & 0x7F) << 2; if (pIns->nPan > 256) pIns->nPan = 128; if (pis->dfp < 0x80) pIns->dwFlags |= INS_SETPANNING; @@ -1621,8 +1621,8 @@ 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.rv = min(pIns->nVolSwing, 100); + iti.rp = min(pIns->nPanSwing, 100); iti.ifc = pIns->nIFC; iti.ifr = pIns->nIFR; iti.nos = 0; Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-09-19 16:14:07 UTC (rev 1045) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-09-19 23:31:30 UTC (rev 1046) @@ -962,8 +962,8 @@ // IT compatibility: MPT has a weird vol swing algorithm.... if(IsCompatibleMode(TRK_IMPULSETRACKER)) { - double d = 2 * (((double) rand()) / RAND_MAX) - 1; - pChn->nVolSwing = d * pIns->nVolSwing / 100.0 * pChn->nVolume; + double d = 128 * (((double) rand()) / RAND_MAX) - 64; + pChn->nVolSwing = d * pIns->nVolSwing / 100.0; } else { int d = ((LONG)pIns->nVolSwing * (LONG)((rand() & 0xFF) - 0x7F)) / 128; Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2011-09-19 16:14:07 UTC (rev 1045) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2011-09-19 23:31:30 UTC (rev 1046) @@ -918,9 +918,14 @@ { if(pChn->nVolSwing) { - if(GetModFlag(MSF_OLDVOLSWING)) + if(IsCompatibleMode(TRK_IMPULSETRACKER)) { vol += pChn->nVolSwing; + Limit(vol, 0, 64); + } else if(GetModFlag(MSF_OLDVOLSWING)) + { + vol += pChn->nVolSwing; + Limit(vol, 0, 256); } else { @@ -928,28 +933,16 @@ pChn->nVolume = CLAMP(pChn->nVolume, 0, 256); vol = pChn->nVolume; pChn->nVolSwing = 0; + Limit(vol, 0, 256); } } - - vol = CLAMP(vol, 0, 256); } void CSoundFile::ProcessPanningSwing(MODCHANNEL *pChn) //---------------------------------------------------- { - if(GetModFlag(MSF_OLDVOLSWING)) - { - pChn->nRealPan = pChn->nPan + pChn->nPanSwing; - } - else - { - pChn->nPan += pChn->nPanSwing; - pChn->nPan = CLAMP(pChn->nPan, 0, 256); - pChn->nPanSwing = 0; - pChn->nRealPan = pChn->nPan; - } - + pChn->nRealPan = pChn->nPan + pChn->nPanSwing; pChn->nRealPan = CLAMP(pChn->nRealPan, 0, 256); } @@ -2020,7 +2013,10 @@ { int vol = pChn->nVolume; - ProcessVolumeSwing(pChn, vol); + if(!IsCompatibleMode(TRK_IMPULSETRACKER)) + { + ProcessVolumeSwing(pChn, vol); + } ProcessPanningSwing(pChn); ProcessTremolo(pChn, vol); ProcessTremor(pChn, vol); @@ -2047,6 +2043,12 @@ // vol is 14-bits if (vol) { + int insVol = pChn->nInsVol; // This is the "SV" value in ITTECH.TXT + if(IsCompatibleMode(TRK_IMPULSETRACKER)) + { + ProcessVolumeSwing(pChn, insVol); + } + // IMPORTANT: pChn->nRealVolume is 14 bits !!! // -> _muldiv( 14+8, 6+6, 18); => RealVolume: 14-bit result (22+12-20) @@ -2057,10 +2059,10 @@ pChn->nRealVolume = 0; } else if (m_pConfig->getGlobalVolumeAppliesToMaster()) { - pChn->nRealVolume = _muldiv(vol * MAX_GLOBAL_VOLUME, pChn->nGlobalVol * pChn->nInsVol, 1 << 20); + pChn->nRealVolume = _muldiv(vol * MAX_GLOBAL_VOLUME, pChn->nGlobalVol * insVol, 1 << 20); } else { - pChn->nRealVolume = _muldiv(vol * m_nGlobalVolume, pChn->nGlobalVol * pChn->nInsVol, 1 << 20); + pChn->nRealVolume = _muldiv(vol * m_nGlobalVolume, pChn->nGlobalVol * insVol, 1 << 20); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-20 01:01:05
|
Revision: 1048 http://modplug.svn.sourceforge.net/modplug/?rev=1048&view=rev Author: saga-games Date: 2011-09-20 01:00:58 +0000 (Tue, 20 Sep 2011) Log Message: ----------- [Fix] More Swing fixage. Old files using the 0...64 volswing range are now upgraded automatically, so that internal algorithms don't need all that case switching anymore. [Fix] Panswing range is 0...64, not 0...100 (yay consistency) [Mod] OpenMPT: Version is now 1.20.00.26 Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Snd_fx.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-20 00:10:15 UTC (rev 1047) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-09-20 01:00:58 UTC (rev 1048) @@ -958,7 +958,7 @@ // Vol/Pan Swing m_SliderVolSwing.SetRange(0, 100); - m_SliderPanSwing.SetRange(0, 100); + m_SliderPanSwing.SetRange(0, 64); m_SliderCutSwing.SetRange(0, 64); m_SliderResSwing.SetRange(0, 64); // Filter @@ -2375,7 +2375,7 @@ else if (pSlider==&m_SliderPanSwing) { n = m_SliderPanSwing.GetPos(); - if ((n >= 0) && (n <= 100) && (n != (int)pIns->nPanSwing)) + if ((n >= 0) && (n <= 64) && (n != (int)pIns->nPanSwing)) { pIns->nPanSwing = (BYTE)n; SetInstrumentModified(true); Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-09-20 00:10:15 UTC (rev 1047) +++ trunk/OpenMPT/mptrack/version.h 2011-09-20 01:00:58 UTC (rev 1048) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 25 +#define VER_MINORMINOR 26 //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-20 00:10:15 UTC (rev 1047) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2011-09-20 01:00:58 UTC (rev 1048) @@ -457,7 +457,7 @@ pIns->nIFC = pis->ifc; pIns->nIFR = pis->ifr; pIns->nVolSwing = min(pis->rv, 100); - pIns->nPanSwing = min(pis->rp, 100); + pIns->nPanSwing = min(pis->rp, 64); pIns->nPan = (pis->dfp & 0x7F) << 2; if (pIns->nPan > 256) pIns->nPan = 128; if (pis->dfp < 0x80) pIns->dwFlags |= INS_SETPANNING; @@ -1249,6 +1249,15 @@ SetModFlag(MSF_OLDVOLSWING, true); } + if(m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 00)) + { + // Previously, volume swing values ranged from 0 to 64. They should reach from 0 to 100 instead. + for(INSTRUMENTINDEX i = 1; i <= GetNumInstruments(); i++) if(Instruments[i] != nullptr) + { + Instruments[i]->nVolSwing = min(Instruments[i]->nVolSwing * 100 / 64, 100); + } + } + if(GetType() == MOD_TYPE_IT) { // Set appropriate mod flags if the file was not made with MPT. @@ -1622,7 +1631,7 @@ iti.dfp = (BYTE)(pIns->nPan >> 2); if (!(pIns->dwFlags & INS_SETPANNING)) iti.dfp |= 0x80; iti.rv = min(pIns->nVolSwing, 100); - iti.rp = min(pIns->nPanSwing, 100); + iti.rp = min(pIns->nPanSwing, 64); iti.ifc = pIns->nIFC; iti.ifr = pIns->nIFR; iti.nos = 0; Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-09-20 00:10:15 UTC (rev 1047) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-09-20 01:00:58 UTC (rev 1048) @@ -959,29 +959,16 @@ // Volume Swing if (pIns->nVolSwing) { - // IT compatibility: MPT has a weird vol swing algorithm.... - if(IsCompatibleMode(TRK_IMPULSETRACKER)) - { - double d = 2 * (((double) rand()) / RAND_MAX) - 1; - pChn->nVolSwing = std::floor(d * pChn->nInsVol * pIns->nVolSwing / 100.0); - } else - { - int d = ((LONG)pIns->nVolSwing * (LONG)((rand() & 0xFF) - 0x7F)) / 128; - pChn->nVolSwing = (signed short)((d * pChn->nVolume + 1) / 128); - } + const double delta = 2 * (((double) rand()) / RAND_MAX) - 1; + pChn->nVolSwing = (LONG)std::floor(delta * (IsCompatibleMode(TRK_IMPULSETRACKER) ? pChn->nInsVol : (pChn->nVolume + 1)) * pIns->nVolSwing / 100.0); } // Pan Swing if (pIns->nPanSwing) { - // IT compatibility: MPT has a weird pan swing algorithm.... - if(IsCompatibleMode(TRK_IMPULSETRACKER)) + const double delta = 2 * (((double) rand()) / RAND_MAX) - 1; + pChn->nPanSwing = (LONG)std::floor(delta * (IsCompatibleMode(TRK_IMPULSETRACKER) ? 4 : 1) * pIns->nPanSwing); + if(!IsCompatibleMode(TRK_IMPULSETRACKER)) { - double d = 2 * (((double) rand()) / RAND_MAX) - 1; - pChn->nPanSwing = std::floor(d * pIns->nPanSwing * 4); - } else - { - int d = ((LONG)pIns->nPanSwing * (LONG)((rand() & 0xFF) - 0x7F)) / 128; - pChn->nPanSwing = (signed short)d; pChn->nRestorePanOnNewNote = pChn->nPan + 1; } } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2011-09-20 00:10:15 UTC (rev 1047) +++ trunk/OpenMPT/soundlib/Sndfile.h 2011-09-20 01:00:58 UTC (rev 1048) @@ -118,10 +118,10 @@ BYTE nNNA; // New note action BYTE nDCT; // Duplicate check type (i.e. which condition will trigger the duplicate note action) BYTE nDNA; // Duplicate note action - BYTE nPanSwing; // Random panning factor - BYTE nVolSwing; // Random volume factor - BYTE nIFC; // Default filter cutoff (00...7F). Used if the high bit is set - BYTE nIFR; // Default filter resonance (00...7F). Used if the high bit is set + BYTE nPanSwing; // Random panning factor (0...64) + BYTE nVolSwing; // Random volume factor (0...100) + BYTE nIFC; // Default filter cutoff (0...127). Used if the high bit is set + BYTE nIFR; // Default filter resonance (0...127). Used if the high bit is set WORD wMidiBank; // MIDI bank BYTE nMidiProgram; // MIDI program @@ -134,8 +134,8 @@ PLUGINDEX nMixPlug; // Plugin assigned to this instrument uint16 nVolRampUp; // Default sample ramping up UINT nResampling; // Resampling mode - BYTE nCutSwing; // Random cutoff factor - BYTE nResSwing; // Random resonance factor + BYTE nCutSwing; // Random cutoff factor (0...64) + BYTE nResSwing; // Random resonance factor (0...64) BYTE nFilterMode; // Default filter mode WORD wPitchToTempoLock; // BPM at which the samples assigned to this instrument loop correctly BYTE nPluginVelocityHandling; // How to deal with plugin velocity Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2011-09-20 00:10:15 UTC (rev 1047) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2011-09-20 01:00:58 UTC (rev 1048) @@ -942,8 +942,17 @@ void CSoundFile::ProcessPanningSwing(MODCHANNEL *pChn) //---------------------------------------------------- { - pChn->nRealPan = pChn->nPan + pChn->nPanSwing; - pChn->nRealPan = CLAMP(pChn->nRealPan, 0, 256); + if(IsCompatibleMode(TRK_IMPULSETRACKER) || GetModFlag(MSF_OLDVOLSWING)) + { + pChn->nRealPan = pChn->nPan + pChn->nPanSwing; + } else + { + pChn->nPan += pChn->nPanSwing; + Limit(pChn->nPan, 0, 256); + pChn->nPanSwing = 0; + pChn->nRealPan = pChn->nPan; + } + Limit(pChn->nRealPan, 0, 256); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-21 14:45:27
|
Revision: 1050 http://modplug.svn.sourceforge.net/modplug/?rev=1050&view=rev Author: saga-games Date: 2011-09-21 14:45:18 +0000 (Wed, 21 Sep 2011) Log Message: ----------- [Fix] Mod Conversion: Fixed IT <-> XM panning slide conversion. [Fix] Fixed panning slide nibble priority for XM format. [Mod] OpenMPT: Version is now 1.20.00.27 Modified Paths: -------------- trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/modcommand.cpp Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-09-20 18:26:00 UTC (rev 1049) +++ trunk/OpenMPT/mptrack/version.h 2011-09-21 14:45:18 UTC (rev 1050) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 26 +#define VER_MINORMINOR 27 //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-09-20 18:26:00 UTC (rev 1049) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-09-21 14:45:18 UTC (rev 1050) @@ -2649,10 +2649,12 @@ { if (param & 0x0F) { + // IT compatibility: Ignore slide commands with both nibbles set. if(!IsCompatibleMode(TRK_IMPULSETRACKER) || (param & 0xF0) == 0) nPanSlide = (int)((param & 0x0F) << 2); } else { + // IT compatibility: Ignore slide commands with both nibbles set. if(!IsCompatibleMode(TRK_IMPULSETRACKER) || (param & 0x0F) == 0) nPanSlide = -(int)((param & 0xF0) >> 2); } @@ -2662,16 +2664,14 @@ { if (!(m_dwSongFlags & SONG_FIRSTTICK)) { - // IT compatibility: Ignore slide commands with both nibbles set. - if (param & 0x0F) + if (param & 0xF0) { + nPanSlide = (int)((param & 0xF0) >> 2); + } else + { nPanSlide = -(int)((param & 0x0F) << 2); } - else - { - nPanSlide = (int)((param & 0xF0) >> 2); - } - // XM compatibility: FT2's panning slide is not as deep + // XM compatibility: FT2's panning slide is like IT's fine panning slide (not as deep) if(IsCompatibleMode(TRK_FASTTRACKER2)) nPanSlide >>= 2; } @@ -3882,7 +3882,7 @@ { if (!(m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT))) nGlbSlide *= 2; nGlbSlide += m_nGlobalVolume; - nGlbSlide = CLAMP(nGlbSlide, 0, 256); + Limit(nGlbSlide, 0, 256); m_nGlobalVolume = nGlbSlide; } } Modified: trunk/OpenMPT/soundlib/modcommand.cpp =================================================================== --- trunk/OpenMPT/soundlib/modcommand.cpp 2011-09-20 18:26:00 UTC (rev 1049) +++ trunk/OpenMPT/soundlib/modcommand.cpp 2011-09-21 14:45:18 UTC (rev 1050) @@ -192,8 +192,14 @@ } break; case CMD_PANNINGSLIDE: - // swap L/R - m->param = ((m->param & 0x0F) << 4) | (m->param >> 4); + // swap L/R, convert to fine slide + if(m->param & 0xF0) + { + m->param = 0xF0 | min(0x0E, (m->param >> 4)); + } else + { + m->param = 0x0F | (min(0x0E, m->param & 0x0F) << 4); + } default: break; } @@ -280,11 +286,24 @@ if(m->param < 0x20) m->command = CMD_NONE; // no tempo slides break; case CMD_PANNINGSLIDE: - // swap L/R - m->param = ((m->param & 0x0F) << 4) | (m->param >> 4); - // remove fine slides - if((m->param > 0xF0) || ((m->param & 0x0F) == 0x0F && m->param != 0x0F)) - m->command = CMD_NONE; + // swap L/R, convert fine slides to normal slides + if((m->param & 0x0F) == 0x0F && (m->param & 0xF0)) + { + m->param = (m->param >> 4); + } else if((m->param & 0xF0) == 0xF0 && (m->param & 0x0F)) + { + m->param = (m->param & 0x0F) << 4; + } else if(m->param & 0x0F) + { + m->param = 0xF0; + } else if(m->param & 0xF0) + { + m->param = 0x0F; + } else + { + m->param = 0; + } + break; case CMD_RETRIG: // Retrig: Q0y doesn't change volume in IT/S3M, but R0y in XM takes the last x parameter if(m->param != 0 && (m->param & 0xF0) == 0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-23 23:11:07
|
Revision: 1051 http://modplug.svn.sourceforge.net/modplug/?rev=1051&view=rev Author: saga-games Date: 2011-09-23 23:10:59 +0000 (Fri, 23 Sep 2011) Log Message: ----------- [Mod] Added more mnemonic keys in some places. [Ref] More refactoring! Modified Paths: -------------- trunk/OpenMPT/mptrack/Childfrm.cpp trunk/OpenMPT/mptrack/CommandSet.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/InputHandler.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/TuningDialog.cpp trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Snd_dsp.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/Childfrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/Childfrm.cpp 2011-09-21 14:45:18 UTC (rev 1050) +++ trunk/OpenMPT/mptrack/Childfrm.cpp 2011-09-23 23:10:59 UTC (rev 1051) @@ -426,7 +426,7 @@ void CChildFrame::OnSetFocus(CWnd* pOldWnd) { CMDIChildWnd::OnSetFocus(pOldWnd); - // TODO: Add your message handler code here + CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); if (pMainFrm) { Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2011-09-21 14:45:18 UTC (rev 1050) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2011-09-23 23:10:59 UTC (rev 1051) @@ -1424,7 +1424,7 @@ if( (outStream = fopen( fileName, "w" )) == NULL ) { - MsgBox(IDS_CANT_OPEN_FILE_FOR_WRITING, NULL, NULL, MB_ICONEXCLAMATION | MB_OK); + ErrorBox(IDS_CANT_OPEN_FILE_FOR_WRITING); return false; } fprintf(outStream, "//-------- OpenMPT key binding definition file -------\n"); Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-09-21 14:45:18 UTC (rev 1050) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-09-23 23:10:59 UTC (rev 1051) @@ -1894,14 +1894,14 @@ if(smpPanningInUse) { 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 " + "Sample panning overrides instrument panning for the notes associated with such samples. " + "Do you wish to disable panning from those samples so that the instrument pan setting is effective " "for the whole instrument?")) == cnfYes) { for(BYTE i = 0; i < CountOf(pIns->Keyboard); i++) { const SAMPLEINDEX smp = pIns->Keyboard[i]; - if(smp <= m_pSndFile->GetNumSamples()) + if(smp > 0 && smp <= m_pSndFile->GetNumSamples()) 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-21 14:45:18 UTC (rev 1050) +++ trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2011-09-23 23:10:59 UTC (rev 1051) @@ -1245,9 +1245,8 @@ BOOL CCtrlPatterns::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) //-------------------------------------------------------------------- { - // TODO: Add your message handler code here and/or call default - - if (nFlags==0) { + if (nFlags==0) + { PostViewMessage(VIEWMSG_DOSCROLL, zDelta); } return CModControlDlg::OnMouseWheel(nFlags, zDelta, pt); Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-09-21 14:45:18 UTC (rev 1050) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-09-23 23:10:59 UTC (rev 1051) @@ -1744,9 +1744,7 @@ UpdateData(TRUE); //Calculate/verify samplerate at C5. - long lSampleRate = sample.nC5Speed; - if(m_pSndFile->m_nType & (MOD_TYPE_MOD|MOD_TYPE_XM)) - lSampleRate = CSoundFile::TransposeToFrequency(sample.RelativeTone, sample.nFineTune); + long lSampleRate = sample.GetSampleRate(m_pSndFile->GetType()); if(lSampleRate <= 0) lSampleRate = 8363; Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2011-09-21 14:45:18 UTC (rev 1050) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2011-09-23 23:10:59 UTC (rev 1051) @@ -1505,6 +1505,7 @@ if(m->note >= NOTE_MIN_SPECIAL) strcpy(s, szSpecialNoteShortDesc[m->note - NOTE_MIN_SPECIAL]); break; + case INST_COLUMN: // display instrument if (m->instr) @@ -1515,8 +1516,7 @@ // display plugin name. if(m->instr <= MAX_MIXPLUGINS) { - strncpy(sztmp, pSndFile->m_MixPlugins[m->instr - 1].GetName(), sizeof(sztmp)); - StringFixer::SetNullTerminator(sztmp); + strncpy(sztmp, pSndFile->m_MixPlugins[m->instr - 1].GetName(), CountOf(sztmp)); } } else { @@ -1530,12 +1530,12 @@ sztmp[32] = 0; if ((m->note) && (m->note <= NOTE_MAX)) { - const SAMPLEINDEX nsmp = pIns->Keyboard[m->note-1]; + const SAMPLEINDEX nsmp = pIns->Keyboard[m->note - 1]; if ((nsmp) && (nsmp <= pSndFile->GetNumSamples())) { if (pSndFile->m_szNames[nsmp][0]) { - wsprintf(sztmp+strlen(sztmp), " (%d: %s)", nsmp, pSndFile->m_szNames[nsmp]); + wsprintf(sztmp + strlen(sztmp), " (%d: %s)", nsmp, pSndFile->m_szNames[nsmp]); } } } @@ -1550,9 +1550,11 @@ } } + StringFixer::SetNullTerminator(sztmp); if (sztmp[0]) wsprintf(s, "%d: %s", m->instr, sztmp); } break; + case VOL_COLUMN: // display volume command if(m->IsPcNote()) @@ -1571,6 +1573,7 @@ if (!pModDoc->GetVolCmdInfo(pModDoc->GetIndexFromVolCmd(m->volcmd), s)) s[0] = 0; } break; + case EFFECT_COLUMN: case PARAM_COLUMN: // display effect command Modified: trunk/OpenMPT/mptrack/InputHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/InputHandler.cpp 2011-09-21 14:45:18 UTC (rev 1050) +++ trunk/OpenMPT/mptrack/InputHandler.cpp 2011-09-23 23:10:59 UTC (rev 1051) @@ -58,7 +58,7 @@ } } if (bSuccess == false) - MsgBox(IDS_UNABLE_TO_LOAD_KEYBINDINGS, NULL, MAINFRAME_TITLE, MB_ICONERROR); + ErrorBox(IDS_UNABLE_TO_LOAD_KEYBINDINGS); } // We will only overwrite the default Keybindings.mkb file from now on. _tcscpy(CMainFrame::GetSettings().m_szKbdFile, sDefaultPath); Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2011-09-21 14:45:18 UTC (rev 1050) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2011-09-23 23:10:59 UTC (rev 1051) @@ -225,12 +225,7 @@ TEXT("C-9"), TEXT("C#9"), TEXT("D-9"), TEXT("D#9"), TEXT("E-9"), TEXT("F-9"), TEXT("F#9"), TEXT("G-9"), TEXT("G#9"), TEXT("A-9"), TEXT("A#9"), TEXT("B-9"), }; -static void ShowChangesDialog() -//----------------------------- -{ -} - TCHAR CTrackApp::m_szExePath[_MAX_PATH] = TEXT(""); ///////////////////////////////////////////////////////////////////////////// @@ -800,13 +795,10 @@ CMainFrame::GetSettings().m_nSampleUndoMaxBuffer = gMemStatus.dwTotalPhys / 10; // set sample undo buffer size if(CMainFrame::GetSettings().m_nSampleUndoMaxBuffer < (1 << 20)) CMainFrame::GetSettings().m_nSampleUndoMaxBuffer = (1 << 20); - ASSERT(NULL == m_pDocManager); + ASSERT(nullptr == m_pDocManager); m_pDocManager = new CModDocManager(); -#ifdef _DEBUG - ASSERT((sizeof(MODCHANNEL)&7) == 0); - // Disabled by rewbs for smoothVST. Might cause minor perf issues due to increased cache misses? -#endif + ASSERT((sizeof(MODCHANNEL) & 7) == 0); // Parse command line for standard shell commands, DDE, file open CMPTCommandLineInfo cmdInfo; @@ -818,7 +810,8 @@ SetupPaths(cmdInfo.m_bPortable); //Force use of custom ini file rather than windowsDir\executableName.ini - if (m_pszProfileName) { + if (m_pszProfileName) + { free((void *)m_pszProfileName); } m_pszProfileName = _tcsdup(m_szConfigFileName); @@ -916,7 +909,6 @@ if (!cmdInfo.m_bNoSettingsOnNewVersion && MptVersion::ToNum(CMainFrame::GetSettings().gcsPreviousVersion) < MptVersion::num) { StopSplashScreen(); - ShowChangesDialog(); m_pMainWnd->PostMessage(WM_COMMAND, ID_VIEW_OPTIONS); } @@ -1576,7 +1568,7 @@ "in the form of ideas, testing and support; thanks|" "particularly to:|" "33, Anboi, BooT-SectoR-ViruZ, Bvanoudtshoorn|" - "christofori, Diamond, Ganja, Georg, Goor00|" + "christofori, Diamond, Ganja, Georg, Goor00, jmkz,|" "KrazyKatz, LPChip, Nofold, Rakib, Sam Zen|" "Skaven, Skilletaudio, Snu, Squirrel Havoc, Waxhead|" "|||||||" @@ -1603,7 +1595,6 @@ //-------------------------- { if (gpAboutDlg) return; - ShowChangesDialog(); gpAboutDlg = new CAboutDlg(); gpAboutDlg->Create(IDD_ABOUTBOX, m_pMainWnd); } Modified: trunk/OpenMPT/mptrack/TuningDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/TuningDialog.cpp 2011-09-21 14:45:18 UTC (rev 1050) +++ trunk/OpenMPT/mptrack/TuningDialog.cpp 2011-09-23 23:10:59 UTC (rev 1051) @@ -1262,7 +1262,7 @@ m_ModifiedTCs[pTCdest] = true; if(CTuningCollection::TransferTuning(pTCsrc, pTCdest, pT)) { - MsgBox(IDS_OPERATION_FAIL, this, NULL, MB_OK); + MsgBox(IDS_OPERATION_FAIL, this); AddTreeItem(pT, treeItemSrcTC, NULL); } else Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2011-09-21 14:45:18 UTC (rev 1050) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2011-09-23 23:10:59 UTC (rev 1051) @@ -210,10 +210,10 @@ // Misc Flags if(ITorMPT) { - GetDlgItem(IDC_CHK_COMPATPLAY)->SetWindowText(_T("More Impulse Tracker compatible playback")); + GetDlgItem(IDC_CHK_COMPATPLAY)->SetWindowText(_T("More Impulse Tracker &compatible playback")); } else { - GetDlgItem(IDC_CHK_COMPATPLAY)->SetWindowText(_T("More Fasttracker 2 compatible playback")); + GetDlgItem(IDC_CHK_COMPATPLAY)->SetWindowText(_T("More Fasttracker 2 &compatible playback")); } GetDlgItem(IDC_CHK_COMPATPLAY)->ShowWindow(XMorITorMPT); Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2011-09-21 14:45:18 UTC (rev 1050) +++ trunk/OpenMPT/mptrack/mptrack.rc 2011-09-23 23:10:59 UTC (rev 1051) @@ -390,9 +390,9 @@ LTEXT "(can be overridden by instrument setting)",IDC_STATIC,18,248,138,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 + PUSHBUTTON "Default Settings",IDC_BUTTON_DEFAULT_RESAMPLING,186,180,66,12 END IDD_WAVECONVERT DIALOGEX 0, 0, 262, 221 @@ -785,7 +785,6 @@ GROUPBOX "Pitch/Pan",IDC_STATIC,3,88,123,80 CTEXT "Action",IDC_STATIC,246,36,59,13,SS_CENTERIMAGE,WS_EX_STATICEDGE GROUPBOX "New Note Action",IDC_STATIC,240,27,122,59 - GROUPBOX "Plugin / MIDI",IDC_STATIC,240,88,216,80 GROUPBOX "Sample Quality",IDC_STATIC,3,118,123,50 CTEXT "Ramping",IDC_STATIC,7,133,39,13,SS_CENTERIMAGE,WS_EX_STATICEDGE CTEXT "Cutoff",IDC_STATIC,136,133,33,13,SS_CENTERIMAGE,WS_EX_STATICEDGE @@ -798,6 +797,7 @@ CTEXT "Velocity handling",IDC_STATIC,367,102,83,10,SS_CENTERIMAGE,WS_EX_STATICEDGE CTEXT "Volume handling",IDC_STATIC,367,133,83,10,SS_CENTERIMAGE,WS_EX_STATICEDGE GROUPBOX "Tuning (experimental)",IDC_STATIC,364,28,92,28 + GROUPBOX "Plugin / MIDI",IDC_STATIC,240,88,216,80 END IDD_MODDOC_MODTYPE DIALOGEX 0, 0, 262, 305 @@ -1468,16 +1468,16 @@ LTEXT "%",IDC_STATIC,78,109,8,8 DEFPUSHBUTTON "OK",IDOK,127,106,50,14 GROUPBOX "Length in Samples",IDC_STATIC,6,5,82,45 - GROUPBOX "Length in ms at C4",IDC_STATIC,95,5,82,45 + GROUPBOX "Length in ms at C-5",IDC_STATIC,95,5,82,45 GROUPBOX "Length in Rows at C4",IDC_STATIC,6,55,171,45 END IDD_OPTIONS_AUTOSAVE DIALOGEX 0, 0, 272, 279 -STYLE DS_SETFONT | DS_3DLOOK | WS_CHILD | WS_DISABLED | WS_CAPTION +STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Auto Save" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - CONTROL "Enable Autosave",IDC_AUTOSAVE_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,15,70,10 + CONTROL "&Enable Auto Save",IDC_AUTOSAVE_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,15,237,10 EDITTEXT IDC_AUTOSAVE_INTERVAL,59,29,24,12,ES_AUTOHSCROLL | ES_NUMBER EDITTEXT IDC_AUTOSAVE_HISTORY,59,46,24,12,ES_AUTOHSCROLL | ES_NUMBER EDITTEXT IDC_AUTOSAVE_PATH,60,96,164,12,ES_AUTOHSCROLL @@ -1485,15 +1485,15 @@ LTEXT "[filename].AutoSave.[timestamp].[extension]",IDC_STATIC,60,120,164,12,SS_CENTERIMAGE,WS_EX_CLIENTEDGE GROUPBOX "Auto Save",IDC_STATIC,4,3,261,157 LTEXT "Save every:",IDC_STATIC,15,29,40,12,SS_CENTERIMAGE - LTEXT "minutes",IDC_STATIC,87,29,36,12,SS_CENTERIMAGE + LTEXT "minutes",IDC_STATIC,87,29,165,12,SS_CENTERIMAGE LTEXT "Filename:",IDC_STATIC,28,120,30,12,SS_CENTERIMAGE LTEXT "(example: mySong.AutoSave.20050327.2343.it)",IDC_STATIC,60,135,157,12,SS_CENTERIMAGE LTEXT "Keep up to:",IDC_STATIC,15,46,36,12,SS_CENTERIMAGE - LTEXT "backups of each file name",IDC_STATIC,87,46,87,12,SS_CENTERIMAGE + LTEXT "backups of each file name",IDC_STATIC,87,46,165,12,SS_CENTERIMAGE GROUPBOX "Location:",IDC_STATIC,15,70,240,80 - CONTROL "Use:",IDC_AUTOSAVE_USECUSTOMDIR,"Button",BS_AUTORADIOBUTTON,28,97,31,10 - CONTROL "Use song's original directory.",IDC_AUTOSAVE_USEORIGDIR, - "Button",BS_AUTORADIOBUTTON,28,83,105,10 + CONTROL "&Use:",IDC_AUTOSAVE_USECUSTOMDIR,"Button",BS_AUTORADIOBUTTON,28,97,31,10 + CONTROL "Use song's &original directory.",IDC_AUTOSAVE_USEORIGDIR, + "Button",BS_AUTORADIOBUTTON,28,83,194,10 END IDD_EDIT_GOTO DIALOGEX 0, 0, 130, 79 @@ -1865,6 +1865,10 @@ BOTTOMMARGIN, 163 END + IDD_PITCHSHIFT, DIALOG + BEGIN + END + IDD_OPTIONS_AUTOSAVE, DIALOG BEGIN RIGHTMARGIN, 266 Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2011-09-21 14:45:18 UTC (rev 1050) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2011-09-23 23:10:59 UTC (rev 1051) @@ -142,9 +142,6 @@ <ClCompile Include="globals.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="KeyConfigDlg.cpp"> - <Filter>Source Files</Filter> - </ClCompile> <ClCompile Include="ChannelNode.cpp"> <Filter>Source Files\MixGraph</Filter> </ClCompile> @@ -430,6 +427,9 @@ <ClCompile Include="..\common\misc_util.cpp"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="KeyConfigDlg.cpp"> + <Filter>Source Files\Dialogs</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="AbstractVstEditor.h"> @@ -519,9 +519,6 @@ <ClInclude Include="KeyboardSettings.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="KeyConfigDlg.h"> - <Filter>Header Files</Filter> - </ClInclude> <ClInclude Include="MainFrm.h"> <Filter>Header Files</Filter> </ClInclude> @@ -753,6 +750,9 @@ <ClInclude Include="..\common\StringFixer.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="KeyConfigDlg.h"> + <Filter>Header Files\Dialogs</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2011-09-21 14:45:18 UTC (rev 1050) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2011-09-23 23:10:59 UTC (rev 1051) @@ -45,40 +45,23 @@ #define MOD_AMIGAC2 0x1AB -// -> CODE#0006 -// -> DESC="misc quantity changes" #define MAX_SAMPLE_LENGTH 0x10000000 // 0x04000000 (64MB -> now 256MB). // Note: Sample size in bytes can be more than 256 MB. -// -! BEHAVIOUR_CHANGE#0006 -#define MAX_SAMPLE_RATE 192000 + // The meaning of this constant is handled differently in various places; sometimes it's samples, sometimes it's bytes... +#define MAX_SAMPLE_RATE 192000 // Max playback / render rate in Hz #define MAX_ORDERS 256 #define MAX_PATTERNS 240 #define MAX_SAMPLES 4000 +#define MAX_INSTRUMENTS 256 //200 const SEQUENCEINDEX MAX_SEQUENCES = 50; -#define MAX_INSTRUMENTS 256 //200 // -> CODE#0006 -> DESC="misc quantity changes" // -! BEHAVIOUR_CHANGE#0006 -//#ifdef FASTSOUNDLIB -//#define MAX_CHANNELS 80 -//#else -// -> CODE#0006 -// -> DESC="misc quantity changes" #define MAX_CHANNELS 256 //200 // Note: This is the maximum number of sound channels, - // see MAX_BASECHANNELS for max pattern channels. -// -! BEHAVIOUR_CHANGE#0006 -//#endif -// -> CODE#0006 -// -> DESC="misc quantity changes" -//#ifdef FASTSOUNDLIB -//#define MAX_BASECHANNELS 64 -//#else #define MAX_BASECHANNELS 127 // Max pattern channels. -//#endif -// -! BEHAVIOUR_CHANGE#0006 -#define MAX_ENVPOINTS 240 -#define MIN_PERIOD 0x0020 -#define MAX_PERIOD 0xFFFF +#define MIN_PERIOD 0x0020 // Note: Period is an Amiga metric that is inverse to frequency. +#define MAX_PERIOD 0xFFFF // Periods in MPT are 4 times as fine as Amiga periods because of extra fine frequency slides. + // String lengths (including trailing null char) #define MAX_SAMPLENAME 32 // also affects module name! #define MAX_SAMPLEFILENAME 22 @@ -89,7 +72,7 @@ #define MAX_EQ_BANDS 6 -#define MAX_MIXPLUGINS 100 //50 // -> CODE#0006 -> DESC="misc quantity changes" -! BEHAVIOUR_CHANGE#0006 +#define MAX_MIXPLUGINS 100 //50 #define MAX_PLUGPRESETS 1000 //rewbs.plugPresets #define MOD_TYPE_NONE 0x00 @@ -176,6 +159,7 @@ #define ENVELOPE_MIN 0 // vertical min value of a point #define ENVELOPE_MID 32 // vertical middle line #define ENVELOPE_MAX 64 // vertical max value of a point +#define MAX_ENVPOINTS 240 // Maximum length of each instrument envelope #define ENVELOPE_MAX_LENGTH 0x3FFF // max envelope length in ticks. note: this value seems to be conservatively low... @@ -216,6 +200,7 @@ #define FLTMODE_HIGHPASS 1 +// Sample formats #define RSF_16BIT 0x04 #define RSF_STEREO 0x08 Modified: trunk/OpenMPT/soundlib/Snd_dsp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_dsp.cpp 2011-09-21 14:45:18 UTC (rev 1050) +++ trunk/OpenMPT/soundlib/Snd_dsp.cpp 2011-09-23 23:10:59 UTC (rev 1051) @@ -222,10 +222,8 @@ LONG a1 = 0, b0 = 1024, b1 = 0; int nXBassCutOff = 50 + (m_nXBassRange+2) * 20; int nXBassGain = m_nXBassDepth; - if (nXBassGain < 2) nXBassGain = 2; - if (nXBassGain > 8) nXBassGain = 8; - if (nXBassCutOff < 60) nXBassCutOff = 60; - if (nXBassCutOff > 600) nXBassCutOff = 600; + Limit(nXBassGain, 2, 8); + Limit(nXBassCutOff, 60, 600); ShelfEQ(1024, &a1, &b0, &b1, nXBassCutOff, gdwMixingFreq, 1.0f + (1.0f/16.0f) * (0x300 >> nXBassGain), 1.0f, Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2011-09-21 14:45:18 UTC (rev 1050) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2011-09-23 23:10:59 UTC (rev 1051) @@ -955,6 +955,8 @@ BOOL CSoundFile::SetWaveConfig(UINT nRate,UINT nBits,UINT nChannels,BOOL bMMX) //---------------------------------------------------------------------------- { + CriticalSection cs; + BOOL bReset = FALSE; DWORD d = gdwSoundSetup & ~SNDMIX_ENABLEMMX; if (bMMX) d |= SNDMIX_ENABLEMMX; @@ -971,6 +973,8 @@ BOOL CSoundFile::SetDspEffects(BOOL bSurround,BOOL bReverb,BOOL bMegaBass,BOOL bNR,BOOL bEQ) //------------------------------------------------------------------------------------------ { + CriticalSection cs; + DWORD d = gdwSoundSetup & ~(SNDMIX_SURROUND | SNDMIX_REVERB | SNDMIX_MEGABASS | SNDMIX_NOISEREDUCTION | SNDMIX_EQ); if (bSurround) d |= SNDMIX_SURROUND; if ((bReverb) && (gdwSysInfo & SYSMIX_ENABLEMMX)) d |= SNDMIX_REVERB; @@ -2632,15 +2636,12 @@ if (!from || from >= MAX_SAMPLES || !to || to >= MAX_SAMPLES) return false; if (/*!Ins[from].pSample ||*/ Samples[to].pSample) return true; - MODSAMPLE *pFrom = &Samples[from]; - MODSAMPLE *pTo = &Samples[to]; + MemCopy(Samples[to], Samples[from]); - memcpy(pTo, pFrom, sizeof(MODSAMPLE)); + Samples[from].pSample = nullptr; + Samples[from].nLength = 0; + Samples[from].uFlags &= ~(CHN_16BIT); - pFrom->pSample = nullptr; - pFrom->nLength = 0; - pFrom->uFlags &= ~(CHN_16BIT); - return true; } // -! NEW_FEATURE#0020 Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2011-09-21 14:45:18 UTC (rev 1050) +++ trunk/OpenMPT/soundlib/Sndfile.h 2011-09-23 23:10:59 UTC (rev 1051) @@ -112,8 +112,8 @@ { UINT nFadeOut; // Instrument fadeout speed DWORD dwFlags; // Instrument flags - UINT nGlobalVol; // Global volume (all sample volumes are multiplied with this) - UINT nPan; // Default pan (overrides sample panning), if the appropriate flag is set + UINT nGlobalVol; // Global volume (0...64, all sample volumes are multiplied with this - TODO: This is 0...128 in Impulse Tracker) + UINT nPan; // Default pan (0...256), if the appropriate flag is set. Sample panning overrides instrument panning. BYTE nNNA; // New note action BYTE nDCT; // Duplicate check type (i.e. which condition will trigger the duplicate note action) @@ -271,7 +271,8 @@ MODSAMPLE *pModSample; // Currently assigned sample slot CHANNELINDEX nMasterChn; DWORD nVUMeter; - LONG nGlobalVol, nInsVol; + LONG nGlobalVol; // Channel volume (CV in ITTECH.TXT) + LONG nInsVol; // Sample / Instrument volume (SV * IV in ITTECH.TXT) LONG nFineTune, nTranspose; LONG nPortamentoSlide, nAutoVibDepth; UINT nAutoVibPos, nVibratoPos, nTremoloPos, nPanbrelloPos; @@ -282,6 +283,7 @@ DWORD nEFxOffset; // offset memory for Invert Loop (EFx, .MOD only) int nRetrigCount, nRetrigParam; ROWINDEX nPatternLoop; + UINT nNoteSlideCounter, nNoteSlideSpeed, nNoteSlideStep; // 8-bit members BYTE nRestoreResonanceOnNewNote; //Like above BYTE nRestoreCutoffOnNewNote; //Like above @@ -291,7 +293,6 @@ BYTE nOldVolumeSlide, nOldFineVolUpDown; BYTE nOldPortaUpDown, nOldFinePortaUpDown; BYTE nOldPanSlide, nOldChnVolSlide; - UINT nNoteSlideCounter, nNoteSlideSpeed, nNoteSlideStep; BYTE nVibratoType, nVibratoSpeed, nVibratoDepth; BYTE nTremoloType, nTremoloSpeed, nTremoloDepth; BYTE nPanbrelloType, nPanbrelloSpeed, nPanbrelloDepth; @@ -305,7 +306,7 @@ BYTE nRowCommand, nRowParam; BYTE nLeftVU, nRightVU; BYTE nActiveMacro, nFilterMode; - BYTE nEFxSpeed, nEFxDelay; // memory for Invert Loop (EFx, .MOD only) + BYTE nEFxSpeed, nEFxDelay; // memory for Invert Loop (EFx, .MOD only) //NOTE_PCs memory. uint16 m_RowPlugParam; @@ -315,7 +316,7 @@ void ClearRowCmd() {nRowNote = NOTE_NONE; nRowInstr = 0; nRowVolCmd = VOLCMD_NONE; nRowVolume = 0; nRowCommand = CMD_NONE; nRowParam = 0;} typedef UINT VOLUME; - VOLUME GetVSTVolume() {return (pModInstrument) ? pModInstrument->nGlobalVol*4 : nVolume;} + VOLUME GetVSTVolume() {return (pModInstrument) ? pModInstrument->nGlobalVol * 4 : nVolume;} //-->Variables used to make user-definable tuning modes work with pattern effects. bool m_ReCalculateFreqOnFirstTick; @@ -351,6 +352,7 @@ #include "modcommand.h" + //////////////////////////////////////////////////////////////////// // Mix Plugins #define MIXPLUG_MIXREADY 0x01 // Set when cleared Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2011-09-21 14:45:18 UTC (rev 1050) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2011-09-23 23:10:59 UTC (rev 1051) @@ -89,6 +89,8 @@ #endif // Log tables for pre-amp +// Pre-amp (or more precisely: Pre-attenuation) depends on the number of channels, +// Which this table takes care of. const UINT PreAmpTable[16] = { 0x60, 0x60, 0x60, 0x70, // 0-7 @@ -1960,8 +1962,6 @@ MODCHANNEL *pChn = Chn; for (CHANNELINDEX nChn = 0; nChn < MAX_CHANNELS; nChn++, pChn++) { - skipchn: - // XM Compatibility: Prevent notes to be stopped after a fadeout. This way, a portamento effect can pick up a faded instrument which is long enough. // This occours for example in the bassline (channel 11) of jt_burn.xm. I hope this won't break anything else... // I also suppose this could decrease mixing performance a bit, but hey, which CPU can't handle 32 muted channels these days... :-) @@ -1984,19 +1984,7 @@ pChn->nLeftVU = pChn->nRightVU = 0; #endif - nChn++; - pChn++; - if (nChn >= m_nChannels) - { - while ((nChn < MAX_CHANNELS) && (!pChn->nLength)) - { - nChn++; - pChn++; - } - } - if (nChn < MAX_CHANNELS) - goto skipchn; // >:( - break; + continue; } // Reset channel data pChn->nInc = 0; @@ -2030,8 +2018,9 @@ ProcessTremolo(pChn, vol); ProcessTremor(pChn, vol); - // Clip volume and multiply - vol = CLAMP(vol, 0, 256) << 6; + // Clip volume and multiply (extend to 14 bits) + Limit(vol, 0, 256); + vol <<= 6; // Process Envelopes if (pIns) @@ -2061,8 +2050,8 @@ // IMPORTANT: pChn->nRealVolume is 14 bits !!! // -> _muldiv( 14+8, 6+6, 18); => RealVolume: 14-bit result (22+12-20) - //Don't let global volume affect level of sample if - //global volume is going to be applied to master output anyway. + // 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) { pChn->nRealVolume = 0; @@ -2079,6 +2068,7 @@ if (pChn->nPeriod < m_nMinPeriod) pChn->nPeriod = m_nMinPeriod; period = pChn->nPeriod; + // TODO Glissando effect is reset after portamento! What would this sound like without the CHN_PORTAMENTO flag? if ((pChn->dwFlags & (CHN_GLISSANDO|CHN_PORTAMENTO)) == (CHN_GLISSANDO|CHN_PORTAMENTO)) { period = GetPeriodFromNote(GetNoteFromPeriod(period), pChn->nFineTune, pChn->nC5Speed); @@ -2089,7 +2079,7 @@ // Preserve Amiga freq limits if (m_dwSongFlags & (SONG_AMIGALIMITS|SONG_PT1XMODE)) { - period = CLAMP(period, 113 * 4, 856 * 4); + Limit(period, 113 * 4, 856 * 4); } ProcessPanbrello(pChn); @@ -2146,9 +2136,9 @@ freq = pChn->m_Freq; } - //Applying Pitch/Tempo lock. + // Applying Pitch/Tempo lock. if(m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT) && pIns && pIns->wPitchToTempoLock) - freq = MulDiv(freq, m_nMusicTempo, pIns->wPitchToTempoLock); + freq = _muldivr(freq, m_nMusicTempo, pIns->wPitchToTempoLock); if ((m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT)) && (freq < 256)) @@ -2487,7 +2477,7 @@ //If new note, determine notevelocity to use. if(note != NOTE_NONE) { - UINT velocity = 4*defaultVolume; + UINT velocity = 4 * defaultVolume; switch(pIns->nPluginVelocityHandling) { case PLUGIN_VELOCITYHANDLING_CHANNEL: Modified: trunk/OpenMPT/soundlib/load_j2b.cpp =================================================================== --- trunk/OpenMPT/soundlib/load_j2b.cpp 2011-09-21 14:45:18 UTC (rev 1050) +++ trunk/OpenMPT/soundlib/load_j2b.cpp 2011-09-23 23:10:59 UTC (rev 1051) @@ -568,10 +568,7 @@ pIns->Keyboard[i] = instheader->samplemap[i] + m_nSamples + 1; } - pIns->nGlobalVol = 64; - pIns->nPan = 128; pIns->nFadeOut = LittleEndianW(instheader->fadeout) << 5; - pIns->nPPC = NOTE_MIDDLEC - 1; // interleaved envelope data... meh. gotta split it up here and decode it separately. // note: mod2j2b is BUGGY and always writes ($original_num_points & 0x0F) in the header, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-23 23:12:12
|
Revision: 1052 http://modplug.svn.sourceforge.net/modplug/?rev=1052&view=rev Author: saga-games Date: 2011-09-23 23:12:06 +0000 (Fri, 23 Sep 2011) Log Message: ----------- [Fix] Setting pattern names was slightly broken, so that CString::IsEmpty() checks "failed". [Mod] Renamed X Param to Parameter Extension Modified Paths: -------------- trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/soundlib/pattern.cpp Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2011-09-23 23:10:59 UTC (rev 1051) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2011-09-23 23:12:06 UTC (rev 1052) @@ -2294,7 +2294,7 @@ {CMD_DELAYCUT, 0x00,0x00, 0, MOD_TYPE_MPT, "Note Delay and Cut"}, // -> CODE#0010 // -> DESC="add extended parameter mechanism to pattern effects" - {CMD_XPARAM, 0x00,0x00, 0, MOD_TYPE_XMITMPT, "X param"}, + {CMD_XPARAM, 0x00,0x00, 0, MOD_TYPE_XMITMPT, "Parameter Extension"}, // -! NEW_FEATURE#0010 {CMD_NOTESLIDEUP, 0x00,0x00, 0, MOD_TYPE_NONE, "Note Slide Up"}, // .IMF effect {CMD_NOTESLIDEDOWN, 0x00,0x00, 0, MOD_TYPE_NONE, "Note Slide Down"}, // .IMF effect Modified: trunk/OpenMPT/soundlib/pattern.cpp =================================================================== --- trunk/OpenMPT/soundlib/pattern.cpp 2011-09-23 23:10:59 UTC (rev 1051) +++ trunk/OpenMPT/soundlib/pattern.cpp 2011-09-23 23:12:06 UTC (rev 1052) @@ -223,7 +223,7 @@ { return false; } - m_PatternName.SetString(newName, maxChars - 1); + m_PatternName.SetString(newName, strnlen(newName, maxChars)); return true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-24 15:07:58
|
Revision: 1053 http://modplug.svn.sourceforge.net/modplug/?rev=1053&view=rev Author: saga-games Date: 2011-09-24 15:07:51 +0000 (Sat, 24 Sep 2011) Log Message: ----------- [Fix] S3M: Some commands (Dxy, Exx, Fxx, Ixy, Jxy, Kxy, Lxy, Qxy, Rxy) use the last non-zero effect parameter as memory. This fixes for example Satellite One by Purple Motion. [Mod] OpenMPT: Version is now 1.20.00.28 Modified Paths: -------------- trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-09-23 23:12:06 UTC (rev 1052) +++ trunk/OpenMPT/mptrack/version.h 2011-09-24 15:07:51 UTC (rev 1053) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 27 +#define VER_MINORMINOR 28 //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-09-23 23:12:06 UTC (rev 1052) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-09-24 15:07:51 UTC (rev 1053) @@ -105,18 +105,21 @@ // -! NEW_FEATURE#0022 UINT nMusicSpeed = m_nDefaultSpeed, nMusicTempo = m_nDefaultTempo, nNextRow = 0; LONG nGlbVol = m_nDefaultGlobalVolume, nOldGlbVolSlide = 0; - vector<BYTE> instr(m_nChannels, 0); - vector<UINT> notes(m_nChannels, 0); - vector<BYTE> vols(m_nChannels, 0xFF); - vector<BYTE> oldparam(m_nChannels, 0); - vector<UINT> chnvols(m_nChannels, 64); - vector<double> patloop(m_nChannels, 0); - vector<ROWINDEX> patloopstart(m_nChannels, 0); + vector<BYTE> instr(GetNumChannels(), 0); + vector<UINT> notes(GetNumChannels(), 0); + vector<BYTE> vols(GetNumChannels(), 0xFF); + vector<BYTE> oldparam(GetNumChannels(), 0); + vector<UINT> chnvols(GetNumChannels(), 64); + vector<double> patloop(GetNumChannels(), 0); + vector<ROWINDEX> patloopstart(GetNumChannels(), 0); VisitedRowsType visitedRows; // temporary visited rows vector (so that GetLength() won't interfere with the player code if the module is playing at the same time) InitializeVisitedRows(true, &visitedRows); - for(CHANNELINDEX icv = 0; icv < m_nChannels; icv++) chnvols[icv] = ChnSettings[icv].nVolume; + for(CHANNELINDEX icv = 0; icv < GetNumChannels(); icv++) + { + chnvols[icv] = ChnSettings[icv].nVolume; + } nCurrentPattern = nNextPattern = 0; nPattern = Order[0]; nRow = nNextRow = 0; @@ -208,7 +211,7 @@ if (p->instr) { instr[nChn] = p->instr; notes[nChn] = 0; vols[nChn] = 0xFF; } if ((note) && (note <= NOTE_MAX)) notes[nChn] = note; if (p->volcmd == VOLCMD_VOLUME) { vols[nChn] = p->vol; } - if (command) switch (command) + switch(command) { // Position Jump case CMD_POSITIONJUMP: @@ -2131,11 +2134,17 @@ case CMD_NOTESLIDEUP: NoteSlide(pChn, param, 1); break; + case CMD_NOTESLIDEDOWN: NoteSlide(pChn, param, -1); break; } + if(param != 0 && GetType() == MOD_TYPE_S3M) + { + UpdateS3MEffectMemory(pChn, param); + } + } // for(...) end // Navigation Effects @@ -2208,18 +2217,33 @@ //////////////////////////////////////////////////////////// // Channels effects + +// Update the effect memory of all S3M effects that use the last non-zero effect parameter ot show up (Dxy, Exx, Fxx, Ixy, Jxy, Kxy, Lxy, Qxy, Rxy) +void CSoundFile::UpdateS3MEffectMemory(MODCHANNEL *pChn, UINT param) const +//------------------------------------------------------------------------ +{ + pChn->nOldVolumeSlide = param; // Dxy / Kxy / Lxy + pChn->nOldPortaUpDown = param; // Exx / Fxx + pChn->nTremorParam = param; // Ixy + pChn->nArpeggio = param; // Jxy + pChn->nRetrigParam = param; // Qxy + pChn->nTremoloDepth = (param & 0x0F) << 2; // Rxy + pChn->nTremoloSpeed = (param >> 4) & 0x0F; // Rxy +} + + void CSoundFile::PortamentoUp(MODCHANNEL *pChn, UINT param, const bool doFinePortamentoAsRegular) -//--------------------------------------------------------- +//----------------------------------------------------------------------------------------------- { MidiPortamento(pChn, param); //Send midi pitch bend event if there's a plugin + if(param) + pChn->nOldPortaUpDown = param; + else + param = pChn->nOldPortaUpDown; + if(GetType() == MOD_TYPE_MPT && pChn->pModInstrument && pChn->pModInstrument->pTuning) { - if(param) - pChn->nOldPortaUpDown = param; - else - param = pChn->nOldPortaUpDown; - if(param >= 0xF0 && !doFinePortamentoAsRegular) PortamentoFineMPT(pChn, param - 0xF0); else @@ -2227,7 +2251,6 @@ return; } - if (param) pChn->nOldPortaUpDown = param; else param = pChn->nOldPortaUpDown; if (!doFinePortamentoAsRegular && (m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT|MOD_TYPE_STM)) && ((param & 0xF0) >= 0xE0)) { if (param & 0x0F) @@ -2252,17 +2275,17 @@ void CSoundFile::PortamentoDown(MODCHANNEL *pChn, UINT param, const bool doFinePortamentoAsRegular) -//----------------------------------------------------------- +//------------------------------------------------------------------------------------------------- { MidiPortamento(pChn, -1*param); //Send midi pitch bend event if there's a plugin + if(param) + pChn->nOldPortaUpDown = param; + else + param = pChn->nOldPortaUpDown; + if(m_nType == MOD_TYPE_MPT && pChn->pModInstrument && pChn->pModInstrument->pTuning) { - if(param) - pChn->nOldPortaUpDown = param; - else - param = pChn->nOldPortaUpDown; - if(param >= 0xF0 && !doFinePortamentoAsRegular) PortamentoFineMPT(pChn, -1*(param - 0xF0)); else @@ -2270,7 +2293,6 @@ return; } - if (param) pChn->nOldPortaUpDown = param; else param = pChn->nOldPortaUpDown; if (!doFinePortamentoAsRegular && (m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT|MOD_TYPE_STM)) && ((param & 0xF0) >= 0xE0)) { if (param & 0x0F) @@ -2566,6 +2588,7 @@ pChn->nOldVolumeSlide = param; else param = pChn->nOldVolumeSlide; + LONG newvolume = pChn->nVolume; if (m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT|MOD_TYPE_STM|MOD_TYPE_AMF)) { @@ -2712,12 +2735,12 @@ } -void CSoundFile::Tremolo(MODCHANNEL *p, UINT param) -//------------------------------------------------- +void CSoundFile::Tremolo(MODCHANNEL *pChn, UINT param) +//---------------------------------------------------- { - if (param & 0x0F) p->nTremoloDepth = (param & 0x0F) << 2; - if (param & 0xF0) p->nTremoloSpeed = (param >> 4) & 0x0F; - p->dwFlags |= CHN_TREMOLO; + if (param & 0x0F) pChn->nTremoloDepth = (param & 0x0F) << 2; + if (param & 0xF0) pChn->nTremoloSpeed = (param >> 4) & 0x0F; + pChn->dwFlags |= CHN_TREMOLO; } @@ -2944,7 +2967,9 @@ //IT compatibility 20. Set pan overrides random pan if(IsCompatibleMode(TRK_IMPULSETRACKER)) + { pChn->nPanSwing = 0; + } } break; // S9x: Sound Control @@ -3507,10 +3532,9 @@ pChn->nRetrigCount = param & 0xf; bDoRetrig = true; } - } - // buggy-like-hell FT2 Rxy retrig! - else if(IsCompatibleMode(TRK_FASTTRACKER2) && (param & 0x100)) + } else if(IsCompatibleMode(TRK_FASTTRACKER2) && (param & 0x100)) { + // buggy-like-hell FT2 Rxy retrig! if(m_dwSongFlags & SONG_FIRSTTICK) { // here are some really stupid things FT2 does @@ -3529,7 +3553,6 @@ } else { // old routines - if (m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT)) { if (!nRetrigSpeed) nRetrigSpeed = 1; Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2011-09-23 23:12:06 UTC (rev 1052) +++ trunk/OpenMPT/soundlib/Sndfile.h 2011-09-24 15:07:51 UTC (rev 1053) @@ -981,6 +981,7 @@ protected: // Channel Effects + void UpdateS3MEffectMemory(MODCHANNEL *pChn, UINT param) const; void PortamentoUp(MODCHANNEL *pChn, UINT param, const bool fineAsRegular = false); void PortamentoDown(MODCHANNEL *pChn, UINT param, const bool fineAsRegular = false); void MidiPortamento(MODCHANNEL *pChn, int param); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-24 22:59:36
|
Revision: 1055 http://modplug.svn.sourceforge.net/modplug/?rev=1055&view=rev Author: saga-games Date: 2011-09-24 22:59:29 +0000 (Sat, 24 Sep 2011) Log Message: ----------- [Fix] S3M: S00 also uses the last non-zero parameter as memory. [Ref] X Param refactoring [Mod] OpenMPT: Version is now 1.20.00.29 Modified Paths: -------------- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/Snd_fx.cpp Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2011-09-24 22:58:02 UTC (rev 1054) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2011-09-24 22:59:29 UTC (rev 1055) @@ -14,78 +14,85 @@ #include "Mainfrm.h" #include "PatternEditorDialogs.h" #include "view_pat.h" +#include "../muParser/include/muParser.h" // -> CODE#0010 // -> DESC="add extended parameter mechanism to pattern effects" -void getXParam(BYTE command, UINT nPat, UINT nRow, UINT nChannel, CSoundFile *pSndFile, UINT * xparam, UINT * multiplier) +void getXParam(BYTE command, PATTERNINDEX nPat, ROWINDEX nRow, CHANNELINDEX nChannel, CSoundFile *pSndFile, UINT &xparam, UINT &multiplier) +//----------------------------------------------------------------------------------------------------------------------------------------- { - if(xparam == NULL || multiplier == NULL) return; - - MODCOMMAND mca = MODCOMMAND::Empty(); - UINT i,xp = 0, ml = 1; + UINT xp = 0, mult = 1; int nCmdRow = (int)nRow; - // If the current command is a parameter extension command - if(command == CMD_XPARAM){ - + if(command == CMD_XPARAM) + { + // current command is a parameter extension command nCmdRow--; // Try to find previous command parameter to be extended - while(nCmdRow >= 0){ - i = nCmdRow * pSndFile->m_nChannels + nChannel; - mca = pSndFile->Patterns[nPat][i]; - if(mca.command == CMD_OFFSET || mca.command == CMD_PATTERNBREAK || mca.command == CMD_PATTERNBREAK) + while(nCmdRow >= 0) + { + const MODCOMMAND *m = pSndFile->Patterns[nPat].GetpModCommand(nCmdRow, nChannel); + if(m->command == CMD_OFFSET || m->command == CMD_PATTERNBREAK || m->command == CMD_PATTERNBREAK) break; - if(mca.command != CMD_XPARAM){ + if(m->command != CMD_XPARAM) + { nCmdRow = -1; break; } nCmdRow--; } + } else if(command != CMD_OFFSET && command != CMD_PATTERNBREAK && command != CMD_TEMPO) + { + // If current row do not own any satisfying command parameter to extend, set return state + nCmdRow = -1; } - // Else if current row do not own any satisfying command parameter to extend, set return state - else if(command != CMD_OFFSET && command != CMD_PATTERNBREAK && command != CMD_TEMPO) nCmdRow = -1; - // If an 'extendable' command parameter has been found, - if(nCmdRow >= 0){ - i = nCmdRow * pSndFile->m_nChannels + nChannel; - mca = pSndFile->Patterns[nPat][i]; + if(nCmdRow >= 0) + { + // An 'extendable' command parameter has been found + const MODCOMMAND *m = pSndFile->Patterns[nPat].GetpModCommand(nCmdRow, nChannel); // Find extension resolution (8 to 24 bits) - UINT n = 1; - while(n < 4 && nCmdRow+n < pSndFile->Patterns[nPat].GetNumRows()){ - i = (nCmdRow+n) * pSndFile->m_nChannels + nChannel; - if(pSndFile->Patterns[nPat][i].command != CMD_XPARAM) break; + ROWINDEX n = 1; + while(n < 4 && nCmdRow + n < pSndFile->Patterns[nPat].GetNumRows()) + { + if(pSndFile->Patterns[nPat].GetpModCommand(nCmdRow + n, nChannel)->command != CMD_XPARAM) break; n++; } // Parameter extension found (above 8 bits non-standard parameters) - if(n > 1){ + if(n > 1) + { // Limit offset command to 24 bits, other commands to 16 bits - n = mca.command == CMD_OFFSET ? n : (n > 2 ? 2 : n); + n = m->command == CMD_OFFSET ? n : (n > 2 ? 2 : n); // Compute extended value WITHOUT current row parameter value : this parameter // is being currently edited (this is why this function is being called) so we // only need to compute a multiplier so that we can add its contribution while // its value is changed by user - for(UINT j = 0 ; j < n ; j++){ - i = (nCmdRow+j) * pSndFile->m_nChannels + nChannel; - mca = pSndFile->Patterns[nPat][i]; + for(UINT j = 0; j < n; j++) + { + m = pSndFile->Patterns[nPat].GetpModCommand(nCmdRow + j, nChannel); - UINT k = 8*(n-j-1); - if(nCmdRow+j == nRow) ml = 1<<k; - else xp += (mca.param<<k); + UINT k = 8 * (n - j - 1); + if(nCmdRow + j == nRow) + mult = 1 << k; + else + xp += (m->param << k); } + } else if(m->command == CMD_OFFSET) + { + // No parameter extension to perform (8 bits standard parameter), + // just care about offset command special case (16 bits, fake) + mult <<= 8; } - // No parameter extension to perform (8 bits standard parameter), - // just care about offset command special case (16 bits, fake) - else if(mca.command == CMD_OFFSET) ml <<= 8; } // Return x-parameter - *multiplier = ml; - *xparam = xp; + multiplier = mult; + xparam = xp; } // -! NEW_FEATURE#0010 @@ -625,15 +632,18 @@ { CPropertySheet::OnDestroy(); - if (m_pageNote) { + if (m_pageNote) + { m_pageNote->DestroyWindow(); delete m_pageNote; } - if (m_pageVolume) { + if (m_pageVolume) + { m_pageVolume->DestroyWindow(); delete m_pageVolume; } - if (m_pageEffect) { + if (m_pageEffect) + { m_pageEffect->DestroyWindow(); delete m_pageEffect; } @@ -663,9 +673,9 @@ const CHANNELINDEX nChannel = CViewPattern::GetChanFromCursor(dwCursor); if ((nPat >= pSndFile->Patterns.Size()) || (!m_pModDoc) - || (nRow >= pSndFile->Patterns[nPat].GetNumRows()) || (nChannel >= pSndFile->m_nChannels) + || (nRow >= pSndFile->Patterns[nPat].GetNumRows()) || (nChannel >= pSndFile->GetNumChannels()) || (!pSndFile->Patterns[nPat])) return FALSE; - m_Command = pSndFile->Patterns[nPat][nRow * pSndFile->m_nChannels + nChannel]; + m_Command = *pSndFile->Patterns[nPat].GetpModCommand(nRow, nChannel); m_nRow = nRow; m_nChannel = nChannel; m_nPattern = nPat; @@ -677,16 +687,17 @@ // -> CODE#0010 // -> DESC="add extended parameter mechanism to pattern effects" // if (m_pageEffect) m_pageEffect->Init(m_Command); - if (m_pageEffect){ + if (m_pageEffect) + { UINT xp = 0, ml = 1; - getXParam(m_Command.command,nPat,nRow,nChannel,pSndFile,&xp,&ml); + getXParam(m_Command.command, nPat, nRow, nChannel, pSndFile, xp, ml); m_pageEffect->Init(m_Command); m_pageEffect->XInit(xp,ml); } // -! NEW_FEATURE#0010 // Update Window Title - wsprintf(s, "Note Properties - Row %d, Channel %d", m_nRow, m_nChannel+1); + wsprintf(s, "Note Properties - Row %d, Channel %d", m_nRow, m_nChannel + 1); SetTitle(s); // Activate Page UINT nPage = 2; @@ -709,7 +720,7 @@ CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); if ((m_nPattern >= pSndFile->Patterns.Size()) || (!m_pModDoc) || (m_nRow >= pSndFile->Patterns[m_nPattern].GetNumRows()) - || (m_nChannel >= pSndFile->m_nChannels) + || (m_nChannel >= pSndFile->GetNumChannels()) || (!pSndFile->Patterns[m_nPattern])) return; MODCOMMAND *m = pSndFile->Patterns[m_nPattern].GetpModCommand(m_nRow, m_nChannel); if ((m->note != note) || (m->instr != instr)) @@ -738,7 +749,7 @@ CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); if ((m_nPattern >= pSndFile->Patterns.Size()) || (!m_pModDoc) || (m_nRow >= pSndFile->Patterns[m_nPattern].GetNumRows()) - || (m_nChannel >= pSndFile->m_nChannels) + || (m_nChannel >= pSndFile->GetNumChannels()) || (!pSndFile->Patterns[m_nPattern])) return; MODCOMMAND *m = pSndFile->Patterns[m_nPattern].GetpModCommand(m_nRow, m_nChannel); if ((m->volcmd != volcmd) || (m->vol != vol)) @@ -766,15 +777,16 @@ CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); if ((m_nPattern >= pSndFile->Patterns.Size()) || (!m_pModDoc) || (m_nRow >= pSndFile->Patterns[m_nPattern].GetNumRows()) - || (m_nChannel >= pSndFile->m_nChannels) + || (m_nChannel >= pSndFile->GetNumChannels()) || (!pSndFile->Patterns[m_nPattern])) return; MODCOMMAND *m = pSndFile->Patterns[m_nPattern].GetpModCommand(m_nRow, m_nChannel); // -> CODE#0010 // -> DESC="add extended parameter mechanism to pattern effects" - if(command == CMD_OFFSET || command == CMD_PATTERNBREAK || command == CMD_TEMPO || command == CMD_XPARAM){ + if(command == CMD_OFFSET || command == CMD_PATTERNBREAK || command == CMD_TEMPO || command == CMD_XPARAM) + { UINT xp = 0, ml = 1; - getXParam(command,m_nPattern,m_nRow,m_nChannel,pSndFile,&xp,&ml); + getXParam(command, m_nPattern, m_nRow, m_nChannel, pSndFile, xp, ml); m_pageEffect->XInit(xp,ml); m_pageEffect->UpdateDialog(); } Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-09-24 22:58:02 UTC (rev 1054) +++ trunk/OpenMPT/mptrack/version.h 2011-09-24 22:59:29 UTC (rev 1055) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 28 +#define VER_MINORMINOR 29 //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-09-24 22:58:02 UTC (rev 1054) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-09-24 22:59:29 UTC (rev 1055) @@ -1976,6 +1976,10 @@ // S3M/IT Sxx Extended Commands case CMD_S3MCMDEX: + if(GetType() == MOD_TYPE_S3M && param == 0) + { + param = pChn->nArpeggio; // S00 uses the last non-zero effect parameter as memory, like other effects including Arpeggio, so we "borrow" our memory there. + } ExtendedS3MCommands(nChn, param); break; @@ -2140,7 +2144,7 @@ break; } - if(param != 0 && GetType() == MOD_TYPE_S3M) + if(GetType() == MOD_TYPE_S3M && param != 0) { UpdateS3MEffectMemory(pChn, param); } @@ -2218,7 +2222,7 @@ // Channels effects -// Update the effect memory of all S3M effects that use the last non-zero effect parameter ot show up (Dxy, Exx, Fxx, Ixy, Jxy, Kxy, Lxy, Qxy, Rxy) +// Update the effect memory of all S3M effects that use the last non-zero effect parameter ot show up (Dxy, Exx, Fxx, Ixy, Jxy, Kxy, Lxy, Qxy, Rxy, Sxy) void CSoundFile::UpdateS3MEffectMemory(MODCHANNEL *pChn, UINT param) const //------------------------------------------------------------------------ { @@ -2229,6 +2233,7 @@ pChn->nRetrigParam = param; // Qxy pChn->nTremoloDepth = (param & 0x0F) << 2; // Rxy pChn->nTremoloSpeed = (param >> 4) & 0x0F; // Rxy + // Sxy is not handled here. } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-25 22:10:24
|
Revision: 1057 http://modplug.svn.sourceforge.net/modplug/?rev=1057&view=rev Author: saga-games Date: 2011-09-25 22:10:17 +0000 (Sun, 25 Sep 2011) Log Message: ----------- [Imp] Order list: Inserting a +++ pattern behaves more logical if the selected pattern is a stop index. [Ref] Removed some irrelevant compatibility checks. [Mod] OpenMPT: Version is now 1.20.00.30 Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_seq.cpp trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/Snd_fx.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2011-09-25 00:38:55 UTC (rev 1056) +++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2011-09-25 22:10:17 UTC (rev 1057) @@ -1243,17 +1243,25 @@ { CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); - const ORD_SELECTION selection = GetCurSel(true); - // Checking whether there is some pattern at the end of orderlist. - if (pSndFile->Order.GetLength() < 1 || pSndFile->Order.Last() < pSndFile->Patterns.Size()) + const ORD_SELECTION selection = GetCurSel(true); + ORDERINDEX insertPos = selection.nOrdLo; + + if(pSndFile->Order[selection.nOrdLo] != pSndFile->Order.GetInvalidPatIndex()) { - if(pSndFile->Order.GetLength() < pSndFile->GetModSpecifications().ordersMax) - pSndFile->Order.Append(); + // If we're not inserting on a stop (---) index, we move on by one position. + insertPos++; + // Checking whether there is some pattern at the end of orderlist. + if (pSndFile->Order.GetLength() < 1 || pSndFile->Order.Last() < pSndFile->Patterns.Size()) + { + if(pSndFile->Order.GetLength() < pSndFile->GetModSpecifications().ordersMax) + pSndFile->Order.Append(); + } + for(int j = pSndFile->Order.GetLastIndex(); j > selection.nOrdLo; j--) + pSndFile->Order[j] = pSndFile->Order[j - 1]; + } - for(int j = pSndFile->Order.GetLastIndex(); j > selection.nOrdHi; j--) - pSndFile->Order[j] = pSndFile->Order[j - 1]; - pSndFile->Order[selection.nOrdHi + 1] = pSndFile->Order.GetIgnoreIndex(); + pSndFile->Order[insertPos] = pSndFile->Order.GetIgnoreIndex(); InvalidateRect(NULL, FALSE); m_pModDoc->SetModified(); Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-09-25 00:38:55 UTC (rev 1056) +++ trunk/OpenMPT/mptrack/version.h 2011-09-25 22:10:17 UTC (rev 1057) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 29 +#define VER_MINORMINOR 30 //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-09-25 00:38:55 UTC (rev 1056) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-09-25 22:10:17 UTC (rev 1057) @@ -932,13 +932,7 @@ pChn->nLeftVU = pChn->nRightVU = 0xFF; pChn->dwFlags &= ~CHN_FILTER; pChn->dwFlags |= CHN_FASTVOLRAMP; - // IT Compatibility: Autovibrato reset - if(bResetEnv && IsCompatibleMode(TRK_IMPULSETRACKER)) - { - pChn->nAutoVibDepth = 0; - pChn->nAutoVibPos = 0; - pChn->nVibratoPos = 0; - } + //IT compatibility 15. Retrigger will not be reset (Tremor doesn't store anything here, so we just don't reset this as well) if(!IsCompatibleMode(TRK_IMPULSETRACKER)) { @@ -991,11 +985,14 @@ } } } - // IT Compatibility: Autovibrato reset - if(!IsCompatibleMode(TRK_IMPULSETRACKER)) + pChn->nAutoVibDepth = 0; + pChn->nAutoVibPos = 0; + // IT Compatibility: Vibrato reset + if(IsCompatibleMode(TRK_IMPULSETRACKER)) { - pChn->nAutoVibDepth = 0; - pChn->nAutoVibPos = 0; + // I think this is not necessary, so let's check if it is actually called. + ASSERT(pChn->nVibratoPos == 0); + pChn->nVibratoPos = 0; } } pChn->nLeftVol = pChn->nRightVol = 0; @@ -1514,12 +1511,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; pChn->dwFlags &= ~CHN_NOTEFADE; pChn->nFadeOutVol = 65536; } @@ -1650,7 +1643,7 @@ TonePortamento(pChn, vol * 16); } else { - // XM Compatibility: FT2 ignores some voluem commands with parameter = 0. + // XM Compatibility: FT2 ignores some volume commands with parameter = 0. if(IsCompatibleMode(TRK_FASTTRACKER2) && vol == 0) { switch(volcmd) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-27 21:41:28
|
Revision: 1060 http://modplug.svn.sourceforge.net/modplug/?rev=1060&view=rev Author: saga-games Date: 2011-09-27 21:41:21 +0000 (Tue, 27 Sep 2011) Log Message: ----------- [Fix] Cleanup: Sustain loops behind sample loops were ignored when optimizing samples. [Fix] When finishing a sustain loop that is behind a sample loop, sample playback simply stopped. [Mod] OpenMPT: Version is now 1.20.00.31 Modified Paths: -------------- trunk/OpenMPT/mptrack/CleanupSong.cpp trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/Snd_fx.cpp Modified: trunk/OpenMPT/mptrack/CleanupSong.cpp =================================================================== --- trunk/OpenMPT/mptrack/CleanupSong.cpp 2011-09-27 16:42:05 UTC (rev 1059) +++ trunk/OpenMPT/mptrack/CleanupSong.cpp 2011-09-27 21:41:21 UTC (rev 1060) @@ -578,10 +578,22 @@ UINT nLoopOpt = 0; - for (SAMPLEINDEX nSmp=1; nSmp <= pSndFile->m_nSamples; nSmp++) + for (SAMPLEINDEX nSmp = 1; nSmp <= pSndFile->GetNumSamples(); nSmp++) { - if(pSndFile->GetSample(nSmp).pSample && (pSndFile->GetSample(nSmp).uFlags & CHN_LOOP) - && (pSndFile->GetSample(nSmp).nLength > pSndFile->GetSample(nSmp).nLoopEnd + 2)) nLoopOpt++; + const MODSAMPLE &sample = pSndFile->GetSample(nSmp); + + // Determine how much of the sample will be played + UINT loopLength = sample.nLength; + if(sample.uFlags & CHN_LOOP) + { + loopLength = sample.nLoopEnd; + } + if(sample.uFlags & CHN_SUSTAINLOOP) + { + loopLength = max(sample.nLoopEnd, sample.nSustainEnd); + } + + if(sample.pSample && sample.nLength > loopLength + 2) nLoopOpt++; } if (nLoopOpt == 0) return false; @@ -593,10 +605,21 @@ for (SAMPLEINDEX nSmp = 1; nSmp <= pSndFile->m_nSamples; nSmp++) { MODSAMPLE &sample = pSndFile->GetSample(nSmp); - if ((sample.uFlags & CHN_LOOP) - && (sample.nLength > sample.nLoopEnd + 2)) + + // Determine how much of the sample will be played + UINT loopLength = sample.nLength; + if(sample.uFlags & CHN_LOOP) { - UINT lmax = sample.nLoopEnd + 2; + loopLength = sample.nLoopEnd; + } + if(sample.uFlags & CHN_SUSTAINLOOP) + { + loopLength = max(sample.nLoopEnd, sample.nSustainEnd); + } + + if (sample.nLength > loopLength + 2) + { + UINT lmax = loopLength + 2; if ((lmax < sample.nLength) && (lmax >= 2)) { m_pModDoc->GetSampleUndo()->PrepareUndo(nSmp, sundo_delete, lmax, sample.nLength); Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-09-27 16:42:05 UTC (rev 1059) +++ trunk/OpenMPT/mptrack/version.h 2011-09-27 21:41:21 UTC (rev 1060) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 30 +#define VER_MINORMINOR 31 //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-09-27 16:42:05 UTC (rev 1059) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-09-27 21:41:21 UTC (rev 1060) @@ -3749,6 +3749,7 @@ pChn->nLoopStart = pSmp->nLoopStart; pChn->nLoopEnd = pSmp->nLoopEnd; if (pChn->nLength > pChn->nLoopEnd) pChn->nLength = pChn->nLoopEnd; + LimitMax(pChn->nPos, pChn->nLength); } else { pChn->dwFlags &= ~(CHN_LOOP|CHN_PINGPONGLOOP|CHN_PINGPONGFLAG); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-28 21:04:30
|
Revision: 1064 http://modplug.svn.sourceforge.net/modplug/?rev=1064&view=rev Author: saga-games Date: 2011-09-28 21:04:23 +0000 (Wed, 28 Sep 2011) Log Message: ----------- [Ref] Moved some mod loading code around [Mod] Old Mod Flags (Emulate old volswing, Emulate VST instrument volume bug) are only set if they are potentitally needed [Fix] Volswing range was not updated for old ITP files [Mod] OpenMPT: Version is now 1.20.00.32 Modified Paths: -------------- trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_itp.cpp trunk/OpenMPT/soundlib/Load_xm.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-09-28 20:53:21 UTC (rev 1063) +++ trunk/OpenMPT/mptrack/version.h 2011-09-28 21:04:23 UTC (rev 1064) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 31 +#define VER_MINORMINOR 32 //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-28 20:53:21 UTC (rev 1063) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2011-09-28 21:04:23 UTC (rev 1064) @@ -1242,22 +1242,8 @@ } } - if(m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 17, 2, 50)) - { - SetModFlag(MSF_COMPATIBLE_PLAY, false); - SetModFlag(MSF_MIDICC_BUGEMULATION, true); - SetModFlag(MSF_OLDVOLSWING, true); - } + UpgradeModFlags(); - if(m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 00)) - { - // Previously, volume swing values ranged from 0 to 64. They should reach from 0 to 100 instead. - for(INSTRUMENTINDEX i = 1; i <= GetNumInstruments(); i++) if(Instruments[i] != nullptr) - { - Instruments[i]->nVolSwing = min(Instruments[i]->nVolSwing * 100 / 64, 100); - } - } - if(GetType() == MOD_TYPE_IT) { // Set appropriate mod flags if the file was not made with MPT. Modified: trunk/OpenMPT/soundlib/Load_itp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_itp.cpp 2011-09-28 20:53:21 UTC (rev 1063) +++ trunk/OpenMPT/soundlib/Load_itp.cpp 2011-09-28 21:04:23 UTC (rev 1064) @@ -454,12 +454,7 @@ m_nMaxPeriod = 0xF000; m_nMinPeriod = 8; - if(m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 17, 2, 50)) - { - SetModFlag(MSF_COMPATIBLE_PLAY, false); - SetModFlag(MSF_MIDICC_BUGEMULATION, true); - SetModFlag(MSF_OLDVOLSWING, true); - } + UpgradeModFlags(); return true; } Modified: trunk/OpenMPT/soundlib/Load_xm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_xm.cpp 2011-09-28 20:53:21 UTC (rev 1063) +++ trunk/OpenMPT/soundlib/Load_xm.cpp 2011-09-28 21:04:23 UTC (rev 1064) @@ -712,8 +712,10 @@ LoadExtendedSongProperties(GetType(), ptr, lpStream, dwMemLength, &bInterpretOpenMPTMade); - if(bInterpretOpenMPTMade && m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 17, 2, 50)) - SetModFlag(MSF_MIDICC_BUGEMULATION, true); + if(bInterpretOpenMPTMade) + { + UpgradeModFlags(); + } if(bInterpretOpenMPTMade && m_dwLastSavedWithVersion == 0) m_dwLastSavedWithVersion = MAKE_VERSION_NUMERIC(1, 17, 01, 00); // early versions of OpenMPT had no version indication. Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2011-09-28 20:53:21 UTC (rev 1063) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2011-09-28 21:04:23 UTC (rev 1064) @@ -762,10 +762,10 @@ if ((m_nRestartPos >= Order.size()) || (Order[m_nRestartPos] >= Patterns.Size())) m_nRestartPos = 0; - // Fix old nasty broken (non-standard) MIDI configs in files. - if(m_dwLastSavedWithVersion && m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 00)) + // When reading a file made with an older version of MPT, it might be necessary to upgrade some settings automatically. + if(m_dwLastSavedWithVersion) { - FixMIDIConfigStrings(m_MidiCfg); + UpgradeSong(); } // plugin loader @@ -2901,6 +2901,53 @@ } +// For old files made with MPT that don't have m_dwSongFlags set yet, set the flags appropriately. +void CSoundFile::UpgradeModFlags() +//-------------------------------- +{ + if(m_dwLastSavedWithVersion && m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 17, 02, 50)) + { + SetModFlag(MSF_COMPATIBLE_PLAY, false); + SetModFlag(MSF_MIDICC_BUGEMULATION, false); + // If there are any plugins, enable volume bug emulation. + for(PLUGINDEX i = 0; i < MAX_MIXPLUGINS; i++) + { + if(m_MixPlugins[i].Info.dwPluginId1 | m_MixPlugins[i].Info.dwPluginId2) + { + SetModFlag(MSF_MIDICC_BUGEMULATION, true); + break; + } + } + // If there are any instruments with random variation, enable the old random variation behaviour. + for(INSTRUMENTINDEX i = 1; i <= GetNumInstruments(); i++) + { + if(Instruments[i] && (Instruments[i]->nVolSwing | Instruments[i]->nPanSwing | Instruments[i]->nCutSwing | Instruments[i]->nResSwing)) + { + SetModFlag(MSF_OLDVOLSWING, true); + break; + } + } + } +} + + +void CSoundFile::UpgradeSong() +//---------------------------- +{ + if(m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 00)) + { + // Previously, volume swing values ranged from 0 to 64. They should reach from 0 to 100 instead. + for(INSTRUMENTINDEX i = 1; i <= GetNumInstruments(); i++) if(Instruments[i] != nullptr) + { + Instruments[i]->nVolSwing = min(Instruments[i]->nVolSwing * 100 / 64, 100); + } + + // Fix old nasty broken (non-standard) MIDI configs in files. + FixMIDIConfigStrings(m_MidiCfg); + } +} + + // Fix old-format (not conforming to IT's MIDI macro definitions) MIDI config strings. void CSoundFile::FixMIDIConfigStrings(MODMIDICFG &midiCfg) //-------------------------------------------------------- Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2011-09-28 20:53:21 UTC (rev 1063) +++ trunk/OpenMPT/soundlib/Sndfile.h 2011-09-28 21:04:23 UTC (rev 1064) @@ -841,6 +841,8 @@ bool ReadJ2B(const LPCBYTE lpStream, const DWORD dwMemLength); bool ReadMID(const LPCBYTE lpStream, DWORD dwMemLength); + void UpgradeModFlags(); + void UpgradeSong(); static void FixMIDIConfigStrings(MODMIDICFG &midiCfg); // Save Functions This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-09-30 22:32:37
|
Revision: 1068 http://modplug.svn.sourceforge.net/modplug/?rev=1068&view=rev Author: saga-games Date: 2011-09-30 22:32:30 +0000 (Fri, 30 Sep 2011) Log Message: ----------- [Fix] Keyboard Split instrument setting was broken since OpenMPT 1.19 [Mod] Keyboard Split: Renamed "No Instrument" list entry to "No Change" for more clarity. [Mod] Updated DE_jojo.mkb. [Mod] OpenMPT: Version is now 1.20.00.33 Modified Paths: -------------- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/packageTemplate/extraKeymaps/DE_jojo.mkb Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2011-09-30 21:38:16 UTC (rev 1067) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2011-09-30 22:32:30 UTC (rev 1068) @@ -1455,8 +1455,9 @@ m_CbnSplitNote.SetCurSel(m_pOptions->splitNote); // Octave modifier - for(int i = -SPLIT_OCTAVE_RANGE; i < SPLIT_OCTAVE_RANGE + 1; i++){ - wsprintf(s,i < 0 ? "Octave -%d" : i > 0 ? "Octave +%d" : "No Change", abs(i)); + for(int i = -SPLIT_OCTAVE_RANGE; i < SPLIT_OCTAVE_RANGE + 1; i++) + { + wsprintf(s, i < 0 ? "Octave -%d" : i > 0 ? "Octave +%d" : "No Change", abs(i)); int n = m_CbnOctaveModifier.AddString(s); m_CbnOctaveModifier.SetItemData(n, i); } @@ -1467,8 +1468,9 @@ // Volume m_CbnSplitVolume.AddString("No Change"); m_CbnSplitVolume.SetItemData(0, 0); - for(int i = 1; i <= 64 ; i++){ - wsprintf(s,"%d",i); + for(int i = 1; i <= 64 ; i++) + { + wsprintf(s, "%d", i); int n = m_CbnSplitVolume.AddString(s); m_CbnSplitVolume.SetItemData(n, i); } @@ -1476,12 +1478,13 @@ // Instruments m_CbnSplitInstrument.ResetContent(); - m_CbnSplitInstrument.SetItemData(m_CbnSplitInstrument.AddString("No Instrument"), 0); + m_CbnSplitInstrument.SetItemData(m_CbnSplitInstrument.AddString("No Change"), 0); - if (m_pSndFile->m_nInstruments) { - for (INSTRUMENTINDEX nIns = 1; nIns <= m_pSndFile->m_nInstruments; nIns++) + if(m_pSndFile->GetNumInstruments()) + { + for (INSTRUMENTINDEX nIns = 1; nIns <= m_pSndFile->GetNumInstruments(); nIns++) { - if (m_pSndFile->Instruments[nIns] == nullptr) + if(m_pSndFile->Instruments[nIns] == nullptr) continue; CString displayName = m_pSndFile->GetpModDoc()->GetPatternViewInstrumentName(nIns); @@ -1490,9 +1493,9 @@ } } else { - for (SAMPLEINDEX nSmp = 1; nSmp <= m_pSndFile->m_nSamples; nSmp++) + for(SAMPLEINDEX nSmp = 1; nSmp <= m_pSndFile->GetNumSamples(); nSmp++) { - if ((m_pSndFile->m_szNames[nSmp][0]) || (m_pSndFile->GetSample(nSmp).pSample)) + if(m_pSndFile->GetSample(nSmp).pSample) { wsprintf(s, "%02d: %s", nSmp, m_pSndFile->m_szNames[nSmp]); int n = m_CbnSplitInstrument.AddString(s); Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-09-30 21:38:16 UTC (rev 1067) +++ trunk/OpenMPT/mptrack/version.h 2011-09-30 22:32:30 UTC (rev 1068) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 32 +#define VER_MINORMINOR 33 //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/packageTemplate/extraKeymaps/DE_jojo.mkb =================================================================== --- trunk/OpenMPT/packageTemplate/extraKeymaps/DE_jojo.mkb 2011-09-30 21:38:16 UTC (rev 1067) +++ trunk/OpenMPT/packageTemplate/extraKeymaps/DE_jojo.mkb 2011-09-30 22:32:30 UTC (rev 1068) @@ -27,9 +27,9 @@ 0:1362:2:86:1 //Paste: Ctrl+V (KeyDown) 0:1363:3:86:1 //Mix Paste: Shift+Ctrl+V (KeyDown) 0:1793:1:86:1 //Paste Flood: Shift+V (KeyDown) -0:1820:6:86:1 //Push Forward Paste: Ctrl+Alt+V (KeyDown) -0:1364:2:53:1 //SelectAll: Ctrl+5 (KeyDown) -0:1365:2:70:1 //Find: Ctrl+F (KeyDown) +0:1820:6:86:1 //Push Forward Paste (Insert): Ctrl+Alt+V (KeyDown) +0:1364:2:53:1 //Select All: Ctrl+5 (KeyDown) +0:1365:2:70:1 //Find / Replace: Ctrl+F (KeyDown) 0:1366:0:114:1 //Find Next: F3 (KeyDown) 0:1021:4:71:1 //View General: Alt+G (KeyDown) 0:1021:0:112:1 //View General: F1 (KeyDown) @@ -85,7 +85,9 @@ 2:1004:0:32:5 //Quick paste: LEER (KeyDown|KeyHold) 2:1001:2:32:1 //Enable recording: Ctrl+LEER (KeyDown) 2:1002:2:13:5 //Play row: Ctrl+EINGABE (KeyDown|KeyHold) -2:1317:4:18:1 //Set row jump on note entry: Alt (KeyDown) +2:1317:4:18:1 //Set row spacing on note entry: Alt (KeyDown) +2:1861:4:187:5 //Increase row spacing: Alt++ (KeyDown|KeyHold) +2:1862:4:189:5 //Decrease row spacing: Alt+- (KeyDown|KeyHold) 2:1685:2:9:1 //Switch to order list: Ctrl+TABULATOR (KeyDown) 2:1806:2:68:5 //Duplicate pattern: Ctrl+D (KeyDown|KeyHold) 2:1836:2:191:1 //Edit plugin assigned to PC note: Ctrl+# (KeyDown) @@ -378,5 +380,5 @@ 19:1817:0:187:5 //Increase pattern index : + (KeyDown|KeyHold) 19:1818:0:109:1 //Decrease pattern index: - (ZEHNERTASTATUR) (KeyDown) 19:1818:0:189:1 //Decrease pattern index: - (KeyDown) -19:1853:0:73:1 //Ignore (+++) Index: I (KeyDown) -19:1854:0:32:1 //Invalid (---) Index: LEER (KeyDown) +19:1853:0:73:1 //Separator (+++) Index: I (KeyDown) +19:1854:0:32:1 //Stop (---) Index: LEER (KeyDown) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-10-01 16:50:51
|
Revision: 1071 http://modplug.svn.sourceforge.net/modplug/?rev=1071&view=rev Author: saga-games Date: 2011-10-01 16:50:44 +0000 (Sat, 01 Oct 2011) Log Message: ----------- [Fix] Instrument Editor: Filter frequency display is now updated instantly when toggling the cutoff checkbox. [Fix] IT Compatibility: Z7F is not supposed to actually enable the filter - it just disables it for the *next* note. [Mod] OpenMPT: Version is now 1.20.00.34 Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/Snd_flt.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-10-01 00:30:05 UTC (rev 1070) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-10-01 16:50:44 UTC (rev 1071) @@ -967,7 +967,7 @@ // Pitch/Pan Separation m_SpinPPS.SetRange(-32, +32); // Pitch/Pan Center - AppendNotesToControl(m_ComboPPC, 0, NOTE_MAX-1); + AppendNotesToControl(m_ComboPPC, 0, NOTE_MAX - NOTE_MIN); // -> CODE#0027 // -> DESC="per-instrument volume ramping setup (refered as attack)" @@ -2233,6 +2233,7 @@ } } } + UpdateFilterText(); SetInstrumentModified(true); SwitchToView(); } Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-10-01 00:30:05 UTC (rev 1070) +++ trunk/OpenMPT/mptrack/version.h 2011-10-01 16:50:44 UTC (rev 1071) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 33 +#define VER_MINORMINOR 34 //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_flt.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_flt.cpp 2011-10-01 00:30:05 UTC (rev 1070) +++ trunk/OpenMPT/soundlib/Snd_flt.cpp 2011-10-01 16:50:44 UTC (rev 1071) @@ -58,9 +58,9 @@ float Fc; ASSERT(nCutOff<128); if (m_dwSongFlags & SONG_EXFILTERRANGE) - Fc = 110.0f * pow(2.0f, 0.25f + ((float)(nCutOff*(flt_modifier+256)))/(20.0f*512.0f)); + Fc = 110.0f * pow(2.0f, 0.25f + ((float)(nCutOff * (flt_modifier + 256))) / (20.0f * 512.0f)); else - Fc = 110.0f * pow(2.0f, 0.25f + ((float)(nCutOff*(flt_modifier+256)))/(24.0f*512.0f)); + Fc = 110.0f * pow(2.0f, 0.25f + ((float)(nCutOff * (flt_modifier + 256))) / (24.0f * 512.0f)); LONG freq = (LONG)Fc; if (freq < 120) return 120; if (freq > 20000) return 20000; @@ -76,53 +76,50 @@ float fs = (float)gdwMixingFreq; float fg, fb0, fb1, fc, dmpfac; -/* if (pChn->pHeader) { - fc = (float)CutOffToFrequency(pChn->nCutOff, flt_modifier); - dmpfac = pow(10.0f, -((24.0f / 128.0f)*(float)pChn->nResonance) / 20.0f); - } else {*/ - - int cutoff = 0; - if(!GetModFlag(MSF_OLDVOLSWING)) + int cutoff = 0; + if(!GetModFlag(MSF_OLDVOLSWING)) + { + if(pChn->nCutSwing) { - if(pChn->nCutSwing) - { - static_assert(sizeof(pChn->nCutOff) == 1, "check cast if this fails"); - pChn->nCutOff = static_cast<BYTE>(pChn->nCutOff + pChn->nCutSwing); - Limit(pChn->nCutOff, BYTE(0), BYTE(127)); - pChn->nCutSwing = 0; - } - if(pChn->nResSwing) - { - static_assert(sizeof(pChn->nResonance) == 1, "check cast if this fails"); - pChn->nResonance = static_cast<BYTE>(pChn->nResonance + pChn->nResSwing); - Limit(pChn->nResonance, BYTE(0), BYTE(127)); - pChn->nResSwing = 0; - } - cutoff = max( min((int)pChn->nCutOff,127), 0); // cap cutoff - fc = (float)CutOffToFrequency(cutoff, flt_modifier); - dmpfac = pow(10.0f, -((24.0f / 128.0f)*(float)((pChn->nResonance)&0x7F)) / 20.0f); + static_assert(sizeof(pChn->nCutOff) == 1, "check cast if this fails"); + pChn->nCutOff = static_cast<BYTE>(pChn->nCutOff + pChn->nCutSwing); + Limit(pChn->nCutOff, BYTE(0), BYTE(127)); + pChn->nCutSwing = 0; } - else + if(pChn->nResSwing) { - cutoff = max( min((int)pChn->nCutOff+(int)pChn->nCutSwing,127), 0); // cap cutoff - fc = (float)CutOffToFrequency(cutoff, flt_modifier); - dmpfac = pow(10.0f, -((24.0f / 128.0f)*(float)((pChn->nResonance+pChn->nResSwing)&0x7F)) / 20.0f); + static_assert(sizeof(pChn->nResonance) == 1, "check cast if this fails"); + pChn->nResonance = static_cast<BYTE>(pChn->nResonance + pChn->nResSwing); + Limit(pChn->nResonance, BYTE(0), BYTE(127)); + pChn->nResSwing = 0; } + cutoff = CLAMP((int)pChn->nCutOff, 0, 127); // cap cutoff + fc = (float)CutOffToFrequency(cutoff, flt_modifier); + dmpfac = pow(10.0f, -((24.0f / 128.0f) * (float)((pChn->nResonance) & 0x7F)) / 20.0f); + } + else + { + cutoff = CLAMP((int)pChn->nCutOff + (int)pChn->nCutSwing, 0, 127); // cap cutoff + fc = (float)CutOffToFrequency(cutoff, flt_modifier); + dmpfac = pow(10.0f, -((24.0f / 128.0f)*(float)((pChn->nResonance + pChn->nResSwing) & 0x7F)) / 20.0f); + } - + if(cutoff == 127 && IsCompatibleMode(TRK_IMPULSETRACKER)) + { + // Z7F shouldn't actually enable the filter. + return; + } -// } - - fc *= (float)(2.0*3.14159265358/fs); + fc *= (float)(2.0 * 3.14159265358 / fs); - float d = (1.0f-2.0f*dmpfac)* fc; - if (d>2.0) d = 2.0; - d = (2.0f*dmpfac - d)/fc; - float e = pow(1.0f/fc,2.0f); + float d = (1.0f - 2.0f * dmpfac) * fc; + LimitMax(d, 2.0f); + d = (2.0f * dmpfac - d) / fc; + float e = pow(1.0f / fc, 2.0f); - fg=1/(1+d+e); - fb0=(d+e+e)/(1+d+e); - fb1=-e/(1+d+e); + fg = 1 / (1 + d + e); + fb0 = (d + e + e ) / (1 + d + e); + fb1 = -e / (1 + d + e); switch(pChn->nFilterMode) { @@ -144,6 +141,7 @@ pChn->nFilter_Y1 = pChn->nFilter_Y2 = 0; pChn->nFilter_Y3 = pChn->nFilter_Y4 = 0; } + pChn->dwFlags |= CHN_FILTER; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-10-01 17:03:30
|
Revision: 1072 http://modplug.svn.sourceforge.net/modplug/?rev=1072&view=rev Author: saga-games Date: 2011-10-01 17:03:23 +0000 (Sat, 01 Oct 2011) Log Message: ----------- [Fix] Sample Editor: Samples created using the "add silence / resize to" button didn't show up in the pattern editor's instrument list instantly. [Imp] When opening a WAV file for rendering fails, the user can choose to retry opening the file. [Ref] Various small changes Modified Paths: -------------- trunk/OpenMPT/common/Reporting.cpp trunk/OpenMPT/common/Reporting.h trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/soundlib/Dlsbank.cpp Modified: trunk/OpenMPT/common/Reporting.cpp =================================================================== --- trunk/OpenMPT/common/Reporting.cpp 2011-10-01 16:50:44 UTC (rev 1071) +++ trunk/OpenMPT/common/Reporting.cpp 2011-10-01 17:03:23 UTC (rev 1072) @@ -112,3 +112,25 @@ return cnfCancel; } } + + +RetryAnswer Reporting::RetryCancel(const char *text, const CWnd *parent) +//---------------------------------------------------------------------- +{ + return RetryCancel(text, MAINFRAME_TITLE, parent); +} + + +RetryAnswer Reporting::RetryCancel(const char *text, const char *caption, const CWnd *parent) +//------------------------------------------------------------------------------------------- +{ + UINT result = ShowNotification(text, caption, MB_RETRYCANCEL, parent); + switch(result) + { + case IDRETRY: + return rtyRetry; + default: + case IDCANCEL: + return rtyCancel; + } +} Modified: trunk/OpenMPT/common/Reporting.h =================================================================== --- trunk/OpenMPT/common/Reporting.h 2011-10-01 16:50:44 UTC (rev 1071) +++ trunk/OpenMPT/common/Reporting.h 2011-10-01 17:03:23 UTC (rev 1072) @@ -19,6 +19,12 @@ cnfCancel, }; +enum RetryAnswer +{ + rtyRetry, + rtyCancel, +}; + //============= class Reporting //============= @@ -55,6 +61,10 @@ 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); + // Show a confirmation dialog. + static RetryAnswer RetryCancel(const char *text, const CWnd *parent = nullptr); + static RetryAnswer RetryCancel(const char *text, const char *caption, const CWnd *parent = nullptr); + }; #endif // REPORTING_H Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-10-01 16:50:44 UTC (rev 1071) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-10-01 17:03:23 UTC (rev 1072) @@ -914,7 +914,7 @@ void CCtrlSamples::OnSampleNew() //------------------------------ { - bool bDuplicate = CMainFrame::GetInputHandler()->ShiftPressed(); + const bool bDuplicate = CMainFrame::GetInputHandler()->ShiftPressed(); SAMPLEINDEX smp = m_pModDoc->InsertSample(true); if (smp != SAMPLEINDEX_INVALID) Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2011-10-01 16:50:44 UTC (rev 1071) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2011-10-01 17:03:23 UTC (rev 1072) @@ -611,12 +611,20 @@ DWORD dwDataOffset; LONG lMax = 256; - if ((!m_pSndFile) || (!m_lpszFileName) || ((f = fopen(m_lpszFileName, "w+b")) == NULL)) + if (!m_pSndFile || !m_lpszFileName) { - Reporting::Notification("Could not open file for writing. Is it open in another application?"); EndDialog(IDCANCEL); return; } + + while((f = fopen(m_lpszFileName, "w+b")) == NULL) + { + if(Reporting::RetryCancel("Could not open file for writing. Is it open in another application?") == rtyCancel) + { + EndDialog(IDCANCEL); + return; + } + } SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); int oldVol = m_pSndFile->GetMasterVolume(); @@ -999,10 +1007,12 @@ if (theApp.GetACMConvert().AcmStreamPrepareHeader(hAStream, &ash, 0L) != MMSYSERR_NOERROR) goto OnError; bPrepared = true; // Creating the output file - if ((f = fopen(m_lpszFileName, "wb")) == NULL) + while ((f = fopen(m_lpszFileName, "wb")) == NULL) { - Reporting::Notification("Could not open file for writing. Is it open in another application?"); - goto OnError; + if(Reporting::RetryCancel("Could not open file for writing. Is it open in another application?") == rtyCancel) + { + goto OnError; + } } wfh.id_RIFF = IFFID_RIFF; wfh.id_WAVE = IFFID_WAVE; Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2011-10-01 16:50:44 UTC (rev 1071) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2011-10-01 17:03:23 UTC (rev 1072) @@ -2516,7 +2516,7 @@ const ctrlSmp::SmpLength nOldLength = sample.nLength; - if( MAX_SAMPLE_LENGTH - nOldLength < dlg.m_nSamples ) + 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::Information(str); @@ -2557,7 +2557,7 @@ { SetCurSel(0, 0); pModDoc->SetModified(); - pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEINFO | HINT_SAMPLEDATA, NULL); + pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEINFO | HINT_SAMPLEDATA | HINT_SMPNAMES, NULL); } } Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2011-10-01 16:50:44 UTC (rev 1071) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2011-10-01 17:03:23 UTC (rev 1072) @@ -781,24 +781,24 @@ UpdateDialog(); int offsetx=108, offsety=30, separatorx=4, separatory=2, - height=18, widthMacro=30, widthVal=90, widthType=135, widthBtn=60; + height=18, widthMacro=30, widthVal=90, widthType=135, widthBtn=70; - for (UINT m=0; m<NUM_MACROS; m++) + for (UINT m = 0; m < NUM_MACROS; m++) { m_EditMacro[m].Create("", /*BS_FLAT |*/ WS_CHILD | WS_VISIBLE | WS_TABSTOP /*| WS_BORDER*/, - CRect(offsetx, offsety+m*(separatory+height), offsetx+widthMacro, offsety+m*(separatory+height)+height), this, ID_PLUGSELECT+NUM_MACROS+m); + CRect(offsetx, offsety + m * (separatory + height), offsetx + widthMacro, offsety + m * (separatory + height) + height), this, ID_PLUGSELECT + NUM_MACROS + m); m_EditMacro[m].SetFont(GetFont()); m_EditMacroType[m].Create(ES_READONLY | WS_CHILD| WS_VISIBLE | WS_TABSTOP | WS_BORDER, - CRect(offsetx+separatorx+widthMacro, offsety+m*(separatory+height), offsetx+widthMacro+widthType, offsety+m*(separatory+height)+height), this, ID_PLUGSELECT+NUM_MACROS+m); + CRect(offsetx + separatorx + widthMacro, offsety + m* (separatory + height), offsetx + widthMacro + widthType, offsety + m * (separatory + height) + height), this, ID_PLUGSELECT + NUM_MACROS + m); m_EditMacroType[m].SetFont(GetFont()); m_EditMacroValue[m].Create(ES_CENTER | ES_READONLY | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER, - CRect(offsetx+separatorx+widthType+widthMacro, offsety+m*(separatory+height), offsetx+widthMacro+widthType+widthVal, offsety+m*(separatory+height)+height), this, ID_PLUGSELECT+NUM_MACROS+m); + CRect(offsetx + separatorx + widthType + widthMacro, offsety + m * (separatory + height), offsetx + widthMacro + widthType + widthVal, offsety + m * (separatory + height) + height), this, ID_PLUGSELECT + NUM_MACROS + m); m_EditMacroValue[m].SetFont(GetFont()); m_BtnMacroShowAll[m].Create("Show All...", WS_CHILD | WS_TABSTOP | WS_VISIBLE, - CRect(offsetx+separatorx+widthType+widthMacro+widthVal, offsety+m*(separatory+height), offsetx+widthMacro+widthType+widthVal+widthBtn, offsety+m*(separatory+height)+height), this, ID_PLUGSELECT+m); + CRect(offsetx + separatorx + widthType + widthMacro + widthVal, offsety + m *(separatory + height), offsetx + widthMacro + widthType + widthVal + widthBtn, offsety + m * (separatory + height) + height), this, ID_PLUGSELECT + m); m_BtnMacroShowAll[m].SetFont(GetFont()); } UpdateMacroList(); @@ -1128,8 +1128,7 @@ m_EditSFx.SetWindowText(macroText); } else { - Reporting::Notification("Warning: Currently MPT can only assign macros to parameters 0 to 383"); - param = 383; + Reporting::Notification("MPT can only assign macros to parameters 0 to 383. Use Parameter Control Notes to automate higher parameters."); } } Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2011-10-01 16:50:44 UTC (rev 1071) +++ trunk/OpenMPT/mptrack/mptrack.rc 2011-10-01 17:03:23 UTC (rev 1072) @@ -1218,7 +1218,7 @@ IDD_MIDIMACRO DIALOGEX 0, 0, 358, 354 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_TOOLWINDOW -CAPTION "Zxx Macros Configuration" +CAPTION "Zxx Macro Configuration" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN DEFPUSHBUTTON "OK",IDOK,300,6,50,14 Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2011-10-01 16:50:44 UTC (rev 1071) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2011-10-01 17:03:23 UTC (rev 1072) @@ -205,9 +205,6 @@ <ClCompile Include="MainFrm.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="MIDIMappingDialog.cpp"> - <Filter>Source Files</Filter> - </ClCompile> <ClCompile Include="..\soundlib\mmcmp.cpp"> <Filter>Source Files</Filter> </ClCompile> @@ -430,6 +427,9 @@ <ClCompile Include="KeyConfigDlg.cpp"> <Filter>Source Files\Dialogs</Filter> </ClCompile> + <ClCompile Include="MIDIMappingDialog.cpp"> + <Filter>Source Files\Dialogs</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="AbstractVstEditor.h"> @@ -525,9 +525,6 @@ <ClInclude Include="..\soundlib\midi.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="MIDIMappingDialog.h"> - <Filter>Header Files</Filter> - </ClInclude> <ClInclude Include="mod2midi.h"> <Filter>Header Files</Filter> </ClInclude> @@ -753,6 +750,9 @@ <ClInclude Include="KeyConfigDlg.h"> <Filter>Header Files\Dialogs</Filter> </ClInclude> + <ClInclude Include="MIDIMappingDialog.h"> + <Filter>Header Files\Dialogs</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.cpp 2011-10-01 16:50:44 UTC (rev 1071) +++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2011-10-01 17:03:23 UTC (rev 1072) @@ -460,12 +460,13 @@ FILE *f; if ((!lpszFileName) || (!lpszFileName[0])) return FALSE; if ((f = fopen(lpszFileName, "rb")) == NULL) return FALSE; - memset(&riff, 0, sizeof(riff)); + MemsetZero(riff); fread(&riff, sizeof(RIFFCHUNKID), 1, f); // Check for embedded DLS sections if (riff.id_RIFF == IFFID_FORM) { - do { + do + { int len = BigEndian(riff.riff_len); if (len <= 4) break; if (riff.id_DLS == IFFID_XDLS) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-10-02 13:31:49
|
Revision: 1074 http://modplug.svn.sourceforge.net/modplug/?rev=1074&view=rev Author: saga-games Date: 2011-10-02 13:31:42 +0000 (Sun, 02 Oct 2011) Log Message: ----------- [Imp] Mod Conversion: When converting XM to S3M/IT and there is pxx and Cxx in the same MODCOMMAND, the commands are swapped. [Mod] XM: Changed volcol panning import/export to use the full 0...64 range for more correct panning Modified Paths: -------------- trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/soundlib/Load_xm.cpp trunk/OpenMPT/soundlib/modcommand.cpp Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2011-10-01 23:06:51 UTC (rev 1073) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2011-10-02 13:31:42 UTC (rev 1074) @@ -3136,16 +3136,8 @@ switch(gVolCmdInfo[ndx].dwVolCmd) { case VOLCMD_VOLUME: - *prangeMax = 64; - break; - case VOLCMD_PANNING: *prangeMax = 64; - if (m_SndFile.GetType() & MOD_TYPE_XM) - { - *prangeMin = 2; // 0*4+2 - *prangeMax = 62; // 15*4+2 - } break; default: Modified: trunk/OpenMPT/soundlib/Load_xm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_xm.cpp 2011-10-01 23:06:51 UTC (rev 1073) +++ trunk/OpenMPT/soundlib/Load_xm.cpp 2011-10-02 13:31:42 UTC (rev 1074) @@ -204,7 +204,7 @@ // B0-BF: Vibrato case 0xB0: p->volcmd = VOLCMD_VIBRATODEPTH; break; // C0-CF: Set Panning - case 0xC0: p->volcmd = VOLCMD_PANNING; p->vol = (vol << 2) + 2; break; + case 0xC0: p->volcmd = VOLCMD_PANNING; p->vol = (vol * 64 / 15); break; // D0-DF: Panning Slide Left case 0xD0: p->volcmd = VOLCMD_PANSLIDELEFT; break; // E0-EF: Panning Slide Right @@ -465,10 +465,10 @@ if (pIns->PanEnv.nLoopStart >= pIns->PanEnv.nLoopEnd) pIns->PanEnv.dwFlags &= ~ENV_LOOP; for (UINT ienv=0; ienv<12; ienv++) { - pIns->VolEnv.Ticks[ienv] = (WORD)xmsh.venv[ienv*2]; - 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]; + pIns->VolEnv.Ticks[ienv] = (WORD)xmsh.venv[ienv * 2]; + 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 > 0) { // libmikmod code says: "Some broken XM editing program will only save the low byte of the position @@ -492,10 +492,10 @@ for (UINT j=0; j<96; j++) { if (xmsh.snum[j] < nsamples) - pIns->Keyboard[j+12] = samplemap[xmsh.snum[j]]; + pIns->Keyboard[j + 12] = samplemap[xmsh.snum[j]]; } // Reading samples - for (UINT ins=0; ins<nsamples; ins++) + for (UINT ins = 0; ins < nsamples; ins++) { if (dwMemPos + max(xmsh.shsize, sizeof(xmss)) > dwMemLength) return true; @@ -611,7 +611,7 @@ bMadeWithModPlug = true; } // Read midi config: "MIDI" - if ((dwMemPos + 8 < dwMemLength) && (LittleEndian(*((DWORD *)(lpStream+dwMemPos))) == 0x4944494D)) + if ((dwMemPos + 8 < dwMemLength) && (LittleEndian(*((DWORD *)(lpStream + dwMemPos))) == 0x4944494D)) { UINT len = *((DWORD *)(lpStream+dwMemPos+4)); dwMemPos += 8; @@ -625,7 +625,7 @@ bMadeWithModPlug = true; } // Read pattern names: "PNAM" - if ((dwMemPos + 8 < dwMemLength) && (LittleEndian(*((DWORD *)(lpStream+dwMemPos))) == 0x4d414e50)) + if ((dwMemPos + 8 < dwMemLength) && (LittleEndian(*((DWORD *)(lpStream + dwMemPos))) == 0x4d414e50)) { UINT len = *((DWORD *)(lpStream + dwMemPos + 4)); dwMemPos += 8; @@ -642,7 +642,7 @@ bMadeWithModPlug = true; } // Read channel names: "CNAM" - if ((dwMemPos + 8 < dwMemLength) && (LittleEndian(*((DWORD *)(lpStream+dwMemPos))) == 0x4d414e43)) + if ((dwMemPos + 8 < dwMemLength) && (LittleEndian(*((DWORD *)(lpStream + dwMemPos))) == 0x4d414e43)) { UINT len = *((DWORD *)(lpStream+dwMemPos+4)); dwMemPos += 8; @@ -651,7 +651,7 @@ UINT n = len / MAX_CHANNELNAME; for (UINT i=0; i<n; i++) { - memcpy(ChnSettings[i].szName, (lpStream+dwMemPos+i*MAX_CHANNELNAME), MAX_CHANNELNAME); + memcpy(ChnSettings[i].szName, (lpStream+dwMemPos + i * MAX_CHANNELNAME), MAX_CHANNELNAME); StringFixer::SetNullTerminator(ChnSettings[i].szName); } dwMemPos += len; @@ -855,7 +855,7 @@ case VOLCMD_FINEVOLUP: vol = 0x90 + (p->vol & 0x0F); break; case VOLCMD_VIBRATOSPEED: vol = 0xA0 + (p->vol & 0x0F); break; case VOLCMD_VIBRATODEPTH: vol = 0xB0 + (p->vol & 0x0F); break; - case VOLCMD_PANNING: vol = 0xC0 + (p->vol >> 2); if (vol > 0xCF) vol = 0xCF; break; + case VOLCMD_PANNING: vol = 0xC0 + (p->vol * 15 / 64); if (vol > 0xCF) vol = 0xCF; break; case VOLCMD_PANSLIDELEFT: vol = 0xD0 + (p->vol & 0x0F); break; case VOLCMD_PANSLIDERIGHT: vol = 0xE0 + (p->vol & 0x0F); break; case VOLCMD_TONEPORTAMENTO: vol = 0xF0 + (p->vol & 0x0F); break; Modified: trunk/OpenMPT/soundlib/modcommand.cpp =================================================================== --- trunk/OpenMPT/soundlib/modcommand.cpp 2011-10-01 23:06:51 UTC (rev 1073) +++ trunk/OpenMPT/soundlib/modcommand.cpp 2011-10-02 13:31:42 UTC (rev 1074) @@ -151,8 +151,15 @@ { m->volcmd = VOLCMD_VOLUME; m->vol = m->param; - if (m->vol > 0x40) m->vol = 0x40; + if(m->vol > 64) m->vol = 64; m->command = m->param = 0; + } else if(m->volcmd == VOLCMD_PANNING) + { + m->SwapEffects(); + m->volcmd = VOLCMD_VOLUME; + if(m->vol > 64) m->vol = 64; + m->command = CMD_S3MCMDEX; + m->param = 0x80 | (m->param * 15 / 64); // XM volcol panning is 4-Bit, so we can use 4-Bit panning here. } break; case CMD_PORTAMENTOUP: @@ -745,7 +752,8 @@ } CHANNELINDEX nScanChnMin = nChn, nScanChnMax = nChn; - MODCOMMAND *p = Patterns[nPat], *m; + MODCOMMAND * const p = Patterns[nPat].GetpModCommand(nRow, nScanChnMin); + MODCOMMAND *m; // Scan all channels if(nChn == CHANNELINDEX_INVALID) @@ -757,9 +765,9 @@ // Scan channel(s) for same effect type - if an effect of the same type is already present, exit. if(!bAllowMultipleEffects) { - for(CHANNELINDEX i = nScanChnMin; i <= nScanChnMax; i++) + m = p; + for(CHANNELINDEX i = nScanChnMin; i <= nScanChnMax; i++, m++) { - m = p + nRow * m_nChannels + i; if(!bIsVolumeEffect && m->command == nEffect) return true; if(bIsVolumeEffect && m->volcmd == nEffect) @@ -768,9 +776,9 @@ } // Easy case: check if there's some space left to put the effect somewhere - for(CHANNELINDEX i = nScanChnMin; i <= nScanChnMax; i++) + m = p; + for(CHANNELINDEX i = nScanChnMin; i <= nScanChnMax; i++, m++) { - m = p + nRow * m_nChannels + i; if(!bIsVolumeEffect && m->command == CMD_NONE) { m->command = nEffect; @@ -791,9 +799,9 @@ // Move some effects that also work in the volume column, so there's place for our new effect. if(!bIsVolumeEffect) { - for(CHANNELINDEX i = nScanChnMin; i <= nScanChnMax; i++) + m = p; + for(CHANNELINDEX i = nScanChnMin; i <= nScanChnMax; i++, m++) { - m = p + nRow * m_nChannels + i; switch(m->command) { case CMD_VOLUME: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-10-02 16:01:36
|
Revision: 1075 http://modplug.svn.sourceforge.net/modplug/?rev=1075&view=rev Author: saga-games Date: 2011-10-02 16:01:29 +0000 (Sun, 02 Oct 2011) Log Message: ----------- [Fix] IT Compatibility: The resonant filter doesn't do any filtering if cutoff is maximum and resonance is minimum. [Fix] IT Compatibility: New filter mode which pretty much sounds like XMPlay's resonant filter (http://bugs.openmpt.org/view.php?id=8). [Mod] IT Saving: Files with filter envlope use a different file version (2.16) now. [Mod] OpenMPT: Version is now 1.20.00.35 Modified Paths: -------------- trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Snd_flt.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Tables.cpp Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-10-02 13:31:42 UTC (rev 1074) +++ trunk/OpenMPT/mptrack/version.h 2011-10-02 16:01:29 UTC (rev 1075) @@ -15,12 +15,12 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 34 +#define VER_MINORMINOR 35 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of //version 1.17.02.28. -#define MAKE_VERSION_NUMERIC(v0,v1,v2,v3) ((0x##v0 << 24) + (0x##v1<<16) + (0x##v2<<8) + (0x##v3)) +#define MAKE_VERSION_NUMERIC(v0,v1,v2,v3) ((0x##v0 << 24) | (0x##v1<<16) | (0x##v2<<8) | (0x##v3)) //Version string. For example "1.17.02.28" #define MPT_VERSION_STR STRINGIZE(VER_MAJORMAJOR)"."STRINGIZE(VER_MAJOR)"."STRINGIZE(VER_MINOR)"."STRINGIZE(VER_MINORMINOR) @@ -39,7 +39,7 @@ { int v1, v2, v3, v4; sscanf(s, "%x.%x.%x.%x", &v1, &v2, &v3, &v4); - return ((v1 << 24) + (v2 << 16) + (v3 << 8) + v4); + return ((v1 << 24) | (v2 << 16) | (v3 << 8) | v4); }; // Returns version string from given numerical version value. @@ -49,7 +49,7 @@ if(v == 0) strVersion = "Unknown"; else - strVersion.Format("%X.%02X.%02X.%02X", (v>>24)&0xFF, (v>>16)&0xFF, (v>>8)&0xFF, (v)&0xFF); + strVersion.Format("%X.%02X.%02X.%02X", (v >> 24) & 0xFF, (v >> 16) & 0xFF, (v >> 8) & 0xFF, (v) & 0xFF); return strVersion; }; Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2011-10-02 13:31:42 UTC (rev 1074) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2011-10-02 16:01:29 UTC (rev 1075) @@ -1439,7 +1439,7 @@ { if(Instruments[nIns] && Instruments[nIns]->PitchEnv.dwFlags & ENV_FILTER) { - header.cmwt = LittleEndianW(0x0217); + header.cmwt = LittleEndianW(0x0216); break; } } Modified: trunk/OpenMPT/soundlib/Snd_flt.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_flt.cpp 2011-10-02 13:31:42 UTC (rev 1074) +++ trunk/OpenMPT/soundlib/Snd_flt.cpp 2011-10-02 16:01:29 UTC (rev 1075) @@ -16,55 +16,24 @@ #ifndef NO_FILTER -//#define _ASM_MATH - -#ifdef _ASM_MATH - -// pow(a,b) returns a^^b -> 2^^(b.log2(a)) - -static float pow(float a, float b) -{ - long tmpint; - float result; - _asm { - fld b // Load b - fld a // Load a - fyl2x // ST(0) = b.log2(a) - fist tmpint // Store integer exponent - fisub tmpint // ST(0) = -1 <= (b*log2(a)) <= 1 - f2xm1 // ST(0) = 2^(x)-1 - fild tmpint // load integer exponent - fld1 // Load 1 - fscale // ST(0) = 2^ST(1) - fstp ST(1) // Remove the integer from the stack - fmul ST(1), ST(0) // multiply with fractional part - faddp ST(1), ST(0) // add integer_part - fstp result // Store the result - } - return result; -} - - -#else - +#define _USE_MATH_DEFINES #include <math.h> -#endif // _ASM_MATH +extern float ITResonanceTable[128]; DWORD CSoundFile::CutOffToFrequency(UINT nCutOff, int flt_modifier) const //----------------------------------------------------------------------- { float Fc; - ASSERT(nCutOff<128); + ASSERT(nCutOff < 128); if (m_dwSongFlags & SONG_EXFILTERRANGE) Fc = 110.0f * pow(2.0f, 0.25f + ((float)(nCutOff * (flt_modifier + 256))) / (20.0f * 512.0f)); else Fc = 110.0f * pow(2.0f, 0.25f + ((float)(nCutOff * (flt_modifier + 256))) / (24.0f * 512.0f)); LONG freq = (LONG)Fc; - if (freq < 120) return 120; - if (freq > 20000) return 20000; - if (freq*2 > (LONG)gdwMixingFreq) freq = gdwMixingFreq>>1; + Limit(freq, 120, 20000); + if (freq * 2 > (LONG)gdwMixingFreq) freq = gdwMixingFreq >> 1; return (DWORD)freq; } @@ -73,67 +42,82 @@ void CSoundFile::SetupChannelFilter(MODCHANNEL *pChn, bool bReset, int flt_modifier) const //---------------------------------------------------------------------------------------- { - float fs = (float)gdwMixingFreq; - float fg, fb0, fb1, fc, dmpfac; - - int cutoff = 0; + int cutoff = (int)pChn->nCutOff + (int)pChn->nCutSwing; + int resonance = (int)(pChn->nResonance & 0x7F) + (int)pChn->nResSwing; + + Limit(cutoff, 0, 127); + Limit(resonance, 0, 127); + if(!GetModFlag(MSF_OLDVOLSWING)) { - if(pChn->nCutSwing) + pChn->nCutOff = (BYTE)cutoff; + pChn->nCutSwing = 0; + pChn->nResonance = (BYTE)resonance; + pChn->nResSwing = 0; + } + + float d, e; + + if(UseITFilterMode()) + { + + // flt_modifier is in [-256, 256], so cutoff is in [0, 127 * 2] after this calculation + cutoff = cutoff * (flt_modifier + 256) / 256; + + // Filtering is only ever done if either cutoff is not full or if resonance is set. + if (cutoff < 254 || resonance != 0) { - static_assert(sizeof(pChn->nCutOff) == 1, "check cast if this fails"); - pChn->nCutOff = static_cast<BYTE>(pChn->nCutOff + pChn->nCutSwing); - Limit(pChn->nCutOff, BYTE(0), BYTE(127)); - pChn->nCutSwing = 0; - } - if(pChn->nResSwing) + pChn->dwFlags |= CHN_FILTER; + } else { - static_assert(sizeof(pChn->nResonance) == 1, "check cast if this fails"); - pChn->nResonance = static_cast<BYTE>(pChn->nResonance + pChn->nResSwing); - Limit(pChn->nResonance, BYTE(0), BYTE(127)); - pChn->nResSwing = 0; + return; } - cutoff = CLAMP((int)pChn->nCutOff, 0, 127); // cap cutoff - fc = (float)CutOffToFrequency(cutoff, flt_modifier); - dmpfac = pow(10.0f, -((24.0f / 128.0f) * (float)((pChn->nResonance) & 0x7F)) / 20.0f); - } - else - { - cutoff = CLAMP((int)pChn->nCutOff + (int)pChn->nCutSwing, 0, 127); // cap cutoff - fc = (float)CutOffToFrequency(cutoff, flt_modifier); - dmpfac = pow(10.0f, -((24.0f / 128.0f)*(float)((pChn->nResonance + pChn->nResSwing) & 0x7F)) / 20.0f); - } - if(cutoff == 127 && IsCompatibleMode(TRK_IMPULSETRACKER)) + static const float freqMultiplier = 2.0f * (float)M_PI * 110.0f * pow(2.0f, 0.25f); + static const float freqParameterMultiplier = 128.0f / (24.0f * 256.0f); + + // 2 ^ (i / 24 * 256) + const float r = (float)gdwMixingFreq / (freqMultiplier * pow(2.0f, (float)cutoff * freqParameterMultiplier)); + + d = ITResonanceTable[resonance] * r + ITResonanceTable[resonance] - 1.0f; + e = r * r; + + } else { - // Z7F shouldn't actually enable the filter. - return; - } - fc *= (float)(2.0 * 3.14159265358 / fs); - - float d = (1.0f - 2.0f * dmpfac) * fc; - LimitMax(d, 2.0f); - d = (2.0f * dmpfac - d) / fc; - float e = pow(1.0f / fc, 2.0f); + pChn->dwFlags |= CHN_FILTER; - fg = 1 / (1 + d + e); - fb0 = (d + e + e ) / (1 + d + e); - fb1 = -e / (1 + d + e); + float fc = (float)CutOffToFrequency(cutoff, flt_modifier); + const float dmpfac = pow(10.0f, -((24.0f / 128.0f) * (float)resonance) / 20.0f); + fc *= (float)(2.0 * 3.14159265358 / (float)gdwMixingFreq); + + d = (1.0f - 2.0f * dmpfac) * fc; + LimitMax(d, 2.0f); + d = (2.0f * dmpfac - d) / fc; + e = pow(1.0f / fc, 2.0f); + + } + + float fg = 1 / (1 + d + e); + float fb0 = (d + e + e) / (1 + d + e); + float fb1 = -e / (1 + d + e); + switch(pChn->nFilterMode) { case FLTMODE_HIGHPASS: - pChn->nFilter_A0 = (int)((1.0f-fg) * FILTER_PRECISION); + pChn->nFilter_A0 = (int)((1.0f - fg) * FILTER_PRECISION); pChn->nFilter_B0 = (int)(fb0 * FILTER_PRECISION); pChn->nFilter_B1 = (int)(fb1 * FILTER_PRECISION); pChn->nFilter_HP = -1; break; + default: pChn->nFilter_A0 = (int)(fg * FILTER_PRECISION); pChn->nFilter_B0 = (int)(fb0 * FILTER_PRECISION); pChn->nFilter_B1 = (int)(fb1 * FILTER_PRECISION); pChn->nFilter_HP = 0; + break; } if (bReset) @@ -142,7 +126,6 @@ pChn->nFilter_Y3 = pChn->nFilter_Y4 = 0; } - pChn->dwFlags |= CHN_FILTER; } #endif // NO_FILTER Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-10-02 13:31:42 UTC (rev 1074) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-10-02 16:01:29 UTC (rev 1075) @@ -1013,7 +1013,7 @@ pChn->nCutSwing = pChn->nResSwing = 0; } #ifndef NO_FILTER - if ((pChn->nCutOff < 0x7F) && (bFlt)) SetupChannelFilter(pChn, true); + if ((pChn->nCutOff < 0x7F || UseITFilterMode()) && (bFlt)) SetupChannelFilter(pChn, true); #endif // NO_FILTER } // Special case for MPT @@ -2114,11 +2114,11 @@ // IMF Commands case CMD_NOTESLIDEUP: - NoteSlide(pChn, param, 1); + NoteSlide(pChn, param, true); break; case CMD_NOTESLIDEDOWN: - NoteSlide(pChn, param, -1); + NoteSlide(pChn, param, false); break; } @@ -2410,8 +2410,8 @@ // Implemented for IMF compatibility, can't actually save this in any formats // sign should be 1 (up) or -1 (down) -void CSoundFile::NoteSlide(MODCHANNEL *pChn, UINT param, int sign) -//---------------------------------------------------------------- +void CSoundFile::NoteSlide(MODCHANNEL *pChn, UINT param, bool slideUp) +//-------------------------------------------------------------------- { BYTE x, y; if (m_dwSongFlags & SONG_FIRSTTICK) @@ -2430,7 +2430,7 @@ pChn->nNoteSlideCounter = pChn->nNoteSlideSpeed; // update it pChn->nPeriod = GetPeriodFromNote - (sign * pChn->nNoteSlideStep + GetNoteFromPeriod(pChn->nPeriod), 8363, 0); + ((slideUp ? 1 : -1) * pChn->nNoteSlideStep + GetNoteFromPeriod(pChn->nPeriod), 8363, 0); } } } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2011-10-02 13:31:42 UTC (rev 1074) +++ trunk/OpenMPT/soundlib/Sndfile.h 2011-10-02 16:01:29 UTC (rev 1075) @@ -624,6 +624,9 @@ return true; // S3M and MOD format don't have compatibility flags, so we will always return true return ((GetType() & type) && GetModFlag(MSF_COMPATIBLE_PLAY)) ? true : false; } + + // Check whether a filter algorithm closer to IT's should be used. + bool UseITFilterMode() const { return IsCompatibleMode(TRK_IMPULSETRACKER) && !(m_dwSongFlags & SONG_EXFILTERRANGE); } //Tuning--> public: @@ -990,7 +993,7 @@ void FinePortamentoDown(MODCHANNEL *pChn, UINT param); void ExtraFinePortamentoUp(MODCHANNEL *pChn, UINT param); void ExtraFinePortamentoDown(MODCHANNEL *pChn, UINT param); - void NoteSlide(MODCHANNEL *pChn, UINT param, int sign); + void NoteSlide(MODCHANNEL *pChn, UINT param, bool slideUp); void TonePortamento(MODCHANNEL *pChn, UINT param); void Vibrato(MODCHANNEL *pChn, UINT param); void FineVibrato(MODCHANNEL *pChn, UINT param); Modified: trunk/OpenMPT/soundlib/Tables.cpp =================================================================== --- trunk/OpenMPT/soundlib/Tables.cpp 2011-10-02 13:31:42 UTC (rev 1074) +++ trunk/OpenMPT/soundlib/Tables.cpp 2011-10-02 16:01:29 UTC (rev 1075) @@ -461,6 +461,44 @@ }; +// LUT for 2 * damping factor +float ITResonanceTable[128] = +{ + 1.0000000000000000f, 0.9786446094512940f, 0.9577452540397644f, 0.9372922182083130f, + 0.9172759056091309f, 0.8976871371269226f, 0.8785166740417481f, 0.8597555756568909f, + 0.8413951396942139f, 0.8234267830848694f, 0.8058421611785889f, 0.7886331081390381f, + 0.7717915177345276f, 0.7553095817565918f, 0.7391796708106995f, 0.7233941555023193f, + 0.7079457640647888f, 0.6928272843360901f, 0.6780316829681397f, 0.6635520458221436f, + 0.6493816375732422f, 0.6355138421058655f, 0.6219421625137329f, 0.6086603403091431f, + 0.5956621170043945f, 0.5829415321350098f, 0.5704925656318665f, 0.5583094954490662f, + 0.5463865399360657f, 0.5347182154655457f, 0.5232990980148315f, 0.5121238231658936f, + 0.5011872053146362f, 0.4904841780662537f, 0.4800096750259399f, 0.4697588682174683f, + 0.4597269892692566f, 0.4499093294143677f, 0.4403013288974762f, 0.4308985173702240f, + 0.4216965138912201f, 0.4126909971237183f, 0.4038778245449066f, 0.3952528536319733f, + 0.3868120610713959f, 0.3785515129566193f, 0.3704673945903778f, 0.3625559210777283f, + 0.3548133969306946f, 0.3472362160682678f, 0.3398208320140839f, 0.3325638175010681f, + 0.3254617750644684f, 0.3185114264488220f, 0.3117094635963440f, 0.3050527870655060f, + 0.2985382676124573f, 0.2921628654003143f, 0.2859236001968384f, 0.2798175811767578f, + 0.2738419771194458f, 0.2679939568042755f, 0.2622708380222321f, 0.2566699385643005f, + 0.2511886358261108f, 0.2458244115114212f, 0.2405747324228287f, 0.2354371547698975f, + 0.2304092943668366f, 0.2254888117313385f, 0.2206734120845795f, 0.2159608304500580f, + 0.2113489061594009f, 0.2068354636430740f, 0.2024184018373489f, 0.1980956792831421f, + 0.1938652694225311f, 0.1897251904010773f, 0.1856735348701477f, 0.1817083954811096f, + 0.1778279393911362f, 0.1740303486585617f, 0.1703138649463654f, 0.1666767448186874f, + 0.1631172895431519f, 0.1596338599920273f, 0.1562248021364212f, 0.1528885662555695f, + 0.1496235728263855f, 0.1464282870292664f, 0.1433012634515762f, 0.1402409970760346f, + 0.1372461020946503f, 0.1343151479959488f, 0.1314467936754227f, 0.1286396980285645f, + 0.1258925348520279f, 0.1232040524482727f, 0.1205729842185974f, 0.1179980933666229f, + 0.1154781952500343f, 0.1130121126770973f, 0.1105986908078194f, 0.1082368120551109f, + 0.1059253737330437f, 0.1036632955074310f, 0.1014495193958283f, 0.0992830246686935f, + 0.0971627980470657f, 0.0950878411531448f, 0.0930572077631950f, 0.0910699293017387f, + 0.0891250967979431f, 0.0872217938303947f, 0.0853591337800026f, 0.0835362523794174f, + 0.0817523002624512f, 0.0800064504146576f, 0.0782978758215904f, 0.0766257941722870f, + 0.0749894231557846f, 0.0733879879117012f, 0.0718207582831383f, 0.0702869966626167f, + 0.0687859877943993f, 0.0673170387744904f, 0.0658794566988945f, 0.0644725710153580f, +}; + + int SpectrumSinusTable[256*2] = { 0, 1, 1, 2, 3, 3, 4, 5, 6, 7, 7, 8, 9, 10, 10, 11, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-10-03 14:26:20
|
Revision: 1077 http://modplug.svn.sourceforge.net/modplug/?rev=1077&view=rev Author: saga-games Date: 2011-10-03 14:26:14 +0000 (Mon, 03 Oct 2011) Log Message: ----------- [Imp] Instrument Tab: Cutoff frequency display reflects filter enable behaviour in IT compatible mode now. [Fix] Filter enable behaviour is always the same in IT compatible mode, even with extended filter rnage. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/soundlib/Snd_flt.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-10-02 16:40:50 UTC (rev 1076) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-10-03 14:26:14 UTC (rev 1077) @@ -1376,9 +1376,14 @@ MODINSTRUMENT *pIns = pSndFile->Instruments[m_nInstrument]; if (pIns) { - CHAR s[64]; - if (pIns->nIFC&0x80 && pIns->nIFC<0xFF) { - wsprintf(s, "%d Hz", pSndFile->CutOffToFrequency(pIns->nIFC & 0x7F)); + CHAR s[32]; + // In IT Compatible mode, it is enough to just have resonance enabled to turn on the filter. + const bool resEnabled = ((pIns->nIFR & 0x80) && (pIns->nIFR & 0x7F) && pSndFile->IsCompatibleMode(TRK_IMPULSETRACKER)); + + if (((pIns->nIFC & 0x80) && pIns->nIFC < 0xFF) || resEnabled) + { + const BYTE cutoff = (resEnabled && !(pIns->nIFC & 0x80)) ? 0x7F : (pIns->nIFC & 0x7F); + wsprintf(s, "%d Hz", pSndFile->CutOffToFrequency(cutoff)); } else { wsprintf(s, "Off"); } @@ -2272,6 +2277,7 @@ } } } + UpdateFilterText(); SetInstrumentModified(true); SwitchToView(); } @@ -2350,7 +2356,7 @@ // -> 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; @@ -2363,7 +2369,7 @@ // -! NEW_FEATURE#0027 } // Volume Swing - else if (pSlider==&m_SliderVolSwing) + else if (pSlider == &m_SliderVolSwing) { n = m_SliderVolSwing.GetPos(); if ((n >= 0) && (n <= 100) && (n != (int)pIns->nVolSwing)) @@ -2373,7 +2379,7 @@ } } // Pan Swing - else if (pSlider==&m_SliderPanSwing) + else if (pSlider == &m_SliderPanSwing) { n = m_SliderPanSwing.GetPos(); if ((n >= 0) && (n <= 64) && (n != (int)pIns->nPanSwing)) @@ -2383,7 +2389,7 @@ } } //Cutoff swing - else if (pSlider==&m_SliderCutSwing) + else if (pSlider == &m_SliderCutSwing) { n = m_SliderCutSwing.GetPos(); if ((n >= 0) && (n <= 64) && (n != (int)pIns->nCutSwing)) @@ -2393,7 +2399,7 @@ } } //Resonance swing - else if (pSlider==&m_SliderResSwing) + else if (pSlider == &m_SliderResSwing) { n = m_SliderResSwing.GetPos(); if ((n >= 0) && (n <= 64) && (n != (int)pIns->nResSwing)) @@ -2403,7 +2409,7 @@ } } // Filter CutOff - else if (pSlider==&m_SliderCutOff) + else if (pSlider == &m_SliderCutOff) { n = m_SliderCutOff.GetPos(); if ((n >= 0) && (n < 0x80) && (n != (int)(pIns->nIFC & 0x7F))) @@ -2415,7 +2421,7 @@ filterChanger = true; } } - else if (pSlider==&m_SliderResonance) + else if (pSlider == &m_SliderResonance) { // Filter Resonance n = m_SliderResonance.GetPos(); @@ -2424,12 +2430,13 @@ pIns->nIFR &= 0x80; pIns->nIFR |= (BYTE)n; SetInstrumentModified(true); + UpdateFilterText(); filterChanger = true; } } // Update channels - if (filterChanger==true) + if (filterChanger == true) { for (UINT i=0; i<MAX_CHANNELS; i++) { Modified: trunk/OpenMPT/soundlib/Snd_flt.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_flt.cpp 2011-10-02 16:40:50 UTC (rev 1076) +++ trunk/OpenMPT/soundlib/Snd_flt.cpp 2011-10-03 14:26:14 UTC (rev 1077) @@ -65,7 +65,7 @@ cutoff = cutoff * (flt_modifier + 256) / 256; // Filtering is only ever done if either cutoff is not full or if resonance is set. - if (cutoff < 254 || resonance != 0) + if(cutoff < 254 || resonance != 0) { pChn->dwFlags |= CHN_FILTER; } else @@ -85,6 +85,12 @@ } else { + // We might end up here even if IT compatible playback mode is enabled and if extended filter range flag is set. + // We'd still want compatible behaviour then, but at the same time use MPT's cutoff / resonance settings + if(IsCompatibleMode(TRK_IMPULSETRACKER) && resonance == 0 && cutoff * (flt_modifier + 256) >= 254 * 256) + { + return; + } pChn->dwFlags |= CHN_FILTER; float fc = (float)CutOffToFrequency(cutoff, flt_modifier); Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-10-02 16:40:50 UTC (rev 1076) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-10-03 14:26:14 UTC (rev 1077) @@ -1013,7 +1013,10 @@ pChn->nCutSwing = pChn->nResSwing = 0; } #ifndef NO_FILTER - if ((pChn->nCutOff < 0x7F || UseITFilterMode()) && (bFlt)) SetupChannelFilter(pChn, true); + if ((pChn->nCutOff < 0x7F || IsCompatibleMode(TRK_IMPULSETRACKER)) && (bFlt)) + { + SetupChannelFilter(pChn, true); + } #endif // NO_FILTER } // Special case for MPT This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-10-03 16:52:55
|
Revision: 1078 http://modplug.svn.sourceforge.net/modplug/?rev=1078&view=rev Author: saga-games Date: 2011-10-03 16:52:48 +0000 (Mon, 03 Oct 2011) Log Message: ----------- [New] Sample Editor: Experimental feature: Autotune sample to the closest C. [Fix] Sample Editor: X-Fade shortcut was broken. [Mod] OpenMPT: Version is now 1.20.00.36 Modified Paths: -------------- trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/CommandSet.h trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/Ctrl_smp.h trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/mptrack.rc 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/res/patterns.bmp trunk/OpenMPT/mptrack/resource.h trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/modsmp_ctrl.cpp trunk/OpenMPT/soundlib/modsmp_ctrl.h Added Paths: ----------- trunk/OpenMPT/mptrack/Autotune.cpp trunk/OpenMPT/mptrack/Autotune.h Added: trunk/OpenMPT/mptrack/Autotune.cpp =================================================================== --- trunk/OpenMPT/mptrack/Autotune.cpp (rev 0) +++ trunk/OpenMPT/mptrack/Autotune.cpp 2011-10-03 16:52:48 UTC (rev 1078) @@ -0,0 +1,243 @@ +/* + * Autotune.cpp + * ------------- + * Purpose: Class for tuning a sample to the next C automatically. + * Notes : (currently none) + * Authors: OpenMPT Devs + */ + + +#include "stdafx.h" +#include <math.h> +#include "../common/misc_util.h" +#include "../soundlib/Sndfile.h" +#include "Autotune.h" + + +// The more bins, the more autocorrelations are done and the more precise the result is. +#define BINS_PER_NOTE 32 +#define MIN_SAMPLE_LENGTH 2 + + +double Autotune::FrequencyToNote(double freq) const +//------------------------------------------------- +{ + return ((12.0 * (log(freq / (440.0 / 2.0)) / log(2.0))) + 57.0); +} + + +double Autotune::NoteToFrequency(double note) const +//------------------------------------------------- +{ + return 440.0 * pow(2.0, (note - 69.0) / 12.0); +} + + +// Calculate the amount of samples for autocorrelation shifting for a given note +SmpLength Autotune::NoteToShift(uint32 sampleFreq, int note) const +//------------------------------------------------------------------- +{ + const double fundamentalFrequency = NoteToFrequency((double)note / BINS_PER_NOTE); + return (SmpLength)max(Util::Round((double)sampleFreq / fundamentalFrequency), 1); +} + + +// Create an 8-Bit sample buffer with loop unrolling and mono conversion for autocorrelation. +template <class T> +void Autotune::CopySamples(const T* origSample, SmpLength sampleLoopStart, SmpLength sampleLoopEnd) +//------------------------------------------------------------------------------------------------- +{ + const uint8 channels = sample.GetNumChannels(); + sampleLoopStart *= channels; + sampleLoopEnd *= channels; + + for(SmpLength i = 0, pos = 0; i < sampleLength; i++, pos += channels) + { + if(pos >= sampleLoopEnd) + { + pos = sampleLoopStart; + } + + const T* sample = origSample + pos; + + int16 data = 0; // Enough for 256 channels... :) + for(uint8 chn = 0; chn < channels; chn++) + { + // We only want the MSB. + data += static_cast<int16>(sample[chn] >> ((sizeof(T) - 1) * 8)); + } + + data /= channels; + + sampleData[i] = static_cast<int8>(data); + } +} + + +// Prepare a sample buffer for autocorrelation +bool Autotune::PrepareSample(SmpLength maxShift) +//---------------------------------------------- +{ + + // Determine which parts of the sample should be examined. + SmpLength sampleOffset = 0, sampleLoopStart = 0, sampleLoopEnd = sample.nLength; + if(selectionEnd >= sampleLoopStart + MIN_SAMPLE_LENGTH) + { + // A selection has been specified: Examine selection + sampleOffset = selectionStart; + sampleLoopStart = 0; + sampleLoopEnd = selectionEnd - selectionStart; + } else if((sample.uFlags & CHN_SUSTAINLOOP) && sample.nSustainEnd >= sample.nSustainStart + MIN_SAMPLE_LENGTH) + { + // A sustain loop is set: Examine sample up to sustain loop and, if necessary, execute the loop several times + sampleOffset = 0; + sampleLoopStart = sample.nSustainStart; + sampleLoopEnd = sample.nSustainEnd; + } else if((sample.uFlags & CHN_LOOP) && sample.nLoopEnd >= sample.nLoopStart + MIN_SAMPLE_LENGTH) + { + // A normal loop is set: Examine sample up to loop and, if necessary, execute the loop several times + sampleOffset = 0; + sampleLoopStart = sample.nLoopStart; + sampleLoopEnd = sample.nLoopEnd; + } + + // We should analyse at least a one second (= GetSampleRate() samples) long sample. + sampleLength = max(sampleLoopEnd, sample.GetSampleRate(modType)) + maxShift; + + if(sampleData != nullptr) + { + delete[] sampleData; + } + try + { + sampleData = new int8[sampleLength]; + } catch(MPTMemoryException) + { + return false; + } + + // Copy sample over. + switch(sample.GetElementarySampleSize()) + { + case 1: + CopySamples(reinterpret_cast<int8 *>(sample.pSample) + sampleOffset * sample.GetNumChannels(), sampleLoopStart, sampleLoopEnd); + return true; + + case 2: + CopySamples(reinterpret_cast<int16 *>(sample.pSample) + sampleOffset * sample.GetNumChannels(), sampleLoopStart, sampleLoopEnd); + return true; + } + + return false; + +} + + +bool Autotune::CanApply() const + //----------------------------- +{ + return (sample.pSample != nullptr && sample.nLength >= MIN_SAMPLE_LENGTH); +} + + +bool Autotune::Apply() +//-------------------- +{ + if(!CanApply()) + { + return false; + } + + const int autocorrStartNote = 24 * BINS_PER_NOTE; // C-2 + const int autocorrEndNote = 96 * BINS_PER_NOTE; // C-8 + const int historyBins = 12 * BINS_PER_NOTE; // One octave + + const uint32 sampleFreq = sample.GetSampleRate(modType); + // At the lowest frequency, we get the highest autocorrelation shift amount. + const SmpLength maxShift = NoteToShift(sampleFreq, autocorrStartNote); + if(!PrepareSample(maxShift)) + { + return false; + } + // We don't process the autocorrelation overhead. + const SmpLength processLength = sampleLength - maxShift; + + // Histogram for all notes. + vector<uint64> autocorrHistogram(historyBins, 0); + + // Do autocorrelation and save results in a note histogram (restriced to one octave). + for(int note = autocorrStartNote, noteBin = note; note < autocorrEndNote; note++, noteBin++) + { + + if(noteBin >= historyBins) + { + noteBin %= historyBins; + } + + const SmpLength autocorrShift = NoteToShift(sampleFreq, note); + + uint64 autocorrSum = 0; + const int8 *normalData = sampleData; + const int8 *shiftedData = sampleData + autocorrShift; + // Add up squared differences of all values + for(SmpLength i = processLength; i > 0; i--, normalData++, shiftedData++) + { + autocorrSum += (*normalData - *shiftedData) * (*normalData - *shiftedData); + } + autocorrHistogram[noteBin] += autocorrSum; + + } + + // Interpolate the histogram... + vector<uint64> interpolatedHistogram(historyBins, 0); + for(int i = 0; i < historyBins; i++) + { + const int kernelWidth = 4; + for(int ki = kernelWidth; ki >= 0; ki--) + { + // Choose bins to interpolate with + int left = (int)i - ki; + if(left < 0) left += historyBins; + int right = (int)i + ki; + if(right >= historyBins) right -= historyBins; + + interpolatedHistogram[i] = interpolatedHistogram[i] / 2 + (autocorrHistogram[left] + autocorrHistogram[right]) / 2; + } + } + + // ...and find global minimum + int minimumBin = 0; + //bool decrease = false; + for(int i = 0; i < historyBins; i++) + { + const int prev = (i > 0) ? (i - 1) : (historyBins - 1); + // Are we at a minimum? + //if(interpolatedHistogram[i] > interpolatedHistogram[prev] && decrease) + { + // Are we at the global minimum? + if(interpolatedHistogram[prev] < interpolatedHistogram[minimumBin]) + { + minimumBin = prev; + } + } + //decrease = (interpolatedHistogram[i] < interpolatedHistogram[prev]); + + } + + // Center around C + if(minimumBin >= 6 * BINS_PER_NOTE) minimumBin -= 12 * BINS_PER_NOTE; + const double newFundamentalFreq = NoteToFrequency(69.0 + (double)minimumBin / BINS_PER_NOTE); + + sample.nC5Speed = (UINT)Util::Round(sample.nC5Speed * 440.0 / newFundamentalFreq); + + if((modType & (MOD_TYPE_XM | MOD_TYPE_MOD)) != 0) + { + CSoundFile::FrequencyToTranspose(&sample); + if((modType & MOD_TYPE_MOD) != 0) + { + sample.RelativeTone = 0; + } + } + + return true; +} Added: trunk/OpenMPT/mptrack/Autotune.h =================================================================== --- trunk/OpenMPT/mptrack/Autotune.h (rev 0) +++ trunk/OpenMPT/mptrack/Autotune.h 2011-10-03 16:52:48 UTC (rev 1078) @@ -0,0 +1,56 @@ +/* + * Autotune.h + * ---------- + * Purpose: Header file for sample auto tuning + * Notes : (currently none) + * Authors: OpenMPT Devs + */ + + +#pragma once +#ifndef AUTOTUNE_H +#define AUTOTUNE_H + +#include "../soundlib/Snd_defs.h" + +//============ +class Autotune +//============ +{ +protected: + MODSAMPLE &sample; + MODTYPE modType; + + SmpLength selectionStart, selectionEnd; + + int8 *sampleData; + SmpLength sampleLength; + +public: + Autotune(MODSAMPLE &smp, MODTYPE type, SmpLength selStart, SmpLength selEnd) : sample(smp), modType(type), selectionStart(selStart), selectionEnd(selEnd) + { + sampleData = 0; + sampleLength = 0; + }; + + ~Autotune() + { + delete[] sampleData; + } + + bool CanApply() const; + bool Apply(); + +protected: + double FrequencyToNote(double freq) const; + double NoteToFrequency(double note) const; + SmpLength NoteToShift(uint32 sampleFreq, int note) const; + + template <class T> + void CopySamples(const T* origSample, SmpLength sampleLoopStart, SmpLength sampleLoopEnd); + + bool PrepareSample(SmpLength maxShift); + +}; + +#endif // AUTOTUNE_H Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2011-10-03 16:52:48 UTC (rev 1078) @@ -609,6 +609,7 @@ DefineKeyCommand(kcFileSaveTemplate, 1860, _T("File/Save As Template")); DefineKeyCommand(kcIncreaseSpacing, 1861, _T("Increase row spacing")); DefineKeyCommand(kcDecreaseSpacing, 1862, _T("Decrease row spacing")); + DefineKeyCommand(kcSampleAutotune, 1863, _T("Autotune sample to C")); // Add new key commands here. #ifdef _DEBUG Modified: trunk/OpenMPT/mptrack/CommandSet.h =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.h 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/CommandSet.h 2011-10-03 16:52:48 UTC (rev 1078) @@ -618,7 +618,8 @@ kcSampleRemoveDCOffset, kcSampleQuickFade, kcSampleXFade, - kcEndSampleEditing=kcSampleXFade, + kcSampleAutotune, + kcEndSampleEditing=kcSampleAutotune, //kcSampStartNotes to kcInsNoteMapEndNoteStops must be contiguous. kcSampStartNotes, Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-10-03 16:52:48 UTC (rev 1078) @@ -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 "Autotune.h" #include "../common/StringFixer.h" #include <Shlwapi.h> @@ -72,6 +73,7 @@ ON_COMMAND(IDC_SAMPLE_SIGN_UNSIGN, OnSignUnSign) ON_COMMAND(IDC_SAMPLE_DCOFFSET, OnRemoveDCOffset) ON_COMMAND(IDC_SAMPLE_XFADE, OnXFade) + ON_COMMAND(IDC_SAMPLE_AUTOTUNE, OnAutotune) ON_COMMAND(IDC_CHECK1, OnSetPanningChanged) ON_COMMAND(ID_PREVINSTRUMENT, OnPrevInstrument) ON_COMMAND(ID_NEXTINSTRUMENT, OnNextInstrument) @@ -215,6 +217,7 @@ m_ToolBar2.AddButton(IDC_SAMPLE_INVERT, TIMAGE_SAMPLE_INVERT); m_ToolBar2.AddButton(IDC_SAMPLE_SIGN_UNSIGN, TIMAGE_SAMPLE_UNSIGN); m_ToolBar2.AddButton(IDC_SAMPLE_XFADE, TIMAGE_SAMPLE_FIXLOOP); + m_ToolBar2.AddButton(IDC_SAMPLE_AUTOTUNE, TIMAGE_SAMPLE_AUTOTUNE); // Setup Controls m_SpinVolume.SetRange(0, 64); m_SpinGlobalVol.SetRange(0, 64); @@ -469,7 +472,12 @@ case IDC_SAMPLE_XFADE: OnXFade(); + break; + case IDC_SAMPLE_AUTOTUNE: + OnAutotune(); + break; + case IDC_SAMPLE_SIGN_UNSIGN: OnSignUnSign(); break; @@ -3179,3 +3187,24 @@ } } + +void CCtrlSamples::OnAutotune() +//----------------------------- +{ + SELECTIONPOINTS selection = GetSelectionPoints(); + if(!selection.bSelected) + { + selection.nStart = selection.nEnd = 0; + } + + Autotune at(m_pSndFile->GetSample(m_nSample), m_pSndFile->GetType(), selection.nStart, selection.nEnd); + if(at.CanApply()) + { + BeginWaitCursor(); + m_pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_none); + at.Apply(); + m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEINFO, NULL); + m_pModDoc->SetModified(); + EndWaitCursor(); + } +} Modified: trunk/OpenMPT/mptrack/Ctrl_smp.h =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.h 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/Ctrl_smp.h 2011-10-03 16:52:48 UTC (rev 1078) @@ -90,6 +90,7 @@ afx_msg void OnSilence(); afx_msg void OnInvert(); afx_msg void OnSignUnSign(); + afx_msg void OnAutotune(); afx_msg void OnNameChanged(); afx_msg void OnFileNameChanged(); afx_msg void OnVolumeChanged(); Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2011-10-03 16:52:48 UTC (rev 1078) @@ -289,6 +289,7 @@ TIMAGE_SAMPLE_DCOFFSET, TIMAGE_PATTERN_OVERFLOWPASTE, TIMAGE_SAMPLE_FIXLOOP, + TIMAGE_SAMPLE_AUTOTUNE, }; Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2011-10-03 16:52:48 UTC (rev 1078) @@ -2514,7 +2514,7 @@ CAddSilenceDlg dlg(this, 32, sample.nLength); if (dlg.DoModal() != IDOK) return; - const ctrlSmp::SmpLength nOldLength = sample.nLength; + const SmpLength nOldLength = sample.nLength; if(MAX_SAMPLE_LENGTH - nOldLength < dlg.m_nSamples) { @@ -2672,6 +2672,7 @@ case kcSampleSignUnsign: PostCtrlMessage(IDC_SAMPLE_SIGN_UNSIGN); return wParam; case kcSampleRemoveDCOffset: PostCtrlMessage(IDC_SAMPLE_DCOFFSET); return wParam; case kcSampleXFade: PostCtrlMessage(IDC_SAMPLE_XFADE); return wParam; + case kcSampleAutotune: PostCtrlMessage(IDC_SAMPLE_AUTOTUNE); return wParam; case kcSampleQuickFade: PostCtrlMessage(IDC_SAMPLE_QUICKFADE); return wParam; // Those don't seem to work. Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/mptrack.rc 2011-10-03 16:52:48 UTC (rev 1078) @@ -2546,6 +2546,7 @@ STRINGTABLE BEGIN IDC_SAMPLE_XFADE "Crossfade Loop Points\nCrossfade between loop start and loop end to create seamless sample loops." + IDC_SAMPLE_AUTOTUNE "Autotune sample to C\nTune the sample to the closest C." END #endif // English (United States) resources Modified: trunk/OpenMPT/mptrack/mptrack.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack.vcproj 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/mptrack.vcproj 2011-10-03 16:52:48 UTC (rev 1078) @@ -187,6 +187,9 @@ RelativePath=".\AutoSaver.cpp"> </File> <File + RelativePath=".\Autotune.cpp"> + </File> + <File RelativePath=".\ChannelManagerDlg.cpp"> </File> <File @@ -678,6 +681,9 @@ RelativePath=".\AutoSaver.h"> </File> <File + RelativePath=".\Autotune.h"> + </File> + <File RelativePath=".\ChannelManagerDlg.h"> </File> <File Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2011-10-03 16:52:48 UTC (rev 1078) @@ -253,6 +253,10 @@ > </File> <File + RelativePath=".\Autotune.cpp" + > + </File> + <File RelativePath=".\ChannelManagerDlg.cpp" > </File> @@ -899,6 +903,10 @@ > </File> <File + RelativePath=".\Autotune.h" + > + </File> + <File RelativePath=".\ChannelManagerDlg.h" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2011-10-03 16:52:48 UTC (rev 1078) @@ -171,6 +171,7 @@ <ClCompile Include="ACMConvert.cpp" /> <ClCompile Include="ArrayUtils.cpp" /> <ClCompile Include="AutoSaver.cpp" /> + <ClCompile Include="Autotune.cpp" /> <ClCompile Include="ChannelManagerDlg.cpp" /> <ClCompile Include="ChildFrm.cpp" /> <ClCompile Include="CleanupSong.cpp" /> @@ -323,6 +324,7 @@ <ClInclude Include="..\common\StringFixer.h" /> <ClInclude Include="..\common\typedefs.h" /> <ClInclude Include="ACMConvert.h" /> + <ClInclude Include="Autotune.h" /> <ClInclude Include="ExceptionHandler.h" /> <ClInclude Include="PatternRandomizer.h" /> <ClInclude Include="PatternRandomizerGUI.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2011-10-03 16:52:48 UTC (rev 1078) @@ -430,6 +430,9 @@ <ClCompile Include="MIDIMappingDialog.cpp"> <Filter>Source Files\Dialogs</Filter> </ClCompile> + <ClCompile Include="Autotune.cpp"> + <Filter>Source Files</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="AbstractVstEditor.h"> @@ -753,6 +756,9 @@ <ClInclude Include="MIDIMappingDialog.h"> <Filter>Header Files\Dialogs</Filter> </ClInclude> + <ClInclude Include="Autotune.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> Modified: trunk/OpenMPT/mptrack/res/patterns.bmp =================================================================== (Binary files differ) Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/resource.h 2011-10-03 16:52:48 UTC (rev 1078) @@ -946,6 +946,7 @@ #define IDC_SAMPLE_XFADE 2434 #define IDC_LASTUPDATE 2435 #define IDC_RESTORE_KEYMAP 2436 +#define IDC_SAMPLE_AUTOTUNE 2437 #define ID_FILE_NEWMOD 32771 #define ID_FILE_NEWXM 32772 #define ID_FILE_NEWS3M 32773 @@ -1214,7 +1215,7 @@ #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 531 #define _APS_NEXT_COMMAND_VALUE 44462 -#define _APS_NEXT_CONTROL_VALUE 2437 +#define _APS_NEXT_CONTROL_VALUE 2438 #define _APS_NEXT_SYMED_VALUE 901 #endif #endif Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/mptrack/version.h 2011-10-03 16:52:48 UTC (rev 1078) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 35 +#define VER_MINORMINOR 36 //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_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2011-10-03 16:52:48 UTC (rev 1078) @@ -41,6 +41,8 @@ const SEQUENCEINDEX SEQUENCEINDEX_INVALID = SEQUENCEINDEX_MAX; typedef uint32 MODTYPE; +typedef uintptr_t SmpLength; + #define MAX_PATTERN_ROWS 1024 // -> CODE#0008 -> DESC="#define to set pattern size" -! BEHAVIOUR_CHANGE#0008 Modified: trunk/OpenMPT/soundlib/modsmp_ctrl.cpp =================================================================== --- trunk/OpenMPT/soundlib/modsmp_ctrl.cpp 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/soundlib/modsmp_ctrl.cpp 2011-10-03 16:52:48 UTC (rev 1078) @@ -579,7 +579,7 @@ void ReplaceSample( MODCHANNEL (&Chn)[MAX_CHANNELS], LPCSTR pOldSample, LPSTR pNewSample, - const ctrlSmp::SmpLength nNewLength, + const SmpLength nNewLength, DWORD orFlags /* = 0*/, DWORD andFlags /* = MAXDWORD*/) { Modified: trunk/OpenMPT/soundlib/modsmp_ctrl.h =================================================================== --- trunk/OpenMPT/soundlib/modsmp_ctrl.h 2011-10-03 14:26:14 UTC (rev 1077) +++ trunk/OpenMPT/soundlib/modsmp_ctrl.h 2011-10-03 16:52:48 UTC (rev 1078) @@ -10,8 +10,6 @@ namespace ctrlSmp { -typedef uintptr_t SmpLength; - enum ResetFlag { SmpResetCompo = 1, @@ -33,7 +31,7 @@ // 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); -bool AdjustEndOfSample(MODSAMPLE &smp, CSoundFile* pSndFile = 0); +bool AdjustEndOfSample(MODSAMPLE &smp, CSoundFile *pSndFile = nullptr); // 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 @@ -77,7 +75,7 @@ void ReplaceSample( MODCHANNEL (&Chn)[MAX_CHANNELS], LPCSTR pOldSample, LPSTR pNewSample, - const ctrlSmp::SmpLength nNewLength, + const SmpLength nNewLength, DWORD orFlags = 0, DWORD andFlags = MAXDWORD); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-10-04 14:34:15
|
Revision: 1083 http://modplug.svn.sourceforge.net/modplug/?rev=1083&view=rev Author: saga-games Date: 2011-10-04 14:34:04 +0000 (Tue, 04 Oct 2011) Log Message: ----------- [Imp] Mod Conversion: When converting to XM, samples are automatically converted to instruments if there are no instruments yet. [Fix] XM Saver: Saving an XM with only samples, garbage extended instrument settings were written. Modified Paths: -------------- trunk/OpenMPT/mptrack/ModConvert.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/soundlib/Load_xm.cpp Modified: trunk/OpenMPT/mptrack/ModConvert.cpp =================================================================== --- trunk/OpenMPT/mptrack/ModConvert.cpp 2011-10-04 13:45:05 UTC (rev 1082) +++ trunk/OpenMPT/mptrack/ModConvert.cpp 2011-10-04 14:34:04 UTC (rev 1083) @@ -513,6 +513,12 @@ UpdateEnvelopes(&(m_SndFile.Instruments[i]->PanEnv), &m_SndFile, warnings); UpdateEnvelopes(&(m_SndFile.Instruments[i]->PitchEnv), &m_SndFile, warnings); } + + // XM requires instruments, so we create them right away. + if(newTypeIsXM && GetNumInstruments() == 0) + { + ConvertSamplesToInstruments(); + } CHAR s[64]; CHANGEMODTYPE_CHECK(wInstrumentsToSamples, "All instruments have been converted to samples.\n"); Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2011-10-04 13:45:05 UTC (rev 1082) +++ trunk/OpenMPT/mptrack/Moddoc.h 2011-10-04 14:34:04 UTC (rev 1083) @@ -286,6 +286,7 @@ void CheckUsedChannels(vector<bool> &usedMask, CHANNELINDEX maxRemoveCount = MAX_BASECHANNELS) const; bool ConvertInstrumentsToSamples(); + bool ConvertSamplesToInstruments(); UINT RemovePlugs(const vector<bool> &keepMask); PATTERNINDEX InsertPattern(ORDERINDEX nOrd = ORDERINDEX_INVALID, ROWINDEX nRows = 64); Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2011-10-04 13:45:05 UTC (rev 1082) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2011-10-04 14:34:04 UTC (rev 1083) @@ -341,12 +341,51 @@ //----------------------------------------- { if (!m_SndFile.GetNumInstruments()) + { return false; + } m_SndFile.Patterns.ForEachModCommand(ConvertInstrumentsToSamplesInPatterns(&m_SndFile)); return true; } +bool CModDoc::ConvertSamplesToInstruments() +//----------------------------------------- +{ + if(GetNumInstruments() > 0) + { + return false; + } + + const INSTRUMENTINDEX nInstrumentMax = m_SndFile.GetModSpecifications().instrumentsMax - 1; + const SAMPLEINDEX nInstruments = min(m_SndFile.GetNumSamples(), nInstrumentMax); + + for(SAMPLEINDEX smp = 1; smp <= nInstruments; smp++) + { + const bool muted = IsSampleMuted(smp); + MuteSample(smp, false); + + try + { + m_SndFile.Instruments[smp] = new MODINSTRUMENT(smp); + } catch(MPTMemoryException) + { + ErrorBox(IDS_ERR_OUTOFMEMORY, CMainFrame::GetMainFrame()); + return false; + } + + InitializeInstrument(m_SndFile.Instruments[smp]); + lstrcpyn(m_SndFile.Instruments[smp]->name, m_SndFile.m_szNames[smp], MAX_INSTRUMENTNAME); + MuteInstrument(smp, muted); + } + + m_SndFile.m_nInstruments = nInstruments; + + return true; + +} + + UINT CModDoc::RemovePlugs(const vector<bool> &keepMask) //----------------------------------------------------- { @@ -491,27 +530,10 @@ } if (result == cnfYes) { - SAMPLEINDEX nInstruments = m_SndFile.m_nSamples; - if (nInstruments > nInstrumentMax) nInstruments = nInstrumentMax; - for (SAMPLEINDEX smp = 1; smp <= nInstruments; smp++) + if(!ConvertSamplesToInstruments()) { - m_SndFile.GetSample(smp).uFlags &= ~CHN_MUTE; - if (!m_SndFile.Instruments[smp]) - { - try - { - MODINSTRUMENT *p = new MODINSTRUMENT(smp); - m_SndFile.Instruments[smp] = p; - } catch(MPTMemoryException) - { - ErrorBox(IDS_ERR_OUTOFMEMORY, CMainFrame::GetMainFrame()); - return INSTRUMENTINDEX_INVALID; - } - InitializeInstrument(m_SndFile.Instruments[smp]); - lstrcpyn(m_SndFile.Instruments[smp]->name, m_SndFile.m_szNames[smp], MAX_INSTRUMENTNAME); - } + return INSTRUMENTINDEX_INVALID; } - m_SndFile.m_nInstruments = nInstruments; } } UINT newins = 0; @@ -1029,8 +1051,8 @@ } // Note - if (s[0] > ' ' && (!doMixPaste || ((!doITStyleMix && origModCmd.note==0) || - (doITStyleMix && origModCmd.note==0 && origModCmd.instr==0 && origModCmd.volcmd==0)))) + if (s[0] > ' ' && (!doMixPaste || ((!doITStyleMix && origModCmd.note == NOTE_NONE) || + (doITStyleMix && origModCmd.note == NOTE_NONE && origModCmd.instr == 0 && origModCmd.volcmd == VOLCMD_NONE)))) { m[col].note = NOTE_NONE; if (s[0] == '=') m[col].note = NOTE_KEYOFF; else @@ -1055,7 +1077,7 @@ } // Instrument if (s[3] > ' ' && (!doMixPaste || ( (!doITStyleMix && origModCmd.instr==0) || - (doITStyleMix && origModCmd.note==0 && origModCmd.instr==0 && origModCmd.volcmd==0) ) )) + (doITStyleMix && origModCmd.note == NOTE_NONE && origModCmd.instr == 0 && origModCmd.volcmd == VOLCMD_NONE) ) )) { if ((s[3] >= '0') && (s[3] <= ('0'+(MAX_SAMPLES/10)))) @@ -1065,7 +1087,7 @@ } // Volume if (s[5] > ' ' && (!doMixPaste || ((!doITStyleMix && origModCmd.volcmd==0) || - (doITStyleMix && origModCmd.note==0 && origModCmd.instr==0 && origModCmd.volcmd==0)))) + (doITStyleMix && origModCmd.note == NOTE_NONE && origModCmd.instr == 0 && origModCmd.volcmd == VOLCMD_NONE)))) { if (s[5] != '.') Modified: trunk/OpenMPT/soundlib/Load_xm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_xm.cpp 2011-10-04 13:45:05 UTC (rev 1082) +++ trunk/OpenMPT/soundlib/Load_xm.cpp 2011-10-04 14:34:04 UTC (rev 1083) @@ -271,7 +271,6 @@ m_nMinPeriod = 27; m_nMaxPeriod = 54784; - if (xmheader.orders > MAX_ORDERS) return false; if ((!xmheader.channels) || (xmheader.channels > MAX_BASECHANNELS)) return false; if (xmheader.channels > 32) bMadeWithModPlug = true; m_nRestartPos = xmheader.restartpos; @@ -346,10 +345,6 @@ xmsh.shsize = LittleEndian(xmsh.shsize); if(xmsh.shsize == 0 && bProbablyMadeWithModPlug) bMadeWithModPlug = true; - for (int i = 0; i < 24; ++i) { - xmsh.venv[i] = LittleEndianW(xmsh.venv[i]); - xmsh.penv[i] = LittleEndianW(xmsh.penv[i]); - } xmsh.volfade = LittleEndianW(xmsh.volfade); xmsh.midiprogram = LittleEndianW(xmsh.midiprogram); xmsh.pitchwheelrange = LittleEndianW(xmsh.pitchwheelrange); @@ -463,12 +458,12 @@ 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; - for (UINT ienv=0; ienv<12; ienv++) + for (UINT ienv = 0; ienv < 12; ienv++) { - pIns->VolEnv.Ticks[ienv] = (WORD)xmsh.venv[ienv * 2]; - 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]; + pIns->VolEnv.Ticks[ienv] = (WORD)LittleEndianW(xmsh.venv[ienv * 2]); + pIns->VolEnv.Values[ienv] = (BYTE)LittleEndianW(xmsh.venv[ienv * 2 + 1]); + pIns->PanEnv.Ticks[ienv] = (WORD)LittleEndianW(xmsh.penv[ienv * 2]); + pIns->PanEnv.Values[ienv] = (BYTE)LittleEndianW(xmsh.penv[ienv * 2 + 1]); if (ienv > 0) { // libmikmod code says: "Some broken XM editing program will only save the low byte of the position @@ -744,9 +739,6 @@ //BYTE s[64*64*5]; vector<BYTE> s(64*64*5, 0); XMFILEHEADER xmheader; - XMINSTRUMENTHEADER xmih; - XMSAMPLEHEADER xmsh; - XMSAMPLESTRUCT xmss; BYTE xmph[9]; FILE *f; int i; @@ -936,6 +928,8 @@ // Writing instruments for (i = 1; i <= xmheader.instruments; i++) { + XMINSTRUMENTHEADER xmih; + XMSAMPLEHEADER xmsh; WORD smptable[32]; BYTE flags[32]; @@ -948,7 +942,7 @@ xmih.samples = 0; if (m_nInstruments) { - MODINSTRUMENT *pIns = Instruments[i]; + const MODINSTRUMENT *pIns = Instruments[i]; if (pIns) { memcpy(xmih.name, pIns->name, 22); @@ -958,12 +952,12 @@ xmsh.pnum = (BYTE)pIns->PanEnv.nNodes; if (xmsh.vnum > 12) xmsh.vnum = 12; if (xmsh.pnum > 12) xmsh.pnum = 12; - for (UINT ienv=0; ienv<12; ienv++) + for (UINT ienv = 0; ienv < 12; ienv++) { - xmsh.venv[ienv*2] = LittleEndianW(pIns->VolEnv.Ticks[ienv]); - xmsh.venv[ienv*2+1] = LittleEndianW(pIns->VolEnv.Values[ienv]); - xmsh.penv[ienv*2] = LittleEndianW(pIns->PanEnv.Ticks[ienv]); - xmsh.penv[ienv*2+1] = LittleEndianW(pIns->PanEnv.Values[ienv]); + xmsh.venv[ienv * 2] = LittleEndianW(pIns->VolEnv.Ticks[ienv]); + xmsh.venv[ienv * 2 + 1] = LittleEndianW(pIns->VolEnv.Values[ienv]); + xmsh.penv[ienv * 2] = LittleEndianW(pIns->PanEnv.Ticks[ienv]); + xmsh.penv[ienv * 2 + 1] = LittleEndianW(pIns->PanEnv.Values[ienv]); } if (pIns->VolEnv.dwFlags & ENV_ENABLED) xmsh.vtype |= 1; if (pIns->VolEnv.dwFlags & ENV_SUSTAIN) xmsh.vtype |= 2; @@ -977,13 +971,13 @@ xmsh.psustain = (BYTE)pIns->PanEnv.nSustainStart; xmsh.ploops = (BYTE)pIns->PanEnv.nLoopStart; xmsh.ploope = (BYTE)pIns->PanEnv.nLoopEnd; - for (UINT j=0; j<96; j++) if (pIns->Keyboard[j+12]) // for all notes + for (UINT j = 0; j < 96; j++) if (pIns->Keyboard[j + 12]) // for all notes { UINT k; - UINT sample = pIns->Keyboard[j+12]; + UINT sample = pIns->Keyboard[j + 12]; // Check to see if sample mapped to this note is already accounted for in this instrument - for (k=0; k<xmih.samples; k++) + for (k = 0; k < xmih.samples; k++) { if (smptable[k] == sample) { @@ -1021,6 +1015,7 @@ if (!xmih.samples) continue; for (UINT ins = 0; ins < samples; ins++) { + XMSAMPLESTRUCT xmss; MemsetZero(xmss); if (smptable[ins]) memcpy(xmss.name, m_szNames[smptable[ins]], 22); const MODSAMPLE &sample = Samples[smptable[ins]]; @@ -1142,7 +1137,7 @@ //Save hacked-on extra info SaveMixPlugins(f); - SaveExtendedInstrumentProperties(xmheader.instruments, f); + SaveExtendedInstrumentProperties(min(GetNumInstruments(), xmheader.instruments), f); SaveExtendedSongProperties(f); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |