Monday, March 20, 2017

Teensy 3.6 Basics: Audio Library Audio Effects

Overview
The Teensy 3.x is able to use an extensive Audio library. This includes using an analog input as an audio ADC, an analog output as an audio DAC, and then having a set of effects in between. In essence, this transforms the Teensy into an audio effect unit.

The infrastructure of using the effects of the Audio library as part of Arduino code can be created, edited and viewed visually using the Audio System Design Tool.

Effects such as chorus, flange, delay, filtering and bitcrushing can be interconnected visually as a system using mixers as a way of combining signals.



Hardware Setup
The audio signal can be captured by the Teensy using the A2 input, as labelled here. The audio is then processed by the effects as coded by the Arduino sketch (in combination with the Audio System Design Tool). The resulting output is sent via DAC0. The ADC and DAC resolutions are 12-bit, although all internal calculations are 16-bit 44.1KHz.

The tip of an audio plug is connected to A2, with the sleeve going to ground. This is the input signal, and can be connected to the output of an electric guitar, a computer, a phone, a synth or a drum machine etc.

The tip of another audio plug is connected to DAC0, with the sleeve going to ground. This audio plug is the output signal, and should be connected to a mixer, sound card or powered speakers.





In this photo, the green alligator lead is connected to the tip of the audio input source. The white alligator lead is connected to the sleeve of the audio input source. The yellow alligator lead is connected to the tip of the audio output destination. The blue alligator lead is connected to the sleeve of the audio output destination. A mono 6.5mm jack (or suitable size) is sufficient for making audio connections.




Software Setup
The effects patch can be visually created using the Audio System Design Tool. In general, the output of the ADC is connected to the input of one or more audio effects, which may also, in turn, be connected to other audio effects or mixer objects.







Example 1 - Reverb
In this example, a one-second reverb is applied to an audio input signal.




Download here: http://milkcrate.com.au/_other/downloads/arduino/teensy_3_6_basics/Audio_Library_Effects_Example_1/







Example 2 - Reverb that Can Be Turned On and Off with a Button
In this example, a one-second reverb is applied to an audio input signal. A pushbutton is added to the hardware setup, attached to pin 32 and using the bounce2 library. A mixer object in the Teensy Audio library controls whether or not the signal is dry (without reverb) or wet (with reverb).





Download here: http://milkcrate.com.au/_other/downloads/arduino/teensy_3_6_basics/Audio_Library_Effects_Example_2/







Example 3 - Cycling Through Different Effects
In this example, the dry signal is routed through three effects. The pushbutton selects the next effect when pressed.



Download here: http://milkcrate.com.au/_other/downloads/arduino/teensy_3_6_basics/Audio_Library_Effects_Example_3/








Example 4 - Using Two Buttons to Sweep and Select Filter Frequency
A second pushbutton is added to the hardware setup. The audio source is fed through a filter, which is then fed to the output. If the left button is pressed and held down, the filter frequency quickly decreases. If the right button is pressed and held down, the filter frequency quickly increases.




Download here: http://milkcrate.com.au/_other/downloads/arduino/teensy_3_6_basics/Audio_Library_Effects_Example_4/








Summary
The Audio library can be used as an effects processor for an analog audio signal. Many features can be customised, chained together and controlled in various ways.

0 comments: