         didSet {
             do {
                 try updateSessionCategoryAndOptions()
-                output?.connect(to: finalMixer)
-                engine.connect(finalMixer.avAudioNode, to: engine.outputNode)
-
-                } catch {
+
+                // if the assigned output is already a mixer, avoid creating an additional mixer and just use
+                // that input as the finalMixer
+                if let mixerInput = output as? AKMixer {
+                    finalMixer = mixerInput
+                } else {
+                    // otherwise at this point create the finalMixer and add the input to it
+                    let mixer = AKMixer()
+                    output?.connect(to: mixer)
+                    finalMixer = mixer
+                }
+                guard let finalMixer = finalMixer else { return }
+                engine.connect(finalMixer.avAudioNode, to: engine.outputNode, format: AKSettings.audioFormat)
+
+            } catch {
                 AKLog("Could not set output: \(error)")
             }
         }
     }
 
     #if os(macOS)
-    /// Enumerate the list of available devices.
-    @objc public static var devices: [AKDevice]? {
-        EZAudioUtilities.setShouldExitOnCheckResultFail(false)
-        return EZAudioDevice.devices().map { AKDevice(ezAudioDevice: $0 as! EZAudioDevice) }
-    }
+        /// Enumerate the list of available devices.
+        @objc public static var devices: [AKDevice]? {
+            EZAudioUtilities.setShouldExitOnCheckResultFail(false)
+            return EZAudioDevice.devices().map { AKDevice(ezAudioDevice: $0 as! EZAudioDevice) }
+        }
     #endif
 
     /// Enumerate the list of available input devices.


/// Top level AudioKit managing class
@objc open class AudioKit: NSObject {

    #if !os(macOS)
    static let deviceSampleRate = AVAudioSession.sharedInstance().sampleRate
    #else
    static let deviceSampleRate: Double = 44_100
    #endif

    // MARK: - Internal audio engine mechanics

    /// Reference to the AV Audio Engine
    @objc public static internal(set) var engine: AVAudioEngine {
        get {
            _ = AudioKit.deviceSampleRate // read the original sample rate before any reference to AVAudioEngine happens, so value is retained
            return _engine


    /// Disconnect all inputs
    @objc public static func disconnectAllInputs() {
        guard let finalMixer = finalMixer else { return }

        engine.disconnectNodeInput(finalMixer.avAudioNode)
    }
}
