In an AudioProcessorGraph, I need an AudioProcessor that captures the audio stream and saves it to a file, while passing the input stream unchanged to the next AudioProcessor in the render chain. I want to use this to bounce live performances of my host to disk.
So far I found the Juce Demo code and AudioFormatWriter::ThreadedWriter, but unfortunately it only takes float** as the argument to write(), which an AudioSampleBuffer can not deliver. I tried a dirty hack with casting AudioSampleBuffer::getSampleData(0) to float**, but that crashed on me.
It would be great if AudioSampleBuffer also had writeFromAudioSampleBuffer(). Would that be possible, or do I miss something?
Erm, oops. Just found AudioSampleBuffer::getArrayOfChannels() :oops:
Anyway, it still crashes on me. I seem to have messed it up somehow. What would be the recommended way to the above?
Sorry for all the noise. I got ot to work now. The AudioProcessor was not initialized properly (channel count), because I added it to the graph too early, before the AudioProcessorPlayer it is hooked into was configured.
In case anyone is interested, here’s how I did it: Basically I copied the recorder from the Juce Demo, made it inherit from AudioProcessor, removed the writeLock member and used the getCallbackLock() instead, and implemented these members:
[code]void RecordProcessor::prepareToPlay ( double sampleRate_, int blockSize_ )
sampleRate = getSampleRate();
sampleRate = 0;
void RecordProcessor::processBlock ( AudioSampleBuffer& buffer, MidiBuffer& midiMessages )
if (activeWriter != 0)
activeWriter->write ((const float**)buffer.getArrayOfChannels(), buffer.getNumSamples());
Hopefully this will be helpful for others.