我正在使用AVAudioEngine进行音频流传输。但是,当我在麦克风中说出任何单词时,它会重复多次,就像回声效果一样。我想说话,听起来只有一次,而不是多次。我想取消回声或额外的噪音。
我怎样才能做到这一点?
var peerAudioEngine: AVAudioEngine = AVAudioEngine()
var peerAudioPlayer: AVAudioPlayerNode = AVAudioPlayerNode()
var peerInput: AVAudioInputNode?
var peerInputFormat: AVAudioFormat?
func setUpAVPlayer() {
self.peerInput = self.peerAudioEngine.inputNode
self.peerAudioEngine.attach(self.peerAudioPlayer)
self.peerInputFormat = AVAudioFormat.init(commonFormat: .pcmFormatFloat32, sampleRate: 44100, channels: 1, interleaved: false)
self.peerAudioEngine.connect(self.peerAudioPlayer, to: self.peerAudioEngine.mainMixerNode, format: self.peerInputFormat)
print("\(#file) > \(#function) > peerInputFormat = \(self.peerInputFormat.debugDescription)")
}
答案 0 :(得分:0)
我认为您应该能够通过此代码解决您的问题
var reverbNode = AVAudioUnitReverb()
reverbNode.loadFactoryPreset( AVAudioUnitReverbPreset.Cathedral)
reverbNode.wetDryMix = 60
// Attach the audio effect node corresponding to the user selected effect
peerAudioEngine.attachNode(reverbNode)
另外,您可能需要考虑其他方法,您可以在讲话后将麦克风静音,并且当peerAudioEngine
没有接收到任何输入音频时,您必须手动检测。
这将彻底消除你演讲中的回声。
有关详细信息,您可以访问 http://asciiwwdc.com/2014/sessions/502