A picture frame which highlights a button and speaker and plays a simple tune.
Concept:
The MIDI Music Box is my final project for ECE 1100, and its concept is relatively simple (from first glance): At the press of a button, a tune will play from the speaker, defined by a MIDI file of your choosing. This would allow the user to endlessly upload new songs to this small yet versatile device.
The MIDI Parser:
My first attempt at the MIDI Music Box involved writing my own MIDI parser from scratch, with guidance from some online resources including a similar project by Technoblogy and an exhaustive MIDI format guide from McGill University.
MIDI consists of a string of bytes which correspond to headers, messages, and data payloads. Parsing MIDI entails iterating through a MIDI file and interpreting each of these messages using a lookup table to extract important information for your program.
In the process of developing my parser, I gained an intimate knowledge of how MIDI is structured, which is a valuable learning experience for future music tech projects. In practice, it turns out that not all MIDI files are formatted in the standard way, so my parser was not 100% accurate. As a result, I used a library called MIDItones to convert the MIDI file into a more useable list of notes.
Synthesis:
To keep things relatively simple, the MIDI frame uses PWM to generate square waves from digital I/O pins on an Arduino Uno R3. Multiple pins can act as different voices to drive the same speaker, as you can hear in this video.
Through this project I learned a great deal about microcontroller programming, audio synthesis, and embedded system design, which are concepts I intend to explore in the future.
In future iterations of this design I'd like to replace the PWM audio generation with wavetable synthesis, which would give me more control over the sound of the music box including using different waveforms and applying a decaying envelope.
My initial plan had been to use a QT PY ESP32-C3 as the microcontroller behind this project due to its diminutive size, but the PWM library I was using required a board with an AT-Mega chip, which made me choose the Arduino.