 
     deinit {
         AKSettings.audioInputEnabled = false
+    }
+
+    private func setAVSessionSampleRate(sampleRate: Double) {
+        do {
+            try AVAudioSession.sharedInstance().setPreferredSampleRate(sampleRate)
+        } catch {
+            AKLog(error)
+        }
     }
 
     /// Function to start, play, or activate the node, all do the same thing

        AKSettings.audioInputEnabled = true

        #if os(iOS)
        let format = setFormatForDevice()
        AudioKit.engine.attach(avAudioUnitOrNode)
        AudioKit.engine.connect(AudioKit.engine.inputNode, to: self.avAudioNode, format: format!)
        #elseif !os(tvOS)
        AudioKit.engine.inputNode.connect(to: self.avAudioNode)
        #endif

    }

    // Here is where we actually check the device type and make the settings, if needed
    private func getFormatForDevice() -> AVAudioFormat? {
        var channelCount: UInt32 = 2
        #if os(iOS) && !targetEnvironment(simulator)
        channelCount = AudioKit.engine.inputNode.inputFormat(forBus: 0).channelCount
        let desiredFS = AudioKit.deviceSampleRate
        #else
        let desiredFS = AKSettings.sampleRate
        #endif
