Optimising sample playback routine for block size

I noticed with the plugins that I’m working on that when there is a really high block size, eg 512, my sample playback gets interrupted intermittently by the block filling up in the background, causing some weird distortion like sounds. When i turn the block size down this goes away.
What’s the correct strategy in vcv/mm to optimise my code to make sure that this doesn’t happen?

OK, I’m getting some low-level errors when block size is >=256, I’ll need to go back and see when this started happening (I2S DMA FIFO errors, which is strange…).

1 Like

I only noticed this happening in the most recent builds post the async stuff going in if that helps.

Ok, I think I fixed it. At least, it doesn’t happen anymore on the latest commit to v2.0-dev.

It started happening when I did the MIDI Output feature. The audio loop was writing the MIDI output stream in one large chunk back to the M4 core which is the core that controls the USB port. (Even if a patch doesn’t have any MIDI, an empty stream was being written). Apparently writing that large amount of data at all once to that region of memory was causing bus contention with the audio DMA.

1 Like

Brilliant! I’ll give it a try tomorrow. Thank you