Re: how do I change bitsperchannel value
Re: how do I change bitsperchannel value
- Subject: Re: how do I change bitsperchannel value
- From: Geoff Brown <email@hidden>
- Date: Mon, 10 Jul 2006 14:14:35 -0700
Yes, you are allowed to change the bits per channel with an audio
converter. I suspect Doug was asking you to share the actual values
of your audio stream basic descriptions so he could see where the
format error was. You dont show how you set mBytesPerFrame, but the
code below would not set that value correctly in the outDataFormat.
You will need to change that value and the mBytesPerPacket value to
be consistent with 16 bits per channel.
Whenever you set up a stream basic description you should look at it
very carefully to be certain that all its values are consistent. I
am sure you will find that the values in your outDataFormat are not.
good luck
-geoff
On Jul 10, 2006, at 2:04 PM, apple question wrote:
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
_______________________________________________
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