Write MixerAudioSource to .wav file

I’m trying to write a MixerAudioSource buffer into a .wav file through the getNextAudioBlock(), is there any way to do that? Since i want to export the processed audio buffer.
And if yes, can i speed up the writing time instead of taking exactly the time length of the audio as it play? Thanks for any help.

Is this what you’re looking for?
https://docs.juce.com/master/classAudioFormatWriter.html#a4d09d96836ebe2779d2e82a090d0b29f

I don’t know where your audio source is coming from, but if it’s a real time process, then I think it would be tough to speed it up…

@AdamVenn My audio is from a local file. I’ve look for a method in the MixerAudioSource but seems like there’s no way to speed up the getNextAudioBlock() call

Nothing stops you from calling getNextAudioBlock yourself, as fast as you want/can. But you don’t want the realtime playback thread also accessing the involved objects at the same time, of course. So, you’d need to stop the realtime playback, and then start your own offline rendering loop to write your output file.

Is it not possible to create and process a separate MixerAudioSource from the editor, ignoring the audio thread?

It would be possible, but care would have to be taken that the separate object instances end up having the same settings as the realtime ones.

So i just need a for loop and call writeFromAudioSource() inside it until the end of the buffer? Do i need to call anything when there’s no more sample left or that’s it