AVAudioEngine
's inputNode
property is not an optional. The Audio Engine creates a singleton on demand when inputNode is first accessed. It cannot be nil and because of that the guard does not make sense.
So, just remove the guard and use audioEngine.inputNode
as it is. It cannot be nil
.
You still have to make sure that the inputNode
is connected to something before using it:
Check the input format of input node (specifically, the hardware
format) for a non-zero sample rate and channel count to see if input
is enabled.
(from Apple's Documentation)
inputNode
is optional even though the documentation says otherwise. – Malonis