From: <sag...@us...> - 2009-08-03 19:20:40
|
Revision: 312 http://modplug.svn.sourceforge.net/modplug/?rev=312&view=rev Author: saga-games Date: 2009-08-03 19:20:23 +0000 (Mon, 03 Aug 2009) Log Message: ----------- [Imp] Instrument editor: Added "Map all notes to <note name>" to instrument mapping context menu [Fix] Instrument editor: Playing correct note in the instrument mapping control (notable difference when editing the scale from bottom to top) [Fix] IT Compatibility: Tremor also works properly with "old effects" on [Fix] IT Compatibility: Fixed retrigger for Qxx when not being triggered together with a note [Fix] XM Saver: Always save with a channel number that's a multiple of two so FT2 will load the file correctly [Imp] VST loading: Included pelya's fix for VSTs that share the same UID (fixes problems with JS Plugins series) [Ref] Making use of the SONG_FIRSTTICK flag where possible Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Ctrl_ins.h trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/resource.h trunk/OpenMPT/soundlib/Load_xm.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2009-07-31 12:56:26 UTC (rev 311) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2009-08-03 19:20:23 UTC (rev 312) @@ -31,7 +31,8 @@ ON_WM_LBUTTONDOWN() ON_WM_RBUTTONDOWN() ON_WM_LBUTTONDBLCLK() - ON_COMMAND(ID_NOTEMAP_COPY, OnMapCopy) + ON_COMMAND(ID_NOTEMAP_COPY_NOTE, OnMapCopyNote) + ON_COMMAND(ID_NOTEMAP_COPY_SMP, OnMapCopySample) ON_COMMAND(ID_NOTEMAP_RESET, OnMapReset) ON_COMMAND(ID_INSTRUMENT_SAMPLEMAP, OnEditSampleMap) ON_COMMAND(ID_INSTRUMENT_DUPLICATE, OnInstrumentDuplicate) @@ -318,7 +319,9 @@ AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); } wsprintf(s, "Map all notes to sample %d", penv->Keyboard[m_nNote]); - AppendMenu(hMenu, MF_STRING, ID_NOTEMAP_COPY, s); + AppendMenu(hMenu, MF_STRING, ID_NOTEMAP_COPY_SMP, s); + wsprintf(s, "Map all notes to %s", GetNoteStr(penv->NoteMap[m_nNote])); + AppendMenu(hMenu, MF_STRING, ID_NOTEMAP_COPY_NOTE, s); AppendMenu(hMenu, MF_STRING, ID_NOTEMAP_RESET, "Reset note mapping"); AppendMenu(hMenu, MF_STRING, ID_INSTRUMENT_DUPLICATE, "Duplicate Instrument\tShift+New"); SetMenuDefaultItem(hMenu, ID_INSTRUMENT_SAMPLEMAP, FALSE); @@ -332,8 +335,8 @@ } -void CNoteMapWnd::OnMapCopy() -//--------------------------- +void CNoteMapWnd::OnMapCopyNote() +//------------------------------- { if (m_pModDoc) { @@ -345,6 +348,34 @@ if (penv) { BOOL bModified = FALSE; + UINT n = penv->NoteMap[m_nNote]; + for (UINT i=0; i<NOTE_MAX; i++) if (penv->NoteMap[i] != n) + { + penv->NoteMap[i] = n; + bModified = TRUE; + } + if (bModified) + { + m_pModDoc->SetModified(); + InvalidateRect(NULL, FALSE); + } + } + } +} + +void CNoteMapWnd::OnMapCopySample() +//------------------------------------- +{ + if (m_pModDoc) + { + CSoundFile *pSndFile; + INSTRUMENTHEADER *penv; + + pSndFile = m_pModDoc->GetSoundFile(); + penv = pSndFile->Headers[m_nInstrument]; + if (penv) + { + BOOL bModified = FALSE; UINT n = penv->Keyboard[m_nNote]; for (UINT i=0; i<NOTE_MAX; i++) if (penv->Keyboard[i] != n) { @@ -467,8 +498,8 @@ } if (bOk) { + PlayNote(m_nNote + 1); //SetCurrentNote(m_nNote+1); - PlayNote(m_nNote); } } Modified: trunk/OpenMPT/mptrack/Ctrl_ins.h =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.h 2009-07-31 12:56:26 UTC (rev 311) +++ trunk/OpenMPT/mptrack/Ctrl_ins.h 2009-08-03 19:20:23 UTC (rev 312) @@ -47,7 +47,8 @@ afx_msg void OnKillFocus(CWnd *pNewWnd); afx_msg BOOL OnEraseBkGnd(CDC *) { return TRUE; } afx_msg void OnPaint(); - afx_msg void OnMapCopy(); + afx_msg void OnMapCopySample(); + afx_msg void OnMapCopyNote(); afx_msg void OnMapReset(); afx_msg void OnEditSample(UINT nID); afx_msg void OnEditSampleMap(); Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2009-07-31 12:56:26 UTC (rev 311) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2009-08-03 19:20:23 UTC (rev 312) @@ -14,6 +14,7 @@ #include "defaultvsteditor.h" //rewbs.defaultPlugGUI #include "midi.h" #include "version.h" +#include "Unzip32.h" //For CRC calculation (to detect plugins with same UID) #ifndef NO_VST @@ -33,7 +34,28 @@ AEffect *DmoToVst(PVSTPLUGINLIB pLib); +class CalculateCRC32: public CZipArchive // Make Plugin ID unique for sure +{ + public: + DWORD calculate( BYTE *s, int len ) + { + CZipArchive::crc32val = 0xFFFFFFFFL; + CZipArchive::UpdateCRC( s, len ); + return CZipArchive::crc32val; + }; + DWORD calculateFilename( const char * s ) + { + char fn[_MAX_PATH]; + strncpy( fn, s, sizeof(fn) ); + fn[sizeof(fn)-1] = 0; + int f; + for( f=0; fn[f] != 0; f++ ) fn[f] = toupper( fn[f] ); + return calculate( (BYTE *)fn, f ); + }; +}; +CalculateCRC32 CRC32; + long VSTCALLBACK CVstPluginManager::MasterCallBack(AEffect *effect, long opcode, long index, long value, void *ptr, float opt) //---------------------------------------------------------------------------------------------------------------------------- { @@ -230,6 +252,10 @@ flagKey.Format("%s.Flags", IDs); int infoex = CMainFrame::GetPrivateProfileLong(cacheSection, flagKey, 0, cacheFile); if (infoex&1) p->bIsInstrument = TRUE; + if( p->dwPluginId1 == kEffectMagic ) + { + p->dwPluginId1 = CRC32.calculateFilename( p->szLibraryName ); // Make Plugin ID unique for sure (for VSTs with same UID) + }; #ifdef VST_LOG Log("Plugin \"%s\" found in PluginCache\n", p->szLibraryName); #endif @@ -295,7 +321,8 @@ && (pEffect->dispatcher)) { pEffect->dispatcher(pEffect, effOpen, 0,0,0,0); - p->dwPluginId1 = pEffect->magic; + //p->dwPluginId1 = pEffect->magic; + p->dwPluginId1 = CRC32.calculateFilename( p->szLibraryName ); // Make Plugin ID unique for sure p->dwPluginId2 = pEffect->uniqueID; if ((pEffect->flags & effFlagsIsSynth) || (!pEffect->numInputs)) p->bIsInstrument = TRUE; #ifdef VST_LOG Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2009-07-31 12:56:26 UTC (rev 311) +++ trunk/OpenMPT/mptrack/resource.h 2009-08-03 19:20:23 UTC (rev 312) @@ -940,7 +940,7 @@ #define ID_SAMPLE_SETLOOPEND 32831 #define ID_SAMPLE_SETSUSTAINSTART 32832 #define ID_SAMPLE_SETSUSTAINEND 32833 -#define ID_NOTEMAP_COPY 32834 +#define ID_NOTEMAP_COPY_SMP 32834 #define ID_NOTEMAP_RESET 32835 #define ID_PATTERN_INTERPOLATE_VOLUME 32836 #define ID_PATTERN_INTERPOLATE_EFFECT 32837 @@ -1108,6 +1108,7 @@ #define ID_SAMPLE_DRAW 59224 #define ID_SAMPLE_ADDSILENCE 59225 #define ID_ECHOPASTE 59226 +#define ID_NOTEMAP_COPY_NOTE 59227 // Next default values for new objects // @@ -1115,7 +1116,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 519 -#define _APS_NEXT_COMMAND_VALUE 59227 +#define _APS_NEXT_COMMAND_VALUE 59228 #define _APS_NEXT_CONTROL_VALUE 2386 #define _APS_NEXT_SYMED_VALUE 901 #endif Modified: trunk/OpenMPT/soundlib/Load_xm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_xm.cpp 2009-07-31 12:56:26 UTC (rev 311) +++ trunk/OpenMPT/soundlib/Load_xm.cpp 2009-08-03 19:20:23 UTC (rev 312) @@ -656,6 +656,17 @@ BOOL CSoundFile::SaveXM(LPCSTR lpszFileName, UINT nPacking) //--------------------------------------------------------- { + #define ASSERT_CAN_WRITE(x) \ + if(len > s.size() - x) /*Buffer running out? Make it larger.*/ \ + s.resize(s.size() + 10*1024, 0); \ + \ + if(len > uint16_max - (UINT)x) /*Reaching the limits of file format?*/ \ + { \ + CString str; str.Format("%s (%s %u)", str_tooMuchPatternData, str_pattern, i); \ + MessageBox(0, str, str_MBtitle, MB_ICONWARNING); \ + break; \ + } + //BYTE s[64*64*5]; vector<BYTE> s(64*64*5, 0); XMFILEHEADER header; @@ -665,6 +676,7 @@ BYTE xmph[9]; FILE *f; int i; + BOOL bAddChannel; // avoid odd channel count for FT2 compatibility if ((!m_nChannels) || (!lpszFileName)) return FALSE; if ((f = fopen(lpszFileName, "wb")) == NULL) return FALSE; @@ -680,7 +692,9 @@ header.size = sizeof(XMFILEHEADER); header.norder = 0; header.restartpos = m_nRestartPos; - header.channels = m_nChannels; + header.channels = (m_nChannels + 1) & 0xFE; // avoid odd channel count for FT2 compatibility + if(m_nChannels & 1) bAddChannel = true; + header.patterns = 0; /*for (i=0; i<MAX_ORDERS; i++) { header.norder++; @@ -767,15 +781,14 @@ if (b & 8) s[len++] = command; if (b & 16) s[len++] = param; } - if(len > s.size() - 5) //Buffer running out? Make it larger. - s.resize(s.size() + 10*1024, 0); - if(len > uint16_max - 5u) //Reaching the limits of file format? + if(bAddChannel && !(j % m_nChannels)) { - CString str; str.Format("%s (%s %u)", str_tooMuchPatternData, str_pattern, i); - MessageBox(0, str, str_MBtitle, MB_ICONWARNING); - break; + ASSERT_CAN_WRITE(1); + s[len++] = 0x80; } + + ASSERT_CAN_WRITE(5); } xmph[7] = (BYTE)(len & 0xFF); xmph[8] = (BYTE)(len >> 8); Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2009-07-31 12:56:26 UTC (rev 311) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2009-08-03 19:20:23 UTC (rev 312) @@ -1195,7 +1195,7 @@ continue; } } else - if (!m_nTickCount) + if(m_dwSongFlags & SONG_FIRSTTICK) { // Pattern Loop ? if ((((param & 0xF0) == 0x60) && (cmd == CMD_MODCMDEX)) @@ -1467,7 +1467,7 @@ // -> NEW_FEATURE#0010 // Set Volume case CMD_VOLUME: - if (!m_nTickCount) + if(m_dwSongFlags & SONG_FIRSTTICK) { pChn->nVolume = (param < 64) ? param*4 : 256; pChn->dwFlags |= CHN_FASTVOLRAMP; @@ -1515,13 +1515,12 @@ // Set Speed case CMD_SPEED: - if (!m_nTickCount) SetSpeed(param); + if(m_dwSongFlags & SONG_FIRSTTICK) + SetSpeed(param); break; // Set Tempo case CMD_TEMPO: - //if (!m_nTickCount) //commented out for rewbs.tempoSlideFix - //{ // -> CODE#0010 // -> DESC="add extended parameter mechanism to pattern effects" m = NULL; @@ -1552,7 +1551,8 @@ // Arpeggio case CMD_ARPEGGIO: - if ((m_nTickCount) || (!pChn->nPeriod) || (!pChn->nNote)) break; + // IT compatibility 01. Don't ignore Arpeggio if no note is playing + if ((m_nTickCount) || (((!pChn->nPeriod) || !pChn->nNote) && !((m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT)) && GetModFlag(MSF_COMPATIBLE_PLAY)))) break; if ((!param) && (!(m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT)))) break; pChn->nCommand = CMD_ARPEGGIO; if (param) pChn->nArpeggio = param; @@ -1597,14 +1597,33 @@ // Tremor case CMD_TREMOR: - if (m_nTickCount) break; + if (!(m_dwSongFlags & SONG_FIRSTTICK)) break; + + if((m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT)) && GetModFlag(MSF_COMPATIBLE_PLAY)) + { + // IT compatibility 12. / 13. Tremor (using modified DUMB's Tremor logic here because of old effects - http://dumb.sf.net/) + + if (param && !(m_dwSongFlags & SONG_ITOLDEFFECTS)) { + // Old effects have different length interpretation (+1 for both on and off) + if (param & 0xf0) param -= 0x10; + if (param & 0x0f) param -= 0x01; + } + pChn->nTremorCount |= 128; // set on/off flag + + } + else + { + // XM Tremor. Logic is being processed in sndmix.cpp + } + pChn->nCommand = CMD_TREMOR; if (param) pChn->nTremorParam = param; + break; // Set Global Volume case CMD_GLOBALVOLUME: - if (m_nTickCount) break; + if (!(m_dwSongFlags & SONG_FIRSTTICK)) break; if (!(m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT))) param <<= 1; if(GetModFlag(MSF_COMPATIBLE_PLAY)) @@ -1631,7 +1650,7 @@ // Set 8-bit Panning case CMD_PANNING8: - if (m_nTickCount) break; + if (!(m_dwSongFlags & SONG_FIRSTTICK)) break; if (!(m_dwSongFlags & SONG_SURROUNDPAN)) pChn->dwFlags &= ~CHN_SURROUND; if (m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT|MOD_TYPE_XM|MOD_TYPE_MT2)) { @@ -1704,7 +1723,8 @@ else { // This is how it's NOT supposed to sound... - if (!m_nTickCount) KeyOff(nChn); + if(m_dwSongFlags & SONG_FIRSTTICK) + KeyOff(nChn); } break; @@ -1745,7 +1765,7 @@ // Set Envelope Position case CMD_SETENVPOSITION: - if (!m_nTickCount) + if(m_dwSongFlags & SONG_FIRSTTICK) { pChn->nVolEnvPosition = param; @@ -1831,7 +1851,7 @@ } // Navigation Effects - if (!m_nTickCount) + if(m_dwSongFlags & SONG_FIRSTTICK) { // Pattern Loop if (nPatLoopRow >= 0) @@ -2435,10 +2455,9 @@ // E7x: Set Tremolo WaveForm case 0x70: pChn->nTremoloType = param & 0x07; break; // E8x: Set 4-bit Panning - //case 0x80: if (!m_nTickCount) { pChn->nPan = (param << 4) + 8; pChn->dwFlags |= CHN_FASTVOLRAMP; } break; - case 0x80: if (!m_nTickCount) + case 0x80: if(m_dwSongFlags & SONG_FIRSTTICK) { - //IT compatibility (Panning always resets surround state) + //IT compatibility 20. (Panning always resets surround state) if( TypeIsIT_MPT_XM() == false || GetModFlag(MSF_COMPATIBLE_PLAY) ) { if (!(m_dwSongFlags & SONG_SURROUNDPAN)) pChn->dwFlags &= ~CHN_SURROUND; @@ -2520,8 +2539,7 @@ } break; // S8x: Set 4-bit Panning - //case 0x80: if (!m_nTickCount) { pChn->nPan = (param << 4) + 8; pChn->dwFlags |= CHN_FASTVOLRAMP; } break; - case 0x80: if (!m_nTickCount) + case 0x80: if(m_dwSongFlags & SONG_FIRSTTICK) { if( TypeIsIT_MPT_XM() == false || GetModFlag(MSF_COMPATIBLE_PLAY) ) { @@ -2537,7 +2555,7 @@ // S9x: Sound Control case 0x90: ExtendedChannelEffect(pChn, param & 0x0F); break; // SAx: Set 64k Offset - case 0xA0: if (!m_nTickCount) + case 0xA0: if(m_dwSongFlags & SONG_FIRSTTICK) { pChn->nOldHiOffset = param; if ((pChn->nRowNote) && (pChn->nRowNote < 0x80)) @@ -2794,7 +2812,7 @@ if (dwMacro != 0x30463046 && dwMacro != 0x31463046) { // we don't cater for external devices at tick resolution. - if (!m_nTickCount) { + if(m_dwSongFlags & SONG_FIRSTTICK) { ProcessMidiMacro(nChn, pszMidiMacro, param); } return; @@ -3014,7 +3032,7 @@ if(GetModFlag(MSF_COMPATIBLE_PLAY) && (m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT))) { //IT compatibility 15. Retrigger - if (!m_nTickCount && pChn->nRowNote) + if ((m_dwSongFlags & SONG_FIRSTTICK) && pChn->nRowNote) { pChn->nRetrigCount = param & 0xf; } @@ -3264,7 +3282,7 @@ } else { - if (param >= 0x20 && !m_nTickCount) //rewbs.tempoSlideFix: only set if not (T0x or T1x) and tick is 0 + if (param >= 0x20 && (m_dwSongFlags & SONG_FIRSTTICK)) //rewbs.tempoSlideFix: only set if not (T0x or T1x) and tick is 0 { m_nMusicTempo = param; } Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2009-07-31 12:56:26 UTC (rev 311) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2009-08-03 19:20:23 UTC (rev 312) @@ -639,8 +639,7 @@ //IT compatibility 15. Retrigger if(GetModFlag(MSF_COMPATIBLE_PLAY) && (m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT))) { - Chn[ich].nRetrigParam = 1; - Chn[ich].nRetrigCount = 0; + Chn[ich].nRetrigParam = Chn[ich].nRetrigCount = 1; } } // Checking instruments @@ -1193,7 +1192,7 @@ Chn[j].nRetrigCount = 0; Chn[j].nRetrigParam = 1; } - Chn[j].nTremorCount = Chn[j].nTremorOn = Chn[j].nTremorOff = 0; + Chn[j].nTremorCount = 0; } if (!nPos) { @@ -1459,7 +1458,7 @@ Chn[i].nRetrigParam = 1; Chn[i].nRetrigCount = 0; } - Chn[i].nTremorCount = Chn[i].nTremorOn = Chn[i].nTremorOff = 0; + Chn[i].nTremorCount = 0; } if(resetMask & 4) Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2009-07-31 12:56:26 UTC (rev 311) +++ trunk/OpenMPT/soundlib/Sndfile.h 2009-08-03 19:20:23 UTC (rev 312) @@ -546,7 +546,7 @@ BYTE nOldOffset, nOldHiOffset; BYTE nCutOff, nResonance; BYTE nRetrigCount, nRetrigParam; - BYTE nTremorCount, nTremorParam, nTremorOn, nTremorOff; + BYTE nTremorCount, nTremorParam; BYTE nPatternLoop, nPatternLoopCount; BYTE nRowNote, nRowInstr; BYTE nRowVolCmd, nRowVolume; Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2009-07-31 12:56:26 UTC (rev 311) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2009-08-03 19:20:23 UTC (rev 312) @@ -1000,33 +1000,21 @@ // Tremor if(pChn->nCommand == CMD_TREMOR) { - if(GetModFlag(MSF_COMPATIBLE_PLAY) && (m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT))) + if((m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT)) && GetModFlag(MSF_COMPATIBLE_PLAY)) { - // IT compatibility 12: Tremor - if(pChn->nTremorOn) - pChn->nTremorOn--; - if(!pChn->nTremorOn) { - if(pChn->nTremorOff) - { - vol = 0; - pChn->nTremorOff--; - } + // IT compatibility 12. / 13.: Tremor + + if ((pChn->nTremorCount & 128) && pChn->nLength) { + if (pChn->nTremorCount == 128) + pChn->nTremorCount = (pChn->nTremorParam >> 4) | 192; + else if (pChn->nTremorCount == 192) + pChn->nTremorCount = (pChn->nTremorParam & 0xf) | 128; else - { - pChn->nTremorOn = pChn->nTremorParam >> 4; - pChn->nTremorOff = pChn->nTremorParam & 0x0F; - if(m_dwSongFlags & SONG_ITOLDEFFECTS) - { - pChn->nTremorOn++; - pChn->nTremorOff++; - } - else - { - if (!pChn->nTremorOn) pChn->nTremorOn = 1; - if (!pChn->nTremorOff) pChn->nTremorOff = 1; - } - } + pChn->nTremorCount--; } + + if ((pChn->nTremorCount & 192) == 128) + vol = 0; } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |