Using sound effects with AudioEngine Using sound effects with AudioEngine ios ios

Using sound effects with AudioEngine


Just connect them.

engine.connect(playerNode, to: reverbNode, format: format)engine.connect(reverbNode, to: distortionNode, format: format)engine.connect(distortionNode, to: delayNode, format: format)engine.connect(delayNode, to: mixer, format: format)


Background - I saw a video titled "Putting it all together - Intro to iOS App Development with Swift" from the following list of videos published at Udacity to apply sound effects to an audio.

https://youtu.be/XiQfjaYJjuQ

After that, I was successfully able to change the pitch of an audio with the following code:

func playAudioWithVariablePith(pitch: Float){        audioPlayer.stop()        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()    }