Skip to content

Add a sample rate converter module? #40

Open

Description

@jackpal

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

Activity

  1. jackpal commented on Sep 29, 2016

    @jackpal
    ContributorAuthor

    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.

  2. jackpal commented on Oct 14, 2016

    @jackpal
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions