From: <sag...@us...> - 2012-02-07 00:11:45
|
Revision: 1173 http://modplug.svn.sourceforge.net/modplug/?rev=1173&view=rev Author: saga-games Date: 2012-02-07 00:11:38 +0000 (Tue, 07 Feb 2012) Log Message: ----------- [Fix] Envelope Editor: Two envelope points cannot be inserted on the same tick anymore. [Imp] VST: audioMasterUpdateDisplay opcode is handled (again?). [Mod] VST: Removed check for TuneFish 2.0 (seems superfluous). [Ref] A bit of refactoring a day keeps the doctor away. Modified Paths: -------------- trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/mptrack/View_ins.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/soundlib/Load_mid.cpp Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2012-02-06 23:55:02 UTC (rev 1172) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2012-02-07 00:11:38 UTC (rev 1173) @@ -891,7 +891,7 @@ //---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- { CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - UINT nChn = GetNumChannels(); + CHANNELINDEX nChn = GetNumChannels(); if ((!pMainFrm) || (!note)) return FALSE; if (nVol > 256) nVol = 256; @@ -1096,18 +1096,18 @@ // Check if a given note of an instrument or sample is playing. // If note == 0, just check if an instrument or sample is playing. -BOOL CModDoc::IsNotePlaying(UINT note, UINT nsmp, UINT nins) -//---------------------------------------------------------- +bool CModDoc::IsNotePlaying(UINT note, SAMPLEINDEX nsmp, INSTRUMENTINDEX nins) +//---------------------------------------------------------------------------- { - MODCHANNEL *pChn = &m_SndFile.Chn[m_SndFile.m_nChannels]; - for (UINT i=m_SndFile.m_nChannels; i<MAX_CHANNELS; i++, pChn++) if (!pChn->nMasterChn) + MODCHANNEL *pChn = &m_SndFile.Chn[m_SndFile.GetNumChannels()]; + for (CHANNELINDEX i = m_SndFile.GetNumChannels(); i < MAX_CHANNELS; i++, pChn++) if (!pChn->nMasterChn) { if ((pChn->nLength) && (!(pChn->dwFlags & (CHN_NOTEFADE|CHN_KEYOFF|CHN_MUTE))) && ((note == pChn->nNewNote) || (!note)) && ((pChn->pModSample == &m_SndFile.GetSample(nsmp)) || (!nsmp)) - && ((pChn->pModInstrument == m_SndFile.Instruments[nins]) || (!nins))) return TRUE; + && ((pChn->pModInstrument == m_SndFile.Instruments[nins]) || (!nins))) return true; } - return FALSE; + return false; } @@ -3534,8 +3534,8 @@ -UINT CModDoc::FindAvailableChannel() -//---------------------------------- +CHANNELINDEX CModDoc::FindAvailableChannel() +//------------------------------------------ { CHANNELINDEX nStoppedChannel = CHANNELINDEX_INVALID; // Search for available channel Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2012-02-06 23:55:02 UTC (rev 1172) +++ trunk/OpenMPT/mptrack/Moddoc.h 2012-02-07 00:11:38 UTC (rev 1173) @@ -252,7 +252,6 @@ bool ChangeNumChannels(CHANNELINDEX nNewChannels, const bool showCancelInRemoveDlg = true); bool RemoveChannels(const vector<bool> &keepMask); CHANNELINDEX ReArrangeChannels(const vector<CHANNELINDEX> &fromToArray, const bool createUndoPoint = true); - bool MoveChannel(CHANNELINDEX chn_from, CHANNELINDEX chn_to); void CheckUsedChannels(vector<bool> &usedMask, CHANNELINDEX maxRemoveCount = MAX_BASECHANNELS) const; bool ConvertInstrumentsToSamples(); @@ -272,7 +271,7 @@ UINT PlayNote(UINT note, INSTRUMENTINDEX nins, SAMPLEINDEX nsmp, bool pause, LONG nVol=-1, SmpLength loopStart = 0, SmpLength loopEnd = 0, CHANNELINDEX nCurrentChn = CHANNELINDEX_INVALID, const SmpLength sampleOffset = 0); //rewbs.vstiLive: added current chan param BOOL NoteOff(UINT note, bool fade = false, INSTRUMENTINDEX nins = INSTRUMENTINDEX_INVALID, CHANNELINDEX nCurrentChn = CHANNELINDEX_INVALID); //rewbs.vstiLive: add params - BOOL IsNotePlaying(UINT note, UINT nsmp=0, UINT nins=0); + bool IsNotePlaying(UINT note, SAMPLEINDEX nsmp = 0, INSTRUMENTINDEX nins = 0); bool MuteChannel(CHANNELINDEX nChn, bool bMute); bool UpdateChannelMuteStatus(CHANNELINDEX nChn); bool MuteSample(SAMPLEINDEX nSample, bool bMute); @@ -426,7 +425,7 @@ private: void ChangeFileExtension(MODTYPE nNewType); - UINT FindAvailableChannel(); + CHANNELINDEX FindAvailableChannel(); }; ///////////////////////////////////////////////////////////////////////////// Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2012-02-06 23:55:02 UTC (rev 1172) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2012-02-07 00:11:38 UTC (rev 1173) @@ -256,51 +256,6 @@ } -bool CModDoc::MoveChannel(CHANNELINDEX chnFrom, CHANNELINDEX chnTo) -//----------------------------------------------------------------- -{ - //Implementation of move channel using ReArrangeChannels(...). So this function - //only creates correct newOrder-vector used in the ReArrangeChannels(...). - if(chnFrom == chnTo) return false; - if(chnFrom >= GetNumChannels() || chnTo >= GetNumChannels()) - { - Reporting::Error("Error: Bad move indexes in CSoundFile::MoveChannel(...)" , "MoveChannel(...)"); - return true; - } - vector<CHANNELINDEX> newOrder; - //First creating new order identical to current order... - for(CHANNELINDEX i = 0; i < GetNumChannels(); i++) - { - newOrder.push_back(i); - } - //...and then add the move channel effect. - if(chnFrom < chnTo) - { - CHANNELINDEX temp = newOrder[chnFrom]; - for(CHANNELINDEX i = chnFrom; i < chnTo; i++) - { - newOrder[i] = newOrder[i + 1]; - } - newOrder[chnTo] = temp; - } - else //case chnFrom > chnTo(can't be equal, since it has been examined earlier.) - { - CHANNELINDEX temp = newOrder[chnFrom]; - for(CHANNELINDEX i = chnFrom; i >= chnTo + 1; i--) - { - newOrder[i] = newOrder[i - 1]; - } - newOrder[chnTo] = temp; - } - - if(newOrder.size() != ReArrangeChannels(newOrder)) - { - Reporting::Error("BUG: Channel number changed in MoveChannel()"); - } - return false; -} - - // Functor for converting instrument numbers to sample numbers in the patterns struct ConvertInstrumentsToSamplesInPatterns //========================================== Modified: trunk/OpenMPT/mptrack/View_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_ins.cpp 2012-02-06 23:55:02 UTC (rev 1172) +++ trunk/OpenMPT/mptrack/View_ins.cpp 2012-02-07 00:11:38 UTC (rev 1173) @@ -1066,11 +1066,18 @@ if (pIns) { if(nTick < 0) return 0; + nValue = Clamp(nValue, 0, 64); - nValue = CLAMP(nValue, 0, 64); - INSTRUMENTENVELOPE *envelope = GetEnvelopePtr(); if(envelope == nullptr) return 0; + + if(std::binary_search(envelope->Ticks, envelope->Ticks + envelope->nNodes, nTick)) + { + // Don't want to insert a node at the same position as another node. + return 0; + } + + BYTE cDefaultValue; switch(m_nEnv) @@ -1639,14 +1646,14 @@ if (rect.PtInRect(pt)) m_nDragItem = ENV_DRAGLOOPEND; } } + if (m_nDragItem) { SetCapture(); m_dwStatus |= INSSTATUS_DRAGGING; // refresh active node colour InvalidateRect(NULL, FALSE); - } - else + } else { // Shift-Click: Insert envelope point here if(CMainFrame::GetMainFrame()->GetInputHandler()->ShiftPressed()) @@ -1896,7 +1903,6 @@ void CViewInstrument::OnEnvInsertPoint() //-------------------------------------- { - EnvInsertPoint(ScreenToTick(m_ptMenu.x), ScreenToValue(m_ptMenu.y)); } Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2012-02-06 23:55:02 UTC (rev 1172) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2012-02-07 00:11:38 UTC (rev 1173) @@ -362,12 +362,6 @@ pEffect->flags, pEffect->realQualities, pEffect->offQualities); #endif // VST_LOG - // Tunefish 2.0 doesn't seem to like that we call effClose at this point... - if(CCONST('T', 'F', '2', '0') != pEffect->uniqueID) - { - pEffect->dispatcher(pEffect, effClose, 0,0,0,0); - } - bOk = TRUE; } } catch(...) @@ -1054,16 +1048,12 @@ case audioMasterUpdateDisplay: if (pVstPlugin != nullptr) { -// pVstPlugin->GetModDoc()->UpdateAllViews(NULL, HINT_MIXPLUGINS, NULL); //No Need. - -/* CAbstractVstEditor *pVstEditor = pVstPlugin->GetEditor(); + // Note to self for testing: Electri-Q sends opcode. + CAbstractVstEditor *pVstEditor = pVstPlugin->GetEditor(); if (pVstEditor && ::IsWindow(pVstEditor->m_hWnd)) { - //pVstEditor->SetupMenu(); + pVstEditor->SetupMenu(); } -*/ -// effect->dispatcher(effect, effEditIdle, 0, 0, NULL, 0.0f); -// effect->dispatcher(effect, effEditTop, 0,0, NULL, 0); } return 0; @@ -1169,7 +1159,7 @@ } FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog( - (pFileSel->command == kVstFileSave ? false : true), + (pFileSel->command != kVstFileSave), "", "", extensions, workingDir, (pFileSel->command == kVstMultipleFilesLoad) ); Modified: trunk/OpenMPT/soundlib/Load_mid.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mid.cpp 2012-02-06 23:55:02 UTC (rev 1172) +++ trunk/OpenMPT/soundlib/Load_mid.cpp 2012-02-07 00:11:38 UTC (rev 1173) @@ -341,23 +341,6 @@ /////////////////////////////////////////////////////////////////////////// // Helper functions -static LONG __fastcall getmidilong(LPCBYTE &p, LPCBYTE pmax) -//---------------------------------------------------------- -{ - DWORD n; - UINT a; - - a = (p < pmax) ? *(p++) : 0; - n = 0; - while (a&0x80) - { - n = (n<<7)|(a&0x7F); - a = (p < pmax) ? *(p++) : 0; - } - return (n<<7)|(LONG)a; -} - - // Returns MOD tempo and tick multiplier static int ConvertMidiTempo(int tempo_us, int &tickMultiplier, int importSpeed) //------------------------------------------------------------------------------ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |