• 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: 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


  • Follow-Ups:
    • Re: how do I change bitsperchannel value
      • From: "apple question" <email@hidden>
    • Re: how do I change bitsperchannel value
      • From: "apple question" <email@hidden>
References: 
 >Re: how do I change bitsperchannel value (From: "apple question" <email@hidden>)

  • Prev by Date: Re: how do I change bitsperchannel value
  • Next by Date: Re: how do I change bitsperchannel value
  • Previous by thread: Re: how do I change bitsperchannel value
  • Next by thread: Re: how do I change bitsperchannel value
  • Index(es):
    • Date
    • Thread