Skip to content

Rendering individual samples events to a file

Igor Zinken edited this page Apr 24, 2022 · 5 revisions

In case you want to process a sample by MWEngine and render its output to a file without activating the recording state (in other words: play the sample in real time while writing the output), you can use the AudioRenderer class.

The render methods of the AudioRenderer class are synchronous in execution and can be called from outside the main MWEngine rendering thread, meaning you can render these files while the sequencer / engine is actually running.

The AudioRenderer class

The AudioRenderer class is located in the utilities namespace and has the same signature in both C++ and Java.

Rendering an AudioEvent

You can easily render an AudioEvent to a WAV file using the renderEvent method:

In C++:

bool AudioRenderer::renderEvent( std::string outputFile, BaseAudioEvent* audioEvent, ProcessingChain* chain );

or in Java:

boolean AudioRenderer.renderEvent( String outputFile, BaseAudioEvent audioEvent, @Nullable ProcessingChain chain );

outputFile is a String describing the path and filename of the file to generate (note that paths will not be automatically created and need to be created upfront). audioEvent is an instance of a BaseAudioEvent to render. chain is an optional ProcessingChain (you can pass nullptr/null accordingly).

When a ProcessingChain is provided, all active processors in the chain are applied onto the audio event being rendered.

Rendering an external sample file

Similar to the renderEvent method, you can easily render a sample file using a ProcessingChain and save the output as a WAV file. For this there is the renderFile method:

In C++:

bool AudioRenderer::renderFile( std::string inputFileName, std::string outputFile, ProcessingChain* chain );

or in Java:

boolean AudioRenderer.renderFile( String inputFileName, String outputFile, ProcessingChain chain );

inputFileName is a String path to the input WAV file. outputFile is a String describing the path and filename of the file to generate (note that paths will not be automatically created and need to be created upfront). chain is a ProcessingChain instance (cannot be null as otherwise this function is useless). All active processors in the chain are applied onto the audio event being rendered.

Clone this wiki locally