Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a sample rate converter module? #40

Open
jackpal opened this issue Sep 28, 2016 · 2 comments
Open

Add a sample rate converter module? #40

jackpal opened this issue Sep 28, 2016 · 2 comments

Comments

@jackpal
Copy link
Contributor

jackpal commented Sep 28, 2016

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.)

@jackpal
Copy link
Contributor Author

jackpal commented Sep 29, 2016

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.

@jackpal
Copy link
Contributor Author

jackpal commented Oct 14, 2016

Or maybe porting AEFloatConverter from TAAE1 would be a better approach?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant