From: <sag...@us...> - 2012-03-12 22:59:32
|
Revision: 1217 http://modplug.svn.sourceforge.net/modplug/?rev=1217&view=rev Author: saga-games Date: 2012-03-12 22:59:25 +0000 (Mon, 12 Mar 2012) Log Message: ----------- [Fix] VST: Current program name was not read properly for plugins that don't support GetProgramNameIndexed. [Fix] Mod Conversion: When fixing envelopes when converting from XM to IT, a sustain point behind a normal loop wasn't handled correctly. Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/View_gen.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/Vstplug.h trunk/OpenMPT/soundlib/ModInstrument.cpp trunk/OpenMPT/soundlib/PluginEventQueue.h Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2012-03-12 22:41:17 UTC (rev 1216) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2012-03-12 22:59:25 UTC (rev 1217) @@ -444,7 +444,7 @@ for (long p = 0; p < numProgs; p++) { - CString programName = m_pVstPlugin->GetFormattedProgramName(p); + CString programName = m_pVstPlugin->GetFormattedProgramName(p, p == curProg); UINT splitMenuFlag = 0; if(entryInThisMenu++ == PRESETS_PER_GROUP) Modified: trunk/OpenMPT/mptrack/View_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_gen.cpp 2012-03-12 22:41:17 UTC (rev 1216) +++ trunk/OpenMPT/mptrack/View_gen.cpp 2012-03-12 22:59:25 UTC (rev 1217) @@ -1528,13 +1528,14 @@ CVstPlugin *pVstPlugin = dynamic_cast<CVstPlugin *>(pSndFile->m_MixPlugins[m_nCurrentPlugin].pMixPlugin); if(pVstPlugin == nullptr) return; - UINT nProg = pVstPlugin->GetNumPrograms(); + UINT nProg = pVstPlugin->GetNumPrograms(); + UINT curProg = pVstPlugin->GetCurrentProgram(); m_CbnPreset.SetRedraw(FALSE); m_CbnPreset.ResetContent(); m_CbnPreset.SetItemData(m_CbnPreset.AddString(_T("current")), 0); for (UINT i = 0; i < nProg; i++) { - m_CbnPreset.SetItemData(m_CbnPreset.AddString(pVstPlugin->GetFormattedProgramName(i)), i + 1); + m_CbnPreset.SetItemData(m_CbnPreset.AddString(pVstPlugin->GetFormattedProgramName(i, i == curProg)), i + 1); } m_nCurrentPreset = 0; m_CbnPreset.SetRedraw(TRUE); Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2012-03-12 22:41:17 UTC (rev 1216) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2012-03-12 22:59:25 UTC (rev 1217) @@ -15,6 +15,7 @@ #include <medparam.h> #include "mainfrm.h" #include "vstplug.h" +#include <pluginterfaces/vst2.x/vstfxstore.h> // VST Presets #include "moddoc.h" #include "sndfile.h" #include "fxp.h" //rewbs.VSTpresets @@ -1512,6 +1513,8 @@ #ifdef VST_LOG Log("~CVstPlugin: m_nRefCount=%d\n", m_nRefCount); #endif + CriticalSection cs; + // First thing to do, if we don't want to hang in a loop if ((m_pFactory) && (m_pFactory->pPluginsList == this)) m_pFactory->pPluginsList = m_pNext; if (m_pMixStruct) @@ -1799,9 +1802,10 @@ if(!GetProgramNameIndexed(index, -1, rawname)) { // Fallback: Try to get current program name. - if(!allowFallback || Dispatch(effGetProgramName, 0, 0, rawname, 0) != 1) + strcpy(rawname, ""); + if(allowFallback) { - strcpy(rawname, ""); + Dispatch(effGetProgramName, 0, 0, rawname, 0); } } StringFixer::SetNullTerminator(rawname); Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2012-03-12 22:41:17 UTC (rev 1216) +++ trunk/OpenMPT/mptrack/Vstplug.h 2012-03-12 22:59:25 UTC (rev 1217) @@ -13,7 +13,6 @@ #ifndef NO_VST #define VST_FORCE_DEPRECATED 0 #include <pluginterfaces/vst2.x/aeffectx.h> // VST - #include <pluginterfaces/vst2.x/vstfxstore.h> #endif #include "../soundlib/Snd_defs.h" @@ -117,7 +116,7 @@ PluginMixBuffer<float, MIXBUFFERSIZE> mixBuffer; // Float buffers (input and output) for plugins int m_MixBuffer[MIXBUFFERSIZE * 2 + 2]; // Stereo interleaved - PluginEventQueue<VstEventQueueLength> vstEvents; // MIDI events that should be sent to the plugin + PluginEventQueue<VstEventQueueLength> vstEvents; // MIDI events that should be sent to the plugin public: CVstPlugin(HINSTANCE hLibrary, VSTPLUGINLIB *pFactory, SNDMIXPLUGIN *pMixPlugin, AEffect *pEffect); Modified: trunk/OpenMPT/soundlib/ModInstrument.cpp =================================================================== --- trunk/OpenMPT/soundlib/ModInstrument.cpp 2012-03-12 22:41:17 UTC (rev 1216) +++ trunk/OpenMPT/soundlib/ModInstrument.cpp 2012-03-12 22:59:25 UTC (rev 1217) @@ -32,6 +32,14 @@ } } else if((fromType & MOD_TYPE_XM) && !(toType & MOD_TYPE_XM)) { + if(nSustainStart > nLoopEnd && (dwFlags & ENV_LOOP)) + { + // In the IT format, the sustain loop is always considered before the envelope loop. + // In the XM format, whichever of the two is encountered first is considered. + // So we have to disable the sustain loop if it was behind the normal loop. + dwFlags &= ~ENV_SUSTAIN; + } + // XM -> IT / MPTM: Shorten loop by one tick by inserting bogus point if(nLoopEnd > nLoopStart && (dwFlags & ENV_LOOP)) { Modified: trunk/OpenMPT/soundlib/PluginEventQueue.h =================================================================== --- trunk/OpenMPT/soundlib/PluginEventQueue.h 2012-03-12 22:41:17 UTC (rev 1216) +++ trunk/OpenMPT/soundlib/PluginEventQueue.h 2012-03-12 22:59:25 UTC (rev 1217) @@ -30,7 +30,9 @@ // Alternative, easy to use implementation of VstEvents struct. template <size_t N> +//==================== class PluginEventQueue +//==================== { protected: @@ -40,10 +42,14 @@ && sizeof(BiggestVstEvent) >= sizeof(VstMidiSysexEvent), "Check typedef above, BiggestVstEvent must be the biggest VstEvent struct."); + // The first three member variables of this class mustn't be changed, to be compatible with the original VSTEvents struct. VstInt32 numEvents; ///< number of Events in array VstIntPtr reserved; ///< zero (Reserved for future use) VstEvent *events[N]; ///< event pointer array - std::deque<BiggestVstEvent> eventQueue; // Here we store our events. + // Here we store our events. + std::deque<BiggestVstEvent> eventQueue; + // Since plugins can also add events to the queue (even from a different thread than the processing thread), + // we need to ensure that reading and writing is never done in parallel. CRITICAL_SECTION criticalSection; public: @@ -62,12 +68,15 @@ DeleteCriticalSection(&criticalSection); } + // Get the number of events that are currently in the output buffer. + // It is possible that there are more events left in the queue if the output buffer is full. size_t GetNumEvents() { return numEvents; } // Add a VST event to the queue. Returns true on success. + // 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; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |