EngineInPlugin demo - Block size issue

When running the EngineInPlugin demo as an AU plugin I can load it in Logic Pro (10.7.4) and hear the click track.

If I change the “I/O Buffer Size” the click track behaves weirdly changing level between clicks.

When debugging it seems the prepareToPlay() function of the plugin receives a block size of 1024 no matter what I set it to in Logic.

It seems however that changing the “Process Buffer Range” in Logic does send different values to the prepareToPlay(). But depending on the “I/O Buffer Size” the weird behaviour is still there.

Shouldn’t the plugin and the tracktion engine adapt to whatever settings are set in Logic?

This issue does not happen in Ableton Live 10 with the exact same AU build and different buffer sizes. So far only Logic Pro seems affected. Any ideas?

If you put a breakpoint in prepareToPlay where you see the block size of 1024, can you look back up the stack to see at what point it changes (if indeed it does)?

At the base JUCE level (where Logic calls in to), what is the block size there?

In the prepareToPlay() method the block size received is 1024 no matter what I set the I/O Buffer Size to in Logic:

It seems like Logic is passing the “Process Buffer Range” value as the block size. When changing from “Medium” to “Small” it ens up passing 512 as the BlockSize regardless of what the I/O Buffer Size is.

TBH I’m not sure why the expectedBlockSize is 1024 there if you’ve specified 512 in Logic. Everything above that in the stack trace is JUCE code though so it’s unlikely to be something we’re doing.
If you examine the stack slightly higher, is it 1024 all the way up (to stack frame 4)?

Yes it is 1024 all the way up. The only way to change the value received is to change the “Process Buffer Range” in Logic Pro.

If that’s the case I don’t think there’s anything that can be done about it in Tracktion Engine or JUCE. It might just be a Logic optimisation so process in larger chunks.

If you have live input or automation on the track does it go down? I’ve seen similar techniques used elsewhere.

Out of curiosity, do you mean it receives that value in prepareToPlay or it receives actual blocks in processBlock in 1024 despite having selected 512?

The value in prepareToPlay is an upper margin which may or may not reflect the actual block size.

Not too sure, it definitely receives a size of 1024 in the prepare to play. And the EngineInPlugin demo seems to have an issue outputting audio properly, the click track is “stuttering” on playback.

This does not happen in other DAWs and the main difference is that Ableton Live calls prepareToPlay with the block size matching what I set it to be in the settings.

Any idea on how I would handle a different blockSize in prepareToPlay and the processBlock to fix the playback of the demo project?

It should just work…
It’s perfectly valid for a host to call processBlock with less samples than were prepared for.

I’ll need to see if there’s anything odd happening with Logic as I’ve not had a chance to test in that host yet.