O'Reilly logo

C Programming for Arduino by Julien Bayle

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Improving the sound engine with Mozzi

The bit-banging technique is very cheap and it's nice to learn how it works. However, I can quote some annoying things here:

  • No pure sound: Square waves are a sum of all odd harmonics at the fundamental frequency
  • No amplitude control available: Each note sounds at the same volume

We are going to use a very nice library called Mozzi, by Tim Barrass. The official website is directly hosted on GitHub at http://sensorium.github.com/Mozzi/. It includes the TimerOne library, a very fast timer handler.

Mozzi provides a very nice 16,384 kHz, 8-bit audio output. There is also a nice basic audio toolkit containing oscillators, samples, lines and envelopes, and filtering too.

Everything is available without external hardware ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required