From: <sag...@us...> - 2009-09-18 18:49:14
|
Revision: 369 http://modplug.svn.sourceforge.net/modplug/?rev=369&view=rev Author: saga-games Date: 2009-09-18 18:48:59 +0000 (Fri, 18 Sep 2009) Log Message: ----------- [Fix] ITI Loader/Saver: Forgot to change vibrato sweep settings here in the last commit [Ref] Some more refactoring Modified Paths: -------------- trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/soundlib/Sampleio.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2009-09-17 16:11:47 UTC (rev 368) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2009-09-18 18:48:59 UTC (rev 369) @@ -1017,13 +1017,13 @@ } -BOOL CModDoc::MuteChannel(UINT nChn, BOOL doMute) +bool CModDoc::MuteChannel(CHANNELINDEX nChn, bool doMute) //---------------------------------------------- { DWORD muteType = (CMainFrame::m_dwPatternSetup&PATTERN_SYNCMUTE)? CHN_SYNCMUTE:CHN_MUTE; if (nChn >= m_SndFile.m_nChannels) { - return FALSE; + return false; } //Mark channel as muted in channel settings @@ -1067,43 +1067,43 @@ CMainFrame::GetMainFrame()->ThreadSafeSetModified(this); } - return TRUE; + return true; } // -> CODE#0012 // -> DESC="midi keyboard split" -BOOL CModDoc::IsChannelSolo(UINT nChn) const -//------------------------------------------ +bool CModDoc::IsChannelSolo(CHANNELINDEX nChn) const +//-------------------------------------------------- { - if (nChn >= m_SndFile.m_nChannels) return TRUE; - return (m_SndFile.ChnSettings[nChn].dwFlags & CHN_SOLO) ? TRUE : FALSE; + if (nChn >= m_SndFile.m_nChannels) return true; + return (m_SndFile.ChnSettings[nChn].dwFlags & CHN_SOLO) ? true : false; } -BOOL CModDoc::SoloChannel(UINT nChn, BOOL bSolo) -//--------------------------------------------- +bool CModDoc::SoloChannel(CHANNELINDEX nChn, bool bSolo) +//------------------------------------------------------ { - if (nChn >= m_SndFile.m_nChannels) return FALSE; + if (nChn >= m_SndFile.m_nChannels) return false; if (m_SndFile.m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT)) SetModified(); if (bSolo) m_SndFile.ChnSettings[nChn].dwFlags |= CHN_SOLO; else m_SndFile.ChnSettings[nChn].dwFlags &= ~CHN_SOLO; - return TRUE; + return true; } // -! NEW_FEATURE#0012 // -> CODE#0015 // -> DESC="channels management dlg" -BOOL CModDoc::IsChannelNoFx(UINT nChn) const +bool CModDoc::IsChannelNoFx(CHANNELINDEX nChn) const //------------------------------------------ { - if (nChn >= m_SndFile.m_nChannels) return TRUE; - return (m_SndFile.ChnSettings[nChn].dwFlags & CHN_NOFX) ? TRUE : FALSE; + if (nChn >= m_SndFile.m_nChannels) return true; + return (m_SndFile.ChnSettings[nChn].dwFlags & CHN_NOFX) ? true : false; } -BOOL CModDoc::NoFxChannel(UINT nChn, BOOL bNoFx, BOOL updateMix) -//-------------------------------------------------------------- +bool CModDoc::NoFxChannel(CHANNELINDEX nChn, bool bNoFx, bool updateMix) +//---------------------------------------------------------------------- { - if (nChn >= m_SndFile.m_nChannels) return FALSE; + if (nChn >= m_SndFile.m_nChannels) return false; if (m_SndFile.m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT)) SetModified(); if (bNoFx){ m_SndFile.ChnSettings[nChn].dwFlags |= CHN_NOFX; @@ -1113,33 +1113,33 @@ m_SndFile.ChnSettings[nChn].dwFlags &= ~CHN_NOFX; if(updateMix) m_SndFile.Chn[nChn].dwFlags &= ~CHN_NOFX; } - return TRUE; + return true; } -BOOL CModDoc::IsChannelRecord1(UINT channel) -//------------------------------------------ +bool CModDoc::IsChannelRecord1(CHANNELINDEX channel) +//-------------------------------------------------- { UINT m = 1 << (channel&7); - return (MultiRecordMask[channel>>3] & m) ? TRUE : FALSE; + return (MultiRecordMask[channel>>3] & m) ? true : false; } -BOOL CModDoc::IsChannelRecord2(UINT channel) -//------------------------------------------ +bool CModDoc::IsChannelRecord2(CHANNELINDEX channel) +//-------------------------------------------------- { UINT m = 1 << (channel&7); - return (MultiSplitRecordMask[channel>>3] & m) ? TRUE : FALSE; + return (MultiSplitRecordMask[channel>>3] & m) ? true : false; } -BYTE CModDoc::IsChannelRecord(UINT channel) -//----------------------------------------- +BYTE CModDoc::IsChannelRecord(CHANNELINDEX channel) +//------------------------------------------------- { if(IsChannelRecord1(channel)) return 1; if(IsChannelRecord2(channel)) return 2; return 0; } -void CModDoc::Record1Channel(UINT channel, BOOL select) -//----------------------------------------------------- +void CModDoc::Record1Channel(CHANNELINDEX channel, bool select) +//------------------------------------------------------------- { UINT m = 1 << (channel&7); @@ -1153,8 +1153,8 @@ } } -void CModDoc::Record2Channel(UINT channel, BOOL select) -//----------------------------------------------------- +void CModDoc::Record2Channel(CHANNELINDEX channel, bool select) +//------------------------------------------------------------- { UINT m = 1 << (channel&7); @@ -1168,7 +1168,7 @@ } } -void CModDoc::ReinitRecordState(BOOL unselect) +void CModDoc::ReinitRecordState(bool unselect) //-------------------------------------------- { memset(MultiRecordMask, unselect ? 0 : 0xff, sizeof(MultiRecordMask)); @@ -1177,31 +1177,31 @@ // -! NEW_FEATURE#0015 -BOOL CModDoc::MuteSample(UINT nSample, BOOL bMute) -//------------------------------------------------ +bool CModDoc::MuteSample(SAMPLEINDEX nSample, bool bMute) +//------------------------------------------------------- { - if ((nSample < 1) || (nSample > m_SndFile.m_nSamples)) return FALSE; + if ((nSample < 1) || (nSample > m_SndFile.m_nSamples)) return false; if (bMute) m_SndFile.Samples[nSample].uFlags |= CHN_MUTE; else m_SndFile.Samples[nSample].uFlags &= ~CHN_MUTE; - return TRUE; + return true; } -BOOL CModDoc::MuteInstrument(UINT nInstr, BOOL bMute) -//--------------------------------------------------- +bool CModDoc::MuteInstrument(INSTRUMENTINDEX nInstr, bool bMute) +//-------------------------------------------------------------- { - if ((nInstr < 1) || (nInstr > m_SndFile.m_nInstruments) || (!m_SndFile.Instruments[nInstr])) return FALSE; + if ((nInstr < 1) || (nInstr > m_SndFile.m_nInstruments) || (!m_SndFile.Instruments[nInstr])) return false; if (bMute) m_SndFile.Instruments[nInstr]->dwFlags |= ENV_MUTE; else m_SndFile.Instruments[nInstr]->dwFlags &= ~ENV_MUTE; - return TRUE; + return true; } -BOOL CModDoc::SurroundChannel(UINT nChn, BOOL bSurround) -//------------------------------------------------------ +bool CModDoc::SurroundChannel(CHANNELINDEX nChn, bool bSurround) +//-------------------------------------------------------------- { DWORD d = (bSurround) ? CHN_SURROUND : 0; - if (nChn >= m_SndFile.m_nChannels) return FALSE; + if (nChn >= m_SndFile.m_nChannels) return false; if (!(m_SndFile.m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT))) d = 0; if (d != (m_SndFile.ChnSettings[nChn].dwFlags & CHN_SURROUND)) { @@ -1212,68 +1212,68 @@ } if (d) m_SndFile.Chn[nChn].dwFlags |= CHN_SURROUND; else m_SndFile.Chn[nChn].dwFlags &= ~CHN_SURROUND; - return TRUE; + return true; } -BOOL CModDoc::SetChannelGlobalVolume(UINT nChn, UINT nVolume) -//----------------------------------------------------------- +bool CModDoc::SetChannelGlobalVolume(CHANNELINDEX nChn, UINT nVolume) +//------------------------------------------------------------------- { - BOOL bOk = FALSE; - if ((nChn >= m_SndFile.m_nChannels) || (nVolume > 64)) return FALSE; + bool bOk = false; + if ((nChn >= m_SndFile.m_nChannels) || (nVolume > 64)) return false; if (m_SndFile.ChnSettings[nChn].nVolume != nVolume) { m_SndFile.ChnSettings[nChn].nVolume = nVolume; if (m_SndFile.m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT)) SetModified(); - bOk = TRUE; + bOk = true; } m_SndFile.Chn[nChn].nGlobalVol = nVolume; return bOk; } -BOOL CModDoc::SetChannelDefaultPan(UINT nChn, UINT nPan) -//------------------------------------------------------ +bool CModDoc::SetChannelDefaultPan(CHANNELINDEX nChn, UINT nPan) +//-------------------------------------------------------------- { - BOOL bOk = FALSE; - if ((nChn >= m_SndFile.m_nChannels) || (nPan > 256)) return FALSE; + bool bOk = false; + if ((nChn >= m_SndFile.m_nChannels) || (nPan > 256)) return false; if (m_SndFile.ChnSettings[nChn].nPan != nPan) { m_SndFile.ChnSettings[nChn].nPan = nPan; if (m_SndFile.m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT | MOD_TYPE_MPT)) SetModified(); - bOk = TRUE; + bOk = true; } m_SndFile.Chn[nChn].nPan = nPan; return bOk; } -BOOL CModDoc::IsChannelMuted(UINT nChn) const -//------------------------------------------- +bool CModDoc::IsChannelMuted(CHANNELINDEX nChn) const +//--------------------------------------------------- { - if (nChn >= m_SndFile.m_nChannels) return TRUE; - return (m_SndFile.ChnSettings[nChn].dwFlags & CHN_MUTE) ? TRUE : FALSE; + if (nChn >= m_SndFile.m_nChannels) return true; + return (m_SndFile.ChnSettings[nChn].dwFlags & CHN_MUTE) ? true : false; } -BOOL CModDoc::IsSampleMuted(UINT nSample) const -//--------------------------------------------- +bool CModDoc::IsSampleMuted(SAMPLEINDEX nSample) const +//---------------------------------------------------- { - if ((!nSample) || (nSample > m_SndFile.m_nSamples)) return FALSE; - return (m_SndFile.Samples[nSample].uFlags & CHN_MUTE) ? TRUE : FALSE; + if ((!nSample) || (nSample > m_SndFile.m_nSamples)) return false; + return (m_SndFile.Samples[nSample].uFlags & CHN_MUTE) ? true : false; } -BOOL CModDoc::IsInstrumentMuted(UINT nInstr) const -//------------------------------------------------ +bool CModDoc::IsInstrumentMuted(INSTRUMENTINDEX nInstr) const +//----------------------------------------------------------- { - if ((!nInstr) || (nInstr > m_SndFile.m_nInstruments) || (!m_SndFile.Instruments[nInstr])) return FALSE; - return (m_SndFile.Instruments[nInstr]->dwFlags & ENV_MUTE) ? TRUE : FALSE; + if ((!nInstr) || (nInstr > m_SndFile.m_nInstruments) || (!m_SndFile.Instruments[nInstr])) return false; + return (m_SndFile.Instruments[nInstr]->dwFlags & ENV_MUTE) ? true : false; } -UINT CModDoc::GetPatternSize(UINT nPat) const -//------------------------------------------- +UINT CModDoc::GetPatternSize(PATTERNINDEX nPat) const +//--------------------------------------------------- { if ((nPat < m_SndFile.Patterns.Size()) && (m_SndFile.Patterns[nPat])) return m_SndFile.PatternSize[nPat]; return 0; Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2009-09-17 16:11:47 UTC (rev 368) +++ trunk/OpenMPT/mptrack/Moddoc.h 2009-09-18 18:48:59 UTC (rev 369) @@ -150,8 +150,8 @@ void PostMessageToAllViews(UINT uMsg, WPARAM wParam=0, LPARAM lParam=0); void SendMessageToActiveViews(UINT uMsg, WPARAM wParam=0, LPARAM lParam=0); UINT GetModType() const { return m_SndFile.m_nType; } - BOOL GetNumInstruments() const { return m_SndFile.m_nInstruments; } - BOOL GetNumSamples() const { return m_SndFile.m_nSamples; } + INSTRUMENTINDEX GetNumInstruments() const { return m_SndFile.m_nInstruments; } + SAMPLEINDEX GetNumSamples() const { return m_SndFile.m_nSamples; } BOOL AddToLog(LPCSTR lpszLog); LPCSTR GetLog() const { return m_lpszLog; } BOOL ClearLog(); @@ -211,33 +211,33 @@ BOOL NoteOff(UINT note, BOOL bFade=FALSE, UINT nins=-1, UINT nCurrentChn=-1); //rewbs.vstiLive: add params BOOL IsNotePlaying(UINT note, UINT nsmp=0, UINT nins=0); - BOOL MuteChannel(UINT nChn, BOOL bMute); - BOOL MuteSample(UINT nSample, BOOL bMute); - BOOL MuteInstrument(UINT nInstr, BOOL bMute); + bool MuteChannel(CHANNELINDEX nChn, bool bMute); + bool MuteSample(SAMPLEINDEX nSample, bool bMute); + bool MuteInstrument(INSTRUMENTINDEX nInstr, bool bMute); // -> CODE#0012 // -> DESC="midi keyboard split" - BOOL SoloChannel(UINT nChn, BOOL bSolo); - BOOL IsChannelSolo(UINT nChn) const; + bool SoloChannel(CHANNELINDEX nChn, bool bSolo); + bool IsChannelSolo(CHANNELINDEX nChn) const; // -! NEW_FEATURE#0012 - BOOL SurroundChannel(UINT nChn, BOOL bSurround); - BOOL SetChannelGlobalVolume(UINT nChn, UINT nVolume); - BOOL SetChannelDefaultPan(UINT nChn, UINT nPan); - BOOL IsChannelMuted(UINT nChn) const; - BOOL IsSampleMuted(UINT nSample) const; - BOOL IsInstrumentMuted(UINT nInstr) const; + bool SurroundChannel(CHANNELINDEX nChn, bool bSurround); + bool SetChannelGlobalVolume(CHANNELINDEX nChn, UINT nVolume); + bool SetChannelDefaultPan(CHANNELINDEX nChn, UINT nPan); + bool IsChannelMuted(CHANNELINDEX nChn) const; + bool IsSampleMuted(SAMPLEINDEX nSample) const; + bool IsInstrumentMuted(INSTRUMENTINDEX nInstr) const; // -> CODE#0015 // -> DESC="channels management dlg" - BOOL NoFxChannel(UINT nChn, BOOL bNoFx, BOOL updateMix = TRUE); - BOOL IsChannelNoFx(UINT nChn) const; - BOOL IsChannelRecord1(UINT channel); - BOOL IsChannelRecord2(UINT channel); - BYTE IsChannelRecord(UINT channel); - void Record1Channel(UINT channel, BOOL select = TRUE); - void Record2Channel(UINT channel, BOOL select = TRUE); - void ReinitRecordState(BOOL unselect = TRUE); + bool NoFxChannel(CHANNELINDEX nChn, bool bNoFx, bool updateMix = true); + bool IsChannelNoFx(CHANNELINDEX nChn) const; + bool IsChannelRecord1(CHANNELINDEX channel); + bool IsChannelRecord2(CHANNELINDEX channel); + BYTE IsChannelRecord(CHANNELINDEX channel); + void Record1Channel(CHANNELINDEX channel, bool select = true); + void Record2Channel(CHANNELINDEX channel, bool select = true); + void ReinitRecordState(bool unselect = true); // -! NEW_FEATURE#0015 - UINT GetNumChannels() const { return m_SndFile.m_nChannels; } - UINT GetPatternSize(UINT nPat) const; + CHANNELINDEX GetNumChannels() const { return m_SndFile.m_nChannels; } + UINT GetPatternSize(PATTERNINDEX nPat) const; BOOL AdjustEndOfSample(UINT nSample); BOOL IsChildSample(UINT nIns, UINT nSmp) const; UINT FindSampleParent(UINT nSmp) const; Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2009-09-17 16:11:47 UTC (rev 368) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2009-09-18 18:48:59 UTC (rev 369) @@ -2537,8 +2537,8 @@ pModDoc = GetDocumentFromItem(hItem); if (pModDoc) { - UINT nSamples = pModDoc->GetNumSamples(); - UINT nInstruments = pModDoc->GetNumInstruments(); + SAMPLEINDEX nSamples = pModDoc->GetNumSamples(); + INSTRUMENTINDEX nInstruments = pModDoc->GetNumInstruments(); if ((dwItemType == MODITEM_SAMPLE) && (!nInstruments)) { for (UINT i=1; i<=nSamples; i++) @@ -2568,8 +2568,8 @@ pModDoc = GetDocumentFromItem(hItem); if (pModDoc) { - UINT nSamples = pModDoc->GetNumSamples(); - UINT nInstruments = pModDoc->GetNumInstruments(); + SAMPLEINDEX nSamples = pModDoc->GetNumSamples(); + INSTRUMENTINDEX nInstruments = pModDoc->GetNumInstruments(); if ((dwItemType == MODITEM_SAMPLE) || (dwItemType == MODITEM_INSTRUMENT)) { for (UINT i=1; i<=nSamples; i++) Modified: trunk/OpenMPT/soundlib/Sampleio.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sampleio.cpp 2009-09-17 16:11:47 UTC (rev 368) +++ trunk/OpenMPT/soundlib/Sampleio.cpp 2009-09-18 18:48:59 UTC (rev 369) @@ -1362,9 +1362,9 @@ if (!k) { xih.vibtype = Samples[n].nVibType; - xih.vibsweep = Samples[n].nVibSweep; - xih.vibdepth = Samples[n].nVibDepth; - xih.vibrate = Samples[n].nVibRate; + xih.vibsweep = min(Samples[n].nVibSweep, 255); + xih.vibdepth = min(Samples[n].nVibDepth, 15); + xih.vibrate = min(Samples[n].nVibRate, 63); } if (nsamples < 32) smptable[nsamples++] = n; k = nsamples - 1; @@ -1693,7 +1693,7 @@ if (pSmp->nPan > 256) pSmp->nPan = 256; if (pis->dfp & 0x80) pSmp->uFlags |= CHN_PANNING; pSmp->nVibType = autovibit2xm[pis->vit & 7]; - pSmp->nVibSweep = (pis->vir + 3) / 4; + pSmp->nVibSweep = pis->vir; pSmp->nVibDepth = pis->vid; pSmp->nVibRate = pis->vis; UINT flags = (pis->cvt & 1) ? RS_PCM8S : RS_PCM8U; @@ -1944,9 +1944,9 @@ itss.vol = psmp->nVolume >> 2; itss.dfp = psmp->nPan >> 2; itss.vit = autovibxm2it[psmp->nVibType & 7]; - itss.vir = (psmp->nVibSweep < 64) ? psmp->nVibSweep*4 : 255; - itss.vid = psmp->nVibDepth; - itss.vis = psmp->nVibRate; + itss.vir = min(psmp->nVibSweep, 255); + itss.vid = min(psmp->nVibDepth, 32); + itss.vis = min(psmp->nVibRate, 64); if (psmp->uFlags & CHN_PANNING) itss.dfp |= 0x80; itss.cvt = 0x01; smpsize = psmp->nLength; Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2009-09-17 16:11:47 UTC (rev 368) +++ trunk/OpenMPT/soundlib/Sndfile.h 2009-09-18 18:48:59 UTC (rev 369) @@ -40,6 +40,7 @@ BYTE nVibSweep; BYTE nVibDepth; BYTE nVibRate; + CHAR name[32]; CHAR filename[22]; // Return the size of one (elementary) sample in bytes. @@ -545,7 +546,10 @@ public: // for Editing CModDoc* m_pModDoc; - UINT m_nType, m_nChannels, m_nSamples, m_nInstruments; + UINT m_nType; + CHANNELINDEX m_nChannels; + SAMPLEINDEX m_nSamples; + INSTRUMENTINDEX m_nInstruments; UINT m_nDefaultSpeed, m_nDefaultTempo, m_nDefaultGlobalVolume; DWORD m_dwSongFlags; // Song flags SONG_XXXX bool m_bIsRendering; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |