Re: how do I change bitsperchannel value
Re: how do I change bitsperchannel value
- Subject: Re: how do I change bitsperchannel value
- From: Doug Wyatt <email@hidden>
- Date: Mon, 10 Jul 2006 14:18:35 -0700
On Jul 10, 2006, at 14:04 , 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;
for 32 bits this should be nChannels * 4
inDataFormat.mFramesPerPacket = 1;
inDataFormat.mChannelsPerFrame = nChannels;
inDataFormat.mBitsPerChannel = 32;
CAStreamBasicDescription outDataFormat = inDataFormat;
outDataFormat.mBitsPerChannel = 16;
for 16 bits this should be nChannels * 2
More generally, you could set mBitsPerChannel first (as long as it's
an even multiple of 8), then:
mBytesPerPacket = mBytesPerFrame = nChannels * mBitsPerChannel / 8;
err = AudioConverterNew(&inDataFormat, &outDataFormat,
&converter); //fail, errcode "fmt?"
return err;
}
Then this will work.
Doug
--
Doug Wyatt
Core Audio, Apple
_______________________________________________
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