背景-从最近在Apple的WWDC上发布的将声音效果应用于音频的视频列表中,我看到了名为“AVAudioEngine in Practice”的视频。
https://developer.apple.com/videos/wwdc/2014/
之后,我可以使用以下代码成功更改音频的音调:
//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: nil, completionHandler: nil)
audioEngine.startAndReturnError(&er)
pitchPlayer.play()
}
据我了解,我使用AudioEngine将AudioPlayerNode附加到AudioEffect,然后将其附加到Output。
我现在很好奇要在音频中添加多种声音效果。例如,音高变化和混响。如何为音频添加多种声音效果?
另外,在viewDidLoad中连接和连接节点是否有意义,而不是在IBAction中如何完成?
最佳答案
只需连接它们即可。
engine.connect(playerNode, to: reverbNode, format: format)
engine.connect(reverbNode, to: distortionNode, format: format)
engine.connect(distortionNode, to: delayNode, format: format)
engine.connect(delayNode, to: mixer, format: format)
关于ios - 在AudioEngine中使用声音效果,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25333140/