Is there way to perform some code whenever the playback in the host application is started/stopped?
In your process block, you can always call getPlayHead()->getCurrentPosition()
Which will give you a struct that also contains the transport state.
You can use this struct very easily to call functions on state change. Just store a member with the last state and compare them with the one in the struct.
But does processBlock also get called while the playback is paused?
Depending on the host. It used to be that way, but more and more hosts do “optimisations” which are not in the plugin developer’s favour.
Logic e.g. only calls it for generative plugins or if there is at least some audio on the track.
Very often you get a prepareToPlay call immediately before playback starts, but again, it is not granted on all hosts.
I need to test, but I’m pretty sure most(all?) hosts will call you with a process function once with transport changes even if (like Ableton Live) they will send you to sleep right after and stop calling you.
Thanks, I guess I’ll have to try that out and work with whatever I have.