On Nov 29, 2005, at 2:27 PM, Brian Whitman wrote:
On Nov 29, 2005, at 4:08 PM, Chris Rogers wrote: No, it doesn't skip 4000 samples, since you gave it 12000 the time before, you absolutely have to continue from where you left off. The idea is very simple; the callback asks you for a specific amount which you must provide. Then, the next time it calls you, you need to give it samples at the point *exactly* where you left off the last time.
OK, this is probably my problem. I ask the AU for 8192 samples by calling Initialize with a 2nd parameter of 8192, it then reads 12000 from my source *but only returns 8192*, always. The total of the numFrames returned by the Render calls is always 8192-- the amount it returns is always what I ask for, not what it reads. The next time I call Render I understand it wants to start reading from sample position 12000. Where are the rendered samples that represent source sample positions 8192-12000? How do I get them? The AU didn't return them the first time, even though it read up to 12000 in my source buffer. The only way I saw to get them was to "roll back" my processIndex to have the AU start at 8192 the next time instead of 12000. I understand I can't do this-- but I still don't know where to find samples 8192-12000.
AudioUnits will *always* render exactly the number of sample-frames that you ask for.
This AudioUnit has state. It reads ahead on the input side, and internally buffers a substantial number of samples. You don't do anything special to get output samples 8192-12000. You feed a continuous *uninterrupted* audio stream on the input side, and receive a continuous *uninterrupted* stream on the output side. There are no gaps, or re-arranging of the order of different chunks of audio. The only subtlety here is that the behavior is slightly different depending on if you're using the format-converter 'aufc' or offline 'auol' version of the AudioUnit. For any AudioUnit of type 'aufc' there will be an initial bit of silence (zero sample-frames) corresponding to the amount of latency which the AudioUnit reports (roughly 70 milliseconds for AUTimePitch) before the actual valid rendered output appears. You can discard this initial bit of silence. For the offline 'auol' version the latency (initial silence) is absorbed internally, so you will immediately get the expected output sample frames.
Chris Rogers Core Audio Apple Computer
|