Nathan Brown
xi:Bound
PicHunt
Arduino Midi Player
SPaDeS Tools

This project makes use of an Arduino Microcontroller to controller buzzers and lights to play and visualize notes that are passed from a MIDI parser. The Arduino has a wifi-card connected, which allows it run a server. The MIDI parser, Written in GoLang, takes a given MIDI file and parses it into a simple format that can be streamed to the Arduino over wifi. The timing of the notes is controlled by the parser, and the Arduino player plays the notes as they are received.

The notes are converted to a frequency before sent across to the player, then each note is played by an individual buzzer.

Each buzzer needs to be powered on and off repeatedly to make a sound. The correct note is created by toggling power to the buzzer at the frequency of the note needed. To achieve this, each buzzer is connected to a different pin, and when a note needs to be played, an interrupt timer is enabled for the pin that fires at the frequency needed, and toggles power for the pin on and off. The frequencies of notes commonly used range between 100-1000.

The Arduino Player also displays a visualization of which buzzers are currently outputting noise, created using LED lights. A 3-to-8 Decoder is used to minimize the number of pins required. The light display is updated every time a note starts or stops playing.

Further Work

After completing this project, I tested a few more possible ways to use the buzzers. It is possible to control the volume of a buzzer by toggling power on and off at a higher frequency than the ear can hear. This is done by switching back and forth from 0 power, to pulsing on and off at a frequency higher than the ear can hear, back to 0 power.

Using this technique, the maximum volume is only 50% of the volume normally possible. This works because of the way the human ear averages the output of frequencies higher than it can hear, and the specific note is created by the frequency at which it switches between no output, and high-frequency output.

The specific volume is managed by controlling percentage of time power is on or off during the high frequency sections of output.

Whereas in the diagram before, the power was split evenly as 50% on and 50% within the high-frequency sections, in this diagram the volume would be much lower because the power is on only about 10% of the time.

Using this technique to change the volume, I proceeded to try and come up with a method to play 2 notes from the same buzzer at the same time. A note can actually be expressed as a sine wave, and the method of turning the power on and off simply creates a crude version of a sine wave. This means that a note can also be created by scaling from 0% volume, up to 100% volume, and back down, instead of toggling on and off.

The specific note is now being created by the frequency at which the volume on the buzzer shifts from 0% to 100% and back.

When the ear hears a note which is complex, such as a note that can't be defined by a simple sine wave, it does a type of fourier analysis to break it into a combination of notes of simple sine waves.

Because of this effect, it is possible to create 2 notes from the same buzzer at the same time by changing the volume in relation to the sum of the waves of the notes; essentially creating the complex wave manually. Using this method I was able to get 2 notes playing at the same time, confirmed by a sound analysis tool, but there were many issues. For one, The Arduino simply isn't powerful enough to do the sine calculations required in real time. I created a lookup table for sine values to increase the speed, but this loses out on accuracy. The Arduino clock speed is not fast enough to get the toggling speed required for accuracy in the volume being output. To get successful results I had to choose notes that had strong interference as to have large enough changes in volume throughout each period of the wave.

The left image and center image both show the buzzer playing one individual note, then the rightmost image shows the spectrogram of the buzzer playing both notes at the same time.

Nathan Brown

NathanBrownDev@gmail.com

1-807-355-5820

Feel free to send me an email with any questions, concerns, or opportunities.

Online

Github

LinkedIn

Discord: SPaDeS#2644