AudioPlayHead::CurrentPositionInfo offset by buffer size samples



I'm not sure, if this is an issue with JUCE or with Ableton Live. But here's what happens: Imagine you want to code a bpm synced tremolo effect that simply multiplies a square-wave (1,1,1,1,0,0,0,0,1,1,1,1,…) to the input signal. For that you'll need the beat position of each sample.

Here's the sample code:

gist on github

So far so good.

When I now play a long sustained note inside Live and put the Plugin on that track, the tremolo effect is applied in querter notes. E.g. a eighth note on followed by an eighth note off.

But if I set the Buffer Size of the host to the maximum value (2048 samples) and copy the Plugin several times, the Audio that comes through gets shorter and shorter until it completely disapears at eight instances.

The reason for that might be, that Live increases the playhead for each plugin instance in the signal chain. Or maybe there's a Bug on how the PlayHead is updated via JUCE? Never the less, the ppqPos that I get does not represent position in the edit, but shifts from plugin instance to plugin instance by an amount related to the buffer size.

btw. I'm on OSX 10.10 and I am using master (15ddb6699eece43f06d7fde151284fac664026a8).

Has anyone experienced something simmilar? Can anyone spot a bug in my code? The effect is so obvious, that I cannot imagine, that nobody had this problem before - any bmp synced effect should have this problem.

I also tried it in reaper and there it works perfectly - I can add as manny instances as I want and the output stays EXACTLY the same - as I'd expect it to.

Thanks for having a look at it
-- Benjamin


Edit: I tried it in Live 8 and Live 9.
Another edit: I'm necessarily asuming, that this a bug in JUCE, just curious, if someone else experienced this problem or if I am doing something wrong. Also this is contrived example to illustrate the issue. I stubled upon this issue in a more complex setup.


I haven't got any experience with Live, but I'd first confirm if there are any delay compensation issues.  I don't imagine you've called setLatencySamples() with a non-zero argument in PlayHeadTestAudioProcessor, but can you confirm that?


Your imagination is spot on. I don't call it. To be double sure, I just tries calling setLatencySamples(0) in the constructor - but unfortunately this makes no difference.

So I guess, we can rule that one out?


I just made another Test:

a miditrack playing eighth note on, eighth note off
multiple instances of third party plugin (AU Highpass with freq set to 10Hz)
Lives internal Auto-Pan - set up so that it exactly cancels out the notes

as A, but with lives EQ8 (neutral setting) instead of third party Plugins

A) Audio started to appear and gets longer depending on the number of instances, then it gets shorter again when more instances are added
B) Audio stays at was before - as one would expect it to

So apparently Live is doing something wonky, when AU/VST Plugins are involved that even effects their own plugins.

I think I'll report a bug with ableton.



Are you still reproducing this?

I'm also working on implementing tempo-sync and use Live as my testing DAW and I see in-stability meaning no sample accurate results.