Skip to content

macOS: working around AVAudioEngine device selection limitations #2130

@wtholliday

Description

@wtholliday

AudioKit is built on AVAudioEngine, which is limited to a single audio device for both input and output. The system (or possibly AVAudioEngine, I'm not sure) creates a hidden Aggregate Audio device for the default system input and output, allowing the user to select whatever devices they want in System Preferences while still being compatible with AVAudioEngine.

On macOS, the current implementation of the AudioKit singleton (AKManager on the V5 branch) changes the input device by changing the device selected in System Preferences. If a user expects to change the input device within an app, they may be surprised to see their default device changed.

Further confusing things, setting the output device via AudioKit will change AVAudioEngine's device for both input and output. This will fail in many cases since AVAudioEngine only works with devices that have both input and output channels.

I believe the best possible behavior is for AudioKit to publish single list of devices for both input and output. If the user doesn't see the device they want, they can always create an aggregate device in Audio MIDI Setup. Ideally, I'd like AudioKit to support separate input and output devices, but AVAudioEngine doesn't support it.

It seems fairly clear that AVAudioEngine wasn't designed for us to reach around it down to CoreAudio and change the audio devices. Consider putting in a feature request for device selection in AVAudioEngine if you would like better support.

I'm happy to start working on this change, probably within the V5 develop branch, but I'd like to know if anyone has thoughts on this first, or if I've got any of this wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions