From: <sag...@us...> - 2011-01-31 23:32:19
|
Revision: 793 http://modplug.svn.sourceforge.net/modplug/?rev=793&view=rev Author: saga-games Date: 2011-01-31 23:32:12 +0000 (Mon, 31 Jan 2011) Log Message: ----------- [Fix] IT Compatibility: Bidi loops are now treated like in IT's software mixer. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2011-01-30 14:50:20 UTC (rev 792) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2011-01-31 23:32:12 UTC (rev 793) @@ -1885,6 +1885,9 @@ const bool bPaused = pSndFile->IsPaused(); const bool bPatLoop = (pSndFile->m_dwSongFlags & SONG_PATTERNLOOP) ? true : false; pSndFile->ResetChannels(); + // Select correct bidi loop mode when playing a module. + pSndFile->SetupITBidiMode(); + if ((m_pSndFile) || (m_dwStatus & MODSTATUS_PLAYING)) PauseMod(); if (((m_pSndFile) && (pSndFile != m_pSndFile)) || (!m_dwElapsedTime)) CSoundFile::ResetAGC(); m_pSndFile = pSndFile; Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2011-01-30 14:50:20 UTC (rev 792) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2011-01-31 23:32:12 UTC (rev 793) @@ -479,6 +479,8 @@ m_pSndFile->m_nDefaultRowsPerBeat = GetDlgItemInt(IDC_ROWSPERBEAT); m_pSndFile->m_nDefaultRowsPerMeasure = GetDlgItemInt(IDC_ROWSPERMEASURE); + m_pSndFile->SetupITBidiMode(); + if(CChannelManagerDlg::sharedInstance(FALSE) && CChannelManagerDlg::sharedInstance()->IsDisplayed()) CChannelManagerDlg::sharedInstance()->Update(); CDialog::OnOK(); @@ -1433,13 +1435,15 @@ combo->SetItemData(combo->AddString("No note"), 0); AppendNotesToControlEx(*combo, pSndFile, m_nInstr); - if (m_nNote <= NOTE_MAX) + if (NOTE_IS_VALID(m_nNote)) { + // Normal note / no note const MODCOMMAND::NOTE noteStart = (pSndFile != nullptr) ? pSndFile->GetModSpecifications().noteMin : 1; combo->SetCurSel(m_nNote - (noteStart - 1)); } else { + // Special notes for(int i = combo->GetCount() - 1; i >= 0; --i) { if(combo->GetItemData(i) == m_nNote) @@ -3191,7 +3195,6 @@ for(size_t n = 0; n < num; n++) { - CString temp; FileHistory *hist = &(m_pModDoc->GetFileHistory()->at(n)); totalTime += hist->openTime; @@ -3200,9 +3203,8 @@ _tcsftime(szDate, sizeof(szDate), _T("%d %b %Y, %H:%M:%S"), &hist->loadDate); // Time + stuff uint32 duration = (uint32)((double)(hist->openTime) / HISTORY_TIMER_PRECISION); - temp.Format(_T("Loaded %s, open in the editor for %luh %02lum %02lus\r\n"), + s.AppendFormat(_T("Loaded %s, open in the editor for %luh %02lum %02lus\r\n"), szDate, duration / 3600, (duration / 60) % 60, duration % 60); - s += temp; } if(num == 0) { Modified: trunk/OpenMPT/soundlib/Fastmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Fastmix.cpp 2011-01-30 14:50:20 UTC (rev 792) +++ trunk/OpenMPT/soundlib/Fastmix.cpp 2011-01-31 23:32:12 UTC (rev 793) @@ -1479,8 +1479,8 @@ pChn->nPos = pChn->nLength - nDeltaHi - (nDeltaLo>>16); pChn->nPosLo = nDeltaLo & 0xffff; // Impulse Tracker's software mixer would put a -2 (instead of -1) in the following line (doesn't happen on a GUS) - // TODO: How can we add IT compatibility here without slowing down the mixing routines? - if ((pChn->nPos <= pChn->nLoopStart) || (pChn->nPos >= pChn->nLength)) pChn->nPos = pChn->nLength-1; + // The bidi mode flag is stored in a static CSoundFile variable. Dirty! + if ((pChn->nPos <= pChn->nLoopStart) || (pChn->nPos >= pChn->nLength)) pChn->nPos = pChn->nLength - (CSoundFile::m_bITBidiMode ? 2 : 1); } else { if (nInc < 0) // This is a bug Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2011-01-30 14:50:20 UTC (rev 792) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2011-01-31 23:32:12 UTC (rev 793) @@ -349,7 +349,6 @@ #define SNDMIX_MAXDEFAULTPAN 0x80000 // Used by the MOD loader (currently unused) #define SNDMIX_MUTECHNMODE 0x100000 // Notes are not played on muted channels #define SNDMIX_SMARTRAMP 0x200000 // Don't apply ramping to sample beginning, but only when it ends -#define SNDMIX_ITBIDIMODE 0x400000 // Process bidi loops like Impulse Tracker (see Fastmix.cpp for explanation) #define MAX_GLOBAL_VOLUME 256 Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2011-01-30 14:50:20 UTC (rev 792) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2011-01-31 23:32:12 UTC (rev 793) @@ -438,6 +438,7 @@ CTuningCollection* CSoundFile::s_pTuningsSharedBuiltIn(0); CTuningCollection* CSoundFile::s_pTuningsSharedLocal(0); uint8 CSoundFile::s_DefaultPlugVolumeHandling = PLUGIN_VOLUMEHANDLING_IGNORE; +bool CSoundFile::m_bITBidiMode = false; #pragma warning(disable : 4355) // "'this' : used in base member initializer list" CSoundFile::CSoundFile() : @@ -3031,6 +3032,7 @@ m_nType = newType; SetModSpecsPointer(m_pModSpecs, m_nType); SetupMODPanning(); // Setup LRRL panning scheme if needed + SetupITBidiMode(); // Setup IT bidi mode m_ModFlags = m_ModFlags & GetModFlagMask(oldtype, newType); @@ -3087,3 +3089,11 @@ ChnSettings[nChn].nPan = (((nChn & 3) == 1) || ((nChn & 3) == 2)) ? 0xC0 : 0x40; } } + + +// Set or unset the IT bidi loop mode (see Fastmix.cpp for an explanation). The variable has to be static... +void CSoundFile::SetupITBidiMode() +//-------------------------------- +{ + CSoundFile::m_bITBidiMode = IsCompatibleMode(TRK_IMPULSETRACKER); +} Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2011-01-30 14:50:20 UTC (rev 792) +++ trunk/OpenMPT/soundlib/Sndfile.h 2011-01-31 23:32:12 UTC (rev 793) @@ -107,7 +107,7 @@ INSTRUMENTENVELOPE PanEnv; // Panning envelope data INSTRUMENTENVELOPE PitchEnv; // Pitch / filter envelope data - BYTE NoteMap[128]; // Note mapping, f.e. C-5 => D-5 + 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 @@ -376,6 +376,7 @@ CHAR szLibraryName[64]; // original DLL name }; // Size should be 128 typedef SNDMIXPLUGININFO* PSNDMIXPLUGININFO; +STATIC_ASSERT(sizeof(SNDMIXPLUGININFO) == 128); // this is directly written to files, so the size must be correct! struct SNDMIXPLUGIN { @@ -452,6 +453,7 @@ CHAR szMidiZXXExt[128*32]; }; typedef MODMIDICFG* LPMODMIDICFG; +STATIC_ASSERT(sizeof(MODMIDICFG) == 4896); // this is directly written to files, so the size must be correct! typedef VOID (__cdecl * LPSNDMIXHOOKPROC)(int *, unsigned long, unsigned long); // buffer, samples, channels @@ -581,11 +583,12 @@ static LPSNDMIXHOOKPROC gpSndMixHook; static PMIXPLUGINCREATEPROC gpMixPluginCreateProc; static uint8 s_DefaultPlugVolumeHandling; + static bool m_bITBidiMode; // Process bidi loops like Impulse Tracker (see Fastmix.cpp for an explanation) public: // for Editing - CModDoc* m_pModDoc; + CModDoc* m_pModDoc; // Can be a null pointer f.e. when previewing samples from the treeview. MODTYPE m_nType; CHANNELINDEX m_nChannels; SAMPLEINDEX m_nSamples; @@ -711,6 +714,8 @@ CHANNELINDEX ReArrangeChannels(const vector<CHANNELINDEX>& fromToArray); bool MoveChannel(UINT chn_from, UINT chn_to); + void SetupITBidiMode(); + bool InitChannel(CHANNELINDEX nChn); void ResetChannelState(CHANNELINDEX chn, BYTE resetStyle); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |