Skip to main content

Voice Changer App

About Voice Changer App

In this example we can look at how we can build a voice changer application from Switchboard SDK components.

We need to create an AudioGraph with an effect to change the voice. For a chipmunk or a deep voice effect, you can use Superpowered's PitchShift effect, which is available for you as a node, so you can easily put it in your process chain without having to do any low-level development.

Also lets have an echo effect in the chain to get a sound, like if you were standing inside a large cave.

You can use all the effects in a chain one after an other, enabling the ones you need at the time. Disabled effects acts as a passthrough node (no change between input and output).

To check the list of other effects please visit our Superpowered extension page.

You can hear the result live on your output device if you connect it as shown in the example.

Code Example

import SwitchboardSDK
import SwitchboardSuperpowered

class VoiceChangerExample {
let audioGraph = SBAudioGraph()
let pitchShiftNode = SBPitchShiftNode()
let echoNode = SBEchoNode()
let audioEngine = SBAudioEngine()

init() {
audioGraph.addNode(pitchShiftNode)
audioGraph.connect(audioGraph.inputNode, to: pitchShiftNode)
audioGraph.connect(pitchShiftNode, to: echoNode)
audioGraph.connect(echoNode, to: audioGraph.outputNode)

audioEngine.microphoneEnabled = true;
audioEngine.start(audioGraph)
}

func enableChipmunkVoice() {
disableVoiceChanger()
// Raise voice pitch by an octave
pitchShiftNode.isEnabled = true
pitchShiftNode.pitchShiftCents = 1200
}

func enableDeepVoice() {
disableVoiceChanger()
// Lower voice pitch by an octave
pitchShiftNode.isEnabled = true
pitchShiftNode.pitchShiftCents = -1200
}

func enableCaveEffect() {
disableVoiceChanger()
// Turn on echo node
echoNode.isEnabled = true
}

func disableVoiceChanger() {
// Turn of all effects
pitchShiftNode.isEnabled = false
echoNode.isEnabled = false
}
}