From: <sag...@us...> - 2010-02-28 18:23:31
|
Revision: 513 http://modplug.svn.sourceforge.net/modplug/?rev=513&view=rev Author: saga-games Date: 2010-02-28 18:23:21 +0000 (Sun, 28 Feb 2010) Log Message: ----------- [New] VST/Instrument handling: The IT instrument note mapping is now also applied to VST instruments (before, it was just available for samples). This way, VST instruments can be transposed easily. [Ref] Small portions of refactoring. Modified Paths: -------------- trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2010-02-25 08:09:05 UTC (rev 512) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2010-02-28 18:23:21 UTC (rev 513) @@ -355,6 +355,7 @@ m_SndFile.ChangeModTypeTo(MOD_TYPE_S3M); break; case MOD_TYPE_PSM: + case MOD_TYPE_ULT: default: m_SndFile.ChangeModTypeTo(MOD_TYPE_IT); } @@ -793,7 +794,7 @@ if ((!pMainFrm) || (!note)) return FALSE; if (nVol > 256) nVol = 256; - if (note < 128) + if (note <= NOTE_MAX) { BEGIN_CRITICAL(); @@ -923,7 +924,7 @@ if ((nPlugin) && (nPlugin <= MAX_MIXPLUGINS)) { IMixPlugin *pPlugin = m_SndFile.m_MixPlugins[nPlugin-1].pMixPlugin; - if (pPlugin) pPlugin->MidiCommand(pIns->nMidiChannel, pIns->nMidiProgram, pIns->wMidiBank, note, pChn->nVolume, MAX_BASECHANNELS); + if (pPlugin) pPlugin->MidiCommand(pIns->nMidiChannel, pIns->nMidiProgram, pIns->wMidiBank, pIns->NoteMap[note - 1], pChn->nVolume, MAX_BASECHANNELS); //if (pPlugin) pPlugin->MidiCommand(pIns->nMidiChannel, pIns->nMidiProgram, pIns->wMidiBank, note, pChn->GetVSTVolume(), MAX_BASECHANNELS); } } @@ -950,13 +951,13 @@ BOOL CModDoc::NoteOff(UINT note, BOOL bFade, UINT nins, UINT nCurrentChn) //rewbs.vstiLive: added chan and nins -//-------------------------------------------------------------------------- +//----------------------------------------------------------------------- { BEGIN_CRITICAL(); - //rewbs.vstiLive - if (nins>0 && nins<=m_SndFile.m_nInstruments) { + if((nins > 0) && (nins <= m_SndFile.m_nInstruments) && (note >= NOTE_MIN) && (note <= NOTE_MAX)) + { MODINSTRUMENT *pIns = m_SndFile.Instruments[nins]; if (pIns && pIns->nMidiChannel > 0 && pIns->nMidiChannel < 17) // instro sends to a midi chan @@ -970,7 +971,7 @@ if ((nPlugin) && (nPlugin <= MAX_MIXPLUGINS)) { IMixPlugin *pPlugin = m_SndFile.m_MixPlugins[nPlugin-1].pMixPlugin; - if (pPlugin) pPlugin->MidiCommand(pIns->nMidiChannel, pIns->nMidiProgram, pIns->wMidiBank, note+NOTE_KEYOFF, 0, MAX_BASECHANNELS); + if (pPlugin) pPlugin->MidiCommand(pIns->nMidiChannel, pIns->nMidiProgram, pIns->wMidiBank, pIns->NoteMap[note - 1] + NOTE_KEYOFF, 0, MAX_BASECHANNELS); } } @@ -1942,19 +1943,7 @@ m_SndFile.m_nMusicTempo, m_SndFile.m_nMusicSpeed, m_SndFile.m_nRowsPerBeat, bpm); break; } -/* - if (CMainFrame::m_dwPatternSetup & PATTERN_MODERNSPEED) { - Message.Format("Using modern speed interpretation.\n\nAssuming:\n. %d ticks per second\n. %d ticks per row\n. %d rows per beat\nthe tempo is approximately: %.20g BPM", - m_SndFile.m_nMusicTempo, m_SndFile.m_nMusicSpeed, CMainFrame::m_nRowSpacing2, bpm); - } - else if (CMainFrame::m_dwPatternSetup & PATTERN_ALTERNTIVEBPMSPEED) { - Message.Format("Using alternative tempo interpretation.\n\nAssuming:\n. %d ticks per second\n. %d ticks per row\n. %d rows per beat\nthe tempo is approximately: %.20g BPM", - m_SndFile.m_nMusicTempo, m_SndFile.m_nMusicSpeed, CMainFrame::m_nRowSpacing2, bpm); - } else { - Message.Format("Using standard tempo interpretation.\n\nAssuming:\n. A mod tempo (tick duration factor) of %d\n. %d ticks per row\n. %d rows per beat\nthe tempo is approximately: %.20g BPM", - m_SndFile.m_nMusicTempo, m_SndFile.m_nMusicSpeed, CMainFrame::m_nRowSpacing2, bpm); - } - */ + CMainFrame::GetMainFrame()->MessageBox(Message, NULL, MB_OK|MB_ICONINFORMATION); } @@ -2667,7 +2656,7 @@ case 0x30: // vibrato waveform case 0x40: // tremolo waveform case 0x50: // panbrello waveform - if(((param & 0x0F) > 0x03) && m_SndFile.IsCompatibleMode(TRK_IMPULSETRACKER | TRK_SCREAMTRACKER)) + if(((param & 0x0F) > 0x03) && m_SndFile.IsCompatibleMode(TRK_IMPULSETRACKER)) { strcpy(s, "ignore"); break; Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2010-02-25 08:09:05 UTC (rev 512) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2010-02-28 18:23:21 UTC (rev 513) @@ -453,18 +453,6 @@ return dwElapsedTime / 1000.0; - /* -// -> CODE#0022 -// -> DESC="alternative BPM/Speed interpretation method" -// return (UINT)((dwElapsedTime+500.0) / 1000.0); -// if(CMainFrame::m_dwPatternSetup & PATTERN_ALTERNTIVEBPMSPEED) { - if (m_nTempoMode == tempo_mode_alternative) { - return (UINT)((dwElapsedTime + 1000.0) / 1000.0); - } else { - return (UINT)((dwElapsedTime + 500.0) / 1000.0); - } -// -! NEW_FEATURE#0022 - */ } @@ -485,7 +473,7 @@ if ((pIns) && (note) && (note <= 128)) { - if (pIns->NoteMap[note-1] >= 0xFE) return; + if (pIns->NoteMap[note-1] >= NOTE_MIN_SPECIAL) return; UINT n = pIns->Keyboard[note-1]; pSmp = ((n) && (n < MAX_SAMPLES)) ? &Samples[n] : NULL; } else @@ -1050,7 +1038,7 @@ //switch off duplicated note played on this plugin IMixPlugin *pPlugin = m_MixPlugins[pHeader->nMixPlug-1].pMixPlugin; if (pPlugin && p->nNote) - pPlugin->MidiCommand(p->pModInstrument->nMidiChannel, p->pModInstrument->nMidiProgram, p->pModInstrument->wMidiBank, p->nNote+NOTE_KEYOFF, 0, i); + pPlugin->MidiCommand(p->pModInstrument->nMidiChannel, p->pModInstrument->nMidiProgram, p->pModInstrument->wMidiBank, p->nNote + NOTE_KEYOFF, 0, i); break; } } @@ -1264,7 +1252,7 @@ if(IsCompatibleMode(TRK_IMPULSETRACKER)) nStartTick = 1; //ST3 ignores notes with SD0 completely - else if(GetType() & MOD_TYPE_S3M) + else if(GetType() == MOD_TYPE_S3M) nStartTick = m_nMusicSpeed; } @@ -2249,7 +2237,8 @@ //---------------------------------------------------------------- { BYTE x, y; - if (m_dwSongFlags & SONG_FIRSTTICK) { + if (m_dwSongFlags & SONG_FIRSTTICK) + { x = param & 0xf0; if (x) pChn->nNoteSlideSpeed = (x >> 4); @@ -2257,13 +2246,15 @@ if (y) pChn->nNoteSlideStep = y; pChn->nNoteSlideCounter = pChn->nNoteSlideSpeed; - } else { - if (--pChn->nNoteSlideCounter == 0) { - pChn->nNoteSlideCounter = pChn->nNoteSlideSpeed; - // update it - pChn->nPeriod = GetPeriodFromNote - (sign * pChn->nNoteSlideStep + GetNoteFromPeriod(pChn->nPeriod), 8363, 0); - } + } else + { + if (--pChn->nNoteSlideCounter == 0) + { + pChn->nNoteSlideCounter = pChn->nNoteSlideSpeed; + // update it + pChn->nPeriod = GetPeriodFromNote + (sign * pChn->nNoteSlideStep + GetNoteFromPeriod(pChn->nPeriod), 8363, 0); + } } } @@ -2289,7 +2280,7 @@ if(param) pChn->nPortamentoSlide = param; else - if(pChn->nPortamentoSlide == NULL) + if(pChn->nPortamentoSlide == 0) return; @@ -3422,7 +3413,7 @@ if(IsCompatibleMode(TRK_IMPULSETRACKER)) nTick = 1; // ST3 doesn't cut notes with SC0 - else if(m_nType & MOD_TYPE_S3M) + else if(m_nType == MOD_TYPE_S3M) return; } @@ -3961,7 +3952,7 @@ void CSoundFile::PortamentoMPT(MODCHANNEL* pChn, int param) -//---------------------------------------------------------------- +//--------------------------------------------------------- { //Behavior: Modifies portamento by param-steps on every tick. //Note that step meaning depends on tuning. @@ -3972,7 +3963,7 @@ void CSoundFile::PortamentoFineMPT(MODCHANNEL* pChn, int param) -//------------------------------------------------------------------- +//------------------------------------------------------------- { //Behavior: Divides portamento change between ticks/row. For example //if Ticks/row == 6, and param == +-6, portamento goes up/down by one tuning-dependent Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2010-02-25 08:09:05 UTC (rev 512) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2010-02-28 18:23:21 UTC (rev 513) @@ -665,12 +665,14 @@ } } +#ifdef MODPLUG_TRACKER if(CMainFrame::GetMainFrame()) { - // If channel resetting is disabled, we will emulate a pattern break + // If channel resetting is disabled in MPT, we will emulate a pattern break if(!(CMainFrame::GetMainFrame()->m_dwPatternSetup & PATTERN_RESETCHANNELS)) m_dwSongFlags |= SONG_BREAKTOROW; } +#endif if (!nRestartPosOverride && !(m_dwSongFlags & SONG_BREAKTOROW)) { @@ -1983,9 +1985,11 @@ if(GetModFlag(MSF_MIDICC_BUGEMULATION)) { - if (note) { - pPlugin->MidiCommand(pIns->nMidiChannel, pIns->nMidiProgram, pIns->wMidiBank, note, pChn->nVolume, nChn); - } else if (volcmd == VOLCMD_VOLUME) { + if((note >= NOTE_MIN) && (note <= NOTE_MAX)) + { + pPlugin->MidiCommand(pIns->nMidiChannel, pIns->nMidiProgram, pIns->wMidiBank, pIns->NoteMap[note - 1], pChn->nVolume, nChn); + } else if (volcmd == VOLCMD_VOLUME) + { pPlugin->MidiCC(pIns->nMidiChannel, MIDICC_Volume_Fine, vol, nChn); } return; @@ -2007,7 +2011,10 @@ break; } - pPlugin->MidiCommand(pIns->nMidiChannel, pIns->nMidiProgram, pIns->wMidiBank, note, velocity, nChn); + MODCOMMAND::NOTE realNote = note; + if((note >= NOTE_MIN) && (note <= NOTE_MAX)) + realNote = pIns->NoteMap[note - 1]; + pPlugin->MidiCommand(pIns->nMidiChannel, pIns->nMidiProgram, pIns->wMidiBank, realNote, velocity, nChn); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |