I’m trying to write a wrapper for admsyn’s AudioUnit block into cinder’s native audio pull but I’m having a really hard time.
I tried creating a subclass of audio::Node and au::Tap and then overriding the process() function.
class AUobj : public cinder::audio::Node, public au::Tap
{
public:
AUobj( const Format &format = Format().channels(2).channelMode( AUobj::ChannelMode::SPECIFIED ) );
virtual ~AUobj(){};
void process( ci::audio::Buffer *buffer ) override;
private:
};
Then using an override method from richardeakin’s wrapper for the stk library
AUobj::AUobj( const Format &format )//set format if no input connected
: Node( format ), au::Tap()
{
}
void AUobj::process( audio::Buffer *buffer )//override
{
const size_t numChannels = buffer->getNumChannels();
const size_t numFrames = buffer->getNumFrames();
//performTick( &mStkFrames );
for( size_t ch = 0; ch < numChannels; ch++ )
{
float *channel = buffer->getChannel( ch );
au::TapSampleBuffer tapBuf ;//for the audiounit tap
for( size_t i = 0; i < numFrames; i++ )
{
getSamples(tapBuf);//au tap sample buffer
//channel[i] = mStkFrames( i, ch );//from stk wrapper
channel[i] = tapBuf[i];//my version
}
}
}
But it crashes the app heavily when I try myWrapper.connect(mMonitor);
Basically, I’d like to pull in and out of the “connect” chain from either cinder::audio or the AudioUnit block.
so ultimately I’d like to do something like
auWrapper>>mMonitor;//AudioUnit to cinder::audio
mMonitor>>auWrapperOut;//cinder::audio to AudioUnit
Instead of the bitwise>> I used
myWrapper.connect(mMonitor);
but I’m still getting issues.
Also, cinder has audio cocoa NodeAudioUnit … perhaps I should start there and try to share a pointer of the AudioUnit block’s audioUnitRef and the NodeAudioUnit’s ::AudioUnit and pull the stream from the appropriate downstream/upstream depending on the type? I was worried about creating two instances of the same audioUnit. Any thoughts on how to do this? Kinda my first wrapper…