Hi all,
I’m excited to be revisiting the great audio api, especially now that audio input on Linux is working (thanks!)! I have a project where I need to select sections of an audio file and export them as separate samples. Hacking the buffer player sample I was able to able to get smaller buffer players from a larger one. However, I can not figure out how to write these to disk like I can with a buffer recorder node. I can’t see any method to get an existing buffer into a recording node and have had no luck with memcpy so far.
Any advice greatly appreciated, thanks!
int numFrames = .5 * mBufferPlayerNode->getNumFrames();
int frameOffset = 0;
int otherFrameOffset = 0;
int numChannels = mBufferPlayerNode->getNumChannels();
audio::BufferRef buffer = make_shared< audio::Buffer >( numFrames, numChannels );
buffer->copyOffset(*mBufferPlayerNode->getBuffer(), numFrames, frameOffset, otherFrameOffset);
auto ctx = audio::Context::master();
audio::BufferPlayerNodeRef player = ctx->makeNode( new audio::BufferPlayerNode( buffer ) );
mWaveformPlot.load( player->getBuffer(), getWindowBounds() );
mBufferPlayerNode = player;
mBufferPlayerNode >> mGain >> ctx->getOutput();
mBufferPlayerNode->setEnabled(true);
audio::BufferRecorderNodeRef recorder = make_shared< audio::BufferRecorderNode >( numFrames );
//not sure what to do next...
memcpy(recorder->getInternalBuffer(), buffer->getData(), numFrames);//< doesn't work
recorder->writeToFile(filepath);