Re: AudioConverter not performing sample rate conversion
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