Re: HALOutputUnit (Pt 2)
Re: HALOutputUnit (Pt 2)
- Subject: Re: HALOutputUnit (Pt 2)
- From: Aaron Eppolito <email@hidden>
- Date: Tue, 24 Feb 2004 11:33:55 -0800
On Feb 24, 2004, at 7:20 AM, Bob Stuller wrote:
>
At 7:13 PM -0800 2/23/04, Aaron Eppolito wrote:
>
> This sounds like the same problem I was having. You must set the
>
> sample rate of the OutputScope of the InputBus equal to the
>
> InputScope of the InputBus, otherwise, you'll get the CannotDo error.
>
>
How is the sample rate of the InputScope of the InputBus set? When I
>
do a AUSetProperty-SampleRate on the input side of the HALAU, i.e. the
>
side the device is hooked up to, I get a
>
kAudioUnitErr_PropertyNotWritable error. Going to Global scope (still
>
on the input element) gives a kAudioUnitErr_InvalidElement error.
Here's what I did:
// get the "input of input" stream description
AudioStreamBasicDescription asbd;
size = sizeof(asbd);
result = AudioUnitGetProperty (unit, kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input, 1, &asbd, &size);
THROW_RESULT ("AudioUnitGetProperty");
// get the "output of input" stream description
AudioStreamBasicDescription outputOfInput;
size = sizeof(outputOfInput);
result = AudioUnitGetProperty (unit, kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Output, 1, &outputOfInput, &size);
THROW_RESULT ("AudioUnitGetProperty");
// set the output of the input to be the right sample rate
// as well as the number of channels
outputOfInput.mSampleRate = asbd.mSampleRate;
if(asbd.mChannelsPerFrame == 1) outputOfInput.mChannelsPerFrame = 1;
result = AudioUnitSetProperty (unit, kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Output, 1, &outputOfInput, size);
THROW_RESULT ("AudioUnitSetProperty");
Better to do would be to skip the second chunk and instead explicitly
set the stream format you want.
>
I'd assumed that setting the device's format via the HALAU would set
>
both the device's sample rate &, necessarily, that of the HALAU's
>
input side (of element == 1).
I assumed that too. Alas, it is an incorrect assumption. All Audio
Units initialize to 44.1kHz de-interleaved stereo float.
-Aaron
_______________________________________________
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.