1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

VST3: Only update parameters from a process block if they've changed

This commit is contained in:
Anthony Nicholls 2023-11-07 12:04:49 +00:00
parent 8c29cab261
commit 9654f4a7e9
3 changed files with 16 additions and 11 deletions

View file

@ -1737,8 +1737,15 @@ public:
Steinberg::Vst::ParamID getParamID (Steinberg::int32 index) const noexcept { return paramIds[(size_t) index]; }
void set (Steinberg::int32 index, float value) { floatCache.setValueAndBits ((size_t) index, value, 1); }
void setWithoutNotifying (Steinberg::int32 index, float value) { floatCache.setValue ((size_t) index, value); }
void set (Steinberg::int32 index, float value)
{
floatCache.setValueAndBits ((size_t) index, value, 1);
}
float exchangeWithoutNotifying (Steinberg::int32 index, float value)
{
return floatCache.exchangeValue ((size_t) index, value);
}
float get (Steinberg::int32 index) const noexcept { return floatCache.get ((size_t) index); }

View file

@ -2244,7 +2244,7 @@ public:
for (const auto* item : queues)
{
auto* ptr = item->ptr.get();
callback (ptr->getParameterIndex(), ptr->getParameterId(), ptr->get());
callback (ptr->getParameterId(), ptr->get());
}
}
@ -2291,8 +2291,8 @@ public:
*/
void setValueWithoutUpdatingProcessor (float newValue)
{
pluginInstance.cachedParamValues.setWithoutNotifying (vstParamIndex, newValue);
sendValueChangedMessageToListeners (newValue);
if (! exactlyEqual (pluginInstance.cachedParamValues.exchangeWithoutNotifying (vstParamIndex, newValue), newValue))
sendValueChangedMessageToListeners (newValue);
}
String getText (float value, int maximumLength) const override
@ -2753,10 +2753,8 @@ public:
processor->process (data);
outputParameterChanges->forEach ([&] (Steinberg::int32 index, Vst::ParamID id, float value)
outputParameterChanges->forEach ([&] (Vst::ParamID id, float value)
{
cachedParamValues.setWithoutNotifying (index, value);
if (auto* param = getParameterForID (id))
param->setValueWithoutUpdatingProcessor (value);
});

View file

@ -140,17 +140,17 @@ public:
size_t size() const noexcept { return values.size(); }
void setValue (size_t index, float value)
float exchangeValue (size_t index, float value)
{
jassert (index < size());
values[index].store (value, std::memory_order_relaxed);
return values[index].exchange (value, std::memory_order_relaxed);
}
void setBits (size_t index, uint32_t bits) { flags.set (index, bits); }
void setValueAndBits (size_t index, float value, uint32_t bits)
{
setValue (index, value);
exchangeValue (index, value);
setBits (index, bits);
}