How do you handle AudioProcessor::getNumPrograms()?

How do you handle AudioProcessor::getNumPrograms()?

My original plan count all my presets and return that number. However:

Returns the number of preset programs the processor supports.

The value returned must be valid as soon as this object is created, and must not change over its lifetime.

This value shouldn’t be less than 1.

If my user creates a preset, then this number changes, which isn’t allowed. In VST3, if the new preset is selected, the VST3 wrapper immediately resets it back to a valid number in range.

So what are my options:

  1. Always return 1. User must handle preset loading through the Plugin.

  2. Return a fixed but very large number (num presets + 100) and assume the user will never create more than 100 presets any time they are using the plugin.

  3. Something else?

I’ve always done 1, because I was lazy.

I would argue against 2, since it’s generally a bad idea to try and second guess what a user might do.

I would like to at some point implement something like:

a) Return the number of factory presets, handle the appropriate “program” methods accordingly
b) Return the number of factory presets + user presets, then as above, but with the caveat that a newly created user preset won’t show up in the host until the plugin is restarted

so those are my suggestions for 3.