free-audio / clap

Audio Plugin API
https://cleveraudio.org/
MIT License
1.78k stars 100 forks source link

Clarification on writing constant mask flags #300

Closed BillyDM closed 1 year ago

BillyDM commented 1 year ago

I would like some clarification on who gets to actually write to the constant_mask field in the clap_audio_buffer struct. I think this should also be clarified in the docs.

So it's my understanding that the host sets the constant_mask field for both input and output buffers accordingly before calling the plugin's process() method. Then in the process() method, the plugin may change the constant_mask field in any output buffer to let the host (and future plugins in the process chain) know if the constant-ness of the output has changed as a result of the processing. Also, a plugin is not allowed to change the constant_mask field for any input buffers.

Is this correct?

robbert-vdh commented 1 year ago

The host doesn't know anything about what the plugin is going to output, so it cannot determine whether that output is going to have a constant value (be it silence or something else) in advance. So the host can set the constant masks on the input buffers, and the plugin can set the constant masks on the output buffers. Note that constant masks are an optional feature, and you'll likely find that most plugins and hosts won't do anything with them.

BillyDM commented 1 year ago

I see. Thanks for clearing things up!