tote-bag-labs / valentine

An open source compressor meant to pump and breathe
GNU General Public License v3.0
123 stars 6 forks source link

I'm updating parameters wrong #100

Open JoseDiazRohena opened 5 months ago

JoseDiazRohena commented 5 months ago
/** Receives a callback when a parameter has been changed.

            IMPORTANT NOTE: This will be called synchronously when a parameter changes, and
            many audio processors will change their parameter during their audio callback.
            This means that not only has your handler code got to be completely thread-safe,
            but it's also got to be VERY fast, and avoid blocking. If you need to handle
            this event on your message thread, use this callback to trigger an AsyncUpdater
            or ChangeBroadcaster which you can respond to on the message thread.
     */
        virtual void parameterValueChanged (int parameterIndex, float newValue) = 0;

from a thread discussing parameter changes in JUCE https://forum.juce.com/t/vst3-wrapper-calls-parameterchanged-from-audio-thread/51589/2

Currently, I'm in violation of this guidance. I change my parameters in parameterValueChanged, which is being called on the message thread. The code is real time safe, but as the comment points out, I should at least be triggering an async updater so we can exit the function as soon as possible.

And for what? I can simply update the processor state by getting parameter values in processBlock