Arduino Tones – A New, New Hope

Having just completed my Arduino Nano Multi-tone or PWM PCB Build Guide I wanted an example application.  So I went back to my Arduino Tone One Year On! project which was designed to do something interesting with my very first projects in celebration of one year of my blog!  At the time, I wrote:

“Note it should be noted that there are many other ways to achieve this… Not to mention a whole host of synthesis approaches and alternative microcontrollers.  But the idea was to return to those first two projects and do something with those.”

But one thing I’ve always wanted to do was to take advantage of my Arduino MIDI Multi-Tone Module approach which can support up to three loudspeakers on a standard Arduino Uno or Nano.  So linking this with my Arduino Nano Multi-tone or PWM PCB which allows four Arduino Nanos with three loudspeakers each gives me the same twelve channels of music to play with!

So this how it works and sounds.

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

These are the key Arduino tutorials for the main concepts used in this project:

If you are new to Arduino, see the Getting Started pages.

Parts list

The Circuit

IMG_6656

This could be reproduced on solderless breadboard or stripboard. It is essentially four of the Arduino MIDI Multi-Tone Modules with a linked RX pin.  But I’ve chosen to use this as a demonstration of my Arduino Nano Multi-tone or PWM PCB so I’m going with that.  This requires the jumpers configuring as follows:

  • Audio output jumper: enable Mono mode (although it doesn’t really matter).
  • PWM mode for each Nano: not relevant as doesn’t apply.
  • RX mode for each of Nanos B, C, D: linked to previous Nano’s RX – i.e. the last of the following jumper options for each Nano:

IMG_6653 - RX Select

The speakers are the earpieces I’ve collected over the years from discarded or broken headphones. I just soldered on two-header-pin jumper cables so they could be easily connected to the board.

You can use any loudspeakers you’ve been able to salvage, but note that as there is no volume control if you want a balanced end result, the more similar the loudspeakers, the better.  As it was, the while one in the photo ended up being a lot quieter than the others so I replaced it in the final build with a more similar one.

IMG_6655

You will need a source of MIDI serial data.  This PCB has no proper MIDI IN interface of its own, it is designed to be sent data from another Arduino or similar.  To send a MIDI file from a PC, I used my PC USB to Arduino Serial MIDI which is based on an Arduino Leonardo compatible “USB Beetle” device.

The Code

This uses the same code as the Arduino MIDI Multi-Tone Module, but there are a couple of enhancements:

  • The code now has an option to tie the polyphony to individual MIDI channels.  So for three note polyphony (i.e. as required here) it will recognise three consecutive MIDI channels started with the value of MIDI_CHANNEL.
  • I’ve also implemented a “MIDI_PASS_THRU” mode that allows additional polyphony with the carrier board for use with the “link RX of this Nano to TX of the previous Nano” mode (the central option in the above photo).  This means that if more notes come in than can be played on a single board, the additional notes are sent back out over MIDI to the next board.

Find it on GitHub here.

Closing Thoughts

I’m really pleased with this module and very happy to see the 12-tone Arduino fanfare tones now supported by a much neater module with its own PCB. It is also more satisfying to know that the Arduinos themselves are being used in a more optimal way, but supporting three loudspeakers each.

Kevin

Leave a comment