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

AudioConverter not performing sample rate conversion


  • Subject: AudioConverter not performing sample rate conversion
  • From: Ethan Funk <email@hidden>
  • Date: Mon, 6 Jul 2009 15:12:26 -0700

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;
}


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.

Thanks,
Ethan...

_______________________________________________
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: AudioConverter not performing sample rate conversion
      • From: Doug Wyatt <email@hidden>
  • Prev by Date: Re: AQOfflineRenderTest
  • Next by Date: Re: Audio distortion after several hours?
  • Previous by thread: Re: Reduce Audio Time Latency
  • Next by thread: Re: AudioConverter not performing sample rate conversion
  • Index(es):
    • Date
    • Thread