I am trying to have my VST play a looped audio sample slaved to the host transport. So in the renderNextBlock I'm simply checking if the host isPlaying and thus rendering the buffer from sample position 0. As the host continues to play, I'm incrementing the sampleCount. This is all fine on the first pass (silence is produced when nulling the audio against an audio track with the same sample loop).
However, when the host loops and also my sample loops by using in my renderNextBlock:
if (sampleCurrentPosition == playbackEndPosition) { // move back to start sampleCurrentPosition = (float) playbackStartPosition; }
The sample loops but the tracks no longer null. Can anyone explain why this happens? Is there an elegant way of handling this?
Thank you.