Midi File to Audio File Offline Rendering

I want to create a console app that does midi file to audio file offline rendering only. Can’t really find much tutorial on offline processing though. I’ve tried to use AudioIODeviceCallback with SynthAudioSource for successful audio playback, but I don’t know how to manually process midi by block offline. How should I do it or am I using the wrong classes?

1 Like

You are doing what the AudioIODeviceCallback would do. You are calling processBlock in a loop to pull the audio samples, while supplying the midi messages.

The caveats are, the processBlock() will execute much faster than from the AudioIODeviceCallback, so you must a) set thesetNonRealtime (true) in the AudioProcessor, and b) additionally you have to make sure, the instrument had enough time to load the samples. Most instruments will output silence, until the loading finished.

It’s not particularly hard to write this - maybe a couple of hundred lines of code. But I’d recommend using the tracktion engine instead, where instead of having to write a render loop and pipe it into a file yourself + handle all the edge-cases, you’d just create an Edit containing the MIDI clip and plugin, and then tell it to render.

(@FigBug @dave96 Do we have an example showing just an offline render? That’s probably quite a common use-case)

1 Like

Thanks daniel and jules, I kind of get the directions you are pointing me towards. And I agree that an offline renderer example would be really helpful, especially for things like dealing with midi message sequence timed in samples and combining audio sample array which are normally automatically handled.

@vomyrak @user1
I want to do a similar thing, namely play a midi file through a loaded external VST and output audio, in batches of multiple midi files and ideally in non-realtime. Any examples youve been able to find?