From: <sag...@us...> - 2013-12-14 16:00:26
|
Revision: 3469 http://sourceforge.net/p/modplug/code/3469 Author: saga-games Date: 2013-12-14 16:00:14 +0000 (Sat, 14 Dec 2013) Log Message: ----------- [Fix] Note preview in instrument editor always uses lowpass filter if "Channel default" filter type is specified Modified Paths: -------------- trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/soundlib/ModChannel.cpp Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-12-14 15:55:10 UTC (rev 3468) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-12-14 16:00:14 UTC (rev 3469) @@ -638,7 +638,7 @@ .WorkingDirectory(TrackerDirectories::Instance().GetWorkingDirectory(DIR_MODS)); if(!dlg.Show()) return FALSE; - TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_MODS, true); + TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_MODS); saveFileName = dlg.GetFirstFile(); } else @@ -1075,77 +1075,63 @@ // Find a channel to play on nChn = FindAvailableChannel(); - - ModChannel *pChn = &m_SndFile.Chn[nChn]; + ModChannel &chn = m_SndFile.Chn[nChn]; // reset channel properties; in theory the chan is completely unused anyway. - pChn->nPos = pChn->nPosLo = 0; - pChn->nLength = 0; - pChn->dwFlags &= CHN_SAMPLEFLAGS; - pChn->dwFlags.reset(CHN_MUTE); - pChn->nGlobalVol = 64; - pChn->nInsVol = 64; - pChn->nPan = 128; - pChn->leftVol = pChn->rightVol = 0; - pChn->nROfs = pChn->nLOfs = 0; - pChn->nCutOff = 0x7F; - pChn->nResonance = 0; - pChn->nVolume = 256; - pChn->nMasterChn = 0; // remove NNA association - pChn->nNewNote = static_cast<BYTE>(note); + chn.Reset(ModChannel::resetTotal, m_SndFile, CHANNELINDEX_INVALID); + chn.nMasterChn = 0; // remove NNA association + chn.nNewNote = static_cast<uint8>(note); if (nins) { // Set instrument - pChn->ResetEnvelopes(); - m_SndFile.InstrumentChange(pChn, nins); - pChn->nFadeOutVol = 0x10000; // Needed for XM files, as the nRowInstr check in NoteChange() will fail. - } else if ((nsmp) && (nsmp < MAX_SAMPLES)) // Or set sample + chn.ResetEnvelopes(); + m_SndFile.InstrumentChange(&chn, nins); + chn.nFadeOutVol = 0x10000; // Needed for XM files, as the nRowInstr check in NoteChange() will fail. + } else if ((nsmp) && (nsmp < MAX_SAMPLES)) // Or set sample { ModSample &sample = m_SndFile.GetSample(nsmp); - pChn->pCurrentSample = sample.pSample; - pChn->pModInstrument = nullptr; - pChn->pModSample = &sample; - pChn->pSample = sample.pSample; - pChn->nFineTune = sample.nFineTune; - pChn->nC5Speed = sample.nC5Speed; - pChn->nPos = pChn->nPosLo = 0; - pChn->nLength = 0; - pChn->nLoopStart = sample.nLoopStart; - pChn->nLoopEnd = sample.nLoopEnd; - pChn->dwFlags = static_cast<ChannelFlags>(sample.uFlags) & (CHN_SAMPLEFLAGS & ~CHN_MUTE); - pChn->nPan = 128; - if (sample.uFlags & CHN_PANNING) pChn->nPan = sample.nPan; - pChn->nInsVol = sample.nGlobalVol; - pChn->nFadeOutVol = 0x10000; + chn.pCurrentSample = sample.pSample; + chn.pModInstrument = nullptr; + chn.pModSample = &sample; + chn.pSample = sample.pSample; + chn.nFineTune = sample.nFineTune; + chn.nC5Speed = sample.nC5Speed; + chn.nLoopStart = sample.nLoopStart; + chn.nLoopEnd = sample.nLoopEnd; + chn.dwFlags = static_cast<ChannelFlags>(sample.uFlags) & (CHN_SAMPLEFLAGS & ~CHN_MUTE); + chn.nPan = 128; + if (sample.uFlags & CHN_PANNING) chn.nPan = sample.nPan; + chn.nInsVol = sample.nGlobalVol; + chn.nFadeOutVol = 0x10000; } m_SndFile.NoteChange(nChn, note, false, true, true); - if (nVol >= 0) pChn->nVolume = nVol; + if (nVol >= 0) chn.nVolume = nVol; // Handle sample looping. // Changed line to fix http://forum.openmpt.org/index.php?topic=1700.0 - //if ((loopstart + 16 < loopend) && (loopstart >= 0) && (loopend <= (LONG)pChn->nLength)) - if ((loopStart + 16 < loopEnd) && (loopStart >= 0) && (pChn->pModSample != nullptr)) + //if ((loopstart + 16 < loopend) && (loopstart >= 0) && (loopend <= (LONG)pchn.nLength)) + if ((loopStart + 16 < loopEnd) && (loopStart >= 0) && (chn.pModSample != nullptr)) { - pChn->nPos = loopStart; - pChn->nPosLo = 0; - pChn->nLoopStart = loopStart; - pChn->nLoopEnd = loopEnd; - pChn->nLength = std::min(loopEnd, pChn->pModSample->nLength); + chn.nPos = loopStart; + chn.nPosLo = 0; + chn.nLoopStart = loopStart; + chn.nLoopEnd = loopEnd; + chn.nLength = std::min(loopEnd, chn.pModSample->nLength); } // Handle extra-loud flag - pChn->dwFlags.set(CHN_EXTRALOUD, !(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_NOEXTRALOUD) && nsmp); + chn.dwFlags.set(CHN_EXTRALOUD, !(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_NOEXTRALOUD) && nsmp); // Handle custom start position - if(sampleOffset > 0 && pChn->pModSample) + if(sampleOffset > 0 && chn.pModSample) { - pChn->nPos = sampleOffset; + chn.nPos = sampleOffset; // If start position is after loop end, set loop end to sample end so that the sample starts // playing. - if(pChn->nLoopEnd < sampleOffset) - pChn->nLength = pChn->nLoopEnd = pChn->pModSample->nLength; + if(chn.nLoopEnd < sampleOffset) + chn.nLength = chn.nLoopEnd = chn.pModSample->nLength; } //rewbs.vstiLive @@ -1157,8 +1143,8 @@ // UINT nPlugin = m_SndFile.GetBestPlugin(nChn, PRIORITISE_INSTRUMENT, EVEN_IF_MUTED); PLUGINDEX nPlugin = 0; - if (pChn->pModInstrument) - nPlugin = pChn->pModInstrument->nMixPlug; // First try instrument plugin + if (chn.pModInstrument) + nPlugin = chn.pModInstrument->nMixPlug; // First try instrument plugin if ((!nPlugin || nPlugin > MAX_MIXPLUGINS) && nCurrentChn != CHANNELINDEX_INVALID) nPlugin = m_SndFile.ChnSettings[nCurrentChn].nMixPlugin; // Then try channel plugin @@ -1168,7 +1154,7 @@ if(pPlugin != nullptr) { - pPlugin->MidiCommand(GetPlaybackMidiChannel(pIns, nCurrentChn), pIns->nMidiProgram, pIns->wMidiBank, pIns->NoteMap[note - 1], static_cast<uint16>(pChn->nVolume), MAX_BASECHANNELS); + pPlugin->MidiCommand(GetPlaybackMidiChannel(pIns, nCurrentChn), pIns->nMidiProgram, pIns->wMidiBank, pIns->NoteMap[note - 1], static_cast<uint16>(chn.nVolume), MAX_BASECHANNELS); } } } Modified: trunk/OpenMPT/soundlib/ModChannel.cpp =================================================================== --- trunk/OpenMPT/soundlib/ModChannel.cpp 2013-12-14 15:55:10 UTC (rev 3468) +++ trunk/OpenMPT/soundlib/ModChannel.cpp 2013-12-14 16:00:14 UTC (rev 3469) @@ -17,7 +17,8 @@ { if(resetMask & resetSetPosBasic) { - nNote = nNewNote = nNewIns = nOldIns = 0; + nNote = nNewNote = NOTE_NONE; + nNewIns = nOldIns = 0; pModSample = nullptr; pModInstrument = nullptr; nPortamentoDest = 0; @@ -40,6 +41,7 @@ { nPeriod = 0; nPos = 0; + nPosLo = 0; nLength = 0; nLoopStart = 0; nLoopEnd = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |