Re: AudioConverter in Realtime
Re: AudioConverter in Realtime
- Subject: Re: AudioConverter in Realtime
- From: Benedict Singer <email@hidden>
- Date: Fri, 8 Aug 2003 10:10:05 +0200 (MEST)
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.