背景 - 我在 Apple 最近的 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 中如何完成?