Re: TAUBuffer circular?
Re: TAUBuffer circular?
- Subject: Re: TAUBuffer circular?
- From: stiwi <email@hidden>
- Date: Mon, 14 Mar 2005 11:00:09 +0100
Hi Michael,
On 14.03.2005, at 01:16, Michael Hanna wrote:
Is TAUBuffer a circular buffer? The reason I ask this is because in
the Delaystrom source that I'm examining, the mWriteIndex is
initialized at the end of the buffer:
No its not. Its just an array of samples of any type, to be optimally
aligned for the processor.
It has some useful methods like AllocateClear(), Clear(), Deallocate.
public:
UniTapDelayKernel(AUEffectBase *inAudioUnit )
: AUKernelBase(inAudioUnit)
{
// Initialize per-channel state of this effect processor
mMaxDelayFrames = (int)(GetSampleRate() * kMaxDelayTime + 10)
/*a little extra so we can support full delay time*/;
mDelayBuffer.AllocateClear(mMaxDelayFrames);
mWriteIndex = mMaxDelayFrames - 1; // end of buffer
}
in ::Process
while (nSampleFrames-- > 0) {
Float32 input = *sourceP;
// write to delay line
mDelayBuffer[mWriteIndex] = input;
mWriteIndex = (mWriteIndex + 1) % mMaxDelayFrames;
Here the % mMaxDelayFrames (modulo) takes care of the wrapping. It's
equal to the following code.
The same could be done with masking via the logical & operator.
mWriteIndex = mWriteIndex + 1;
If (mWriteIndex >= mMaxDelayFrames)
mWriteIndex = 0;
int readIndex = NormalizeIndex(mWriteIndex - frames);
so it writes to mDelayBuffer at the last index, then increments it by
one.. if it weren't circular, it would write the sample out of bounds.
So is my assumption correct?
Michael
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
------------------------------------------------------------------------
---------------------------
Stefan Kirch
web: www.alphakanal.de
aim: email@hidden
_______________________________________________
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