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.

Find the coaxial cable spool in the Max Lab:

Cut a section of the cable from the spool using a stripper. We recommend that you cut a 2 feet section but feel free to take more if you think that might be useful:

Strip the outer part of the cable:

Then isolate the ground wire (silver wire) of the cable by wrapping it and then strip the center wire to get something like:

Do the same operation on the other end of the coax cable and then pre-solder all the wires (the 2 copper wires and 2 silver wires on both ends of the coax cable). Do this quickly as the insulation material might melt if you heat it for too long!

Take one the piezos from your kit and cut the 2 pre-soldered wires that came with it. Make sure to leaver the solder points though:

Solder one end of the coax cable to the piezo as shown on this picture:

You wanna be quick when doing this: piezos don’t like to be heated for too long. Just put the wire on top of the solder joint on the Teensy. Heat the area until they merge and then remove the soldering iron immediately.

Now take the 1/4" male audio jack connector from your kit, unscrew it and pre-mount its enclosure on the cable as shown here:

Solder the other end of the cable to the Jack connector:

Re-screw the body of the Jack connector. Your piezo and is now ready to be used!

We now need to prepare the Teensy audio shield to connect the piezo to it. Cut 2 short (about 3") stranded wires. 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 right pin is the ground so the black wire should be soldered to it. The upper pin is the positive signal so the white wire should be used for that one.

Insert the white wire in 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 Feb. 9, 2022)