We’re trying to track down a behavior that seems to change randomly in Pro Tools. If we put our audio at a non-zero position in the timeline, insert our plugin, then start playback at the start of the timeline (as opposed to the start of the audio we inserted), then sometimes the first reported buffer position (via getTimeInSamples()) is a negative number (which is ok), and sometimes it is at (or about) the actual starting position of the audio clip. It does not seem to be tied to any differences in how I set up the test, but is apparently random.
My test is this: I have a session with no plugins, but some audio at 0 on the timeline. I open ProTools and then open that session. Then I drag the clip a few seconds to the right, so it’s not at 0 any more. Then I click the rewind button to put the playhead back at the start. Then I insert our plugin. Then I click a “Record” button in our plugin. Then I start the transport. (Doesn’t seem to matter if I click the Transport Play button or hit the spacebar to start.) That’s it.
We only capture the start position when the transport says that isPlaying is true, and we have not yet started our recording process. At that point, debugging statements sometimes show a fairly small negative number (such as less than a buffer before 0), and other times it shows the sample position that the audio clip was dragged to.
This causes differences in behavior for us, sometimes recording silence until we get to the audio in question and sometimes not triggering our code to start recording until the playhead reaches the actual audio. Which makes it impossible to know where the audio actually starts with certainty.
Anyone else seen this happen? It’s the strangest behavior! It’s as if either 1) our processBlock() function is getting called sometimes and not others in that leading silence, or else 2) it is always calling processBlock(), but sometimes the isPlaying flag is set and others it is not.
