Engine.getPlayhead() functionality
-
Assuming the doc entry is accurate, onBeatChange won't work as I need the exact position.
-
@Simon The reason is that HISE splits up buffers bigger than 512 into chunks of 512 samples - above 512 there's hardly any CPU benefits but the memory consumption gets annoying (plus there are a few ugly edge cases with the audio buffer size conflicting with the streaming buffers).
Now the problem is that for every 2048 sample buffer that comes in, it calls the internal processing function 4 times and each time the ppq is bumped to stay consistent with the actual DAW position - that is if the playback is running. If not, then it jitters around like you analysed.
You can temporarily deactivate this by setting
HISE_MAX_PROCESSING_BLOCKSIZE
to a bigger value, but the real fix shouldn't be too hard. Please open a github issue and refer to this topic so that it doesn't get lost. -
@Christoph-Hart found the culprit:
// if this is non-zero it means that the buffer coming // from the DAW was split into chunks for processing // so we need to update the playhead to reflect the // "real" position for the given buffer if(offsetWithinProcessBuffer != 0) { newTime.timeInSamples += offsetWithinProcessBuffer; newTime.timeInSeconds += (double)offsetWithinProcessBuffer / processingSampleRate; const auto numSamplesPerQuarter = (double)TempoSyncer::getTempoInSamples(newTime.bpm, processingSampleRate, 1.0f); newTime.ppqPosition += (double)offsetWithinProcessBuffer / numSamplesPerQuarter; }