I'm trying to write a AUv3 host for iOS and I'm stumbling on a problem handling audio input.
I can already handle AUv3's sound output but when working with FX's I'm not able to pass audio to the AUv3 unit.
I'm calling the AURenderBlock with the input parameter, filling the respective AURenderPullInputBlock.
The render method has pointers to the output and input that will be called from the C++ kernel side of the code.
If I print the inputData buffers, the input data is being placed correctly however, I can see audio data being printed but the audio unit does not seem to receive this audio input and therefore I can't understand if the output is also being placed on the output buffers.
Is anyone able to tell me what is missing here? What am I missing?
- (void)render:(IAudioSample*)outL rightChannel:(IAudioSample*)outR leftIn:(IAudioSample*)inL rightIn:(IAudioSample*)inR frames:(int)frames
{
if (_ready)
{
AudioUnitRenderActionFlags flags = 0;
if (_isEffect)
{
memcpy((IAudioSample *)_inputBuffers[0].mBuffers[0].mData, inL, sizeof(IAudioSample)*frames);
memcpy((IAudioSample *)_inputBuffers[0].mBuffers[1].mData, inR, sizeof(IAudioSample)*frames);
_auRenderBlock(&flags, &_renderTimeStamp, frames, 0, _outputBuffers,
(AURenderPullInputBlock)^(AudioUnitRenderActionFlags *actionFlags, const AudioTimeStamp *timestamp, AUAudioFrameCount frameCount, NSInteger inputBusNumber, AudioBufferList *inputData)
{
memcpy((IAudioSample *)inputData[inputBusNumber].mBuffers[0].mData, (IAudioSample *)_inputBuffers[inputBusNumber].mBuffers[0].mData, sizeof(IAudioSample)*frameCount);
memcpy((IAudioSample *)inputData[inputBusNumber].mBuffers[1].mData, (IAudioSample *)_inputBuffers[inputBusNumber].mBuffers[1].mData, sizeof(IAudioSample)*frameCount);
}
);
}
else
{
_auRenderBlock(&flags, &_renderTimeStamp, frames, 0, _outputBuffers, NULL);
}
memcpy(outL, (IAudioSample *)_outputBuffers[0].mBuffers[0].mData, sizeof(IAudioSample)*frames);
memcpy(outR, (IAudioSample *)_outputBuffers[0].mBuffers[1].mData, sizeof(IAudioSample)*frames);
unsigned int sampleTime = _renderTimeStamp.mSampleTime + frames;
_renderTimeStamp.mSampleTime = sampleTime;
}
}