Tag: avaudioengineavaudioplayernode

如何用AVAudioEngine取消或删除回声/重复的声音?

我使用AVAudioEngine进行audiostream传输。 但是当我对麦克风说话的时候,它就像回声效果一样重复多次。 我想说话时,听起来只有一次,而不是多次。 我想取消回声或额外的噪音。 我怎样才能做到这一点? 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)") }

在AudioEngine中使用音效

背景 – 在苹果最近的WWDC发布的video列表中,我看到了一个名为“AVAudioEngine in Practice”的video,将音效应用于audio。 https://developer.apple.com/videos/wwdc/2014/ 之后,我用下面的代码成功地改变了audio的音调: //Audio Engine is initialized in viewDidLoad() audioEngine = AVAudioEngine() //The following Action is called on clicking a button @IBAction func chipmunkPlayback(sender: UIButton) { var pitchPlayer = AVAudioPlayerNode() var timePitch = AVAudioUnitTimePitch() timePitch.pitch = 1000 audioEngine.attachNode(pitchPlayer) audioEngine.attachNode(timePitch) audioEngine.connect(pitchPlayer, to: timePitch, format: myAudioFile.processingFormat) audioEngine.connect(timePitch, to: audioEngine.outputNode, format: myAudioFile.processingFormat) pitchPlayer.scheduleFile(myAudioFile, atTime: […]