• 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: AudioConverter not performing sample rate conversion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AudioConverter not performing sample rate conversion


  • Subject: Re: AudioConverter not performing sample rate conversion
  • From: Doug Wyatt <email@hidden>
  • Date: Mon, 13 Jul 2009 21:51:06 -0700


On Jul 6, 2009, at 15:12 , Ethan Funk wrote:

Given that inFormat is the AudioStreamBasicDescription for a mono version from a built-in sound input device, 44.1 ksps, I set up an Audio Converter as follows.

outFormat.mSampleRate = 22050.0;
outFormat.mFormatID = kAudioFormatMPEG4AAC;
outFormat.mChannelsPerFrame = 1;
outFormat.mFormatFlags = 0;
outFormat.mBytesPerFrame = 0;
outFormat.mBytesPerPacket = 0;
outFormat.mBitsPerChannel = 0;
outFormat.mFramesPerPacket = 1024;
br = 32 * 1024;
err = AudioConverterNew(&inFormat, &outFormat, &Encoder);
if(err)
goto error;
err = AudioConverterSetProperty(Encoder, kAudioConverterEncodeBitRate, sizeof(br), &br);
if(err){
AudioConverterDispose(Encoder);
goto error;
}



If you add this here: CAShow(Encoder);

what does it print?

No errors. I then compress my audio one packet at a time until no more data is available:

UInt32 temp = feedCompressedBufferList->mBuffers[0].mDataByteSize;
while(1){
UInt32 packets = 1;
err = AudioConverterFillComplexBuffer(Encoder, encoderInputCallback, self, &packets, feedCompressedBufferList, NULL);
if(err)
break;
if(packets != 1)
break;
< --- do something here with the buffer --- >
feedCompressedBufferList->mBuffers[0].mDataByteSize = temp;
}


What's strange here is that my encoderInputCallback is being asked for 1024 samples, not approximately 2048 samples as I would expect on the other side of a 44.1 ksps to 22.05 ksps converter. Have I done something wrong in the converter setup? In the other direction (decoding AAC), the AudioConverter handles the sample rate conversion just fine.

Are you getting any errors here? Are you receiving correct output?

Doug


_______________________________________________ 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: 
 >AudioConverter not performing sample rate conversion (From: Ethan Funk <email@hidden>)

  • Prev by Date: Re: mono channel to stereo channel mapping problem.
  • Next by Date: Echo in 3.0
  • Previous by thread: AudioConverter not performing sample rate conversion
  • Next by thread: Re: Audio distortion after several hours?
  • Index(es):
    • Date
    • Thread