The Arduino as a Native Sound Generator

Many interactive artifacts still torment their users with loud, harsh sounding binary beeps and purposefully designed sounds are an exception. As powerful embedded microcontrollers have become ubiquitous and relatively easy to use, new opportunities for sound design in interactive products emerge. Their computing powers often exceed the capabilities of early personal-computers and they are embedded in many common everyday objects – even seemingly simple devices and appliances such as coffee makers, garage door openers and microwave ovens, etc. For most of the time these small computers run idle and are not used to their full extent. What if we could leverage this potential?

Tackling this issue is one focus of our course module Physical Interaction Design 3 – Delightful Noise / Embedded Sound-Design for the Masses at the Bauhaus-Universität Weimar during the Summer Semester 2014. We will investigate a variety of ways to generate sound on the arduino and develop algorithms, applications, while making a lot of noise along the way.

Of course some audio shields exist in the arduino ecosystem to playback mp3 or wave files but they add to the cost, the weight and the size of a project. Code in comparison is rather lightweight. Arduino libraries to the rescue! They provide a good starting point to get deeper into the topic.

the_synth

DZL/Illutron from Geekphysical have published a library of a wavetable synthesizer that brings brack memories of the good old days of 8bit gaming consoles. (We have successfully managed to reproduce every sound from the old Super Mario games). The great news is: its polyphonic – currently the library supports up to four independent voices.
Here are the specifications:

  • 20KHz sample rate using approx 45 % of the available CPU time.
  • Output audio as PWM on pin 11, pin 3 or ad differential signal on both.
  • Has 5 build in waveforms SINE, RAMP, SAW, SQUARE and NOISE.
  • Has 4 build in envelopes.
  • Each of the 4 voices has parameters for Waveform, Pitch (MIDI note or Frequency), Envelope, Duration and modulation.
  • Each voice has trigger functions for simple ot MIDI note trigger.
  • Timing functions are available for sample rate sync and end-of-envelope detection.

https://github.com/dzlonline/the_synth
An example on how make practical use of the library can be found here:http://www.instructables.com/id/Turn-your-Arduino-into-a-4-voice-wavetable-synth-w/

Mozzi

Mozzi is another library to generate sounds on the Arduino. It can also be used for sample playback at surprisingly high quality and is even capable of some basic audio processing. The library comes with a variety of examples that demonstrate its potential as a standalone (digital) synth-engine, sampler, DSP or whatever use you can imagine. It even comes with its own mozziAnalogRead() function to optimize the performance of analog-to-digital conversions.

Here are the specifications:

  • 16384 Hz sample rate or experimental 32768 Hz rate.
  • 8 bit or 14 bit audio output modes.
  • Variable control rate from 64 Hz up.
  • Useful basic audio toolkit: oscillators, samples, lines, envelopes, scheduling, filtering.
  • Fast ADC and other cpu-efficient code utilities to help keep audio running smoothly.
  • Example sketches for easy modification.
  • Readymade wavetables and a script to convert your own soundfiles for Mozzi.
  • Designed to be easy to use, open source and extendable.

http://sensorium.github.io/Mozzi/

More…

An overview of other ways to use the Arduino as a sound generator can also be found on the Arduino Playground:
http://playground.arduino.cc/Main/ArduinoSynth