Lab 4: “Hybrid” Instruments

Download this lab’s code here.

The goal of this lab is to make a musical instrument combining acoustic sound excitations with digital elements. Sounds excitations are fed into a digital resonator (e.g., a waveguide, a comb filter, a reverb, etc.). The parameters of the resonator can be changed to modify the properties of the generated sound.

Connecting a Piezo to Your Teensy

Your lab kit comes with a piezo disc with pre-soldered cables which should just look like this:

Piezos can be used to pick up sound in solids. Just like a microphone, they can also emit sound when an electric signal is sent to them. When used to pick up sound, they deliver a very “weak” electric signal that can be easily contaminated by magnetic fields. Hence, “shielded” cables should be used with them to prevent noise in the produced signal. Coaxial cables are ideal for this type of application because the ground (-) wire is wrapped around the power (+) wire, protecting it from magnetic fields. In many cases, an aluminium foil wrapped around the ground wire completes the protection.

Your kit comes with a 1/4in male to male shielded audio jack cable. You will use it to connect a piezo to the Teensy. For that, you should first cut it in half using your wire cutter. After this, you should have 2 cables with a jack plug on one end and nothing on the other end. Take one of the 2 cables and strip it on the empty end (information on how to strip a wire is provided in lab 3):

Separate the ground wire from the positive pin (center cable) as well as from the aluminum foil:

Cut the aluminum foil and strip the center wire. Bend the center wire to make a “hook.” Do the same with the red piezo wire and hook them together:

Solder the center pin of the coaxial cable to the red wire of the piezo:

Then wrap your solder joint with electrical tape to insolate it:

Solder the black wire of the piezo to the ground wire of the coax cable using the same technique as before:

Wrap the intersection between the 2 wires with electrical tape:

Your piezo is now ready to be connected to your Teensy:

We now need to prepare the Teensy audio shield to connect the piezo to it. Cut 2 short (about 3") stranded wires (one white and one black). The shorter, the better. These wires will carry the piezo signal to the Teensy audio shield and since this section wont be shielded, it’s better to make it as short as possible:

Solder these 2 wires to the center and left pins of one of the female 1/4" jack plug of your kit as shown on the picture here:

The center pin is the ground so the black wire should be soldered to it. The left pin is the positive signal so the white wire should be used for that one.

Insert the white wire is the “MIC” pin of the audio shield and the black wire in the GND pin next to it:

Solder these 2 pins to the audio shield:

and cut the extra wire:

Finally, plug your piezo to the Teensy:

You’re now ready to make some sound with this!

Getting an Audio Input Into Faust

process = _;
process = _ <: _,_;
mult2(x) = x*2;
process = mult2;

or even:

mult(y,x) = x*y;
process = mult(2);

Running Your Piezo-Controlled Models on the Teensy

#include <Audio.h>
#include "FaustEffect.h"

FaustEffect faustEffect;
AudioInputI2S in;
AudioOutputI2S out;
AudioControlSGTL5000 audioShield;
AudioConnection patchCord0(in,0,faustEffect,0);
AudioConnection patchCord2(faustEffect,0,out,0);
AudioConnection patchCord3(faustEffect,0,out,1);

void setup() {
  audioShield.micGain(10); // in dB

void loop() {

Note About Audio Latency

Using the web browser as our main prototyping platform has some drawbacks. One of them is audio latency. Indeed, you might have noticed that it takes some time to process a sound and then play it back.

A more efficient solution is of course to use your Teensy which has a much lower latency. Keep in mind that latency can be further reduced on the Teensy (in fact, significantly more than on a computer) by following these instructions:

Exercise: Adding Sensor Control to the Previous Instruments

Assignment (Due on May. 5, 2021)