Build an Auduino Step Sequencer

Pages
Contributors: Nick Poole
Favorited Favorite 6

Understanding the Framework

The beauty of Auduino is that it's elegantly written. There are no libraries to install, just a single sketch to download and unzip into its own folder. Heck, the whole thing compiles to only about 2KB! Instead of dumping that code out here and sifting through it, I'll try to abbreviate and give you sort of a wireframe view of how it works:

The top of the sketch is mainly used as a space for declaring global variables where the oscillator parameters will be stored. There's also a section that defines hardware dependent functions like PWM_INTERRUPT based on what hardware is detected by the compiler. After that, there are a few frequency mapping tables for the grain repetition frequency, the sketch uses a pentatonic mapping by default, which is nice because it makes it impossible to play a really sour note.

Next, we happen upon a procedure called AudioOn() which sets up the PWM timer. This is another hardware dependent setting.

Finally, we get to the familiar setup() routine, which is refreshingly straight-forward. All that happens here is that we put the PWM output (the audio out pin) in OUTPUT mode. Then the audioOn() procedure gets the PWM timer rolling, and we finish up by setting up our status LED.

The main loop of the sketch reads the analog inputs that are used to control the synth parameters. The controller will basically read and re-read the analog inputs until a preset timer overflows, and then the SIGNAL(PWM_INTERRUPT) procedure will launch. That's where all of the action happens.

SIGNAL is a procedure that runs every time that the timer defined by PWM_INTERRUPT overflows. This ensures that the synthesizer runs at a set frequency, regardless of what's happening in the main loop. We'll use this to our advantage, when we make our modifications later. If you want to understand exactly how this routine creates the wild and wacky sounds you're hearing, then you'll need to poke around the Auduino Wiki; algorithmic synthesis can be a challenging concept.

In short, the sound is comprised of two triangle waves which are calculated based on the analog inputs. There are two analog inputs for each wave: one controls the frequency of the wave, and the other controls the decay.

figure 1

These waves have the same static duration, and the combined waves over the length of that duration comprise what's called a grain.

figure 2

Finally there's an analog input that controls the frequency at which this "grain" is repeated. The result is a mashup of the repetition frequency and the original grain.

figure 3

The Auduino Wiki claims that it sounds a lot like a single oscillator with a pair of resonating bandpass filters, and it does indeed. In fact, you could be forgiven for thinking of the frequency and decay knobs as frequency and resonance ('Q') knobs. However, because the effect is achieved through granular synthesis, some really interesting stuff happens when frequencies approach the extreme limits of the timer.

To accomplish this musical magic, the SIGNAL() procedure performs a handful of fancy bitwise operations, which make the code difficult to understand at first glance but make it very fast. So fast, in fact, that there's plenty of room in between timer overflows for us to add a few features...