Free-Form: Create A Musical Hit Structure
Project concept and motivation
The goal of my project was to help musicians with musical arrangements /forms (In this article forms and musical arrangements used interchangeably). As a musician I felt that arranging my musical ideas to a full-length structure is the place I tend to get stuck the most, thus having a lot of unfinished songs. I think that having an arrangement as a reference could help me produce music more efficiently and to be able to communicate musical ideas better. I envision that every musician could benefit from using this kind of tool. It could easily integrate with any music writing process, allowing easy and simple integration with common music making software. This kind of application will still require me to come up with my own musical ideas but putting them in the right context will make full song form a simple process.
I have explored different academic articles about common songwriting forms [1,2] from a research perspective and from a practical perspective, online magazines with more hands-on approach [3,4]. I found an online app that randomized different musical forms [12] but it leaked a context. In addition, I found an academic article that examined style imitation in music using statistical modeling [11] but it was irrelevant for my research since it discussed style as opposed to form. I was also looking for existing software that is able to help with song forms, however I could not find one that resembled to what I had in mind. Therefore, I understood that the application I wanted to create is relevant and might also help others.
Implementation and Practice
I created an application using Max/Msp where the users could insert information about the song they currently write (BPM, genre, key, scale) and their dream goals about it (plays, place in chart, length). Max processes the data and sends it to Wekinator [7]. Using Machine learning Wekinator will return a recommended musical form based on the input and the trained data. The selected musical form also being sent to Ableton live and plays an example song according to the selected form and input information (BPM, genre, key, scale) allowing everyone to explore the suggested form, not necessarily while writing a new song.
check the YouTube for a short video:
https://www.youtube.com/watch?v=b9c3OBMtCcw&feature=youtu.be
The first part of my project was to understand what kind of data set I'll be using to train Wekinator. I decided to use Spotify's top 200 (April 2018) chart and explore different elements in each song.
The elements I explored were: rank, plays, BPM, genre, length, root note and scale. These musical elements are the core part of each musical piece. By inspecting the form and the commercial successes in relation to these core elements, I will be able to gain insight about how to reverse the process of making a hit song. I wanted to examine the relationship between all elements, core and commercial, with their song form hoping to formulate what makes a song successful. Some of the data was available from Spotify's website [5] and the rest I extracted using analyzing tools from a DJ software (Traktor DJ pro [6]). The next part was assigning a class for each song. After exploring the different musical forms, I have defined five distinct musical forms that my application would suggest as output classes (see appendix A). These forms distinct between different structure of parts in a song similar to AABA and others [10]. I have analyzed the songs by listening, looking for patterns (intro, verse, chorus, etc..) and labeling them according to similarities to one of the five different forms I have defined. In order to simplify the data, I have scaled down the numbers and convert the output to a float number between 0.0-1.0. This process allowed me to generalize the data and helped me make assumptions while testing my application with new data compared to the trained system.
I have tried several different classification algorithms for machine learning with each having different results. I decided to focus mainly on two: AdaBoost.M1 and Naïve Bayes. Approaching the project, I assumed that Naïve Bayes will be the best algorithm for the task. I thought that the diversity of data will make simpler sense when put through a statistical lens. The pros about using this is having the additional statistical distribution. The distribution chart makes exploring the different values very convenient and showed both similarities to other forms and approximation to the actual class. In general, I felt that having this as a tool in my application would improve user experience and also will invoke users to not be strict to an absolute form and see what else might fit the closest. The problem with this algorithm was its accuracy. When I performed model evaluation both training accuracy and cross validation tests Naïve Bayes had the lowest scores comparing all other classification algorithms. A training accuracy of less than 40% meant that either I do not have enough data, or this algorithm is not fitting for the job. As I predicted, it added a lot of value looking at the distribution chart. However, after endless tries to predict the machine and verify that Wekinator did learn what I wanted I decided to change approach. Naïve Bayes was too unpredictable and under fit for the task. As an alternative I've experimented with SVM as well. Although it made sense using this algorithm for examining the different probabilities, it felt undefined enough and I was looking for a more pronounce resolute.
The second algorithm I experimented with and ended up using is AdaBoost.M1 with a decision tree as a base classifier. Experimenting with a simple decision tree (J48) could not comprehend the complicities of the data. The additional iterations of the training rounds using AdaBoost.M1 produced better results. This algorithm broke down the data to several small and simple decision-tree problems and provided great results from the start. When I performed model evaluation the training accuracy was between 95% to 98% (depending of training rounds). While this was almost perfect, experimenting with the application and checking cross validation data again yield less then 40%. Fewer training rounds simplified the results, generalizing the data and made it very consistent. Higher training rounds made the application more dynamic and responsive. Eventually I used hundred training rounds, and this really highlighted the relationship of musical keys, length and BPM with the associated class. Having more training data could probably blur these relationships and could produce more coherent results.
Conclusions
Overall, I think my project was successful, but I could easily improve it by providing bigger amounts of data. When I started the project, I explored Top 50 chart but after few experiments I understood that the data is too diverse and not enough. After adding additional 150 songs to my database the resulting forms started to make sense, however it is still complicated to predict. If I had more time I would try to implement an automated system to detect structures [8,9] which would have been a major time saver. Automated system might detect patters I was unable to or unaware of. I am also interested in simplifying the accompanied Ableton live set to make a simpler template to interact with the Max patch.
Credits and Clarifications
For this project I have used data gathered from Spotify and YouTube. All music I have listened and analyzed (on my own or through Traktor DJ pro software) in copyrighted to the original owners and accompanied by a full list "Data for ML - full chart.CSV" in the project files. For the record I have not verified the data (BPM/key/Genre). The usage of the data is for the purpose of this project only. In my Max patch I have implemented two features that I did not write the code for (credit in code as well):
Reading txt/csv files - https://cycling74.com/forums/importing-from-excel-csv-questions/
Truncate decimal points - https://cycling74.com/forums/progressively-remove-decimal-digits
Instructions for running the project
In order to run my project, just open the Max patch, Wekinator project and Ableton live project. From the Max patch interface, you can start Wekinator (since it is already trained) and start experimenting with the sliders and dials to produce a recommended musical form. You can also play the form in Ableton live. You can change values (BPM, genre, key, scale) while live is playing, however it is recommended to stop and start again, otherwise the form might be broken. Notice that not all musical keys/ genres work well in this musical context thought it is part of the fun to experiment.
References
1. Tough, David T. "An Analysis of Common Songwriting and Production Practices in 2014-2015 Billboard Hot 100 Songs." MEIEA Journal 17, no. 1 (2017): 79-120.
2. Tough, David. "Teaching Modern Production and Songwriting Techniques: What Makes a Hit Song?." MEIEA Journal 13, no. 1 (2013): 97.
3. MusicRadar. "How to write a hit: structure" Accessed May 01, 2012. https://www.musicradar.com/tuition/tech/how-to-write-a-hit-structure-542126
4. MusicTech. "Songwriting Tutorial: part one - introduction to song forms" Accessed Oct 27, 2014 http://www.musictech.net/2014/10/sw-1/
5. https://spotifycharts.com/regional
6. https://www.native-instruments.com/en/products/traktor/dj-software/traktor-pro-2/
7. http://www.wekinator.org/kadenze/#Install_the_Wekinator
8. Maddage, Namunu C. "Automatic structure detection for popular music." Ieee Multimedia 13, no. 1 (2006): 65-77.
9. Serra, Joan, Meinard Müller, Peter Grosche, and Josep Ll Arcos. "Unsupervised music structure annotation by time series structure features and segment similarity." IEEE Transactions on Multimedia 16, no. 5 (2014): 1229-1240.
10. Von Appen, Ralf, and Markus Frei-Hauenschild. "AABA, Refrain, Chorus, Bridge, Prechorus-Song Forms and their Historical Development." Samples. Online-Publikationen der Gesellschaft für Popularmusikforschung (2015).
11. Conklin, Darrell. "Music generation from statistical models." In Proceedings of the AISB 2003 Symposium on Artificial Intelligence and Creativity in the Arts and Sciences, pp. 30-35. London: AISB Society, 2003.
12. Random Song Form Structure Song Writing app http://learnhowtowritesongs.com/random-song-form-structure-songwriting-app/
Appendix A
After examining different musical forms here are five distinct forms I used for classification during this project.
Form I:
This form is characterized by having a second verse before going to first course - it's not a pre-chorus but a variation on a verse after the first one.
Examples of full arrangements are:
Avicii - Wake me up (13 on the chart):
Intro - Verse - Verse II - Pre-Chorus - Chorus - Verse - Verse II - Pre-Chorus - Chorus
Camila Cabello - Havana (40 on the chart):
Intro - Verse - Verse II - Pre-Chorus - Chorus - C part - Chorus - D part - Chorus
Lil Dicky - Freaky Friday (11 on the chart):
Intro - Verse - Verse II -Chorus - Verse - Chorus -Verse - Chorus - Outro
Form II:
This form is characterized by having a buildup Pre-chorus before the first Chorus.
Examples of full arrangements are:
Dua Lipa - IDGAF (18 on the chart):
Intro - Verse - Pre-Chorus - Chorus - Verse - Pre-Chorus - Chorus - C part - Verse - Pre-Chorus - Chorus - Outro
Dennis Lloyd - Nevermind (22 on the chart):
Intro - Verse - Pre-Chorus - Chorus - Verse - Pre-Chorus - Chorus - Chorus
ZAYN - let me (42 on the chart):
Intro - Verse - Pre-Chorus - Chorus - Verse - Pre-Chorus - Chorus - C part - Pre-Chorus - Chorus
Form III:
This form is characterized by shifting from verse to chorus directly.
Examples of full arrangements are:
Ariana Grande - No Tears Left to Cry (2 on the chart):
Intro - Verse --Chorus - Intro - Verse - Chorus -Verse - Chorus - C part - Chorus - Outro
Khalid - Love Lies (14 on the chart):
Intro - Verse --Chorus - Intro - Verse - Chorus - C part
Drake - Nice for What (1 on the chart):
Intro - Verse --Chorus - Verse - Verse II - C part - Chorus - Verse II - Outro
Form IV:
This form is characterized by starting from the Chorus.
Examples of full arrangements are:
Daddy Yankee - Dura (34 on the chart):
Intro - Chorus - Verse - Chorus - Verse - Verse II - Chorus - C part
Kendrick Lamar, SZA - All the Stars (25 on the chart):
Intro - Chorus - Verse - Chorus - Intro - Chorus - Verse II - C part - Outro
Nicky Jam - X (10 on the chart):
Intro - Chorus - Verse - Chorus - Verse - Chorus - Verse - Chorus -Outro
Form V:
This form represents all other forms that I could not fit into forms I-IV since they are too complex, unexpected and I couldn't detect patterns and similarities between songs. They often miss an intro, have a double verse or a D part and have a unique arrangement.
Examples of full arrangements are:
David Guetta, Martin Garrix - Like I Do (30 on the chart):
Verse - Pre-Chorus - Chorus - C part - Verse - D part - Pre-Chorus - Chorus - C part
Shawn Mendes - In My Blood (29 on the chart):
Verse - Verse - Chorus - Verse - Chorus - Chorus - Verse - Chorus - Chorus
Cardi B - Be Careful (46 on the chart):
Intro - Verse - Verse - Pre-Chorus - Chorus - Verse - Verse - Pre-Chorus - Chorus