How do I share or save audio after effects such as changing tone or speed?

Basically, I need that after my application has recorded the audio, I write code that changes its height and / or speed. And I am using the Activity View Controller to share audio from the app with other media, But what happens when I chat is that the "Original Recorded" sound is generic, not the sound that had "Effects" to it, like speed or step. So I do what I am going to share (may it be great if you can also tell me how to save and then share) the audio.

Sample 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 changing it. Whenever I share it via UIActivityViewController, the original "audioFile" is shared, how can I share the modified audio?

+3


source to share





All Articles