Re: HALOutputUnit (Pt 2)
Re: HALOutputUnit (Pt 2)
- Subject: Re: HALOutputUnit (Pt 2)
- From: William Stewart <email@hidden>
- Date: Wed, 25 Feb 2004 18:42:39 -0800
On 25/02/2004, at 6:20 PM, Bob Stuller wrote:
>
Bill, Greetings!
>
>
At 12:14 PM -0800 2/25/04, William Stewart wrote:
>
> The other thing to note after these steps, is that if you have a
>
> mismatch between the device's available channels (lets say it has 10)
>
> and what you want (lets say 2) - you can use the channel map property
>
> to describe which channels of the device you want your data to go
>
> to/from. This is true both for the input and output cases (and was
>
> covered in my email and will be covered in the technote)... If you
>
> don't set a channel map, then you basically go to/from the first 2
>
> channels of the device (in the example above)
>
>
I do this (error-handling removed for clarity):
>
Boolean writable = false;
>
status = AudioUnitGetPropertyInfo(mHALOutInstance,
>
kAudioOutputUnitProperty_ChannelMap,
>
kAudioUnitScope_Output,
>
kDeviceInputElement,
>
&propertySize, &writable);
>
SignalIf_(writable == false);
>
>
long nChannels = propertySize / sizeof(SInt32);
>
long* channelMapPtr = (long*)malloc(propertySize);
>
>
UInt32 scratch = propertySize;
>
status = ::AudioUnitGetProperty(mHALOutInstance,
>
kAudioOutputUnitProperty_ChannelMap,
>
kAudioUnitScope_Output,
>
kDeviceInputElement,
>
channelMapPtr,
>
&scratch);
>
>
channelMapPtr[0] = 0;
>
for (long i = 1; i < nChannels; i++)
>
{
>
channelMapPtr[i] = -1;
>
}
You only need to set the channel map if you want anything BUT the
default mapping... The default mapping is this:
Device Channel Your Channel
1 1
2 2
etc....
>
status = AudioUnitSetProperty(mHALOutInstance,
>
kAudioOutputUnitProperty_ChannelMap,
>
kAudioUnitScope_Output,
>
kDeviceInputElement, channelMapPtr, sizeof(UInt32));
>
>
The question: Do I also do right if I conform the format that I am
>
setting on the AUHAL's (<<<= note conforming terminology!) output
>
scope (of the input bus/element)? That is, I do this & it works:
>
mInputDesc.description.mSampleRate = current.mSampleRate; //
>
input scope's SR, thanx, Aaron!
>
if (mInputDesc.description.mChannelsPerFrame != 1)
>
{
>
mInputDesc.description.mChannelsPerFrame = 1;
>
UInt32 sampleBytes = mInputDesc.description.mBitsPerChannel / 8;
>
mInputDesc.description.mBytesPerPacket = sampleBytes;
>
mInputDesc.description.mBytesPerFrame = sampleBytes;
>
}
You might want to look at CAStreamBasicDescription in PublicUtility -
it provides some very convenient methods to set a format:
CAStreamBasicDescription desc;
desc.SetCanonical (numChannels, false);
desc.mSampleRate = mySampleRate;
Bill
>
Having done the channel map, is this redundant? Will it be prohibited
>
behavior some day?
>
>
> The value of the flags should be zero thus:
>
>
>
> AudioUnitRenderActionFlags flags = 0;
>
> AudioUnitRender (unit, &flags, ×tamp, 1, numFrames,
>
> bufferlist);
>
>
>
> You have been warned :)
>
>
Question: I just pass the same pointer that the callback gets as a
>
parameter. Should I be sending in a pointer to zero? Will
>
AudioUnitRender ever use this pointer to give feedback on its
>
activities?
not a pointer to zero (char* ptr = 0!!!!) WRONG!!!! :)
We're massaging this render flags param, so that's fine to just use the
one we're passing you.
Bill
>
>
Thanks to all the CA for the great help that I got whilst getting this
>
going.
>
>
Peace,
>
Bob
>
--
>
>
It's Great to be Green!
>
http://www.greenpartyus.org/
>
>
--
mailto:email@hidden
tel: +1 408 974 4056
________________________________________________________________________
__
Culture Ship Names:
Ravished By The Sheer Implausibility Of That Last Statement
I said, I've Got A Big Stick [OU]
Inappropiate Response [OU]
Far Over The Borders Of Insanity And Still Accelerating [Eccentric]
________________________________________________________________________
__
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.