Using function pointer with AudioProcessorValueTreeState

Is there a way to set a function pointer in the AudioProcessorValueTreeState?

I currently have my UI and backend setup such that I have a FilterModule class and a Filter class.

What I would like to do is have a ComboBox of FilterTypes which would adjust a function pointer that the tick function then uses. What I currently do is just query a type based off a switch statement per frame. I don’t think this is possible and I have no idea if it’s really thread safe but I see no reason why it wouldn’t be.

It might be possible to store an actual function pointer (or std::function object), but I wouldn’t recommend it. The APVTS is meant for saving state that can then be reloaded, potentially on a different computer, where memory addresses of functions would obviously be different.

What I would do instead is store an enum or a string that identifies which option is chosen, and then use that data to pick which function to call.

It is possible. I’ve done this by casting the pointer to/from int64. I think there may be better methods, but this has proven usable this far. Using template specialization, I made the casting automatic.