Open jackpal opened 7 years ago
I tried it, and it seems to work. I overrode |rendererDidChangeSampleRate| to set the input and output sample rates separately. The semantics are a little awkward: I set the subrenderer sample rate and numberOfChannels before initializing the module.
I would be happy to send a pull request, if you wish. But it's so short that I bet you could write a better version directly.
Or maybe porting AEFloatConverter from TAAE1 would be a better approach?
Would it be possible to add a AESampleRateConverterModule, for sample rate conversion?
My use case is a streaming music player for iOS. There is no AudioUnit for streaming music, so I currently use the AudioStreamFile APIs to produce PCM audio at the output sample rate.
On some iOS devices the output sample rate changes when the headphone is plugged/unplugged. In that situation, I'd like to avoid having to restart the streaming to pick up the new sample rate. Instead, I'd like to use an kAudioUnitSubType_AUConverter to convert the PCM data from its "native" sample rate to the current output sample rate.
I'm going to try implementing it myself, by subclassing AEAudioUnitModule. I'm guessing I'll have to do something special with subrenderer.sampleRate, to make it stay constant when renderer.sampleRate changes.
(I apologize if I'm missing something obvious, and TAAE2 already handles this case some other way.)