Re: AudioUnitKernal constructor called twice...
Re: AudioUnitKernal constructor called twice...
- Subject: Re: AudioUnitKernal constructor called twice...
- From: "email@hidden" <email@hidden>
- Date: Fri, 19 Aug 2011 12:29:16 +0100
Hi Brian
That is an extremely good point. For me (and possibly others in a similar situation), it all rests on accessing the kernel index from within the kernel. If any one knows how to do this, I would love to know!
Cheers
Simon
Sent from my iPhone
On 19 Aug 2011, at 09:06, Brian Willoughby <email@hidden> wrote:
> On Aug 19, 2011, at 00:34, email@hidden wrote:
>> For processing audio on two channels in the same function (stereo panning, for example), it seems overriding ProcessBufferLists() is the way to go.
>
> Simon,
>
> The most important thing you can do if you want stereo processing is to either work within the kernel system defined by AUEffectBase, or simply avoid that class and use AUBase instead. In other words, if you're considering overriding ProcessBufferLists(), then you should really consider using RenderBus() in a subclass of AUBase.
>
> Note that it isn't so difficult to work with kernels, even if you want to process each channel differently. Stereo panning is nothing more than simple gain processing where one channel's volume is inverted with respect to the other. There are a couple of potential solutions:
>
> A) You can handle this by storing the pan position in the master object and then use the kernel index to decide whether to use the pan directly or inversely to set the gain. Off the top of my head, though, I'm not sure how easy it is for a kernel object to determine it's own index, but I seem to recall doing so in the past. The bulk of your kernel code would be generic, except for the initial determination of gain based on channel index.
>
> B) A totally different solution would be to have a gain parameter in the kernel objects, such that each channel has an independent gain. Then, when your master object receives a pan position change, your code can calculate two gains (or any number of gains) and store each independent gain value in the appropriate kernel object. Thus, when the kernel executes, it simply applies the local gain to an individual channel.
>
> The advantage of working within the kernel system is that you maintain all of the carefully designed behavior that Apple's CoreAudio team has developed within the AUEffectBase class. Do not underestimate the advantages of having your plugin automatically work with quad, 5.1 and other surround formats beyond stereo. You also avoid bucking the standard of non-interleaved audio data, i.e., you're not trying to go back to the deprecated interleaved data scheme.
>
> There are certainly multi-channel effects where kernel coding might prove too difficult, thus tipping the scale towards working under AUBase directly. However, with careful placement of state variables in the global objects and kernels objects, as appropriate, I suspect that you'd be hard pressed to come up with an example that would not work.
>
> Brian Willoughby
> Sound Consulting
>
_______________________________________________
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