Basically, what i need here is that, after my app has recorded an audio, I have written code that alters its pitch and/or rate, And I use Activity View Controller, to share the audio from the app to other medias. But, what happens, when I share it is that, the "ORIGINAL RECORDED" audio is shared, instead of the audio that had "EFFECTS" to it like rate or pitch. So, I do i go about sharing (itd be awesome, if you could also tell me how to save then share) the audio.
EXAMPLE OF MY CODE:
//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()
}
PLEASE TELL ME HOW I CAN SAVE AND/OR SHARE THE AUDIO AFTER IT HAS BEEN ALTERED??
Whenever, i share it through UIActivityViewController, the original "audioFile" is shared, how do i share the altered audio?