Tremus / CPLUG

C wrapper for VST3, AUv2, CLAP audio plugin formats
Other
97 stars 8 forks source link

AudioUnit does not update parameters to host if audio not running #5

Open ollierik opened 3 months ago

ollierik commented 3 months ago

AudioUnit does not seem to report parameter updates to the host if audio is not running.

Easy to reproduce on Max/MSP, where the audio engine can be enabled or disabled separately.

Probably happens since the process callback that would enqueue the changes coming from the GUI does not get called. This would probably also be an issue with AAX if such wrapper was written.

Easiest fix would probably be to add a timer that calls the processing even when GUI is not running. However, CPLUG would likely benefit from having a mechanism for parameter updates that is decoupled from the processing loop, but it would be quite a large rethink and refactor. :)

Tremus commented 2 months ago

Interesting. A potential solution may look like this:

struct CplugHostContext
{
    // [Any thread] VST3 & AUv2 only. Send parameter update to host
    void (*parameterChanged)(struct CplugHostContext* ctx, uint32_t eventType, uint32_t paramIndex, double value);
    // ... other features
};

CPLUG_API void* cplug_createPlugin(struct CplugHostContext*);

A plugin would simply keep a copy of the pointer and call the method from its GUI for example. This would only introduce a minor API change to the CPLUG API & wrapper implementations, and it would work well with other suggested features. See https://github.com/Tremus/CPLUG/issues/3#issuecomment-1963081104.

This change would be the second half to this existing function: https://github.com/Tremus/CPLUG/blob/0e5ee952209bbe0eadffd3d52d5a395166776886/src/cplug.h#L156-L157

Unfortunately I won't test this any time soon because I don't own Max or plan on buying it any time soon. Their 30 day trial will force me to buy it if I choose to start promising support for the platform.

Tremus commented 2 days ago

The API change suggested above is now available on the develop branch https://github.com/Tremus/CPLUG/blob/c4114e92f4e9915f2226fd87fa6ab1d52b25ffb8/src/cplug.h#L51