减少AVAudioEngine中的背景噪音

时间:2016-10-03 16:39:55

标签: ios swift avaudiosession avaudioengine

我使用以下代码从iPhone输入语音并同时在扬声器上播放。但是我收到了很多噪音反馈。怎么能修好?

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)

0 个答案:

没有答案