Hello. We are trying to get audio volume from microphone.
We have 2 questions.
1. Can anyone tell me about AVAudioEngine.InputNode.volume?
AVAudioEngine.InputNode.volume
Return 0
in the silence, Return float type value within 1.0
depending on the
volume are expected work, but it looks 1.0
(default value) is returned at any time.
Which case does it return 0.5
or 0
?
Sample code is below. Microphone works correctly.
// instance member
private var engine: AVAudioEngine!
private var node: AVAudioInputNode!
// start method
self.engine = .init()
self.node = engine.inputNode
engine.prepare()
try! engine.start()
// volume getter
print(\(self.node.volume))
2. What is the best practice to get audio volume from microphone?
Requirements are:
- Without
AVAudioRecorder
. We use it for streaming audio. - it should withstand high frequency access.
Testing info
- device: iPhone XR
- OS version: iOS 18
Best Regards.