[英]Record, modify pitch and play back audio in real time on iOS
我只是想知道是否有人可以向我解釋如何錄制音頻,修改音頻(音高?)並在iPhone上播放給用戶。
我不是要求有人為我做這件事,只是提示我應該怎么做。 通過文檔查看我似乎應該使用AVAudioSession
, AVAudioRecorder
和AVAudioPlayer
( AVFoundation.Framework
)來錄制播放部分。 或者我應該使用CoreAudio.Framework
? 然后是關於修改音頻的問題。
AVAudioUnitTimePitch應該做的伎倆。
來自udacity.com的示例代碼使用Swift進行iOS應用程序開發的簡介 :
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()
}
OpenAL是一個庫,支持您正在搜索的內容。 它在iPhone上很受歡迎,所以也許你應該看看這個。 即只需一個命令即可輕松更改樣本的音高:
alSourcef(source, AL_PITCH, pitch);
但是我不確定,如果音調改變也可以使用AVFoundation或CoreAudio類 - 從不使用它們。
這可能有所幫助。 DIRAC-mobile ,一個用於復音音頻信號的實時速度和音調操作的庫。 它們還有示例代碼,您可以在下載庫后查看它們。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.