• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: HALOutputUnit (Pt 2)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: HALOutputUnit (Pt 2)


  • Subject: Re: HALOutputUnit (Pt 2)
  • From: Bob Stuller <email@hidden>
  • Date: Tue, 24 Feb 2004 18:16:30 -0500

Aaron, Greetings!

At 11:33 AM -0800 2/24/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.

Ouch! Reviewing the situation (all references are to the input bus, element #1):
1) The input (device) scope is a read-only property for format in general and sample rate in particular.
2) The input & output ends of the bus must match on sample rates & number of channels.
3) I'm always going to find the output end's sample rate to be 44.1kHz.
Therefore, I can _only_ get 44.1kHz out of the HALAU.

So I simply cannot do what I feel I need to do using the HALAU. Bummer!

I guess the thing to do now is to advocate to the wider set of Core Audio engineers to have this change sometime soon. Look at it from our point of view: We have plenty to do with the processor and, especially, with memory bandwidth once the sample have been sent to the speech-recognition engine. This is not to speak of the processing involved by the target application, e.g. Word doing on-the-fly spell checking.

Secondly, I am concerned about down-sampling artifacts & was figuring to use the fancier converter whenever a microphone couldn't be throttled down to 16kHz. Most speech-oriented hardware can, however.

Aaron, thank you for passing along your no-doubt hard-won experience. I don't want you to think that you are a target of my current disappointed state. Fact is, all the CA engineers are super-helpful...

Peace,
Bob
--

It's Great to be Green!
http://www.greenpartyus.org/
_______________________________________________
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.


  • Follow-Ups:
    • Re: HALOutputUnit (Pt 2)
      • From: Aaron Eppolito <email@hidden>
    • Re: HALOutputUnit (Pt 2)
      • From: Doug Wyatt <email@hidden>
References: 
 >Re: HALOutputUnit (Pt 2) (From: Bob Stuller <email@hidden>)
 >Re: HALOutputUnit (Pt 2) (From: Doug Wyatt <email@hidden>)
 >Re: HALOutputUnit (Pt 2) (From: Bob Stuller <email@hidden>)
 >Re: HALOutputUnit (Pt 2) (From: Doug Wyatt <email@hidden>)
 >Re: HALOutputUnit (Pt 2) (From: Bob Stuller <email@hidden>)
 >Re: HALOutputUnit (Pt 2) (From: Doug Wyatt <email@hidden>)
 >Re: HALOutputUnit (Pt 2) (From: Bob Stuller <email@hidden>)
 >Re: HALOutputUnit (Pt 2) (From: Aaron Eppolito <email@hidden>)
 >Re: HALOutputUnit (Pt 2) (From: Bob Stuller <email@hidden>)
 >Re: HALOutputUnit (Pt 2) (From: Aaron Eppolito <email@hidden>)

  • Prev by Date: Re: Audiounits: For the love of Xcode!!
  • Next by Date: Re: HALOutputUnit (Pt 2)
  • Previous by thread: Re: HALOutputUnit (Pt 2)
  • Next by thread: Re: HALOutputUnit (Pt 2)
  • Index(es):
    • Date
    • Thread