背景 - 我看了苹果最近WWDC发布的视频列表中标题为“AVAudioEngine实践”的视频,以将音效应用于音频。
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连接,并将其附加到输出。
现在,我想尝试给音频添加多个声音效果。例如,改变音高和混响。如何添加多个声音效果到音频中?
此外,将节点附加和连接到viewDidLoad而不是像我在这里的IBAction中完成,这样做有意义吗?