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:28:16 -0800
Yes, it works. My mistake. Thanks.
From: Doug Wyatt <email@hidden>
To: apple question <email@hidden>
CC: email@hidden
Subject: Re: how do I change bitsperchannel value
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
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
_______________________________________________
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