我只是想知道是否有人可以向我解释如何录制音频、修改音频(音调?)并在 iPhone 上向用户播放。
我并不是要求有人为我做这件事,只是关于我应该如何去做的一些提示。浏览文档似乎我应该使用 AVAudioSession
、AVAudioRecorder
和 AVAudioPlayer
(AVFoundation.Framework
)录音演奏部分。或者我应该使用CoreAudio.Framework
?然后是关于修改音频的问题。
最佳答案
AVAudioUnitTimePitch应该可以解决问题。
来自 udacity.com 的示例代码 Intro to iOS App Development with Swift :
func playAudioWithVariablePitch(pitch: Float) {
audioEngine.stop()
audioEngine.reset()
let audioPlayerNode = AVAudioPlayerNode()
audioEngine.attachNode(audioPlayerNode)
let changePitchEffect = AVAudioUnitTimePitch()
changePitchEffect.pitch = pitch
audioEngine.attachNode(changePitchEffect)
audioEngine.connect(audioPlayerNode, to:changePitchEffect, format:nil)
audioEngine.connect(changePitchEffect, to:audioEngine.outputNode, format:nil)
audioPlayerNode.scheduleFile(audioFile, atTime:nil, completionHandler: nil)
try! audioEngine.start()
audioPlayerNode.play()
}
关于ios - 在 iOS 上实时录制、修改音高和播放音频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4393415/