Recently I wanted to add some drums to my systems, specifically taking advantage of the gate outputs of the Quad Comparator to sequence some beats. I had a Teensy 3.6 and knew there was some example code that uses it to play drum samples triggered by a push button. The beauty of modular is that we can replace a button push or knob turn with control voltage, and doing so with the Teensy turned out to be pretty straightforward.
The official Teensy audio examples use tactile buttons to trigger events, and in the “sample player” example it sets the Teensy inputs to a “high” (in this case 3.3V) voltage level using an internal pull up resistor, and when the button is pressed that voltage goes “low” (GND or 0V). I’ve included an image of the main loop below where you can see “fallingEdge” being used to determine when a sample should be played. In the case of the “button0.fallingEdge()” that I highlighted, that means when the Teensy sees button0’s pin go from high to low “button0.fallingEdge()” will be TRUE and it will play “AudioSampleSnare”.
In a modular system we can use triggers or gates to create the same edge that would result from a button press. To do this I used an NPN transistor, which is a component that can be used like a voltage controlled switch. This will allow us to keep the signal to the Teensy at a value that is safe for it, and require no change to the code, since we can easily convert the rising edge of a gate to the falling edge expected by the code.
To swap the buttons out (and make for as little coding as possible) we want a circuit that pulls inputs to ground when gate is active. We can set an NPN transistor up so that 3.3V is at the collector and GND is at the emitter, so when the transistor is in saturation mode (acting like a short circuit) the Teensy pin will be pulled from 3.3V to GND (0V) making a “fallingEdge” that our code will recognize and do something with (trigger drum sound). Schematic for one gate to Teensy conversion is shown below.
What I was reminded of through internet searching/double-checking/self-doubting (ultimately from this ModWiggler thread) is that in addition to a simple transistor switch circuit I should also be careful about reverse voltage between the base and emitter of the transistor. This can destroy a transistor and a simple safety measure is to place a diode between the emitter and base (as seen in image above).
Now there are some way fancier ways to do this, but I was (and often am) looking for a quick way to get an idea up and running, and it doesn’t get much more straightforward than this. A more detailed explanation with modular example is in the works, but for now there’s this IG video and this TikTok. Feel free to comment any questions or ideas, but please be kind.