From: <sag...@us...> - 2011-09-06 16:04:07
|
Revision: 1025 http://modplug.svn.sourceforge.net/modplug/?rev=1025&view=rev Author: saga-games Date: 2011-09-06 16:03:56 +0000 (Tue, 06 Sep 2011) Log Message: ----------- [Ref] Moved envelope flags from channel flags to MODCHANNEL_ENVINFO. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/View_ins.cpp trunk/OpenMPT/mptrack/View_ins.h trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2011-09-06 12:23:23 UTC (rev 1024) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2011-09-06 16:03:56 UTC (rev 1025) @@ -1076,17 +1076,16 @@ && (pChn->pModInstrument) && (pChn->pModInstrument == m_pSndFile->Instruments[nIns]) && ((!(pChn->dwFlags & CHN_NOTEFADE)) || (pChn->nFadeOutVol))) { + MODCHANNEL_ENVINFO *env = &pChn->VolEnv; if (m_dwNotifyType & MPTNOTIFY_PITCHENV) { - if (pChn->dwFlags & CHN_PITCHENV) p->dwPos[k] = MPTNOTIFY_POSVALID | (DWORD)(pChn->PitchEnv.nEnvPosition); - } else - if (m_dwNotifyType & MPTNOTIFY_PANENV) + env = &pChn->PitchEnv; + } else if (m_dwNotifyType & MPTNOTIFY_PANENV) { - if (pChn->dwFlags & CHN_PANENV) p->dwPos[k] = MPTNOTIFY_POSVALID | (DWORD)(pChn->PanEnv.nEnvPosition); - } else - { - if (pChn->dwFlags & CHN_VOLENV) p->dwPos[k] = MPTNOTIFY_POSVALID | (DWORD)(pChn->VolEnv.nEnvPosition); + env = &pChn->PanEnv; } + + if (env->flags & ENV_ENABLED) p->dwPos[k] = MPTNOTIFY_POSVALID | (DWORD)(env->nEnvPosition); } } } else Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2011-09-06 12:23:23 UTC (rev 1024) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2011-09-06 16:03:56 UTC (rev 1025) @@ -945,7 +945,7 @@ pChn->nPos = pChn->nPosLo = pChn->nLength = 0; pChn->nLoopStart = sample.nLoopStart; pChn->nLoopEnd = sample.nLoopEnd; - pChn->dwFlags = sample.uFlags & (0xFF & ~CHN_MUTE); + pChn->dwFlags = sample.uFlags & (CHN_SAMPLEFLAGS & ~CHN_MUTE); pChn->nPan = 128; if (sample.uFlags & CHN_PANNING) pChn->nPan = sample.nPan; pChn->nInsVol = sample.nGlobalVol; Modified: trunk/OpenMPT/mptrack/View_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_ins.cpp 2011-09-06 12:23:23 UTC (rev 1024) +++ trunk/OpenMPT/mptrack/View_ins.cpp 2011-09-06 16:03:56 UTC (rev 1025) @@ -540,31 +540,81 @@ } -bool CViewInstrument::EnvToggleEnv(INSTRUMENTENVELOPE *pEnv, CSoundFile *pSndFile, MODINSTRUMENT *pIns, bool bEnable, BYTE cDefaultValue, DWORD dwChanFlag, DWORD dwExtraFlags) -//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +bool CViewInstrument::EnvToggleEnv(enmEnvelopeTypes envelope, CSoundFile *pSndFile, MODINSTRUMENT *pIns, bool enable, BYTE defaultValue, DWORD extraFlags) +//-------------------------------------------------------------------------------------------------------------------------------------------------------- { - if(pEnv == nullptr) return false; + if(pIns == nullptr || pSndFile == nullptr) + { + return false; + } - if (bEnable) + INSTRUMENTENVELOPE *env; + + switch(envelope) { - pEnv->dwFlags |= (ENV_ENABLED|dwExtraFlags); - if (!pEnv->nNodes) + case ENV_VOLUME: + default: + env = &pIns->VolEnv; + break; + case ENV_PANNING: + env = &pIns->PanEnv; + break; + case ENV_PITCH: + env = &pIns->PitchEnv; + break; + } + + const DWORD flags = (ENV_ENABLED | extraFlags); + + if (enable) + { + env->dwFlags |= flags; + if(!env->nNodes) { - pEnv->Values[0] = pEnv->Values[1] = cDefaultValue; - pEnv->Ticks[0] = 0; - pEnv->Ticks[1] = 10; - pEnv->nNodes = 2; + env->Values[0] = env->Values[1] = defaultValue; + env->Ticks[0] = 0; + env->Ticks[1] = 10; + env->nNodes = 2; InvalidateRect(NULL, FALSE); } } else { - pEnv->dwFlags &= ~(ENV_ENABLED|dwExtraFlags); - for(CHANNELINDEX nChn = 0; nChn < MAX_CHANNELS; nChn++) + env->dwFlags &= ~flags; + } + + CriticalSection cs; + + // Update mixing flags... + for(CHANNELINDEX nChn = 0; nChn < MAX_CHANNELS; nChn++) + { + if(pSndFile->Chn[nChn].pModInstrument == pIns) { - if(pSndFile->Chn[nChn].pModInstrument == pIns) - pSndFile->Chn[nChn].dwFlags &= ~dwChanFlag; + MODCHANNEL_ENVINFO *envInfo; + + switch(envelope) + { + case ENV_VOLUME: + default: + envInfo = &pSndFile->Chn[nChn].VolEnv; + break; + case ENV_PANNING: + envInfo = &pSndFile->Chn[nChn].PanEnv; + break; + case ENV_PITCH: + envInfo = &pSndFile->Chn[nChn].PitchEnv; + break; + } + + if(enable) + { + envInfo->flags |= flags; + } else + { + envInfo->flags &= ~flags; + } } } + return true; } @@ -576,7 +626,7 @@ if(pIns == nullptr) return false; CSoundFile *pSndFile = GetDocument()->GetSoundFile(); // security checks are done in GetInstrumentPtr() - return EnvToggleEnv(&pIns->VolEnv, pSndFile, pIns, bEnable, 64, CHN_VOLENV); + return EnvToggleEnv(ENV_VOLUME, pSndFile, pIns, bEnable, 64); } @@ -587,7 +637,7 @@ if(pIns == nullptr) return false; CSoundFile *pSndFile = GetDocument()->GetSoundFile(); // security checks are done in GetInstrumentPtr() - return EnvToggleEnv(&pIns->PanEnv, pSndFile, pIns, bEnable, 32, CHN_PANENV); + return EnvToggleEnv(ENV_PANNING, pSndFile, pIns, bEnable, 32); } @@ -599,7 +649,7 @@ CSoundFile *pSndFile = GetDocument()->GetSoundFile(); // security checks are done in GetInstrumentPtr() pIns->PitchEnv.dwFlags &= ~ENV_FILTER; - return EnvToggleEnv(&pIns->PitchEnv, pSndFile, pIns, bEnable, 32, CHN_PITCHENV); + return EnvToggleEnv(ENV_PITCH, pSndFile, pIns, bEnable, 32); } @@ -610,8 +660,7 @@ if(pIns == nullptr) return false; CSoundFile *pSndFile = GetDocument()->GetSoundFile(); // security checks are done in GetInstrumentPtr() - pIns->PitchEnv.dwFlags &= ~ENV_FILTER; - return EnvToggleEnv(&pIns->PitchEnv, pSndFile, pIns, bEnable, 64, CHN_PITCHENV, ENV_FILTER); + return EnvToggleEnv(ENV_PITCH, pSndFile, pIns, bEnable, 64, ENV_FILTER); } @@ -1135,11 +1184,11 @@ { if (m_dwNotifyPos[i]) { - memset(m_dwNotifyPos, 0, sizeof(m_dwNotifyPos)); + MemsetZero(m_dwNotifyPos); InvalidateEnvelope(); break; } - memset(m_baPlayingNote, 0, sizeof(bool)*NOTE_MAX); //rewbs.instViewNNA + MemsetZero(m_baPlayingNote); //rewbs.instViewNNA m_nPlayingChannel = CHANNELINDEX_INVALID; //rewbs.instViewNNA } } else Modified: trunk/OpenMPT/mptrack/View_ins.h =================================================================== --- trunk/OpenMPT/mptrack/View_ins.h 2011-09-06 12:23:23 UTC (rev 1024) +++ trunk/OpenMPT/mptrack/View_ins.h 2011-09-06 16:03:56 UTC (rev 1025) @@ -91,7 +91,7 @@ bool EnvToggleReleaseNode(int nPoint); // Set envelope status - bool EnvToggleEnv(INSTRUMENTENVELOPE *pEnv, CSoundFile *pSndFile, MODINSTRUMENT *pIns, bool bEnable, BYTE cDefaultValue, DWORD dwChanFlag, DWORD dwExtraFlags = 0); + bool EnvToggleEnv(enmEnvelopeTypes envelope, CSoundFile *pSndFile, MODINSTRUMENT *pIns, bool enable, BYTE defaultValue, DWORD extraFlags = 0); bool EnvSetVolEnv(bool bEnable); bool EnvSetPanEnv(bool bEnable); bool EnvSetPitchEnv(bool bEnable); Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2011-09-06 12:23:23 UTC (rev 1024) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2011-09-06 16:03:56 UTC (rev 1025) @@ -151,17 +151,13 @@ #define CHN_PANBRELLO 0x40000 // apply panbrello #define CHN_PORTAMENTO 0x80000 // apply portamento #define CHN_GLISSANDO 0x100000 // glissando mode -#define CHN_VOLENV 0x200000 // volume envelope is active -#define CHN_PANENV 0x400000 // pan envelope is active -#define CHN_PITCHENV 0x800000 // pitch envelope is active -#define CHN_FASTVOLRAMP 0x1000000 // ramp volume very fast -#define CHN_EXTRALOUD 0x2000000 // force master volume to 0x100 -#define CHN_REVERB 0x4000000 // apply reverb -#define CHN_NOREVERB 0x8000000 // forbid reverb -#define CHN_SOLO 0x10000000 // solo channel -> CODE#0012 -> DESC="midi keyboard split" -! NEW_FEATURE#0012 -#define CHN_NOFX 0x20000000 // dry channel -> CODE#0015 -> DESC="channels management dlg" -! NEW_FEATURE#0015 -#define CHN_SYNCMUTE 0x40000000 // keep sample sync on mute -#define CHN_FILTERENV 0x80000000 // force pitch envelope to act as filter envelope +#define CHN_FASTVOLRAMP 0x200000 // ramp volume very fast +#define CHN_EXTRALOUD 0x400000 // force master volume to 0x100 +#define CHN_REVERB 0x800000 // apply reverb +#define CHN_NOREVERB 0x1000000 // forbid reverb +#define CHN_SOLO 0x2000000 // solo channel -> CODE#0012 -> DESC="midi keyboard split" -! NEW_FEATURE#0012 +#define CHN_NOFX 0x4000000 // dry channel -> CODE#0015 -> DESC="channels management dlg" -! NEW_FEATURE#0015 +#define CHN_SYNCMUTE 0x8000000 // keep sample sync on mute #define CHN_SAMPLEFLAGS (CHN_16BIT|CHN_LOOP|CHN_PINGPONGLOOP|CHN_SUSTAINLOOP|CHN_PINGPONGSUSTAIN|CHN_PANNING|CHN_STEREO|CHN_PINGPONGFLAG) #define CHN_CHANNELFLAGS (~CHN_SAMPLEFLAGS) Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-09-06 12:23:23 UTC (rev 1024) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-09-06 16:03:56 UTC (rev 1025) @@ -667,7 +667,7 @@ pChn->dwFlags = (pChn->dwFlags & (CHN_CHANNELFLAGS | CHN_PINGPONGFLAG)) | (pSmp->uFlags & CHN_SAMPLEFLAGS); } else { - pChn->dwFlags &= ~(CHN_KEYOFF|CHN_NOTEFADE|CHN_VOLENV|CHN_PANENV|CHN_PITCHENV); + pChn->dwFlags &= ~(CHN_KEYOFF|CHN_NOTEFADE); //IT compatibility tentative fix: Don't change bidi loop direction when //no sample nor instrument is changed. @@ -679,18 +679,13 @@ if (pIns) { - if (pIns->VolEnv.dwFlags & ENV_ENABLED) pChn->dwFlags |= CHN_VOLENV; - if (pIns->PanEnv.dwFlags & ENV_ENABLED) pChn->dwFlags |= CHN_PANENV; - if (pIns->PitchEnv.dwFlags & ENV_ENABLED) pChn->dwFlags |= CHN_PITCHENV; + // Copy envelope flags (we actually only need the "enabled" and "pitch" flag) + pChn->VolEnv.flags = pIns->VolEnv.dwFlags; + pChn->PanEnv.flags = pIns->PanEnv.dwFlags; + pChn->PitchEnv.flags = pIns->PitchEnv.dwFlags; if ((pIns->PitchEnv.dwFlags & ENV_ENABLED) && (pIns->PitchEnv.dwFlags & ENV_FILTER)) { - pChn->dwFlags |= CHN_FILTERENV; if (!pChn->nCutOff) pChn->nCutOff = 0x7F; - } else - { - // Special case: Reset filter envelope flag manually (because of S7D/S7E effects). - // This way, the S7x effects can be applied to several notes, as long as they don't come with an instrument number. - pChn->dwFlags &= ~CHN_FILTERENV; } if (pIns->nIFC & 0x80) pChn->nCutOff = pIns->nIFC & 0x7F; if (pIns->nIFR & 0x80) pChn->nResonance = pIns->nIFR & 0x7F; @@ -2072,9 +2067,9 @@ if (pChn->pModInstrument) { MODINSTRUMENT *pIns = pChn->pModInstrument; - if ((pChn->dwFlags & CHN_PANENV) && (pIns->PanEnv.nNodes) && (param > pIns->PanEnv.Ticks[pIns->PanEnv.nNodes-1])) + if ((pChn->PanEnv.flags & ENV_ENABLED) && (pIns->PanEnv.nNodes) && (param > pIns->PanEnv.Ticks[pIns->PanEnv.nNodes - 1])) { - pChn->dwFlags &= ~CHN_PANENV; + pChn->PanEnv.flags &= ~ENV_ENABLED; } } } @@ -2924,23 +2919,23 @@ case 4: pChn->nNNA = NNA_CONTINUE; break; case 5: pChn->nNNA = NNA_NOTEOFF; break; case 6: pChn->nNNA = NNA_NOTEFADE; break; - case 7: pChn->dwFlags &= ~CHN_VOLENV; break; - case 8: pChn->dwFlags |= CHN_VOLENV; break; - case 9: pChn->dwFlags &= ~CHN_PANENV; break; - case 10: pChn->dwFlags |= CHN_PANENV; break; - case 11: pChn->dwFlags &= ~CHN_PITCHENV; break; - case 12: pChn->dwFlags |= CHN_PITCHENV; break; + case 7: pChn->VolEnv.flags &= ~ENV_ENABLED; break; + case 8: pChn->VolEnv.flags |= ENV_ENABLED; break; + case 9: pChn->PanEnv.flags &= ~ENV_ENABLED; break; + case 10: pChn->PanEnv.flags |= ENV_ENABLED; break; + case 11: pChn->PitchEnv.flags &= ~ENV_ENABLED; break; + case 12: pChn->PitchEnv.flags |= ENV_ENABLED; break; case 13: case 14: if(GetType() == MOD_TYPE_MPT) { - pChn->dwFlags |= CHN_PITCHENV; + pChn->PitchEnv.flags |= ENV_ENABLED; if(param == 13) // pitch env on, filter env off { - pChn->dwFlags &= ~CHN_FILTERENV; + pChn->PitchEnv.flags &= ~ENV_FILTER; } else // filter env on { - pChn->dwFlags |= CHN_FILTERENV; + pChn->PitchEnv.flags |= ENV_FILTER; } } break; @@ -3723,7 +3718,7 @@ const bool bKeyOn = (pChn->dwFlags & CHN_KEYOFF) ? false : true; pChn->dwFlags |= CHN_KEYOFF; //if ((!pChn->pModInstrument) || (!(pChn->dwFlags & CHN_VOLENV))) - if ((pChn->pModInstrument) && (!(pChn->dwFlags & CHN_VOLENV))) + if ((pChn->pModInstrument) && (!(pChn->VolEnv.flags & ENV_ENABLED))) { pChn->dwFlags |= CHN_NOTEFADE; } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2011-09-06 12:23:23 UTC (rev 1024) +++ trunk/OpenMPT/soundlib/Sndfile.h 2011-09-06 16:03:56 UTC (rev 1025) @@ -231,6 +231,7 @@ struct MODCHANNEL_ENVINFO { DWORD nEnvPosition; + DWORD flags; LONG nEnvValueAtReleaseJump; }; Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2011-09-06 12:23:23 UTC (rev 1024) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2011-09-06 16:03:56 UTC (rev 1025) @@ -1014,7 +1014,7 @@ // IT Compatibility: S77 does not disable the volume envelope, it just pauses the counter // Problem: This pauses on the wrong tick at the moment... - if (((pChn->dwFlags & CHN_VOLENV) || ((pIns->VolEnv.dwFlags & ENV_ENABLED) && IsCompatibleMode(TRK_IMPULSETRACKER))) && (pIns->VolEnv.nNodes)) + if (((pChn->VolEnv.flags & ENV_ENABLED) || ((pIns->VolEnv.dwFlags & ENV_ENABLED) && IsCompatibleMode(TRK_IMPULSETRACKER))) && (pIns->VolEnv.nNodes)) { int envvol = GetVolEnvValueFromPosition(pChn->VolEnv.nEnvPosition, pIns); @@ -1050,7 +1050,7 @@ // IT Compatibility: S79 does not disable the panning envelope, it just pauses the counter // Problem: This pauses on the wrong tick at the moment... - if (((pChn->dwFlags & CHN_PANENV) || ((pIns->PanEnv.dwFlags & ENV_ENABLED) && IsCompatibleMode(TRK_IMPULSETRACKER))) && (pIns->PanEnv.nNodes)) + if (((pChn->PanEnv.flags & ENV_ENABLED) || ((pIns->PanEnv.dwFlags & ENV_ENABLED) && IsCompatibleMode(TRK_IMPULSETRACKER))) && (pIns->PanEnv.nNodes)) { int envpos = pChn->PanEnv.nEnvPosition; UINT pt = pIns->PanEnv.nNodes - 1; @@ -1104,7 +1104,7 @@ // IT Compatibility: S7B does not disable the pitch envelope, it just pauses the counter // Problem: This pauses on the wrong tick at the moment... - if ((pIns) && ((pChn->dwFlags & CHN_PITCHENV) || ((pIns->PitchEnv.dwFlags & ENV_ENABLED) && IsCompatibleMode(TRK_IMPULSETRACKER))) && (pChn->pModInstrument->PitchEnv.nNodes)) + if ((pIns) && ((pChn->PitchEnv.flags & ENV_ENABLED) || ((pIns->PitchEnv.dwFlags & ENV_ENABLED) && IsCompatibleMode(TRK_IMPULSETRACKER))) && (pChn->pModInstrument->PitchEnv.nNodes)) { int envpos = pChn->PitchEnv.nEnvPosition; UINT pt = pIns->PitchEnv.nNodes - 1; @@ -1140,7 +1140,7 @@ envpitch = CLAMP(envpitch, -256, 256); //if (pIns->PitchEnv.dwFlags & ENV_FILTER) - if (pChn->dwFlags & CHN_FILTERENV) + if (pChn->PitchEnv.flags & ENV_FILTER) { // Filter Envelope: controls cutoff frequency #ifndef NO_FILTER @@ -1184,7 +1184,7 @@ { const MODINSTRUMENT *pIns = pChn->pModInstrument; - if (pChn->dwFlags & CHN_VOLENV) + if (pChn->VolEnv.flags & ENV_ENABLED) { // Increase position pChn->VolEnv.nEnvPosition++; @@ -1232,7 +1232,7 @@ { const MODINSTRUMENT *pIns = pChn->pModInstrument; - if (pChn->dwFlags & CHN_PANENV) + if (pChn->PanEnv.flags & ENV_ENABLED) { pChn->PanEnv.nEnvPosition++; if (pIns->PanEnv.dwFlags & ENV_LOOP) @@ -1262,7 +1262,7 @@ { const MODINSTRUMENT *pIns = pChn->pModInstrument; - if (pChn->dwFlags & CHN_PITCHENV) + if (pChn->PitchEnv.flags & ENV_ENABLED) { // Increase position pChn->PitchEnv.nEnvPosition++; @@ -2426,7 +2426,7 @@ //If new note, determine notevelocity to use. - if(note) + if(note != NOTE_NONE) { UINT velocity = 4*defaultVolume; switch(pIns->nPluginVelocityHandling) @@ -2437,7 +2437,7 @@ } MODCOMMAND::NOTE realNote = note; - if((note >= NOTE_MIN) && (note <= NOTE_MAX)) + if(NOTE_IS_VALID(note)) realNote = pIns->NoteMap[note - 1]; // Experimental VST panning //ProcessMIDIMacro(nChn, false, m_MidiCfg.szMidiGlb[MIDIOUT_PAN], 0, nPlugin); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |