From: <sag...@us...> - 2012-03-13 22:15:35
|
Revision: 1220 http://modplug.svn.sourceforge.net/modplug/?rev=1220&view=rev Author: saga-games Date: 2012-03-13 22:15:28 +0000 (Tue, 13 Mar 2012) Log Message: ----------- [Fix] Pattern Editor: Reset Channel shortcut never worked. [Imp] VST: Implemented (deprecated) GetPreviousPlug / GetNextPlug opcodes. [Mod] Plugins: When using Randomise Params, only automatable parameters are now randomised. [Mod] OpenMPT: Version is now 1.20.00.78 Modified Paths: -------------- trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_pat.h trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/Vstplug.h trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/PluginEventQueue.h Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2012-03-13 14:49:58 UTC (rev 1219) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2012-03-13 22:15:28 UTC (rev 1220) @@ -1624,15 +1624,22 @@ void CViewPattern::OnChannelReset() //--------------------------------- { - const CHANNELINDEX nChn = m_MenuCursor.GetChannel(); + ResetChannel(m_MenuCursor.GetChannel()); +} + + +// Reset all channel variables +void CViewPattern::ResetChannel(CHANNELINDEX chn) +//----------------------------------------------- +{ CModDoc *pModDoc = GetDocument(); CSoundFile *pSndFile; if(pModDoc == nullptr || (pSndFile = pModDoc->GetSoundFile()) == nullptr) return; - const bool bIsMuted = pModDoc->IsChannelMuted(nChn); - if(!bIsMuted) pModDoc->MuteChannel(nChn, true); - pSndFile->Chn[nChn].Reset(ModChannel::resetTotal, *pSndFile, nChn); - if(!bIsMuted) pModDoc->MuteChannel(nChn, false); + const bool isMuted = pModDoc->IsChannelMuted(chn); + if(!isMuted) pModDoc->MuteChannel(chn, true); + pSndFile->Chn[chn].Reset(ModChannel::resetTotal, *pSndFile, chn); + if(!isMuted) pModDoc->MuteChannel(chn, false); } @@ -3958,7 +3965,7 @@ case kcChannelUnmuteAll: OnUnmuteAll(); return wParam; case kcToggleChanMuteOnPatTransition: TogglePendingMute(GetCurrentChannel()); return wParam; case kcUnmuteAllChnOnPatTransition: OnPendingUnmuteAllChnFromClick(); return wParam; - case kcChannelReset: OnChannelReset(); return wParam; + case kcChannelReset: ResetChannel(m_Cursor.GetChannel()); return wParam; case kcTimeAtRow: OnShowTimeAtRow(); return wParam; case kcSoloChnOnPatTransition: PendingSoloChn(GetCurrentChannel()); return wParam; case kcTransposeUp: OnTransposeUp(); return wParam; Modified: trunk/OpenMPT/mptrack/View_pat.h =================================================================== --- trunk/OpenMPT/mptrack/View_pat.h 2012-03-13 14:49:58 UTC (rev 1219) +++ trunk/OpenMPT/mptrack/View_pat.h 2012-03-13 22:15:28 UTC (rev 1220) @@ -280,6 +280,9 @@ void ExecutePaste(PatternClipboard::PasteModes mode); + // Reset all channel variables + void ResetChannel(CHANNELINDEX chn); + public: //{{AFX_VIRTUAL(CViewPattern) virtual void OnDraw(CDC *); Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2012-03-13 14:49:58 UTC (rev 1219) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2012-03-13 22:15:28 UTC (rev 1220) @@ -728,7 +728,7 @@ { // Called when plugin param is changed via gui case audioMasterAutomate: - if (pVstPlugin != nullptr && pVstPlugin->Dispatch(effCanBeAutomated, index, nullptr, nullptr, 0.0f) != 0) + if (pVstPlugin != nullptr && pVstPlugin->CanAutomateParameter(index)) { // This parameter can be automated. Ugo Motion constantly sends automation callback events for parameters that cannot be automated... pVstPlugin->AutomateParameter((PlugParamIndex)index); @@ -927,12 +927,24 @@ // input pin in <value> (-1: first to come), returns cEffect* - DEPRECATED in VST 2.4 case audioMasterGetPreviousPlug: - Log("VST plugin to host: Get Previous Plug\n"); + if(pVstPlugin != nullptr) + { + CArray<CVstPlugin *, CVstPlugin *> list; + pVstPlugin->GetInputPlugList(list); + // We don't assign plugins to pins... + return ToVstPtr(list[0]); + } break; // output pin in <value> (-1: first to come), returns cEffect* - DEPRECATED in VST 2.4 case audioMasterGetNextPlug: - Log("VST plugin to host: Get Next Plug\n"); + if(pVstPlugin != nullptr) + { + CArray<CVstPlugin *, CVstPlugin *> list; + pVstPlugin->GetOutputPlugList(list); + // We don't assign plugins to pins... + return ToVstPtr(list[0]); + } break; // realtime info @@ -1589,14 +1601,10 @@ } -BOOL CVstPlugin::HasEditor() +bool CVstPlugin::HasEditor() //-------------------------- { - if ((m_pEffect) && (m_pEffect->flags & effFlagsHasEditor)) - { - return TRUE; - } - return FALSE; + return (m_pEffect != nullptr) && (m_pEffect->flags & effFlagsHasEditor); } //rewbs.VSTcompliance: changed from BOOL to long @@ -1622,6 +1630,14 @@ } +// Check whether a VST parameter can be automated +bool CVstPlugin::CanAutomateParameter(PlugParamIndex index) +//--------------------------------------------------------- +{ + return (Dispatch(effCanBeAutomated, index, nullptr, nullptr, 0.0f) != 0); +} + + VstInt32 CVstPlugin::GetUID() //--------------------------- { @@ -1671,7 +1687,12 @@ LimitMax(maxParam, PlugParamIndex(m_pEffect->numParams)); for(PlugParamIndex p = minParam; p < maxParam; p++) - SetParameter(p, (float(rand()) / float(RAND_MAX))); + { + if(CanAutomateParameter(p)) + { + SetParameter(p, (float(rand()) / float(RAND_MAX))); + } + } return true; } @@ -1798,7 +1819,7 @@ CString CVstPlugin::GetFormattedProgramName(VstInt32 index, bool allowFallback) //----------------------------------------------------------------------------- { - char rawname[max(kVstMaxProgNameLen, 256)]; // kVstMaxProgNameLen is 24... + char rawname[max(kVstMaxProgNameLen + 1, 256)]; // kVstMaxProgNameLen is 24... if(!GetProgramNameIndexed(index, -1, rawname)) { // Fallback: Try to get current program name. @@ -1886,7 +1907,7 @@ CString CVstPlugin::GetParamPropertyString(VstInt32 param, VstInt32 opcode) //------------------------------------------------------------------------- { - CHAR s[max(kVstMaxParamStrLen, 64)]; // Increased to 64 bytes since 32 bytes doesn't seem to suffice for all plugs. Kind of ridiculous if you consider that kVstMaxParamStrLen = 8... + CHAR s[max(kVstMaxParamStrLen + 1, 64)]; // Increased to 64 bytes since 32 bytes doesn't seem to suffice for all plugs. Kind of ridiculous if you consider that kVstMaxParamStrLen = 8... s[0] = '\0'; if(m_pEffect != nullptr && m_pEffect->numParams > 0 && param < m_pEffect->numParams) @@ -1933,7 +1954,7 @@ //-------------------------------------------------- { pszName[0] = 0; - if (m_bIsVst2) + if(m_bIsVst2) { Dispatch(effGetEffectName, 0, 0, pszName, 0); return TRUE; @@ -1941,6 +1962,7 @@ return FALSE; } + void CVstPlugin::Init(unsigned long /*nFreq*/, int /*bReset*/) //------------------------------------------------------------ { @@ -2967,7 +2989,7 @@ PLUGINDEX nOutput = m_pMixStruct->GetOutputPlugin(); if(m_pSndFile && nOutput > m_nSlot && nOutput != PLUGINDEX_INVALID) { - pOutputPlug = reinterpret_cast<CVstPlugin *>(m_pSndFile->m_MixPlugins[nOutput].pMixPlugin); + pOutputPlug = dynamic_cast<CVstPlugin *>(m_pSndFile->m_MixPlugins[nOutput].pMixPlugin); } } list.Add(pOutputPlug); @@ -2986,7 +3008,7 @@ for (int nPlug = 0; nPlug < MAX_MIXPLUGINS; nPlug++) { - pCandidatePlug = reinterpret_cast<CVstPlugin *>(m_pSndFile->m_MixPlugins[nPlug].pMixPlugin); + pCandidatePlug = dynamic_cast<CVstPlugin *>(m_pSndFile->m_MixPlugins[nPlug].pMixPlugin); if (pCandidatePlug) { pCandidatePlug->GetOutputPlugList(candidatePlugOutputs); @@ -3317,6 +3339,9 @@ } break; + case effCanBeAutomated: + return (index < m_pMachineInfo->numGlobalParameters); + // Buzz extensions case effBuzzGetNumCommands: { @@ -3676,6 +3701,9 @@ } break; + case effCanBeAutomated: + return (index < m_Effect.numParams); + case effSetSampleRate: m_nSamplesPerSec = (int)opt; break; @@ -3871,9 +3899,10 @@ CString SNDMIXPLUGIN::GetParamName(PlugParamIndex index) const //------------------------------------------------------------ { - if(pMixPlugin) + CVstPlugin *vstPlug = dynamic_cast<CVstPlugin *>(pMixPlugin); + if(vstPlug != nullptr) { - return reinterpret_cast<CVstPlugin *>(pMixPlugin)->GetParamName(index); + return vstPlug->GetParamName(index); } else { return CString(); Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2012-03-13 14:49:58 UTC (rev 1219) +++ trunk/OpenMPT/mptrack/Vstplug.h 2012-03-13 22:15:28 UTC (rev 1220) @@ -125,7 +125,7 @@ public: PVSTPLUGINLIB GetPluginFactory() const { return m_pFactory; } - BOOL HasEditor(); + bool HasEditor(); long GetNumPrograms(); PlugParamIndex GetNumParameters(); long GetCurrentProgram(); @@ -206,6 +206,9 @@ void SetDryRatio(UINT param); void AutomateParameter(PlugParamIndex param); + // Check whether a VST parameter can be automated + bool CanAutomateParameter(PlugParamIndex index); + void SetZxxParameter(UINT nParam, UINT nValue); UINT GetZxxParameter(UINT nParam); //rewbs.smoothVST @@ -231,15 +234,17 @@ #else // case: NO_VST public: - PlugParamIndex GetNumParameters() {return 0;} + PlugParamIndex GetNumParameters() { return 0; } void ToggleEditor() {} - BOOL HasEditor() {return FALSE;} - UINT GetNumCommands() {return 0;} + bool HasEditor() { return false; } + UINT GetNumCommands() { return 0; } void GetPluginType(LPSTR) {} - PlugParamIndex GetNumPrograms() {return 0;} + PlugParamIndex GetNumPrograms() { return 0; } bool GetProgramNameIndexed(long, long, char*) { return false; } - CString GetFormattedProgramName(VstInt32, bool = false) { return ""; }; + CString GetFormattedProgramName(VstInt32, bool = false) { return ""; } void SetParameter(PlugParamIndex, PlugParamValue) {} + + bool CanAutomateParameter(PlugParamIndex index) { return false; } CString GetFormattedParamName(PlugParamIndex) { return ""; }; CString GetFormattedParamValue(PlugParamIndex){ return ""; }; Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2012-03-13 14:49:58 UTC (rev 1219) +++ trunk/OpenMPT/mptrack/version.h 2012-03-13 22:15:28 UTC (rev 1220) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 77 +#define VER_MINORMINOR 78 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of Modified: trunk/OpenMPT/soundlib/PluginEventQueue.h =================================================================== --- trunk/OpenMPT/soundlib/PluginEventQueue.h 2012-03-13 14:49:58 UTC (rev 1219) +++ trunk/OpenMPT/soundlib/PluginEventQueue.h 2012-03-13 22:15:28 UTC (rev 1220) @@ -36,7 +36,9 @@ { protected: - typedef VstMidiEvent BiggestVstEvent; + // Although originally all event types were apparently supposed to be of the same size, this is not the case on 64-Bit systems. + // VstMidiSysexEvent contains 3 pointers, so the struct size differs between 32-Bit and 64-Bit systems. + typedef VstMidiSysexEvent BiggestVstEvent; static_assert(sizeof(BiggestVstEvent) >= sizeof(VstEvent) && sizeof(BiggestVstEvent) >= sizeof(VstMidiEvent) && sizeof(BiggestVstEvent) >= sizeof(VstMidiSysexEvent), @@ -79,14 +81,39 @@ // Set insertFront to true to prioritise this event (i.e. add it at the front of the queue instead of the back) bool Enqueue(const VstEvent &event, bool insertFront = false) { - VstMidiEvent midiEvent; - memcpy(&midiEvent, &event, min(event.byteSize, sizeof(event))); ASSERT(event.byteSize == sizeof(event)); - return Enqueue(midiEvent, insertFront); +#if 1 + // True on 32-Bit hosts: No copying is necessary + static_assert(sizeof(VstEvent) == sizeof(VstMidiSysexEvent), "This is no 32-Bit host!"); + return Enqueue(reinterpret_cast<const VstMidiSysexEvent &>(event), insertFront); +#else + // True on 64-Bit hosts: VstMidiSysexEvent is bigger, so copy smaller event into bigger event. + static_assert(sizeof(VstEvent) <= sizeof(VstMidiSysexEvent), "This is no 32-Bit host!"); + VstMidiSysexEvent copyEvent; + memcpy(©Event, &event, min(event.byteSize, sizeof(event))); + return Enqueue(copyEvent, insertFront); +#endif } + bool Enqueue(const VstMidiEvent &event, bool insertFront = false) { - static_assert(sizeof(BiggestVstEvent) <= sizeof(VstMidiEvent), "Also check implementation here."); + ASSERT(event.byteSize == sizeof(event)); +#if 1 + // True on 32-Bit hosts: No copying is necessary + static_assert(sizeof(VstMidiEvent) == sizeof(VstMidiSysexEvent), "This is no 32-Bit host!"); + return Enqueue(reinterpret_cast<const VstMidiSysexEvent &>(event), insertFront); +#else + // True on 64-Bit hosts: VstMidiSysexEvent is bigger, so copy smaller event into bigger event. + static_assert(sizeof(VstMidiEvent) <= sizeof(VstMidiSysexEvent), "This is no 32-Bit host!"); + VstMidiSysexEvent copyEvent; + memcpy(©Event, &event, min(event.byteSize, sizeof(event))); + return Enqueue(copyEvent, insertFront); +#endif + } + + bool Enqueue(const VstMidiSysexEvent &event, bool insertFront = false) + { + static_assert(sizeof(BiggestVstEvent) <= sizeof(VstMidiSysexEvent), "Also check implementation here."); EnterCriticalSection(&criticalSection); if(insertFront) { @@ -98,13 +125,6 @@ LeaveCriticalSection(&criticalSection); return true; } - bool Enqueue(const VstMidiSysexEvent &event, bool insertFront = false) - { - VstMidiEvent midiEvent; - memcpy(&midiEvent, &event, min(event.byteSize, sizeof(event))); - ASSERT(event.byteSize == sizeof(event)); - return Enqueue(midiEvent, insertFront); - } // Set up the queue for transmitting to the plugin. Returns number of elements that are going to be transmitted. VstInt32 Finalise() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |