How to render an Edit to a new file audio file?

I am guessing the needed functionality is in the Renderer class, but I just can’t figure out how to hook it all up correctly. Is it allowed to attempt to render an edit that is currently playing back in real time? If not, is there an easy way to make a temporary clone of the edit for the rendering?

My current code is as follows. Probably completely wrong, but the only way was to do guess work. The code fails when trying to create the rendering audio node, a nullptr is returned :

WavAudioFormat wavformat;
				te::Renderer::Parameters pars{ edit };
				pars.engine = &engine;
				pars.destFile = File("C:\\MusicAudio\\sourcesamples\\dirac\\te_export1.wav");
				pars.audioFormat = &wavformat;
				pars.time = { 0.0,1.0 };
				auto node = te::Renderer::createRenderingAudioNode(pars);
				if (node)
				{
					te::Renderer::RenderTask task{ "foo task",pars,node };
					while (task.runJob() != ThreadPoolJob::jobHasFinished)
					{
						Thread::sleep(10);
					}
					delete node;
					Logger::writeToLog("Render job finished");
				}
				else Logger::writeToLog("Could not create node");

No, you can’t render an edit while it’s playing, mainly because there is only one copy of the plugins loaded, and they can’t be used for both playback and render at the same time.

The easiest way to do a render is with the static function Renderer::renderToFile

Renderer::renderToFile ("Render"), outputFile, edit, { start, end }, tracksToDo);

To create a copy of an edit, first I’d edit.flushState() and then edit.state.createCopy() and pass the ValueTree to a new edit.

1 Like