Issue with timing in processBlock in FL Studio [SOLVED]

Hello,

I build an arpegiattor like plugin. For now, my plugin is very simple : I have a big button that can toggle the playing state of the processor. My processor plays a very simple list of notes :

MidiMessages cOn = MidiMessage::noteOn(1, 60, 1.0f); //quarter note
MidiMessages eOn = MidiMessage::noteOn(1, 64, 1.0f); //quarter note
MidiMessages gOn = MidiMessage::noteOn(1, 67, 1.0f); //half note

I have a little sequencer that uses the processor samplerate / buffersize / playhead to make the conversion between musical time and sample time. And all works well with Reaper, and Studio One.

My problem is when I use FL Studio, the bigger the buffe size is, the faster my midi messages are sent. I donā€™t understand this difference. When I put a little buffer (256 samples per block) my little ā€œmelodyā€ is almost played at the correct rate.

Does somebody have an idea? ? ^^

Have you tried setting the fixed-buffer sizes checkbox in the plugin settings? Sorry, itā€™a long time since I used FL, but from what I remember its buffer sizes are extremely ā€˜variableā€™ and likely to change quite a lot between calls to the audio processBlock() method.

Thank you for your answer.

I tried to test your advice, but I didnā€™t find this option in my audio settings.

Furthermore, I displayed the buffer size and the samplerate in my plugin, and they are stable. Is it possible FL Studio changes them without notifying my plugin ?

EDIT : Eventually I found it. And it worked. image

So how to correctly handle it in my code ? I mean, currently I use the buffer size and samplerate given by the prepareToPlay method. How to get the ā€œtrueā€ values if those ones arenā€™t valid.

You can query the size of the buffer each time processBlock() is called. To be honest, Iā€™ve never had to deal with this issue myself, but I remember the variable buffer sizes in FL causing me grief in the past.

Yeah. Itā€™s a good test DAW. Itā€™s buffer size can go down to 1 sample! It tells you that you must treat the process as a single stream of data, and not to presume thereā€™s time before your buffer loop to do any setup stuff.

0k, thank you for the advices, now it works !

I use the processBlock audiobuffer size to increment my play time instead of the buffer size given by the prepare to play :slight_smile:

1 Like

Yep, I use the prepareToPlay parameter as just giving the maximum number of samples possible.