Re: AudioConverter in Realtime
Re: AudioConverter in Realtime
- Subject: Re: AudioConverter in Realtime
- From: Bill Stewart <email@hidden>
- Date: Fri, 8 Aug 2003 12:00:33 -0700
I think some of the confusion is that the output scope for a device
unit on elementID == 0 is the device format. To set the output unit up,
you set the *INPUT* scope to the data format you will provide - then
the AU will do a conversion from that input format to the output format
(which is the device) - You can't set the device format using the
output unit.
One good benefit of doing it this way, is that as you've told the AU
what input you are going to give it, if the devices format changes, the
AU will automatically re-establish a different converter chain from
your input format to the new device format.
One of the *big* benefits of using the output unit to do this work, is
that in Panther this will also turn off unused streams on the device.
So, if you aren't doing input (which is also a new feature for
Panther), the output unit will turn off the input stream(s). If you
have say a multichannel device and you are only doing 2 channels, then
it will turn off all the streams that aren't in use. So, this can lead
to a big saving of CPU performance, so its worth doing it this way if
possible.
Bill
On Friday, August 8, 2003, at 01:10 AM, Benedict Singer wrote:
The behavior you're seeing is normal; if you're doing output at the
AudioDevice level like this, then you'll have to deal with the format
issues. Luckily, it's fairly easy using an AudioConverter. The basic
idea
is that you get the format of the device, then, in a copy of that
description, update the values to be your sample rate, channels
(changing
related values as needed) and then make an AudioConverter to convert
from
your format to the device's format. At that point, you'll want to use
AudioConverterFillBuffer. I've included a code snippet below that does
the
description setup.
Alternatively, you can look into using the DefaultOutputUnit stuff, and
doing this from an AudioUnit perspective. That has the advantage that
it
should do any conversions needed automatically.
// change description according to requirements, keeping the actual
one to
// init the AudioConverter with
descriptionActual = description;
//first get the word size
UInt32 wordSize = description.mBytesPerFrame /
description.mChannelsPerFrame;
//then change the values needed to update the channels
description.mBytesPerPacket = description.mBytesPerFrame =
yourChannels *
wordSize;
//then update that channels and sample rate
description.mChannelsPerFrame = yourChannels;
description.mSampleRate = yourSampleRate;
//create the audio converter
status = AudioConverterNew(&description, &descriptionActual,
&gConverter);
On Thu, 7 Aug 2003 email@hidden wrote:
I have an iBook and the built in hardware only has 2 channel 44 kHz
I/O.
I'm playing floting point, PCM data. When I call
AudioDeviceSetProperty(kAudioDevicePropertyStreamFormat)
with a sample rate other than 44100.0 for the output I get an '!dat'
errror.
When I hook up an iMic I don't get the error.
When I call
AudioDeviceGetPropertyInfo(kAudioDevicePropertyStreamFormats),
it returns a sample rate of 0.0 for the iMic and 44100.0 for the
built in
hardware.
thanks
Jeff
In a message dated 08/07/03 5:47:51 PM, email@hidden writes:
The HAL Output units (which inc the Default and System output) use a
converter internally to convert from your input format (which as
long
as it is a PCM format, can be *anything* (nearly)) to the device's
format
In the SDK there's some kinda ugly code in DefaultOutput that shows
you
different options you can entertain here.
Bill
_______________________________________________
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.
_______________________________________________
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.
--
mailto:email@hidden
tel: +1 408 974 4056
________________________________________________________________________
__
"Much human ingenuity has gone into finding the ultimate Before.
The current state of knowledge can be summarized thus:
In the beginning, there was nothing, which exploded" - Terry Pratchett
________________________________________________________________________
__
_______________________________________________
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.