Introduction
Hey everyone! Thanks to those who have subscriptions to my newsletter and thanks to those who have been reading them. Please take the time (seconds) to subscribe if you haven’t done so already. It’s free and you’ll receive new articles as I publish them automatically in your email. Welcome to any new readers!
Here’s my fifth post in Substack and the second article in my new series “Music Discovery”. In my previous post, “Music Discovery: Article 1”, I described my approach to music composition as a search process. There’s this multidimensional, mathematical, musical space, where all the points correspond to music pieces (melody, harmony, and rhythm). These points correspond to music with various degrees of good, bad or ugly. Of course, one person’s ugly could be another person’s good! The goal is to find the good points; that is, the good music. Perhaps you’re lucky enough to have some deity that reveals the good music to you; Perhaps you’re lucky enough to have a brain wired in such a way that it thinks music; Perhaps you’re lucky enough to have had a mentor who trained you how to create music acceptable to today’s taste. But what if none of these situations apply, what you going to do then? Well, the music is there in that musical space … you just need to learn how to search for it! More accurately, you only need to find a musical point in the neighborhood of a good musical point. Then you can use trial-and-error (tweaking the pitch and duration of notes) along with some music theory to “move” from this initial point to a good musical point. Of course, the closer this initial musical point is to a good musical point the easier it will be to find that good musical point. So, there’s two parts to this search:
Obtain an initial musical point. Recall that this point comes from a space with an infinite number of points, with some unknown number of good points. I’m assuming there are far more bad points than there are good points, so obtaining a good point without the help of a deity is not very likely. At best, you could obtain point in the neighborhood of a good point. So, how do you obtain this initial point? Well, you could build some special dice with notes and with note durations and repeatably toss them to create your melody. You could also create some special dice with chords to generate a chord progression. I use the programming language Python to help me with this search.
Incrementally tweak, massage, or refine that initial musical point, producing a sequence of new points, with each point sounding better and hence converging into a good point. It’s best to make incremental changes, with each change transforming the point into a point closer to being a good point. Here’s where good ears and some music theory can help.
If you had infinite resources (time, people, etc…), you could write down every possible combination of notes, rests, articulations, and ornaments for a specified number of bars and then listen to them all, keeping the good ones and marginally good, fixer-uppers. But you don’t have infinite resources, so this is impossible to do. The best you can do is place restrictions on the search space to reduce the size of the search space and then use some method to obtain a musical point from this reduced musical space. Here are examples of restrictions:
Restrict the search to points that contain only a subset of the possible pitches. In this article, the search will be only for the key of C, with pitches ranging from C3 to C5. You can improve your search by assigning different preferences for the notes in this specified range. You don’t restrict the search space by doing this, but you will be starting in perhaps a better neighborhood.
Restrict the search to points that contain only a subset of the possible note and rest durations. In this article, the search was restricted to those durations between 1/64 to 1/2. This isn’t much of a restriction.
Rather than generating a sequence of pitches that have no statistical dependence on previous pitches, establish some dependency. In this article, unlike in the previous article, only the first pitch of a bar is independent. Subsequent generated pitches in the bar have a statistical dependence on the previous note. This dependency helps reduce the “wild” fluctuations (up and down in pitch) of adjacent notes, resulting in a smoother melody.
Rather than generating a sequence of note durations that have no statistical dependence on previous note durations, establish some dependency. In this article, like in the previous article, the generated note and rest durations are statistically independent. A selected note duration is not affected at all by the duration of the previous notes. Because of this, there was quite a few instances of “wild” fluctuations (wider and narrower in duration) of adjacent notes, resulting in some “choppy” rhythm. This will be the subject of the next post.
Specify a time signature and restrict the search to only a 6-bar riff or solo. Limit or eliminate articulations and ornaments. You could easily add these later (after refining the initial point into a good point) if desired. In this article, I increased the search to a 6-bar riff. In the previous article, I used 2-bar riffs. For both articles, I restricted the search to the 4/4-time signature.
Say that you restrict your search to a melody with the two-octave pitch range in (1) above; you only allow 1/4 note durations; rests are not allowed; articulations and ornaments are not allowed; all generated pitches are independent of previously generated pitches; and only 2-bar riffs are allowed. So, how many possible points are there in this subset of the infinite space? Well, there are 15 possible pitches (C3 to C5 in key of C) and each bar has 4 pitches, resulting in a total of 8 pitches. The number is therefore 15^8, which is about 2.56E9 distinct points. As you can see, an exhaustive search even for such a simple subset is not practical. The best you can do is obtain some musical point in a subset restricted according to your tastes and then massage it to make it sound good. The better that initial musical point is, the less massaging you’ll need to do to produce that good musical point.
A Refined Search Algorithm
The algorithm from the last post was a good start, but there were some abrupt changes between the pitch and the duration of adjacent notes that put the initial musical point for most of the musical samples too far from a good musical point. There were some “wild” fluctuations in pitch and in duration that needed to be massaged. But this was to be expected because there was no built-in dependence of a note’s pitch or duration on previous notes. The pitch and the duration generated was statistically independent of previously generated note pitches and durations.
In the revised algorithm presented in this article, the algorithm will implement statistical dependence on a note’s pitch upon the pitch of the previous note. This will help reduce the “wild” fluctuations in pitch between adjacent notes. The next article will address the “wild” fluctuations in note duration between adjacent notes and will implement changes to the algorithm to minimize them. As shown in the figure below, the first pitch of a bar is selected independently of all other pitches. However, the remaining pitches in the bar depend upon the preceding pitch.
In the figure below, four 6-bar samples generated by the algorithm are pasted together in the music composition and playback software MuseScore. The “wild” fluctuations in pitch common in the previous algorithm are much more tamed! I took this sequence of samples, and made the following types of modifications:
Delete awful sounding bars.
Drop a few notes to bring them closer to the C4 octave.
Modify the pitch of some notes to make them easier to match to a chord that fits the adjacent notes.
Delete notes with durations far removed from adjacent notes. In some cases, I was able to absorb such notes into adjacent notes. Essentially, I was smoothing the progression of note durations. More on this in the next article.
Created some repetition of bars. More on this in the next or a near future article.
Once I had something sounding ok, I added a piano to create some triad harmony. I then modified the pitches of the melody to better fit the chords.
Here is what it sounds like, raw and wild!
Ok, so here’s the massaged version of the original sequence of samples shown above.
Here is what it sounds like after all the massaging!
Hoped you liked it! If you did, please subscribe to my weekly newsletter from Substack!
Here are links to previous posts.