• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: how do I change bitsperchannel value
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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:54:04 -0800

Ok. In my original program I am getting the mFormatFlags value from iSight, which is kAudioFormatFlagIsFloat | kAudioFormatFlagIsPacked. When I try to change bitsperchannel from 32 to 16 without changing the flag, create converter fails. Now if I change the new 16bit flag to kLinearPCMFormatFlagIsSignedInteger , it will pass. So the idea seems to be for kAudioFormatFlagIsFloat to set, the bitsperchannel value should be muliple of 4 bytes. Thanks Doug and Geoff for their help.


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


_________________________________________________________________
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


References: 
 >Re: how do I change bitsperchannel value (From: Doug Wyatt <email@hidden>)

  • Prev by Date: DRM and Apple Loops
  • Next by Date: Re: DRM and Apple Loops
  • Previous by thread: Re: how do I change bitsperchannel value
  • Next by thread: Question about HALRunLoop thread
  • Index(es):
    • Date
    • Thread