In the fall of 2023, I had the distinct privilege of joining Majestic Data Systems Inc. as a subject matter expert for the "Math to Music" project. Within this innovative endeavor, we set out to create a remarkable robot capable of translating musical notes into audible sound. My role encompasses directing the process of generating sample music notes, ranging from the simplest to the most complex compositions. Additionally, I'm tasked with designing functions that can produce music at various levels of complexity, and crafting the product webpages. This project has been a fascinating learning experience, as it has exposed me to the intricacies of generating and analyzing arrays and waves from musical notes, and programming music using languages like Python. Although I've just embarked on this exciting journey, my eagerness knows no bounds, and I'm enthusiastic about contributing further to the project's success and ultimately building an exceptional product.
This product can accept music notes from multiple channels, like a mobile app, a toy, or a web form. Below are illustrations and some progresses.
Music Robot Can Read, Write and Analyze Music Note, and Generate Music.
Introducing 'Destiny', a musical piece I both composed and programmed. Please follow me to dive into the step-by-step journey of how I crafted, analyzed, and brought 'Destiny' to life using my computer.
Step 0 - Playing & Composing Music On Piano
Step I - Computer Composing Music
Step II - Computer Analyzing Music
Destiny -- Note Data
Showing music note data of 'Destiny'.
Fast-fourier transform Visualization
Examining the audio waveform of the music 'Destiny' using its Fast Fourier Transform (FFT) visualization.
Pitch Frequencies
Analyzing the frequency of pitches.
Note Duration Frequency
Analyzing frequency of note duration.
Most Common Chords
Analyzing frequency of chords.
Step III - Computer Producing Music
Step IV - Computer Tuning Music
Step V - Future Step? Construct a Real Music Robot!
I was told to get this Jetson Nano kit, and honestly, it sounds a bit complex. But I really want to build an actual music robot and show it off to my classmates next semester! I'm not sure what comes after that. One thing I've realized is that teaching a machine to play music is one thing, but getting it to play with emotion? That's a whole other challenge. I guess that's something I'll tackle later. For now, I'm all about creating my music robot!
Octaves
A piano has many octaves, and each octave looks the same on the outside, but they can sound a little higher or lower compared to each other. To make one octave (a set of 12 keys), we need to understand how each key is set up in comparison to the others. Then, we can simply make the next octave by either doubling or halving the frequency of all the keys.
Pianos are tuned using a system called "equal temperament." This system means that the frequencies of the keys (the notes) are arranged in a specific way.
Frequency of Keys (notes)
note_freq = base_freq * 2^(n/12)
Frequency of Octaves
Illustrated Wave Graph of a Base Note
Music Data -- "Twinkle-Twinkle"
Middle C Note
Scale of Nuances in Music Notation
NOTE Messages
There are two main messages: NOTE ON and NOTE OFF messages. The NOTE ON message is sent when a key on a music keyboard is pressed, indicating the pitch and intensity of the note. When this message is received by a synthesizer, it plays the note accordingly. The NOTE OFF message stops the synthesizer from playing the note.
The NOTE ON message is structured as follows:
Status byte : 1001 CCCC
Data byte 1 : 0PPP PPPP
Data byte 2 : 0VVV VVVV
where:
"CCCC" is the MIDI channel (from 0 to 15)
"PPP PPPP" is the pitch value (from 0 to 127)
"VVV VVVV" is the velocity value (from 0 to 127)
The pitch value, ranging from 0 to 127, determines the note's frequency, with middle C as 60. Each value represents a half step. To transpose up an octave, add 12 in MIDI, but ensure values remain between 0 and 127. Velocity, from 1 to 127, dictates volume. In basic synthesizers, it affects only volume, while in advanced ones, it also influences sound quality. A velocity of zero turns the note off.
The NOTE OFF message is structured as follows:
Status byte : 1000 CCCC
Data byte 1 : 0PPP PPPP
Data byte 2 : 0VVV VVVV
where CCCC and PPPPPPP have the same meaning as above. The VVVVVVV is the release velocity, which is very rarely used. By default, set it to zero.
FFT - Fast-Fourier Transformer
The FFT, or Fast Fourier Transform, is like a machine that breaks down a complex sound into its individual tones or frequencies. Think of it as figuring out the ingredients of a fruit smoothie. In music, it shows the main and quieter tones in a note. This helps musicians understand sound, adjust frequencies, remove noise, and even compress music for streaming. Essentially, FFT reveals the "recipe" of a musical piece.
Some Small Practices
C Major Scale & FFT Transformation
A Widget Converting Note to Sound
I just started to participate in this project. There are still lots of challenges waiting for me. But I enjoy these challenges. I am so excited to provide my expertise in music to a real life application. And I get opportunity to learn how to use mathematical expressions to display music. It is of such a wonderful magic!