Inspiration
I had attempted to do something like this years ago for iOS before I had any sort of realistic understanding of how to code. Needless to say it was a complete failure. I had done a ton of research about scales (names, origins, etc...) for that project and always wanted to use that at some point in the future when I actually learned how to code. For this hackathon, I decided to blow the dust off of the idea and did my best to implement a (very basic) version of it in Python. It went significantly (surprisingly) better than my first attempt. There are still a ton of features I would like to build into it before I made it truly public, but I think once it's done, it will be a truly useful tool for music students, educators, professionals, composers, and hobbyists.
What it does
Scale Explorer has all of the known data about every musical scale in modern music (and many unknown) and allows users to search through them in a variety of different ways. The tool was built with composers, educators, performers, and students in mind. For composers, they can explore scales by tone, learn some of their alternate names, and listen through some scales they are likely unfamiliar with to get inspiration for new ideas. Performers, educators, and students can use the Explorer to create scales for their own individual practice on their instrument. Users have the option to create PDF scale sheets for themselves to print out, or optionally, they can export a scale to MuseScore for playback and editing.
How I built it
I started by extracting all of the research data from my old attempt years ago and completely reformatting it into JSON. I then built a small utility script that generated every combination of possible scales from 5 notes to 12 notes (in Western music theory there are twelve possible pitches, or tones. I set 5 as the minimum for what we could call a "scale" vs. a "chord".) The utility script merged the JSON file with the generated combinations to create a master JSON file that essentially held every possible note combination from 5-12 and tacked on the merged data from the old file, if it existed.
From there, I created classes to handle the objects I'd be working with: Scale, Note, NoteCollection, ScaleCollection. I also created a ScaleConverter class which was handy for converting the scale formats in a variety of ways depending on the user input.
After that, I attempted at first to use the Kivy GUI solution for Python, but it wound up being very poorly documented and cumbersome so I abandoned it. I eventually landed on PySimpleGUI which made the process of creating a GUI reasonably simple, by comparison.
Then, I sought out ways to allow the user to hear the scale and interact with it in some way. At first, I was thinking of a more advanced solution like a plugin that might assist me in creating my own solution like matplotlib or pygame. I came to the realization that interacting with music in Python is likely something that people have done before and came across two helpful dependencies: Lilypond, which has its own scripting language for creating sheet music, and Music21, created by two guys from MIT to create & export music in a variety of ways. I managed to hook them into the application and get everything mostly running!
Challenges I ran into
Oh so, so many. Here are the highlights though:
The GUI solution. I wasted so much time trying to learn how to use Kivy. I'm very grateful that I found PySimpleGUI.
The structure of my classes. At first, I made the data members of the classes sort of clunky, and sending information between classes wound up being cumbersome and frustrating. I had to go back and think through (again) what exactly I needed each thing to do, and do some heavy refactoring of each. I still think there's room for improvement there, but for the most part, I'm happy with it.
Learning Music21 and Lilypond. This was sort of nightmarish as Lilypond's API seemed to be written for musical aliens who can comprehend software at its highest level, and Music21 was just confusing. I soon realized to my luck that Music21 was, in fact, a Lilypond wrapper and exposed some very helpful API to make doing things with Lilypond slightly less horrifying.
Making PySimpleGUI do what I needed it to. This was my first time working with a GUI in Python. I've done stuff stuff in iOS and the web using frameworks and whatnot, but working with a GUI in Python is sort of a different animal. I had to read through the very spastically written guide several times to make sense of some of the core concepts, like the event loop. I did manage to get it work and even refactored code to make updating UI elements much more elegant.
Accomplishments that I'm proud of
More than anything, I'm proud that I have something functional to present tonight. I never would've been able to do something like this before OSU. At each point that I overcame a hurdle and saw something doing what it was supposed to do, it was a rush. I'm sure to many in this program this will seem like a relatively basic application, but I'm more proud of this than nearly anything I've made.
What I learned
A few things:
Don't overcomplicate things. Often the best solution to a problem is the simplest. It can sometimes take some trial and error to arrive at what is "simplest", but if you're confusing yourself with the implementation of something, chances are it's not the simplest.
Use the resources that are available to you. There's no shame in creating something on the backs of people who dedicated themselves to a dependency you're using. It's a great way to learn, and someday, we might create something equally useful to the programming community.
Spend a little extra time to find the right tool. It took me too long to realize that there were likely simpler solutions (GUI, music display, etc...) out there that are well-documented, are easy to grasp, and will do the job much better than even a more popular dependency or solution.
Step away from the computer. I realized that taking breaks every couple of hours really helped me gain perspective on the project when I was running into a wall.
What's next for Scale Explorer
There are so many things I'd like this to do (and it will!) Ideally, it will be able to create entire scale sheets with any number of settings so that the user can very easily create real, workable music for themselves. I'd like the playback to be set into the project GUI itself rather than from the Musescore app. Finally, it would be cool to offer the option to generate scale patterns with a variety of note permutations/lengths/clefs so the user doesn't just have a line moving up (which is boring).
Built With
- lilypond
- music21
- pysimplegui
- python




Log in or sign up for Devpost to join the conversation.