0

I'm using the below code to input voice from iPhone and playing on speaker simultaneously. But I'm getting a lot of noise feedback sound. How can that be fixed?

import AVFoundation
    // Setup engine and node instances
    var engine = AVAudioEngine()
    var delay = AVAudioUnitDelay()
    var reverb = AVAudioUnitReverb()
    var mixer = engine.mainMixerNode
    var input = engine.inputNode
    var output = engine.outputNode
    var format = input.inputFormatForBus(0)
    var error:NSError?
    // Attach FX nodes to engine
    engine.attachNode(delay)
    engine.attachNode(reverb)
    // Connect nodes
    engine.connect(input, to: delay, format: format)
    engine.connect(delay, to: reverb, format: format)
    engine.connect(reverb, to: output, format: format)
    // Start engine
    engine.startAndReturnError(&error)
MBajaj
  • 67
  • 6
  • What do you call `noise feedback` exactly? A loop feedback (Larsen)? Something else? – Eric Aya Oct 04 '16 at 09:25
  • Yes, a loop feedback. – MBajaj Oct 05 '16 at 10:26
  • It means that the audio coming out of the speaker is caught by the mic, making a classic loop feedback. Unfortunately the solution is not with code - it's a matter of not setting the output level too high, so that it's not caught by the mic. Or to ask the user to use headphones. – Eric Aya Oct 05 '16 at 12:04
  • I thought so, but one of the app on the app store has achieved this... – MBajaj Oct 15 '16 at 05:01

0 Answers0