Vox Imperium: Stormtrooper Voice Changer

Contributors: Shawn Hymel
Favorited Favorite 9

Audio System Design

One of the coolest tools for developing on the Teensy is the PJRC Audio System Design Tool. With it, you can drag and drop blocks that correspond to various components on the Teensy, like the ADC and DAC, in addition to useful functions like filters. After connecting them with "patch cords," you can export the whole thing as Arduino code. Pretty sweet.

Feel free to try it out and replicate the block diagram.

Note: You don't actually have to recreate the block diagram; the code in The Code section already has the necessary audio pieces built in.

Vox Imperium Audio System Design Tool

Doing a basic microphone-to-speaker pass through requires simply connecting the ADC to the DAC. To add features, we'll need to put blocks in between those two.

Stormtrooper voices are marked by a nasal sound that can easily be accomplished by turning the treble way up and turning the bass way down. To accomplish this in the Design Tool, we'll use a state variable filter with a corner frequency set to 2000 Hz. Frequencies below that are considered "bass" (for a voice), and frequencies above that are "treble." By separating the low and high frequencies, we can put them back into a mixer and play with the individual gain. In the code, we'll set the treble gain to 0.25 (so as not to blow out the amplifier) and bass to 0.01 (we want it pretty much gone). You can play with any of the GAIN parameters in the code to adjust the volume and treble/bass mix.

You'll also notice that we added a biquad filter right after the ADC. We ultimately want to use this as a low-pass filter to reduce feedback we might get between the microphone and speakers. However, if we enable it in the code, it reduces the quality of the sound, as we effectively filter out most of the voice frequencies we want. Feel free to play with the FEEDBACK_SUPPRESSION and LOWPASS_CUTOFF parameters in the code to try setting the low-pass filter to an acceptable frequency.

The peak is an analysis block that gives us a measure of the amplitude of the audio signal. We use this to determine when someone is talking into the microphone. Play with the SQUELCH_CUTOFF parameter to adjust the volume where the Teensy begins playing sound through the speakers.

playFlashRaw allows us to play a raw audio file that has been loaded into the Prop Shield's serial flash memory. We'll upload the "click" and "static burst" sounds and play them whenever a user starts or finishes talking. Change the BEGIN_CLICK parameter to choose whether to play the click sound at the start, and change END_SOUND to choose whether to play a randomly chosen click or static burst at the end of talking.

Click the export button to get the necessary Arduino code. You can just copy it into a sketch!

If you want to try the other blocks, feel free to drag them in and connect some patch cables. To really get some distorted sound, I recommend the Bitcrusher (details for each audio block can be found on the righthand side of the Audio System Design Tool).