Finding the first sample when playback starts

On some (most?) audio hosts, audio flows through the plugin even when playback is not active, and processBlock receives silent samples during this time (or, I believe, live audio samples if the track is armed for record). When playback starts, processBlock starts receiving pre-recorded samples from audio clips on that track, so there is some point where the host switches from passing “silent” samples to “pre recorded” samples into the plugin. I am trying to find that point in the incoming stream. Some hosts, like Reaper, seem to always precede the start of audio playback with a prepareToPlay, and the next processBlock after that is the sample I am looking for, so that case is fine. But other hosts, like Pro Tools, rarely precede audio playback with prepareToPlay, and so it is this case that I am struggling with. I can detect playback with AudioPlayHead, but the state transition from !isPlaying to isPlaying does not seem to line up with the sample I am looking for. It seems like an important point in the stream, is there a way to detect it? Thanks in advance.

1 Like