I’m working with Tracktion Engine plugins and noticed that PluginRenderContext::bufferStartSample exists as a parameter, but in all the engine’s code I can find, it’s always set to 0:
There’s even an assertion: jassert (fc.bufferStartSample == 0); // This
assumes bufferStartSample is always 0
The parameter seems designed for writing to sub-sections of larger buffers, but I can’t find any scenario where it’s actually non-zero.
Is bufferStartSample always 0 in practice, or are there specific use cases where it would have a different value? Understanding this would help me write more robust plugin code.
It definitely used to be the case where it was non-zero before I re-wrote it to use tracktion_graph. And when doing that I remember trying to avoid having to use the buffer offset, only ever creating buffer views than can be fully iterated.
But I can’t guarantee there are no edge cases where this exists…
If it was me, I’d probably assume it was always 0 and add an assertion. Then at least if you do find a case where it’s not, you should find out. I have a feeling it’s left in there because it would be a bug API break to remove it.
Thanks! I see. Actually I can come up with a case when in my plugin I would split processing by subblocks and invoke for that some applySubBuffer method with altered PluginRenderContext having the same buffers but shifted bufferStartSample and smaller bufferNumSamples.
And regarding midiBufferOffset, do you remember what purpose it served? Does it relate to bufferStartSample or something different? I’m asking because I’m developing a MIDI-only effect plugin that splits MIDI buffer to subblocks and if I use midiBufferOffset there I want to be sure not to break things in the future.