基本上,我需要的是,在我的应用程序录制了音频之后,我编写了改变其音高和/或速率的代码,并使用Activity View Controller,将应用程序中的音频共享到其他媒体。但是,当我分享的时候会发生这样的事情,即“原始录制的”音频是共享的,而不是像速率或音调那样对其产生“效果”的音频。所以,我去做分享(如果你还可以告诉我如何保存然后分享的话,那就太棒了)。
示例代码:
//For fast rate playback
@IBAction func fasterAudio(sender: UIButton) {
audioEngine.reset()
audioPlayer.currentTime = 0
audioPlayer.rate = 1.75
audioPlayer.play()
}
//For higher Pitch
@IBAction func highPitchAudio(sender: UIButton) {
audioPlayer.stop()
audioEngine.stop()
audioEngine.reset()
audioPlayer.currentTime = 0
var audioPlayerNode = AVAudioPlayerNode()
audioEngine.attachNode(audioPlayerNode)
var changePitchEffect = AVAudioUnitTimePitch()
changePitchEffect.pitch = 1000
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)
audioEngine.startAndReturnError(nil)
audioPlayerNode.play()
}
请告诉我如何在更改后保存和/或共享音频。 无论何时,我通过UIActivityViewController共享它,原始的“audioFile”是共享的,我如何分享改变的音频?