Imperial March in 8 bits

Imperial March in 8 bits

After taking the introductory class of digital systems and learning Assembly language, I decided to put my new skills to test and try to make some music with code! Of course, I wanted to keep it simple but extremely cool so I decided to play one of my favorite music piece through an 8 ohm speaker. With my then-limited-but-not-yet-perfected ability to read music sheets, I embark myself to translate the first 66 (get it? Order 66) music notes of the Imperial March by John Williams. The entire code was written in assembly, the red LEDs were sync with the music notes duration, and the PWM frequency for each note was calculated, approximating to the nearest integer, using this formula:

f = 2n12 x 440 Hz

Where n is an integer that denotes the number of half-steps away the music note is from A in fourth octave (A4); if the frequency is above it, n is positive, and negative if the note is below it. This gives the audio a very (and literal) 8 bit vibe.

[GitHub Repo]