Re: Resampling
Re: Resampling
- Subject: Re: Resampling
- From: email@hidden
- Date: Fri, 13 Mar 2009 16:30:32 -0700 (PDT)
Great, I'm starting to understand how this works... :-)
I am also trying to convert input data (recording) from 44.1 to 16KHz, and the problem here is that I don't know how many 16KHz frames I will need. After all, the recording callback gives me a fixed number of 44.1KHz frames (512), but the AudioConverterFillComplexBuffer function expects me to say how many 16KHz frames those will turn into.
If I always as for 185, the converter will eventually store more and more leftovers. If I always ask for 186, the converter will call me multiple times (based on what Doug said below) but I won't have anything to provide it.
How can I simply convert whatever number of frames I currently have?
Thanks!
----- Original Message ----
From: Doug Wyatt <email@hidden>
To: Jens Alfke <email@hidden>
Cc: email@hidden; email@hidden
Sent: Friday, March 13, 2009 2:51:29 PM
Subject: Re: Resampling
On Mar 13, 2009, at 13:55 , Jens Alfke wrote:
>
> On Mar 13, 2009, at 12:10 PM, email@hidden wrote:
>
>> So if I'm going to use AudioConverter, then will the AudioConverter
>> callback simply request the number of 16KHz frames it needs in order to
>> satisfy each call to AudioConverterFillComplexBuffer (probably
>> alternating between 185 and 186 16KHz frames for 512 44.1KHz frames)?
>
> Something like that. I wouldn't make any assumptions about how many frames it asks for at a time, though, since it might ask for more if it has internal buffering, or just needs to work on larger sample sets for better interpolation, or whatever. Just be prepared to give it as many as it asks for.
If you're connected to an audio unit, you have to give exactly what it asks for.
If you're providing data to an AudioConverter callback, you can give it however much you like, as long as you promise not to free or change the contents of that memory until you're called again (the converter holds pointers into these buffers until it's done with them, avoiding copying in many cases). If you provide more than is necessary, the converter will keep track of how much it consumed and start consuming from the point next time. If you provide less than what is necessary, the converter will call you again for more.
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