From: <sag...@us...> - 2014-03-19 01:17:41
|
Revision: 3904 http://sourceforge.net/p/modplug/code/3904 Author: saga-games Date: 2014-03-19 01:17:34 +0000 (Wed, 19 Mar 2014) Log Message: ----------- [Imp] VST: Implement more timing information for plugins that want it. [Mod] VST: Don't call (potentially expensive) effGetChunk before effSetChunk. I'm not aware of any other hosts doing this. Modified Paths: -------------- trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/Vstplug.h Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2014-03-19 00:09:05 UTC (rev 3903) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2014-03-19 01:17:34 UTC (rev 3904) @@ -106,15 +106,18 @@ if(pVstPlugin->IsSongPlaying()) { timeInfo.flags |= kVstTransportPlaying; + if(pVstPlugin->GetSoundFile().m_SongFlags[SONG_PATTERNLOOP]) timeInfo.flags |= kVstTransportCycleActive; timeInfo.samplePos = sndFile.GetTotalSampleCount(); if(sndFile.HasPositionChanged()) { timeInfo.flags |= kVstTransportChanged; + pVstPlugin->lastBarStartPos = -1.0; } } else { timeInfo.flags |= kVstTransportChanged; //just stopped. timeInfo.samplePos = 0; + pVstPlugin->lastBarStartPos = -1.0; } if((value & kVstNanosValid)) { @@ -131,6 +134,16 @@ { timeInfo.ppqPos = 0; } + + if((pVstPlugin->GetSoundFile().m_PlayState.m_nRow % pVstPlugin->GetSoundFile().m_PlayState.m_nCurrentRowsPerMeasure) == 0) + { + pVstPlugin->lastBarStartPos = std::floor(timeInfo.ppqPos); + } + if(pVstPlugin->lastBarStartPos >= 0) + { + timeInfo.barStartPos = pVstPlugin->lastBarStartPos; + timeInfo.flags |= kVstBarsValid; + } } if((value & kVstTempoValid)) { @@ -1458,7 +1471,7 @@ { ProcessVSTEvents(); - //If the plug is found & ok, continue + // If the plug is found & ok, continue if(m_pProcessFP != nullptr && (mixBuffer.GetInputBufferArray()) && mixBuffer.GetOutputBufferArray() && m_pMixStruct != nullptr) { @@ -1510,7 +1523,7 @@ // if m_Effect.numOutputs is odd, mix half the signal of last output to each channel if(numOutputs != m_Effect.numOutputs) { - // trick : if we are here, nOuts = m_Effect.numOutputs - 1 !!! + // trick : if we are here, numOutputs = m_Effect.numOutputs - 1 !!! for(size_t i = 0; i < nSamples; i++) { float v = 0.5f * outputBuffers[numOutputs][i]; @@ -2130,9 +2143,6 @@ if ((Dispatch(effIdentify, 0, 0, nullptr, 0) == 'NvEf') && (nType == 'NvEf')) { - void *p = nullptr; - Dispatch(effGetChunk, 0,0, &p, 0); //init plug for chunk reception - if ((nProgram>=0) && (nProgram < m_Effect.numPrograms)) { // Bank @@ -2141,11 +2151,14 @@ } else { // Program + Dispatch(effBeginSetProgram, 0, 0, nullptr, 0.0f); Dispatch(effSetChunk, 1, m_pMixStruct->nPluginDataSize - 4, m_pMixStruct->pPluginData + 4, 0); + Dispatch(effEndSetProgram, 0, 0, nullptr, 0.0f); } } else { + Dispatch(effBeginSetProgram, 0, 0, nullptr, 0.0f); float *p = (float *)m_pMixStruct->pPluginData; if (m_pMixStruct->nPluginDataSize >= nLen + 4) p++; if (m_pMixStruct->nPluginDataSize >= nLen) @@ -2155,6 +2168,7 @@ SetParameter(i, p[i]); } } + Dispatch(effEndSetProgram, 0, 0, nullptr, 0.0f); } } } Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2014-03-19 00:09:05 UTC (rev 3903) +++ trunk/OpenMPT/mptrack/Vstplug.h 2014-03-19 01:17:34 UTC (rev 3904) @@ -140,6 +140,7 @@ SNDMIXPLUGINSTATE m_MixState; int32 m_nEditorX, m_nEditorY; + double lastBarStartPos; float m_fGain; PLUGINDEX m_nSlot; bool m_bSongPlaying; @@ -166,6 +167,7 @@ public: VSTPluginLib &GetPluginFactory() const { return m_Factory; } + CVstPlugin *GetNextInstance() const { return m_pNext; } bool HasEditor(); VstInt32 GetNumPrograms(); PlugParamIndex GetNumParameters(); @@ -226,7 +228,7 @@ size_t AddRef() { return ++m_nRefCount; } size_t Release(); void SaveAllParameters(); - void RestoreAllParameters(long nProg=-1); //rewbs.plugDefaultProgram - added param + void RestoreAllParameters(long nProg=-1); void RecalculateGain(); void Process(float *pOutL, float *pOutR, size_t nSamples); float RenderSilence(size_t numSamples); @@ -255,9 +257,9 @@ protected: void MidiPitchBend(uint8 nMidiCh, int32 pitchBendPos); - // Converts a 14-bit MIDI pitch bend position to a 16.11 fixed point pitch bend position + // Converts a 14-bit MIDI pitch bend position to our internal pitch bend position representation static int32 EncodePitchBendParam(int32 position) { return (position << vstPitchBendShift); } - // Converts a 16.11 fixed point pitch bend position to a 14-bit MIDI pitch bend position + // Converts the internal pitch bend position to a 14-bit MIDI pitch bend position static int16 DecodePitchBendParam(int32 position) { return static_cast<int16>(position >> vstPitchBendShift); } // Apply Pitch Wheel Depth (PWD) to some MIDI pitch bend value. static inline void ApplyPitchWheelDepth(int32 &value, int8 pwd); @@ -304,7 +306,7 @@ bool LoadProgram() { return false; } bool SaveProgram() { return false; } void SetCurrentProgram(VstInt32) {} - void SetSlot(UINT) {} + void SetSlot(PLUGINDEX) {} void UpdateMixStructPtr(void*) {} void Bypass(bool = true) { } bool IsBypassed() const { return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |