For The Birds - Basic Chord Progression Game
For my final project, I created a game inspired by the Pixar short For The Birds that teaches basic chord progressions.
I was motivated by the many years I had invested in piano, and comparatively little I knew about improvisation and common chord progressions. Courses in music theory helped fill that gap, but I wanted to help novices get a quick and dirty rundown of common progressions in a fun and interesting way. And so For The Birds was born. The aim of the game is to shake all the birds off of the dangerously electric telephone wire. To do this, play the correct chords shown on the screen. Doing so will shake the wire (with the waveform) and cause a bird to fly off the wire. Playing a chord incorrectly will send an electric shock down the wire and cause you to lose a life (no birds are harmed at this point). But if you lose all your lives, the birds will be electrocuted! If you need a hint, press 'h' and the chord you're supposed to play will be arpeggiated out, and the rays of the sun, corresponding to the 12 notes in an octave, will become bold so you can see the intervals required - pro tip, the tonic note is the one pointing directly out to the right (3 o'clock).
And so it began. It started small, just detecting when three notes were pressed more or less at the same time, but quickly escalated.
The design was as follows. There was a Bird class, a Karplus Strong class, and the
RtAudio/OpenGL libraries. Within my main program, I had Note, Chord and Level structures which
could probably have been expanded into whole classes. However given that the chords and
notes were only data-containing structures with no corresponding actions (a chord does not
actually DO anything, it just houses information), I felt that simply using a struct would suffice.
I began, as previously mentioned, by detecting the event of three notes pressed at the same time. I continued by detecting the key, quality, and 'relationship to the tonic.' (as well as adding infrastructure to assign a tonic). Simultaneously, I drew the waveform from the midi input to the screen. While I was on a roll in terms of audio, I added in a single level - I, IV, V, I. Then I drew the landscape, telephone poles, wire, sky, grass, and all. Over break I focused on drawing a single bird and giving it the ability of flapping/flying/moving. Then I made it flap/fly/move upon playing the correct note. I continued this incremental development, building on what was once a black screen and a white waveform (drawing microphone input) until around right now as I type this. Trials and tribulations included a lot of segmentation faults, tons of googling what the word "new" actually means (and other issues involving memory management), adding global variable after global variable, and sometimes, just saying "well I should probably not fixate on this." Given that For The Birds was my second experience with OpenGL, definitely one of my more intimate experiences with pointers and memory, and way more algorithmically challenging than I initially expected, I'm pretty content with what I've managed to accomplish in the time allotted. Even disregarding all of that, For The Birds is a pretty decent prototype.
After a little over 4 weeks, I ended up with a solid product, but there is always room for improvement.
Although I have written up the core functionality of the game, there are a few things that, with more time, I would like to improve. First off, using Fluid Synth. The Karplus Strong method used to generate the "plucking" noise was taken from a previous assignment for the sake of time, but the tone is a bit inaccurate, especially in the higher registers. Fluid Synth would allow much more flexibility in choosing sounds, and I could see which would be best - be it a piano or maybe a flute (like a bird tweeting kind of). Secondly, I would like to look into how to use different fonts using texture mapping, or some other method. The bitmap characters are a little boring and constraining, and different fonts would add a lot of character to the game. Additionally, the game only focuses on basic major chord progressions, with 3-note chords only. I would try to allow for more complex chord progressions and cadences, as well as capturing 4-note events, such as V7 or ii7 chords. This would create potential for much richer chord progressions overall. There is also the question of how valuable this game is to a beginner/novice in chord progressions. I will be the first to acknowledge the lack of teaching infrastructure - I never really say what a I or IV or V chord is, so if they don't already have some notion of scales and tonics and resolution, they're going to be confused from the get-go with no real way to figure that basic stuff out. Thus, the game is mostly catering to a group who is familiar with chord progressions, but just doesn't know or recognize common patterns. That's a relatively specific demographic. Ideally in the future I could explain the importance of the tonic and resolution and what the roman numerals mean, but perhaps that is for a different project. For The Birds: THE PREQUEL. Lastly (in terms of improvements), graphics and optimization can always be improved (CPU works real hard to run this bad boy).
If you want to try it out, here's how to download everything, and what to do after that.
Getting the files:
- Download the zip file
- cd to the directory in Terminal
- Type 'make'
- Open a virtual midi keyboard (such as MidiKeys) or plug in your midi keyboard
- Type './ForTheBirds'
- Play some chords and save some birds!
- To erase the files you made to generate the executable ('./ForTheBirds'), type 'make clean'
Some notes - MidiKeys is actually was 4 notes off. As such, there is a line inside the main file, ForTheBirds.cpp, that reads noteNum += 4. If you're not using MidiKeys and this offset really bothers you, comment out that line.
Playing the actual game:
- When the game opens, you should the home screen with the title of the game
- [Q] will just quit, [Enter] will allow you to play immediately, and [I] will show some instructions
- If you're confused, press [H] for a hint.
- If you're totally lost, bang on the keyboard or press escape to eventually lose/return to the homescreen.
All in all, I had a great time making a product from scratch that was
extremely creative and that gave me and opportunity to be a bit more ambitious with a final project. For The Birds definitely taught me a lot about aesthetics, memory management, graphics, and products that are greater than the sum of their parts!