From: <sag...@us...> - 2010-03-28 22:53:49
|
Revision: 561 http://modplug.svn.sourceforge.net/modplug/?rev=561&view=rev Author: saga-games Date: 2010-03-28 22:53:43 +0000 (Sun, 28 Mar 2010) Log Message: ----------- [Fix] IT Compatibility: S77 / S79/ S7B are supposed to pause the envelope, not disable it. [Ref] Added some comments to the CHN_* flags and in the pattern drawing code, minor refactoring there as well. Modified Paths: -------------- trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2010-03-28 19:31:53 UTC (rev 560) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2010-03-28 22:53:43 UTC (rev 561) @@ -93,8 +93,12 @@ -3, 1, 9, // InstrOfs + nInstrHiWidth }; +// NOTE: See also CViewPattern::DrawNote() when changing stuff here +// or adding new fonts - The custom tuning note names might require +// some additions there. + ///////////////////////////////////////////////////////////////////////////// // CViewPattern Drawing Implementation @@ -667,7 +671,7 @@ // -> CODE#0015 // -> DESC="channels management dlg" - BOOL activeDoc = pMainFrm ? pMainFrm->GetActiveDoc() == GetDocument() : FALSE; + bool activeDoc = pMainFrm ? (pMainFrm->GetActiveDoc() == GetDocument()) : false; if(activeDoc && CChannelManagerDlg::sharedInstance(FALSE) && CChannelManagerDlg::sharedInstance()->IsDisplayed()) CChannelManagerDlg::sharedInstance()->SetDocument((void*)this); @@ -1045,13 +1049,13 @@ CRect rect; POINT ptTopLeft, ptBottomRight; DWORD dwTopLeft, dwBottomRight; - BOOL bLeft, bTop, bRight, bBottom; + bool bLeft, bTop, bRight, bBottom; int x1, y1, x2, y2, dx, dy, c1, c2; int nChannels, nRows; - if ((pModDoc = GetDocument()) == NULL) return; + if ((pModDoc = GetDocument()) == nullptr) return; pSndFile = pModDoc->GetSoundFile(); - bLeft = bTop = bRight = bBottom = TRUE; + bLeft = bTop = bRight = bBottom = true; x1 = (m_dwBeginSel & 0xFFF8) >> 3; y1 = (m_dwBeginSel) >> 16; x2 = (m_dwEndSel & 0xFFF8) >> 3; @@ -1066,15 +1070,15 @@ y2 += dy; nChannels = pSndFile->m_nChannels; nRows = pSndFile->PatternSize[m_nPattern]; - if (x1 < GetXScrollPos()) bLeft = FALSE; - if (x1 >= nChannels) x1 = nChannels-1; - if (x1 < 0) { x1 = 0; c1 = 0; bLeft = FALSE; } - if (x2 >= nChannels) { x2 = nChannels-1; c2 = 4; bRight = FALSE; } + if (x1 < GetXScrollPos()) bLeft = false; + if (x1 >= nChannels) x1 = nChannels - 1; + if (x1 < 0) { x1 = 0; c1 = 0; bLeft = false; } + if (x2 >= nChannels) { x2 = nChannels-1; c2 = 4; bRight = false; } if (x2 < 0) x2 = 0; - if (y1 < GetYScrollPos() - (int)m_nMidRow) bTop = FALSE; + if (y1 < GetYScrollPos() - (int)m_nMidRow) bTop = false; if (y1 >= nRows) y1 = nRows-1; - if (y1 < 0) { y1 = 0; bTop = FALSE; } - if (y2 >= nRows) { y2 = nRows-1; bBottom = FALSE; } + if (y1 < 0) { y1 = 0; bTop = false; } + if (y2 >= nRows) { y2 = nRows-1; bBottom = false; } if (y2 < 0) y2 = 0; dwTopLeft = (y1<<16)|(x1<<3)|c1; dwBottomRight = ((y2+1)<<16)|(x2<<3)|(c2+1); @@ -1300,13 +1304,15 @@ } // rewbs.fix3417: adding error checking CModDoc *pModDoc = GetDocument(); - if (pModDoc) { + if (pModDoc) + { CSoundFile *pSndFile = pModDoc->GetSoundFile(); - if (pSndFile) { + if (pSndFile) + { y1 = max(y1, 0); - y2 = min(y2, (int)pSndFile->PatternSize[m_nPattern]); + y2 = min(y2, (int)pSndFile->Patterns[m_nPattern].GetNumRows()); x1 = max(x1, 0); - x2 = min(x2, pSndFile->m_nChannels*8 - 4); + x2 = min(x2, pSndFile->GetNumChannels() * 8 - 4); } } // end rewbs.fix3417 Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2010-03-28 19:31:53 UTC (rev 560) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2010-03-28 22:53:43 UTC (rev 561) @@ -123,39 +123,39 @@ // Channel flags: // Bits 0-7: Sample Flags -#define CHN_16BIT 0x01 -#define CHN_LOOP 0x02 -#define CHN_PINGPONGLOOP 0x04 -#define CHN_SUSTAINLOOP 0x08 -#define CHN_PINGPONGSUSTAIN 0x10 -#define CHN_PANNING 0x20 -#define CHN_STEREO 0x40 -#define CHN_PINGPONGFLAG 0x80 //When flag is on, sample is processed backwards +#define CHN_16BIT 0x01 // 16-bit sample +#define CHN_LOOP 0x02 // looped sample +#define CHN_PINGPONGLOOP 0x04 // bidi-looped sample +#define CHN_SUSTAINLOOP 0x08 // sample with sustain loop +#define CHN_PINGPONGSUSTAIN 0x10 // sample with bidi sustain loop +#define CHN_PANNING 0x20 // sample with forced panning +#define CHN_STEREO 0x40 // stereo sample +#define CHN_PINGPONGFLAG 0x80 // when flag is on, sample is processed backwards // Bits 8-31: Channel Flags -#define CHN_MUTE 0x100 -#define CHN_KEYOFF 0x200 -#define CHN_NOTEFADE 0x400 -#define CHN_SURROUND 0x800 -#define CHN_NOIDO 0x1000 -#define CHN_HQSRC 0x2000 -#define CHN_FILTER 0x4000 -#define CHN_VOLUMERAMP 0x8000 -#define CHN_VIBRATO 0x10000 -#define CHN_TREMOLO 0x20000 -#define CHN_PANBRELLO 0x40000 -#define CHN_PORTAMENTO 0x80000 -#define CHN_GLISSANDO 0x100000 -#define CHN_VOLENV 0x200000 -#define CHN_PANENV 0x400000 -#define CHN_PITCHENV 0x800000 -#define CHN_FASTVOLRAMP 0x1000000 -#define CHN_EXTRALOUD 0x2000000 -#define CHN_REVERB 0x4000000 -#define CHN_NOREVERB 0x8000000 -#define CHN_SOLO 0x10000000 // -> CODE#0012 -> DESC="midi keyboard split" -! NEW_FEATURE#0012 -#define CHN_NOFX 0x20000000 // -> CODE#0015 -> DESC="channels management dlg" -! NEW_FEATURE#0015 -#define CHN_SYNCMUTE 0x40000000 -#define CHN_FILTERENV 0x80000000 +#define CHN_MUTE 0x100 // muted channel +#define CHN_KEYOFF 0x200 // exit sustain +#define CHN_NOTEFADE 0x400 // fade note (instrument mode) +#define CHN_SURROUND 0x800 // use surround channel +#define CHN_NOIDO 0x1000 // ??? +#define CHN_HQSRC 0x2000 // ??? +#define CHN_FILTER 0x4000 // filtered output +#define CHN_VOLUMERAMP 0x8000 // ramp volume +#define CHN_VIBRATO 0x10000 // apply vibrato +#define CHN_TREMOLO 0x20000 // apply tremolo +#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_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/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2010-03-28 19:31:53 UTC (rev 560) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2010-03-28 22:53:43 UTC (rev 561) @@ -912,6 +912,9 @@ for (UINT nChn=0; nChn<MAX_CHANNELS; nChn++,pChn++) { skipchn: + + MODINSTRUMENT *pIns = pChn->pModInstrument; + if ((pChn->dwFlags & CHN_NOTEFADE) && (!(pChn->nFadeOutVol|pChn->nRightVol|pChn->nLeftVol))) { pChn->nLength = 0; @@ -1071,7 +1074,8 @@ { MODINSTRUMENT *pIns = pChn->pModInstrument; // Volume Envelope - if ((pChn->dwFlags & CHN_VOLENV) && (pIns->VolEnv.nNodes)) + // IT Compatibility: S77 does not disable the volume envelope, it just pauses the counter + if (((pChn->dwFlags & CHN_VOLENV) || ((pIns->VolEnv.dwFlags & ENV_ENABLED) && IsCompatibleMode(TRK_IMPULSETRACKER))) && (pIns->VolEnv.nNodes)) { int envvol = getVolEnvValueFromPosition(pChn->nVolEnvPosition, pIns); @@ -1097,7 +1101,8 @@ vol = (vol * CLAMP(envvol, 0, 512)) >> 8; } // Panning Envelope - if ((pChn->dwFlags & CHN_PANENV) && (pIns->PanEnv.nNodes)) + // IT Compatibility: S79 does not disable the panning envelope, it just pauses the counter + if (((pChn->dwFlags & CHN_PANENV) || ((pIns->PanEnv.dwFlags & ENV_ENABLED) && IsCompatibleMode(TRK_IMPULSETRACKER))) && (pIns->PanEnv.nNodes)) { int envpos = pChn->nPanEnvPosition; UINT pt = pIns->PanEnv.nNodes - 1; @@ -1273,9 +1278,9 @@ period = CLAMP(period, 113 * 4, 856 * 4); // Pitch/Filter Envelope - if ((pChn->pModInstrument) && (pChn->dwFlags & CHN_PITCHENV) && (pChn->pModInstrument->PitchEnv.nNodes)) + // IT Compatibility: S7B does not disable the pitch envelope, it just pauses the counter + if ((pIns) && ((pChn->dwFlags & CHN_PITCHENV) || ((pIns->PitchEnv.dwFlags & ENV_ENABLED) && IsCompatibleMode(TRK_IMPULSETRACKER))) && (pChn->pModInstrument->PitchEnv.nNodes)) { - MODINSTRUMENT *pIns = pChn->pModInstrument; int envpos = pChn->nPitchEnvPosition; UINT pt = pIns->PitchEnv.nNodes - 1; for (UINT i=0; i<(UINT)(pIns->PitchEnv.nNodes-1); i++) @@ -1583,7 +1588,7 @@ }*/ UINT freq = 0; - if(m_nType != MOD_TYPE_MPT || !pChn->pModInstrument || pChn->pModInstrument->pTuning == NULL) + if(m_nType != MOD_TYPE_MPT || !pIns || pIns->pTuning == nullptr) { freq = GetFreqFromPeriod(period, pChn->nC5Speed, nPeriodFrac); } @@ -1591,7 +1596,7 @@ { if(pChn->m_CalculateFreq || (pChn->m_ReCalculateFreqOnFirstTick && m_nTickCount == 0)) { - pChn->m_Freq = pChn->nC5Speed * vibratoFactor * pChn->pModInstrument->pTuning->GetRatio(pChn->nNote - NOTE_MIDDLEC + arpeggioSteps, pChn->nFineTune+pChn->m_PortamentoFineSteps); + pChn->m_Freq = pChn->nC5Speed * vibratoFactor * pIns->pTuning->GetRatio(pChn->nNote - NOTE_MIDDLEC + arpeggioSteps, pChn->nFineTune+pChn->m_PortamentoFineSteps); if(!pChn->m_CalculateFreq) pChn->m_ReCalculateFreqOnFirstTick = false; else @@ -1602,8 +1607,8 @@ } //Applying Pitch/Tempo lock. - if(m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT) && pChn->pModInstrument && pChn->pModInstrument->wPitchToTempoLock) - freq *= (float)m_nMusicTempo / (float)pChn->pModInstrument->wPitchToTempoLock; + if(m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT) && pIns && pIns->wPitchToTempoLock) + freq *= (float)m_nMusicTempo / (float)pIns->wPitchToTempoLock; if ((m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT)) && (freq < 256)) @@ -1621,9 +1626,8 @@ } // Increment envelope position - if (pChn->pModInstrument) + if (pIns) { - MODINSTRUMENT *pIns = pChn->pModInstrument; // Volume Envelope if (pChn->dwFlags & CHN_VOLENV) { @@ -1852,7 +1856,8 @@ if (pChn->nInc >= 0xFE00) pChn->dwFlags |= CHN_NOIDO; #endif // FASTSOUNDLIB } - if (m_pConfig->getUseGlobalPreAmp()) { + if (m_pConfig->getUseGlobalPreAmp()) + { pChn->nNewRightVol >>= MIXING_ATTENUATION; pChn->nNewLeftVol >>= MIXING_ATTENUATION; } @@ -1989,9 +1994,9 @@ MODINSTRUMENT *pIns = pChn->pModInstrument; IMixPlugin *pPlugin = NULL; - if ((instr) && (instr < MAX_INSTRUMENTS)) { + if ((instr) && (instr < MAX_INSTRUMENTS)) pIns = Instruments[instr]; - } + if ((pIns) && (pIns->nMidiChannel >= 1) && (pIns->nMidiChannel <= 16)) { UINT nPlugin = GetBestPlugin(nChn, PRIORITISE_INSTRUMENT, RESPECT_MUTES); if ((nPlugin) && (nPlugin <= MAX_MIXPLUGINS)) { @@ -2060,7 +2065,7 @@ } int CSoundFile::getVolEnvValueFromPosition(int position, MODINSTRUMENT* pIns) -//------------------------------------------------------------------------------ +//--------------------------------------------------------------------------- { UINT pt = pIns->VolEnv.nNodes - 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |