Re: how do I change bitsperchannel value
Re: how do I change bitsperchannel value
- Subject: Re: how do I change bitsperchannel value
- From: "apple question" <email@hidden>
- Date: Mon, 10 Jul 2006 13:04:25 -0800
I am using the following test function. Any idea what is wrong here? Are we
even allowed to do simple bitsperchannel converting? Thanks.
OSStatus Test::TestConverter()
{
OSStatus err;
AudioConverterRef converter;
int nChannels = 1;
CAStreamBasicDescription inDataFormat;
inDataFormat.mFormatID = kAudioFormatLinearPCM;
inDataFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger |
kAudioFormatFlagIsPacked; //Little Endian
inDataFormat.mBytesPerPacket = inDataFormat.mBytesPerFrame = nChannels * 2;
inDataFormat.mFramesPerPacket = 1;
inDataFormat.mChannelsPerFrame = nChannels;
inDataFormat.mBitsPerChannel = 32;
CAStreamBasicDescription outDataFormat = inDataFormat;
outDataFormat.mBitsPerChannel = 16;
err = AudioConverterNew(&inDataFormat, &outDataFormat, &converter); //fail,
errcode "fmt?"
return err;
}
From: Doug Wyatt <email@hidden>
To: apple question <email@hidden>
CC: email@hidden
Subject: Re: how do I change bitsperchannel value
Date: Fri, 7 Jul 2006 13:23:22 -0700
On Jul 7, 2006, at 09:42 , apple question wrote:
How do I change the bitsperchannel value for the audio data? i.e, the
original LPCM data is 32bits per channel, I want to convert the data to
16bits per channel. Create Audio Converter will fail if I have different
bitsperchannel value for input and output data formats. Thanks.
What are the full AudioStreamBasicDescriptions?
One or both are probably incorrect.
For 16-bit big-endian signed integer, the ASBD should be:
mFormatID = kAudioFormatLinearPCM;
mFormatFlags = kLinearPCMFormatFlagIsBigEndian |
kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked;
mBytesPerPacket = mBytesPerFrame = nchannels * 2; // 16 bits -> 2 bytes
mFramesPerPacket = 1;
mChannelsPerFrame = nchannels;
mBitsPerChannel = 16;
--
Doug Wyatt
Core Audio, Apple
_________________________________________________________________
On the road to retirement? Check out MSN Life Events for advice on how to
get there! http://lifeevents.msn.com/category.aspx?cid=Retirement
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden