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 phase (+) wire, protecting it from magnetic fields.

The goal of this first step is to connect the piezo disc to the Teensy through an extension cable (coaxial). There’s a large spool of coaxial cable in the max lab, with a wire cutter, cut a section of about 1 foot and then strip it as such on both ends:

The idea is basically to isolate the ground from the phase.

Then shorten the pre-soldered wire on the piezo and solder it to the coaxial cable as such:

The red wire should go with the center wire on the coax and the black wire on the ground.

Use electrical tape to prevent the 2 wires from touching each others:

On the audio shield, you’ll find two pins next to each others with one saying “MIC” and the other “GND” that can be used to connect the piezo. These pins are directly connected to the built-in preamp of the audio shield.

Solder 2 wires connected to female crimps to these pins (you’ll find more crimps and housings in the corresponding drawer in the Max Lab):

Attach 2 male crimps (use the grey ones in the drawer, not the golden ones) on the other side of the coax cable soldered to the piezo. Male crimps often don’t go all the way in the housing: feel free to use small pliers to pull them. Make sure that you don’t squeeze them too much when you do that and that you don’t bend them.

Finally, connect the piezo to the shield through the connections that you just made.

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() {
  AudioMemory(6);
  audioShield.enable();
  audioShield.inputSelect(AUDIO_INPUT_MIC);
  audioShield.inputLevel(1);
  audioShield.micGain(10); // in dB
  audioShield.volume(0.5);
}

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: https://faust.grame.fr/doc/tutorials/index.html#additional-configuration-for-low-audio-latency

Exercise: Adding Sensor Control to the Previous Instruments

Assignment (Due on Feb. 5, 2020)