-
Notifications
You must be signed in to change notification settings - Fork 6
The Teensy Audio Library
The Bleep Base uses the Teensy 4.0 and the Teensy audio adapter board, allowing for high quality i/o. Here's how we can start coding for it.
The design tool website allows us to easily set the signal flow of the device we want to code.
Two things are always needed when making a new design for the adapter board.
The sgtl5000 control object, located near the bottom in the menu on the left. This is the type of codec chip on this specific adapter board.
The i2s output located in the output section. i2s is the digital communication protocol the chip uses.
The first step in adding these objects to our code is to just drag them from the left menu to anywhere in the middle.
We’ll need something to make sound so for this example we’ll use two "waveform" oscillators from the synth section and mixer from the mixer section.

Next we’ll need to connect these objects.
Inputs are on the left, outputs on the right.
A single output can go to multiple inputs but to get multiple outputs to go to a single input you need a mixer.
Click on the dots on the right or left of an object to draw a patch cable.
The sgtl5000 control object just hangs out and isn’t connected to anything.

Here we have two oscillators that get mixed together then go to both of the outputs of the adapter board.
Now to export the block of code we’ll need. It is just to set up the devices and their connections. We’ll need to tell them what to do.
Press the red export button at the top and copy the pre selected text. It will look like this:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioSynthWavetable wavetable1; //xy=190,227
AudioSynthWavetable wavetable2; //xy=201,278
AudioMixer4 mixer1; //xy=383,245
AudioOutputI2S i2s1; //xy=591,244
AudioConnection patchCord1(wavetable1, 0, mixer1, 0);
AudioConnection patchCord2(wavetable2, 0, mixer1, 1);
AudioConnection patchCord3(mixer1, 0, i2s1, 0);
AudioConnection patchCord4(mixer1, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=484,355
// GUItool: end automatically generated code
Next we can use the list of function in the tool to control the different audio objects. We'll do this in the next class.