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!
This is the sixth post/article on my newsletter! It’s hard to believe and what’s even harder to believe is that these posts are about music composition, which is definitely not one of my areas of expertise! I guess that’s something that popular writers quickly learn: Don’t let ignorance of something prevent you from writing about it! Politicians are born knowing this … recent politicians have even learned to present themselves as experts in areas where they are completely bankrupt! Ok, enough of politics!
In this article, I will present an improved version of the Article 2 Algorithm that does the following:
The “wild” fluctuations in adjacent note durations are “tamed” or smoothed to rid the sample points that abrupt choppiness appearing in the points of the previous algorithm. This choppiness can definitely mess with your digestion of the rhythm, resulting in a nauseous feeling, much akin to tumbling in the surf after being hit by a giant wave on the northern shore of Hawaii! This new algorithm accomplishes this the same way that the previous algorithm tamed the “wild” fluctuations in pitch. The duration of the first note or rest in a bar and at the beginning of a half-bar will be randomly selected without any dependence on previous notes. However, the remaining notes and rests will be selected with a probability that favors a duration not much different than the previous note or rest duration.
More control of the “wild” randomly applied syncopation is implemented. The previous algorithm always placed a note on the first beat of a bar. It could be any duration, but always occurred at the beginning of the bar. After that, anything could happen, especially due to the independent random selection of the note and rest durations in the bar after that initial note. In this algorithm, the notes at the beginning of a bar and at the beginning of each half-bar are independent. This ensures that the first and third beats of the bar has a note synchronized to the beat. There will still be randomly applied syncopation at both the second and fourth beat. The algorithm allows for synchronizing at the quarter beat and the three-quarter beat, but I didn’t like the samples as much.
Repetition is incorporated into the musical sample or point. Music without repetition overwhelms the listener … the brain’s deep memory storage will overflow eventually after a series of nonrepeating pitches, rhythms, or intervals. What I have discovered is that even a not so good bar of notes sounds much better if you repeat it. I guess it’s similar to meeting a weird looking person. At first you may want to avoid him, but once you get to know him, he could become a friend. A short riff of choppy rhythm or choppy pitches is somewhat smoothed by the right amount of repetition. The new algorithm generates this repetition. More about this will be presented later in the article.
The New Algorithm
A lot of changes were made in this new algorithm. The changes to the probabilities for the notes and durations is shown in the figure below.
Note that the table values are relative probabilities. The higher the number, the more probable a value will occur. Note the tables for both the pitch and duration, which show the sliding window of probability that minimizes the “wild” fluctuations in note duration and in note pitch between adjacent notes.
In the previous algorithm, a new independently random note pitch and note duration only occurred at the beginning of bar. In this new algorithm, you have the flexibility to have independent values at half-bar, quarter-bar or any other sub-bar interval. All the remaining notes and rests have values dependent upon the previous note or rest. I first tried the quarter-bar intervals. It did get rid of the random syncopation at beats 2, 3, and 4, but there were sometimes unwanted fluctuations at these boundaries and now the largest possible note duration was a quarter note. As a compromise, I chose the half-bar approach.
It’s amazing to me how a poor-sounding bar repeated several times begins to sound better! Taking advantage of this, I came up with a pattern that repeated the bars. Here is the process:
Generate 6 half-bar samples with the algorithm.
Combine these half-bar samples into 3 bars, identified as bar1, bar2, and bar3.
Arrange the bars in the following sequence:
[bar1, bar1, bar2, bar1, bar2, bar2, bar1, bar3]
Tweak on the final bar3 to make it finish good. For example, make the notes converge to the tonic (C in this program), and end on a longer duration note.
This algorithm also allows you to add another musical melody part. I tried the following:
A second part identical to the first part but transposed downward by some combination of fourths and fifths.
A second part where each of the bars have notes reversed in time from the first part. This gave some really weird sounds! There were no devil sounds and no mention of John either.
The algorithm even allowed me to add a third part consisting of 2 note chords made from the above two parts. As you can see, there were some big changes in this algorithm!
New Music: Music Discovery Article 3 Algorithm
Below is the sheet music for one of the samples:
Here is just the first part, an electric guitar with a square-wave soundfont:
Here is the complete composition, with all three parts:
Here is an interesting sample using the backwards approach for the second part:
Weird, but I kind of like it!
Summary
At this point (post # 6) in my journey towards understanding how music works and how to compose it, I’m not trying to recreate existing music or extrapolate upon some other composer’s work (how boring!); instead, I’m using statistical methods to search the infinite musical space for music points that sound good to me. It would be nice if others liked it too! My facebook videos and future game videos would be more entertaining if the music were enjoyable.
In future articles, I will continue to refine my search methods. Here are some topics I’m considering for future articles in this Music Discovery Series:
What is the fundamental unit of a melody? A note? A bar? A phrase? What information can be extracted from these potential fundamental units? How is such a fundamental melody unit related to other units in the same melody?
How do you transform an ugly melody into a pretty one? What makes a melody ugly? What makes a melody pretty? What is a good musical point? Is it just a popularity contest? If 20 people like it, then it’s a good point? Or is it an intrinsic property of a musical point? Can it be good if no one has ever heard it?
Are rests more important that the notes? What if instead of focusing on the notes you instead focused on the rests when composing a melody?
Are the intervals between notes in a melody more important than the notes themselves? My algorithms presently randomly select notes and durations. With the smoothing modifications made on this version and the previous version algorithms, some of this was performed indirectly. What if I focused the search on intervals between notes of a melody instead of the actual melody notes?
What if you define a scale as several octaves of allowable pitches in a composition. Assume these pitches are arranged in order of increasing frequency. Suppose further you define a mode as a particular “home” pitch that you tend to never stray away from for too long. Is it easier to make interesting melodies or chord progressions by working with a mode? Will it write itself if you pick the right mode? For example, suppose you discovered a “bad” melody in the C major scale. If you transposed the melody through every note in this scale, would you eventually find a mode in this scale where the melody sounded good? Can mode adjustment “fix” bad melodies?
The present algorithm generates melodies. What if I modified it or created a new one that would instead create chords? Would it better search out the good musical points?
With the presented algorithms, I usually crank out no more than 3 to 4 samples and if it sounds ok I stop and begin my tweaking. But what if I just kept cranking out samples until something requiring no tweaking appeared? How long would it take? What if I searched for a simple melody like “Mary had a Little Lamb”, “Three Blind Mice”, or “Twinkle Twinkle Little Star”? How long would it take me to find them with my latest algorithm? After all, the algorithm is a search engine for the infinite space of musical points!
What about applying Artificial Intelligence to this search process? Well, the algorithms I developed so far are AI. They are rule based with statistical rules. How about the State Machines? How about Fuzzy Logic? How about Artificial Neural Networks? How about a Genetic Algorithm? My goal is to apply each of these to my search of the infinite musical space in an AI Series of articles.
Thanks for reading. Please subscribe if you liked it!