Classical music theory follows a strict set of rules that often can be looked at with a logical perspective rather an an artistic one. We believed that machines, being purely logical, would be able to create original, sonically pleasing music, if given these rules.
What it does
The mobile application randomly generates notes to form chords, which are checked against the guidelines of 18th century classical music. Our system assigns values to notes using a base 7 number system while being compared against these rules, which are turned into audio output through the use of a custom made sine wave synthesizer.
How we built it
The development process was split into four major steps. The first step was creating a program that can create notes using a base 7 number system, form them into chords and measures using two dimensional arrays, and analyze the music generated to assure they follow the rules of classical music theory. The second step was to create a program that can synthesize four voices of polyphonic sine waves at once using tools built into the android operating system. The third step was to create the application's minimal GUI and visualizer. The final step was to combine these three elements. The program had to convert the notes and chords output into frequencies able to be generated by the synthesizer, and the visualizer had to sync with the synthesizer.
Challenges we ran into
Initially, there difficulty deciding between the tradeoffs of using a base 7 or a base 10 number system. A base 7 number system was easier for humans to conceptualize, as each digit could correspond to the 7 notes in the major scale, and the 10s place could be used to designate octaves. A base 10 system was easier for the program to use to check that the music followed the theory rules, and allowed for easier conversion into frequencies for the synthesizer to use. We ended up converting from a base 7 system to a base 10 system midway though the system, before it checks the music against the rules.
Another difficulty faced was creating a synthesizer that was polyphonic (able to play more than one note at once). Android does not support the writing of MIDI files, and playing audio files such as .mp3s would not work as android does not allow for playing multiple audio files at once, and therefore it would be impossible to play a chord using those methods. We had to create our own polyphonic synthesizer to play chords.
We also faced difficulties while attempting to convert the music writing algorithm from one that would generate four chords, to one that would generate an endless stream of chords in real time. The rules initially created for the program were developed specifically for these four chord patters. It did not support writing multiple measures, let alone an infinite number of measures. Additionally, when it took longer than the length of a chord to create the next chord, the program would end as there was no music to play.
Accomplishments that we're proud of
We are able to randomly generate sonically pleasing music with no human interaction. Additionally, we were able to work cooperatively and productively with a new hackathon team featuring two members with no hackathon experience, and one member with only a single hackathon under his belt.
What we learned
Many members learned much about music theory over the weekend. One member took part in his first large scale programing project.
Developing the synthesizer taught us much about the mathematics behind acoustics, and development in Android Studio.
What's next for Music Cyborg
There are many more techniques and rules pertaining to the music theory of the era that could still be implemented, such as embellishing tones, rhythmic variation, suspensions, secondary dominants and modulations. Additionally, many of these rules can be broken in the proper circumstances. Theoretically, implementing some form of artificial intelligence could be used to determine when breaking these rules would be beneficial. Additionally, technology like this could be developed even further to create many different styles of existing music, or even to create new styles of music.