Re: Audio Units - newbie questions
Re: Audio Units - newbie questions
- Subject: Re: Audio Units - newbie questions
- From: Olivier Tristan <email@hidden>
- Date: Wed, 12 Oct 2005 14:17:25 +0200
Muon Software Ltd - Dave wrote:
//populate our list of buffers
if (nNumBusses==1)
{
//got a single output buss
AUOutputElement* ptrOutput = GetOutput(0);
AudioBufferList& bufferList = ptrOutput->GetBufferList();
//find out how many buffers this bus contains
UInt32 nBuffers=bufferList.mNumberBuffers;
if (nBuffers==1)
{
//bus contains a single (mono) buffer
memset((float*)bufferList.mBuffers[0].mData,0,nFrames*sizeof(float));
for (i=0;i<kNumOutputs;i++)
{
//use the same buffer pointer for all our outputs
m_ptrAudioBuffers[i]=(float*)bufferList.mBuffers[0].mData;
}
}
Use
uint channelCount = outputBufferList.mNumberBuffers;
instead of kNumOutputs
Use AUBufferList::ZeroBuffer(bufferList) instead of your memset
Is there a reason to have two different case nBuffers==1 and
nBuffers==2, I see no difference.
Anyway, according to what I see you ll just need to do this:
uint numOutputBusCount = Outputs().GetNumberOfElements();
uint channelSoFar = 0;
for (uint i = 0; i < numOutputBusCount ; i++)
{
AUOutputElement *output = GetOutput(i);
AudioBufferList &outputBufferList = output->PrepareBuffer(nFrames);
AUBufferList::ZeroBuffer(outputBufferList);
uint channelCount = outputBufferList.mNumberBuffers;
for (uint j = 0; j < channelCount ; j++)
{
m_ptrAudioBuffers[channelSoFar+j] =
reinterpret_cast<float*>(outputBufferList.mBuffers[j].mData);
}
channelSoFar += channelCount ;
}
After this you'll be like in VST processing.
Your code seems to mush complicated IMHO.
Concerning this part
if (nFrames>(UInt32)m_nBlockSize)
{
//is this likely to happen?
m_nBlockSize=(int)GetMaxFramesPerSlice();
getLock();
m_ptrSynth->reset((int)m_fSampleRate,m_nBlockSize);
releaseLock();
}
Just use directly nFrames instead of GetMaxFramesPerSlice and I wonder
why you will need to lock because Render is always called in the audio
thread.
Hope this helps.
--
Olivier Tristan
Ultimate Sound Bank
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden