You are on page 1of 7

MOZZI : INTERACTIVE SOUND SYNTHESIS ON THE

OPEN SOURCE ARDUINO MICROPROCESSOR

Tim Barrass
Independent Artist
Melbourne

ABSTRACT 2. BACKGROUND
Mozzi is an open source sound synthesis library for the The original Arduino was based on an embedded 8 bit
Arduino microprocessor. Mozzi can be used to generate microprocessor that can only do integer operations at
algorithmic music for an installation, wearable sounds for rates of up to 16 MHz. This capability is very limited
a performance, or interactive sonifications of sensors, on compared to computer music systems with floating point
a small, modular and cheap Arduino, without the need for operations running at hundreds or thousands of times this
additional shields, message passing or external speed. However, the uptake of the open source Arduino
synthesiser hardware. This opens the way to increased microprocessor by artists and designers has highlighted
creative uses of the Arduino and other compatible the need for sound as part of interactive digital media
platforms. This paper describes software architecture that installations and performances. The recognition of this
enables the synthesis of sounds from sensors in realtime shortcoming has led to a number of efforts to develop
on such a limited microprocessor, the programming API, interactive synthesis of sounds on the Arduino. However
and a variety of artistic and scientific applications that the limitations of the platform have lead some people to
have been created by the Mozzi community. express the feeling that realtime interactive synthesis on
the Arduino was not technically possible[1].
Nevertheless, Joe Marshall's Octosynth[2] which was able
1. INTRODUCTION to play sixteen oscillators at once provided evidence of
Sound art installations and performances typically what could be done with clever programming and a good
involve a combination of laptops, MIDI synths, software understanding of the microprocessor architecture. Martin
packages and sensor systems connected by cables, Nawrath demonstrated the capability to do digital signal Figure 1. Mozzi Architecture
wireless and MIDI or OSC protocols. These systems are processing (DSP) in realtime to create delays and
technically complex with many points of potential failure, buffering[3]. Bruce Land demonstrated DSP through
involve lots of expensive equipment, are not very mobile fixed point arithmetic using integer operations for filters Mozzi developed out of research into mobile More than 30 example sketches demonstrating basic
or robust, and have large power requirements. The open and synthesis[4]. These examples and code were sonification[6] when it became apparent that a naive use.
source Arduino microprocessor has provided a platform illustrative but not designed for re-use. A previous attempt approach to programming audio on Arduino would not Comprehensive API documentation.
for artists and designers to create interactive installations by Sofian Audry to create a general purpose synthesis provide satisfactory realtime performance. Many Mozzi is open source software and easy to extend or
and mobile interfaces that are cheap, robust and can be library called Glade[5] has critical performance optimisation problems existed which had to be teased out adapt for specific applications.
programmed in a java based API specifically targeted to bottlenecks due to overuse of floating point maths, virtual one by one. This project is novel in that it has found
interactive sensor based systems. However, the Arduino functions and other issues and is no longer maintained. solutions to the problems of affordable and easy
API lacks any audio capability beyond the tone() embedded audio synthesis and has broken out of the 4. ARCHITECTURE
command which produces a square wave beeping sound sample-playback, single wave beeping paradigm widely
3. WHAT IS MOZZI? 4.1. User space
with no dynamics, and blocks the input from sensors and accepted as embedded audio to date. This opens the way
other processing while it is playing. Mozzi is an open source software library which enables to increased creative uses of the Arduino and other Mozzi inherits the concepts of separate audio and control
This paper begins by locating Mozzi in relation to the Arduino microprocessor to generate complex and compatible platforms. rate processes directly from Csound[7] and Pure Data[8].
other software approaches to audio for the Arduino. It interesting sounds using familiar synthesis units including The interface between Mozzi and the Arduino
then highlights the main features of Mozzi which make it oscillators, samples, delays, filters and envelopes. Mozzi Mozzi has the following features: environment consists of four main functions. These are
a viable synthesis toolkit of a kind which has not been is modular and can be used to construct many different 16384 Hz audio sample rate with almost-9-bit startMozzi(), updateAudio(), updateControl() and
available before. Then a broad outline of how Mozzi sounds and instruments. The library is designed to be STANDARD and 14 bit HIFI output modes. audioHook(), visible in the User space section of Figure
works is given in terms of its general framework. The flexible and easy to use, while also aiming to use the Variable control rate from 64 Hz upwards. 1. All four are required for a Mozzi sketch to compile.
outline is extended with an overview of Mozzi's processor efficiently, which is one of the hurdles Familiar audio and control units including oscillators,
programming interface. Then two simple programming preventing this kind of project from succeeding until now. samples, filters, envelopes, delays and interpolation. startMozzi(control_rate) goes in Arduino's setup(). It
examples are described in detail to illustrate basic usage To give an idea of Mozzi's ability, one of the example Modules providing fast asynchronous analog to digital starts the control and audio output timers, given the
of the library. This is followed by a section which sketches which comes with the library demonstrates conversion, fixed point arithmetic and other cpu- requested control rate in Hz as a parameter.
presents existing applications of Mozzi in art, music and fourteen audio oscillators playing simultaneously while efficient utilities to help keep audio running smoothly.
education. Finally, options are considered for the future also receiving realtime control data from light and updateControl() is where any analog input sensing code
Readymade wave tables and scripts to convert sound
development, utilisation and community support for the temperature sensors without blocking. should be placed and relatively slow changes such as
files or generate custom tables for Mozzi.
open source Mozzi synthesiser.

24 | 2013 ICMC idea | LONG PAPERS 25 | 2013 ICMC idea | LONG PAPERS
MOZZI : INTERACTIVE SOUND SYNTHESIS ON THE
OPEN SOURCE ARDUINO MICROPROCESSOR

Tim Barrass
Independent Artist
Melbourne

ABSTRACT 2. BACKGROUND
Mozzi is an open source sound synthesis library for the The original Arduino was based on an embedded 8 bit
Arduino microprocessor. Mozzi can be used to generate microprocessor that can only do integer operations at
algorithmic music for an installation, wearable sounds for rates of up to 16 MHz. This capability is very limited
a performance, or interactive sonifications of sensors, on compared to computer music systems with floating point
a small, modular and cheap Arduino, without the need for operations running at hundreds or thousands of times this
additional shields, message passing or external speed. However, the uptake of the open source Arduino
synthesiser hardware. This opens the way to increased microprocessor by artists and designers has highlighted
creative uses of the Arduino and other compatible the need for sound as part of interactive digital media
platforms. This paper describes software architecture that installations and performances. The recognition of this
enables the synthesis of sounds from sensors in realtime shortcoming has led to a number of efforts to develop
on such a limited microprocessor, the programming API, interactive synthesis of sounds on the Arduino. However
and a variety of artistic and scientific applications that the limitations of the platform have lead some people to
have been created by the Mozzi community. express the feeling that realtime interactive synthesis on
the Arduino was not technically possible[1].
Nevertheless, Joe Marshall's Octosynth[2] which was able
1. INTRODUCTION to play sixteen oscillators at once provided evidence of
Sound art installations and performances typically what could be done with clever programming and a good
involve a combination of laptops, MIDI synths, software understanding of the microprocessor architecture. Martin
packages and sensor systems connected by cables, Nawrath demonstrated the capability to do digital signal Figure 1. Mozzi Architecture
wireless and MIDI or OSC protocols. These systems are processing (DSP) in realtime to create delays and
technically complex with many points of potential failure, buffering[3]. Bruce Land demonstrated DSP through
involve lots of expensive equipment, are not very mobile fixed point arithmetic using integer operations for filters Mozzi developed out of research into mobile More than 30 example sketches demonstrating basic
or robust, and have large power requirements. The open and synthesis[4]. These examples and code were sonification[6] when it became apparent that a naive use.
source Arduino microprocessor has provided a platform illustrative but not designed for re-use. A previous attempt approach to programming audio on Arduino would not Comprehensive API documentation.
for artists and designers to create interactive installations by Sofian Audry to create a general purpose synthesis provide satisfactory realtime performance. Many Mozzi is open source software and easy to extend or
and mobile interfaces that are cheap, robust and can be library called Glade[5] has critical performance optimisation problems existed which had to be teased out adapt for specific applications.
programmed in a java based API specifically targeted to bottlenecks due to overuse of floating point maths, virtual one by one. This project is novel in that it has found
interactive sensor based systems. However, the Arduino functions and other issues and is no longer maintained. solutions to the problems of affordable and easy
API lacks any audio capability beyond the tone() embedded audio synthesis and has broken out of the 4. ARCHITECTURE
command which produces a square wave beeping sound sample-playback, single wave beeping paradigm widely
3. WHAT IS MOZZI? 4.1. User space
with no dynamics, and blocks the input from sensors and accepted as embedded audio to date. This opens the way
other processing while it is playing. Mozzi is an open source software library which enables to increased creative uses of the Arduino and other Mozzi inherits the concepts of separate audio and control
This paper begins by locating Mozzi in relation to the Arduino microprocessor to generate complex and compatible platforms. rate processes directly from Csound[7] and Pure Data[8].
other software approaches to audio for the Arduino. It interesting sounds using familiar synthesis units including The interface between Mozzi and the Arduino
then highlights the main features of Mozzi which make it oscillators, samples, delays, filters and envelopes. Mozzi Mozzi has the following features: environment consists of four main functions. These are
a viable synthesis toolkit of a kind which has not been is modular and can be used to construct many different 16384 Hz audio sample rate with almost-9-bit startMozzi(), updateAudio(), updateControl() and
available before. Then a broad outline of how Mozzi sounds and instruments. The library is designed to be STANDARD and 14 bit HIFI output modes. audioHook(), visible in the User space section of Figure
works is given in terms of its general framework. The flexible and easy to use, while also aiming to use the Variable control rate from 64 Hz upwards. 1. All four are required for a Mozzi sketch to compile.
outline is extended with an overview of Mozzi's processor efficiently, which is one of the hurdles Familiar audio and control units including oscillators,
programming interface. Then two simple programming preventing this kind of project from succeeding until now. samples, filters, envelopes, delays and interpolation. startMozzi(control_rate) goes in Arduino's setup(). It
examples are described in detail to illustrate basic usage To give an idea of Mozzi's ability, one of the example Modules providing fast asynchronous analog to digital starts the control and audio output timers, given the
of the library. This is followed by a section which sketches which comes with the library demonstrates conversion, fixed point arithmetic and other cpu- requested control rate in Hz as a parameter.
presents existing applications of Mozzi in art, music and fourteen audio oscillators playing simultaneously while efficient utilities to help keep audio running smoothly.
education. Finally, options are considered for the future also receiving realtime control data from light and updateControl() is where any analog input sensing code
Readymade wave tables and scripts to convert sound
development, utilisation and community support for the temperature sensors without blocking. should be placed and relatively slow changes such as
files or generate custom tables for Mozzi.
open source Mozzi synthesiser.

24 | 2013 ICMC idea | LONG PAPERS 25 | 2013 ICMC idea | LONG PAPERS
LFO's or frequency changes can be performed. An provides an alternative method for scheduling (see Module Description The audio sine tone oscillator is created like this:
example of this is shown in section 5.2. EventDelay() in the API).
Audio data is generated in updateAudio() and placed fixmath fixed point fractional number types and Oscil <2048, AUDIO_RATE> aSin(SIN_DATA);
updateAudio() is where audio synthesis code should be in the output buffer by audioHook(), in Arduino's loop(), conversion routines
placed. This runs on average 16384 times per second, so running as fast as possible. The buffer has 256 cells analog fast and non-blocking functions for The control rate, like the audio rate, must be a literal
code here needs to be lean. There is also The only other which equates to a maximum delay of about 15 reading analog input asynchronously, number and power of two to enable fast internal
strict requirement is that it returns an integer between milliseconds, to give leeway for control operations speeding up or replacing Arduino calculations. It is not necessary to define it as follows,
-244 and 243 inclusive in STANDARD mode or -8192 to without interrupting audio output. The buffer is emptied analogRead() but it helps to keep programs legible and simple to
8191 in HIFI mode. behind the scenes by the regular 16384 Hz audio modify.
interrupt. midi midi note number to frequency
audioHook() goes in Arduino's loop(). It wraps Mozzi employs pulse wave modulation (PWM) for conversions at various resolutions #define CONTROL_RATE 128
updateAudio() and takes care of filling the output buffer, audio output. This allows a single Arduino pin to be random fast pseudo random number generator
hiding the details of this from user space. allocated for output, requiring minimal external functions Now to the program functions. In Arduino's setup()
components. Depending on the application, the output routine goes:
4.2. Under the Hood signal may be adequate as it is. Passive filter designs to core core definitions and functions
reduce aliasing and PWM carrier frequency noise are startMozzi(CONTROL_RATE);
Mozzi uses hardware interrupts on the processor which Table 2. Modules and descriptions
available on the Mozzi wiki[9] if required.
automatically call interrupt service routines (ISR) at This sets up one timer to call updateControl() at the
regular intervals. rate chosen and another timer which works behind the
startMozzi() sets up two interrupts, one for audio 5. PROGRAMMING INTERFACE 6. WRITING A MOZZI SKETCH
scenes to send audio samples to the output pin at the fixed
output at a sample rate of 16384 Hz and a control 6.1. Bare bones example: playing a sine wave rate of 16384 Hz.
interrupt which can be set by the user at 64 Hz or more, in Mozzi has a growing collection of classes for synthesis,
powers of two. modules containing useful functions, commonly used This section explains a minimal Mozzi sketch step by
wave tables, and sampled sound tables. Mozzi includes The oscillator frequency can be set in a range of ways,
In STANDARD mode, the internal timers used by step. The sketch plays a sine wave at a specified
Python scripts to convert raw audio files and templates but in this case it will be with an unsigned integer as
Mozzi on the ATmega processors are the 16 bit Timer 1 frequency. Although there are abundant instances online
which can be used to generate other custom tables. follows:
for audio and 8 bit Timer 0 for control. HIFI mode of Arduino sketches performing this task, this example
additionally employs Timer 2 with Timer 1 for audio. Descriptions of the classes currently available are illustrates the structure and gist of a bare-bones Mozzi
shown in Table 1. Modules are described in Table 2. aSin.setFreq(440u);
Using Timer 0 disables Arduino time functions millis(), sketch. It does not assume much previous experience
micros(), delay() and delayMicroseconds(). This saves Comprehensive documentation of the library is available with Arduino programming.
online[10] and in the Mozzi download[11]. Now Arduino's setup() function looks like this:
processor time which would be spent on the interrupts First include MozziGuts.h. This is always required, as
and the blocking action of the delay() functions. Mozzi are headers for any other Mozzi classes, modules or void setup(){
tables used in the sketch. In this case an oscillator will be startMozzi(CONTROL_RATE);
used, and a wavetable for the oscillator to play: aSin.setFreq(440u);
Class Description Audio rate Control rate
}
Oscillators #include <MozziGuts.h>
Oscil plays a wavetable, cycling yes yes #include <Oscil.h> The next parts of the sketch are updateControl() and
Sample plays a wavetable, with extra controls yes yes #include <tables/sin2048_int8.h> updateAudio(), which are both required. In this example
Phasor generates a high resolution ramp yes yes the frequency has already been set and the oscillator just
The oscillator needs to be instantiated using literal needs to be run in updateAudio(), using the Oscil::next()
Filters numeric values as template parameters (inside the < > method which returns a signed 8 bit value from the
StateVariable 12db resonant lp, hp, bp and notch yes - brackets). This allows the compiler to do some of the oscillator's wavetable. The int return value of
LowPassFilter resonant low pass filter yes - Oscil's internal calculations at compile time instead of updateAudio() must be in the range -244 to 243.
Smooth IIR low pass filter - yes slowing down execution by repeating the same operations
Envelope generators over and over while the program runs. An oscillator is void updateControl(){
ADSR simple ADSR envelope generator - yes declared as follows: // no controls being changed
Ead exponential attack decay envelope yes yes }
Oscil <table_size, update_rate> name(table_data);
Delays int updateAudio(){
AudioDelay delay for comb filter, flange, chorus and slapback yes - The table size must be a power of two, typically at return aSin.next();
AudioDelayFeedback audio delay with feedback yes - least 256 cells and preferably longer for lower aliasing }
EventDelay non-blocking replacement for Arduino's delay() - yes noise.1 This Oscil will be operating as an audio generator.
ReverbTank simple recirculating reverb yes - AUDIO_RATE is internally defined by Mozzi, and provided Finally, audioHook() goes in Arduino's loop().
Synthesis/Distortion here so the Oscil can calculate frequencies in relation to
how often it is updated. The table_data is an array of void loop(){
WavePacket overlapping streams of windowed sine wave grains yes - audioHook();
WaveShaper maps input values through a table to output yes yes byte sized cells contained in the table file included at the
}
top of the sketch.
Interpolation
Line efficient linear interpolator yes yes This is where the sound actually gets synthesised,
1
The Mozzi download contains an example sketch comparing the running as fast as possible to fill the output buffer which
Portamento simple portamento for note-based applications - yes audible results of different table sizes being played over a sweep of
frequencies.
Table 1. The current collection of Mozzi classes, with descriptions and the update rates of each.

26 | 2013 ICMC idea | LONG PAPERS 27 | 2013 ICMC idea | LONG PAPERS
LFO's or frequency changes can be performed. An provides an alternative method for scheduling (see Module Description The audio sine tone oscillator is created like this:
example of this is shown in section 5.2. EventDelay() in the API).
Audio data is generated in updateAudio() and placed fixmath fixed point fractional number types and Oscil <2048, AUDIO_RATE> aSin(SIN_DATA);
updateAudio() is where audio synthesis code should be in the output buffer by audioHook(), in Arduino's loop(), conversion routines
placed. This runs on average 16384 times per second, so running as fast as possible. The buffer has 256 cells analog fast and non-blocking functions for The control rate, like the audio rate, must be a literal
code here needs to be lean. There is also The only other which equates to a maximum delay of about 15 reading analog input asynchronously, number and power of two to enable fast internal
strict requirement is that it returns an integer between milliseconds, to give leeway for control operations speeding up or replacing Arduino calculations. It is not necessary to define it as follows,
-244 and 243 inclusive in STANDARD mode or -8192 to without interrupting audio output. The buffer is emptied analogRead() but it helps to keep programs legible and simple to
8191 in HIFI mode. behind the scenes by the regular 16384 Hz audio modify.
interrupt. midi midi note number to frequency
audioHook() goes in Arduino's loop(). It wraps Mozzi employs pulse wave modulation (PWM) for conversions at various resolutions #define CONTROL_RATE 128
updateAudio() and takes care of filling the output buffer, audio output. This allows a single Arduino pin to be random fast pseudo random number generator
hiding the details of this from user space. allocated for output, requiring minimal external functions Now to the program functions. In Arduino's setup()
components. Depending on the application, the output routine goes:
4.2. Under the Hood signal may be adequate as it is. Passive filter designs to core core definitions and functions
reduce aliasing and PWM carrier frequency noise are startMozzi(CONTROL_RATE);
Mozzi uses hardware interrupts on the processor which Table 2. Modules and descriptions
available on the Mozzi wiki[9] if required.
automatically call interrupt service routines (ISR) at This sets up one timer to call updateControl() at the
regular intervals. rate chosen and another timer which works behind the
startMozzi() sets up two interrupts, one for audio 5. PROGRAMMING INTERFACE 6. WRITING A MOZZI SKETCH
scenes to send audio samples to the output pin at the fixed
output at a sample rate of 16384 Hz and a control 6.1. Bare bones example: playing a sine wave rate of 16384 Hz.
interrupt which can be set by the user at 64 Hz or more, in Mozzi has a growing collection of classes for synthesis,
powers of two. modules containing useful functions, commonly used This section explains a minimal Mozzi sketch step by
wave tables, and sampled sound tables. Mozzi includes The oscillator frequency can be set in a range of ways,
In STANDARD mode, the internal timers used by step. The sketch plays a sine wave at a specified
Python scripts to convert raw audio files and templates but in this case it will be with an unsigned integer as
Mozzi on the ATmega processors are the 16 bit Timer 1 frequency. Although there are abundant instances online
which can be used to generate other custom tables. follows:
for audio and 8 bit Timer 0 for control. HIFI mode of Arduino sketches performing this task, this example
additionally employs Timer 2 with Timer 1 for audio. Descriptions of the classes currently available are illustrates the structure and gist of a bare-bones Mozzi
shown in Table 1. Modules are described in Table 2. aSin.setFreq(440u);
Using Timer 0 disables Arduino time functions millis(), sketch. It does not assume much previous experience
micros(), delay() and delayMicroseconds(). This saves Comprehensive documentation of the library is available with Arduino programming.
online[10] and in the Mozzi download[11]. Now Arduino's setup() function looks like this:
processor time which would be spent on the interrupts First include MozziGuts.h. This is always required, as
and the blocking action of the delay() functions. Mozzi are headers for any other Mozzi classes, modules or void setup(){
tables used in the sketch. In this case an oscillator will be startMozzi(CONTROL_RATE);
used, and a wavetable for the oscillator to play: aSin.setFreq(440u);
Class Description Audio rate Control rate
}
Oscillators #include <MozziGuts.h>
Oscil plays a wavetable, cycling yes yes #include <Oscil.h> The next parts of the sketch are updateControl() and
Sample plays a wavetable, with extra controls yes yes #include <tables/sin2048_int8.h> updateAudio(), which are both required. In this example
Phasor generates a high resolution ramp yes yes the frequency has already been set and the oscillator just
The oscillator needs to be instantiated using literal needs to be run in updateAudio(), using the Oscil::next()
Filters numeric values as template parameters (inside the < > method which returns a signed 8 bit value from the
StateVariable 12db resonant lp, hp, bp and notch yes - brackets). This allows the compiler to do some of the oscillator's wavetable. The int return value of
LowPassFilter resonant low pass filter yes - Oscil's internal calculations at compile time instead of updateAudio() must be in the range -244 to 243.
Smooth IIR low pass filter - yes slowing down execution by repeating the same operations
Envelope generators over and over while the program runs. An oscillator is void updateControl(){
ADSR simple ADSR envelope generator - yes declared as follows: // no controls being changed
Ead exponential attack decay envelope yes yes }
Oscil <table_size, update_rate> name(table_data);
Delays int updateAudio(){
AudioDelay delay for comb filter, flange, chorus and slapback yes - The table size must be a power of two, typically at return aSin.next();
AudioDelayFeedback audio delay with feedback yes - least 256 cells and preferably longer for lower aliasing }
EventDelay non-blocking replacement for Arduino's delay() - yes noise.1 This Oscil will be operating as an audio generator.
ReverbTank simple recirculating reverb yes - AUDIO_RATE is internally defined by Mozzi, and provided Finally, audioHook() goes in Arduino's loop().
Synthesis/Distortion here so the Oscil can calculate frequencies in relation to
how often it is updated. The table_data is an array of void loop(){
WavePacket overlapping streams of windowed sine wave grains yes - audioHook();
WaveShaper maps input values through a table to output yes yes byte sized cells contained in the table file included at the
}
top of the sketch.
Interpolation
Line efficient linear interpolator yes yes This is where the sound actually gets synthesised,
1
The Mozzi download contains an example sketch comparing the running as fast as possible to fill the output buffer which
Portamento simple portamento for note-based applications - yes audible results of different table sizes being played over a sweep of
frequencies.
Table 1. The current collection of Mozzi classes, with descriptions and the update rates of each.

26 | 2013 ICMC idea | LONG PAPERS 27 | 2013 ICMC idea | LONG PAPERS
gets steadily emptied at Mozzi's audio rate. For this to produce an interactive installation where people could 9. REFERENCES
reason, it's best to avoid placing any other code in loop(). void updateControl(){ play chords which represented the different resistances of
It's important to design a sketch with efficiency in float vibrato = depth * kVib.next(); a group of pieces of fruit infested with fruit flies. [1] teckel, "toneAC v1.2 - Twice the volume, higher
mind in terms of what can be processed in updateAudio(), aSin.setFreq(centre_freq+vibrato); According to the project documentation, resistance is quality, higher frequency, etc.", Online posting.
updateControl() and setup(). Keep updateAudio() lean, } sometimes used as a measure of fruit quality[12]. January 31, 2013. Arduino Forum :: Using
put slow changing values in updateControl(), and pre- Teaching interface design at the Queen Mary Arduino :: Audio, Retrieved 7 Feb 2013,
calculate as much as possible in setup(). Control values The modified sketch complete with vibrato is listed in University. One of the vehicles for learning is a musical http://arduino.cc/forum/index.php?
which directly modify audio synthesis can be efficiently Program 2. instrument based on an electric guitar, exploring PHPSESSID=b479b487efab1e2ac9fc7a52d4561
interpolated with a Line() object in updateAudio() if ergonomics with digital and analog inputs to a Mozzi 6cd&topic=142097.45
necessary. #include <MozziGuts.h> synthesiser[13]. [2] Marshall, J. Arduino Octo-Synth, Retrieved 7
The whole sketch is shown in Program 1. #include <Oscil.h> B.O.M.B.-Beat Of Magic Box-, a palm-sized Feb 2013, http://www.cs.nott.ac.uk/~jqm/?p=605
#include <tables/sin2048_int8.h> interactive musical device by Yoshihito Nakanishi,
designed for cooperative performance between novice [3] Nawrath, M. Arduino Realtime Audio
#include <MozziGuts.h> #define CONTROL_RATE 128 participants. The devices communicate wirelessly and Processing, Retrieved 7 Feb 2013,
#include <Oscil.h> Oscil <2048, AUDIO_RATE> aSin(SIN_DATA); http://interface.khm.de/index.php/lab/experiment
s/arduino-realtime-audio-processing
produce related evolving harmonic and rhythmic
#include <tables/sin2048_int8.h> Oscil <2048, CONTROL_RATE> kVib(SIN_DATA); sequences depending on how they are handled[14].
MIDI-based synthesisers using Mozzi as a synthesis [4] Land, B. Fixed Point DSP functions in GCC,
Retrieved 7 Feb 2013,
#define CONTROL_RATE 128 float centre_freq = 440.0; engine. One example is ^ [xor] synth by Vclav
http://people.ece.cornell.edu/land/courses/ece47
Oscil <2048, AUDIO_RATE> aSin(SIN_DATA); float depth = 0.25;
Pelouek, founder of the Standuino hand-made electronic
music project, with six voice polyphony, velocity 60/Math/avrDSP.htm
void setup(){ void setup(){
sensitivity, envelopes, selectable wavetables, modulation
aSin.setFreq(440u); kVib.setFreq(6.5f);
and bit-logic distortions[15]. Others include Arduino [5] Audrey, S. Glade, Retrieved 7 Feb 2013,
startMozzi(CONTROL_RATE); startMozzi(CONTROL_RATE);
Mozzi synthesizer vX.0 by e-licktronic, a mono synth http://code.google.com/p/glade/
} }
with selectable wavetables, LFO and resonant filtering
[6] Barrass, S. and Barrass, T. SweatSonics,
void updateControl(){ void updateControl(){ [16], and the ironically humorous FM-based CheapSynth
Retrieved 7 Feb 2013,
} float vibrato = depth * kVib.next(); constructed and played by Dave Green and Dave Pape in
http://stephenbarrass.wordpress.com/tag/sweatso
aSin.setFreq(centre_freq+vibrato); a band called Fakebit Polytechnic[17].
}
nics
int updateAudio(){
return aSin.next(); My own sound-sculptural object exhibited at PICA
} int updateAudio(){ [7] Vercoe, B. Csound A Manual for the Audio
during ICMC 2013 also uses Mozzi. This is a small solar
return aSin.next(); Processing System and Supporting Programs
powered sound-generating object which responds to
void loop(){ } with Tutorials, Media Lab, M.I.T., 1993
changes in solar energy with 6 voice polyphonic audio
audioHook(); synthesised in real time.
} void loop(){ [8] Puckette, M. S. Pure Data, Proceedings,
audioHook(); International Computer Music Conference, San
Program 1. Playing a sine wave at 440 Hz. } 8. THE FUTURE OF MOZZI Francisco, USA, 1996.

Program 2. Playing a sine wave with vibrato. Mozzi is relatively young yet ripe for a community of [9] Barrass, T. Output circuits, filters, amplifiers,
open source development and practice to emerge around etc., Retrieved 7 Feb 2013,
6.2. Adding a control signal: vibrato
While this example uses floating point numbers, it is it. It's easy to write new classes and to construct https://github.com/sensorium/Mozzi/wiki/Output
Vibrato can be added to the sketch by periodically best to avoid their use for intensive audio code which composite instrument sketches. Feedback from educators -circuits,-filters,-amplifiers,-etc.-%28*-this-has-
changing the frequency of the audio wave with a low needs to run fast, especially in updateAudio(). When the has shown that the library is able to be used by children. content%29
frequency oscillator. The new oscillator can use the same speed of integer maths is required along with fractional There is the potential for porting the library to new
wave table but this time it is instantiated to update at precision, it is better to use fixed point fractional Arduino platforms as they become available. As it is, [10] Barrass, T. Mozzi API, Retrieved 7 Feb 2013,
control rate. The naming convention of using a prefix of arithmetic. The mozzi_fixmath module has number types there is already a long to-do list, including a variety of http://sensorium.github.com/Mozzi/doc/html/ind
k for control and a for audio rate units is a personal and conversion functions which assist in keeping track of half-finished sound generators and instruments, and the ex.html
mnemonic, influenced by Csound. precision through complex calculations. ever-receding lure of creative work beyond the making of
the tool. [11] Barrass, T. Mozzi Sound Synthesis Library for
Oscil <2048, CONTROL_RATE> kVib(SIN_DATA); Mozzi expands the possibilities for sonification and Arduino, Retrieved 7 Feb 2013,
7. APPLICATIONS synthesis in new contexts away from expensive hardware, http://sensorium.github.com/Mozzi/
This time the frequency can be set with a floating cables and power requirements. The low cost and
point value: Mozzi has been been available on Github since June
accessibility of Mozzi synthesis on open source Arduino [12] Freeman, C. Untitled Sound Project Two,
2012. The range of potential applications has yet to be
and compatible microprocessors offers people a way to Retrieved 7 Feb 2013,
kVib.setFreq(6.5f); explored, however some examples which have appeared
create applications and compositions adapted to a wide http://reprage.com/post/28654178439/untitled-
so far include:
range of localised conditions. sound-project-two
Now, using variables for depth and centre frequency, A musical fruit fly experiment for a science fair at The
Edge in the State Library of Queensland. Kinetic and
the vibrato oscillator can modulate the frequency of the [13] McPherson, A. Build Your Own Arduinitar,
Retrieved 10 Jun 2013,
audio oscillator in updateControl(). kVib.next() returns a electronic artists Clinton Freeman, Michael Candy,
signed byte between -128 to 127 from the wave table, so Daniel Flood and Mick Byrne worked with Dr Caroline http://www.eecs.qmul.ac.uk/~andrewm/arduinita
depth has to be set proportionately. Hauxwell from the Queensland University of Technology r.html

28 | 2013 ICMC idea | LONG PAPERS 29 | 2013 ICMC idea | LONG PAPERS
gets steadily emptied at Mozzi's audio rate. For this to produce an interactive installation where people could 9. REFERENCES
reason, it's best to avoid placing any other code in loop(). void updateControl(){ play chords which represented the different resistances of
It's important to design a sketch with efficiency in float vibrato = depth * kVib.next(); a group of pieces of fruit infested with fruit flies. [1] teckel, "toneAC v1.2 - Twice the volume, higher
mind in terms of what can be processed in updateAudio(), aSin.setFreq(centre_freq+vibrato); According to the project documentation, resistance is quality, higher frequency, etc.", Online posting.
updateControl() and setup(). Keep updateAudio() lean, } sometimes used as a measure of fruit quality[12]. January 31, 2013. Arduino Forum :: Using
put slow changing values in updateControl(), and pre- Teaching interface design at the Queen Mary Arduino :: Audio, Retrieved 7 Feb 2013,
calculate as much as possible in setup(). Control values The modified sketch complete with vibrato is listed in University. One of the vehicles for learning is a musical http://arduino.cc/forum/index.php?
which directly modify audio synthesis can be efficiently Program 2. instrument based on an electric guitar, exploring PHPSESSID=b479b487efab1e2ac9fc7a52d4561
interpolated with a Line() object in updateAudio() if ergonomics with digital and analog inputs to a Mozzi 6cd&topic=142097.45
necessary. #include <MozziGuts.h> synthesiser[13]. [2] Marshall, J. Arduino Octo-Synth, Retrieved 7
The whole sketch is shown in Program 1. #include <Oscil.h> B.O.M.B.-Beat Of Magic Box-, a palm-sized Feb 2013, http://www.cs.nott.ac.uk/~jqm/?p=605
#include <tables/sin2048_int8.h> interactive musical device by Yoshihito Nakanishi,
designed for cooperative performance between novice [3] Nawrath, M. Arduino Realtime Audio
#include <MozziGuts.h> #define CONTROL_RATE 128 participants. The devices communicate wirelessly and Processing, Retrieved 7 Feb 2013,
#include <Oscil.h> Oscil <2048, AUDIO_RATE> aSin(SIN_DATA); http://interface.khm.de/index.php/lab/experiment
s/arduino-realtime-audio-processing
produce related evolving harmonic and rhythmic
#include <tables/sin2048_int8.h> Oscil <2048, CONTROL_RATE> kVib(SIN_DATA); sequences depending on how they are handled[14].
MIDI-based synthesisers using Mozzi as a synthesis [4] Land, B. Fixed Point DSP functions in GCC,
Retrieved 7 Feb 2013,
#define CONTROL_RATE 128 float centre_freq = 440.0; engine. One example is ^ [xor] synth by Vclav
http://people.ece.cornell.edu/land/courses/ece47
Oscil <2048, AUDIO_RATE> aSin(SIN_DATA); float depth = 0.25;
Pelouek, founder of the Standuino hand-made electronic
music project, with six voice polyphony, velocity 60/Math/avrDSP.htm
void setup(){ void setup(){
sensitivity, envelopes, selectable wavetables, modulation
aSin.setFreq(440u); kVib.setFreq(6.5f);
and bit-logic distortions[15]. Others include Arduino [5] Audrey, S. Glade, Retrieved 7 Feb 2013,
startMozzi(CONTROL_RATE); startMozzi(CONTROL_RATE);
Mozzi synthesizer vX.0 by e-licktronic, a mono synth http://code.google.com/p/glade/
} }
with selectable wavetables, LFO and resonant filtering
[6] Barrass, S. and Barrass, T. SweatSonics,
void updateControl(){ void updateControl(){ [16], and the ironically humorous FM-based CheapSynth
Retrieved 7 Feb 2013,
} float vibrato = depth * kVib.next(); constructed and played by Dave Green and Dave Pape in
http://stephenbarrass.wordpress.com/tag/sweatso
aSin.setFreq(centre_freq+vibrato); a band called Fakebit Polytechnic[17].
}
nics
int updateAudio(){
return aSin.next(); My own sound-sculptural object exhibited at PICA
} int updateAudio(){ [7] Vercoe, B. Csound A Manual for the Audio
during ICMC 2013 also uses Mozzi. This is a small solar
return aSin.next(); Processing System and Supporting Programs
powered sound-generating object which responds to
void loop(){ } with Tutorials, Media Lab, M.I.T., 1993
changes in solar energy with 6 voice polyphonic audio
audioHook(); synthesised in real time.
} void loop(){ [8] Puckette, M. S. Pure Data, Proceedings,
audioHook(); International Computer Music Conference, San
Program 1. Playing a sine wave at 440 Hz. } 8. THE FUTURE OF MOZZI Francisco, USA, 1996.

Program 2. Playing a sine wave with vibrato. Mozzi is relatively young yet ripe for a community of [9] Barrass, T. Output circuits, filters, amplifiers,
open source development and practice to emerge around etc., Retrieved 7 Feb 2013,
6.2. Adding a control signal: vibrato
While this example uses floating point numbers, it is it. It's easy to write new classes and to construct https://github.com/sensorium/Mozzi/wiki/Output
Vibrato can be added to the sketch by periodically best to avoid their use for intensive audio code which composite instrument sketches. Feedback from educators -circuits,-filters,-amplifiers,-etc.-%28*-this-has-
changing the frequency of the audio wave with a low needs to run fast, especially in updateAudio(). When the has shown that the library is able to be used by children. content%29
frequency oscillator. The new oscillator can use the same speed of integer maths is required along with fractional There is the potential for porting the library to new
wave table but this time it is instantiated to update at precision, it is better to use fixed point fractional Arduino platforms as they become available. As it is, [10] Barrass, T. Mozzi API, Retrieved 7 Feb 2013,
control rate. The naming convention of using a prefix of arithmetic. The mozzi_fixmath module has number types there is already a long to-do list, including a variety of http://sensorium.github.com/Mozzi/doc/html/ind
k for control and a for audio rate units is a personal and conversion functions which assist in keeping track of half-finished sound generators and instruments, and the ex.html
mnemonic, influenced by Csound. precision through complex calculations. ever-receding lure of creative work beyond the making of
the tool. [11] Barrass, T. Mozzi Sound Synthesis Library for
Oscil <2048, CONTROL_RATE> kVib(SIN_DATA); Mozzi expands the possibilities for sonification and Arduino, Retrieved 7 Feb 2013,
7. APPLICATIONS synthesis in new contexts away from expensive hardware, http://sensorium.github.com/Mozzi/
This time the frequency can be set with a floating cables and power requirements. The low cost and
point value: Mozzi has been been available on Github since June
accessibility of Mozzi synthesis on open source Arduino [12] Freeman, C. Untitled Sound Project Two,
2012. The range of potential applications has yet to be
and compatible microprocessors offers people a way to Retrieved 7 Feb 2013,
kVib.setFreq(6.5f); explored, however some examples which have appeared
create applications and compositions adapted to a wide http://reprage.com/post/28654178439/untitled-
so far include:
range of localised conditions. sound-project-two
Now, using variables for depth and centre frequency, A musical fruit fly experiment for a science fair at The
Edge in the State Library of Queensland. Kinetic and
the vibrato oscillator can modulate the frequency of the [13] McPherson, A. Build Your Own Arduinitar,
Retrieved 10 Jun 2013,
audio oscillator in updateControl(). kVib.next() returns a electronic artists Clinton Freeman, Michael Candy,
signed byte between -128 to 127 from the wave table, so Daniel Flood and Mick Byrne worked with Dr Caroline http://www.eecs.qmul.ac.uk/~andrewm/arduinita
depth has to be set proportionately. Hauxwell from the Queensland University of Technology r.html

28 | 2013 ICMC idea | LONG PAPERS 29 | 2013 ICMC idea | LONG PAPERS
[14] Nakanishi, Y. B.O.M.B. Performance, Retrieved A JAVA-BASED REMOTE LIVE CODING SYSTEM FOR CONTROLLING
10 Jun 2013, http://yoshihito-
nakanishi.com/performance/b-o-m-b- MULTIPLE RASPBERRY PI UNITS
performance/
Oliver Bown Miriama Young
[15] Pelouek, V. ^ [xor] synth, Retrieved 7 Feb
2013, Design Lab Music Department
http://www.standuino.eu/devices/instruments/xor
-synth University of Sydney University of New South Wales
oliver.bown@sydney.edu.au miriama.young@gmail.com
[16] e-licktronic. E-licktronic Arduino Mozzi
synthesizer, Online posting. March 13, 2013.
Arduino Forum :: Community :: Products and Samuel Johnson
Services, Retrieved 10 Jun 2013,
http://arduino.cc/forum/index.php/topic,154024. Design Lab
0.html University of Sydney
sjoh7452@uni.sydney.edu.au
[17] Pape, D. and Green, D. Fakebit Polytechnic,
Retrieved 10 Jun 2013,
http://www.fakebitpolytechnic.com/equipment/
ABSTRACT system is completely wireless extends its range of possi-
ble uses, given that it can be incorporated into miscella-
Cheap embedded devices create new opportunities for net- neous portable objects. The ability to hide the device in
worked, distributed, generative or remote-controlled mu- objects without telltale hidden wires is also conducive to
sic. In this paper we present a simple audio programming a sense of enchantment in interaction design. Finally the
environment designed to run realtime, remote live-coded PI can be easily extended to further include other kinds of
audio on a low-cost completely wireless hardware setup inputs and outputs, such as sensors and lights. This range
consisting of a Raspberry PI, a WiFi dongle, a speaker of uses and interactive experiences is already covered by
and a battery pack. Audio is processed in realtime using programmable smartphones but not at the same cost, pro-
the Beads library for realtime audio in Java, running on grammability and configurability of the PI-based system.
Oracles distribution of Java for embedded devices. Code
is remotely injected in realtime by sending Java class files The PI is easily configured so that on power-up, it au-
over a socket connection to a dynamic class loader, which tomatically logs in, connects to a given WiFi network with
instantiates and runs the classes. We describe the system a known network address, and loads an audio application.
and its capabilities, and give an example of a performance Thus, given a collection of PI modules, each module is
that utilises this system. This paper is accompanied by a ready to respond to dedicated control messages once acti-
musical performance at ICMC 2013. vated.

1. INTRODUCTION

The range and availability of cheap embedded devices has


been accelerating in recent years, exciting audio develop-
ers with the growing plausibility of use-cases involving
multiple low-cost audio computers. The release of the
Raspberry PI in 2012 marked a significant development
in this area. The Raspberry PI is a $35 computer capable
of running a full Linux distribution, loaded from an SD
card. Importantly it has USB ports and an analogue audio
output. For a total cost of around $100 the PI can be ex-
panded to include speaker, battery pack and WiFi dongle,
turning it into a fully portable networked music generator
(Figure 1). Alternatively, for roughly the same price it can
be expanded with an audio dongle, switches and knobs to Figure 1. Portable wireless configuration consisting of
become a programmable effects pedal. Raspberry PI (centre), Moshi Bassburger self-powered
In this paper we consider the first configuration. In this rechargeable speaker (top), WiFi dongle (left of PI) and
configuration the PI has no audio input, but can be inter- battery pack (right). Data is stored on an SD card (right of
acted with remotely over a network connection to control PI).
the realtime generation of sound. Although not necessary
for most distributed music applications, the fact that the

30 | 2013 ICMC idea | LONG PAPERS 31 | 2013 ICMC idea | LONG PAPERS

You might also like