Making music with Strudel

My computer system for transcribing music from audio data is working at a basic level. The other end of my problem, to generate music that has been composed, was still unsolved. That is until I saw Switch Angel on youtube. She uses Strudel to create music using javascript with special musical functions which she explains for her watchers.

Live coding music with Strudel.

Strudel is the official javascript port of the Haskel program Tidal Cycles . The Haskell version looks cool, but I went with the zero-setup javascript option in browser at studel.cc. The user writes javascript to instruct an interpreter to generate music in the browser. It comes loaded with many instrument samples, drum machines, and synthesized instruments.

I have enjoyed putting on a song and trying to write something on the spot inspired by what I’m hearing. The other day I put on Getting Killed by Geese. To start, I set the cycles per minute using the setcpm function. It starts with a steady 4/4 rhythm somewhat energetic but a bit weighed down. I adjust the CPM value until it matches the intro I’m listening to. I create a four on the floor bass drum pattern with the s() function. This is an alias for sound() and saves four keystrokes.

Four on the floor bass drum pattern

This means that strudel with generate music by playing 25.5 cycles per minute. If you write music in 4/4 time, this equates to 102 beats per minute.

Next, I’ll add a guitar part. For now I’ll keep it simple by repeating the tonic note F# four times. The duration of each note is divided equally around one cycle. So, by writing bd four times, I get four equally spaced notes in a cycle. Conventional music notation, this would be four quarter notes of F#.

Adding a guitar part

The intro to this song has a heavy distorted guitar chord part with two measures of F# and two measure of E. There are two ways to write chords. You can simply write the notes you want to use with commas and they will be played at the same time. This gives fine control over how chords are voice but requires some music theory knowledge. Another way to create chords is to use the chord() function which accepts chord names. By calling the .voicing() method on the output of the chord function, it creates notes that are in those chords. The voicing method gives you some control on how the notes of the chord are chosen. Here I am using both methods n() and chord().voicing() to create the chords of the song.

Two equivalent ways to create F# and E chords

The n(0,4,7) is a F# major chord. Similarly, n(-2,2,5) is an E chord. The numbers correspond to steps in the F# chromatic scale. I specify the scale to use by calling n(“<[0,4,7][-2,2,5]>”).scale(“F#3:chromatic”). The string input to n() uses mini notation. This notation comes from Tidal cycles, so you can refer to either the Strudel mini notation documentation or the Tidal Cycles mini notation documentation to see how it works. Mini notation uses <a b> to denote alternation between notes a and b, once each cycle. Using the !8 causes the cycle to use the first alternation item 8 times, then use the second alternation item 8 times. I want four beats per measure, so I slow down the rhythm by half using .slow(2). Now I have a four bar phrase F# F# E E that repeats.

Next, I’ll add a bass line.

The bass uses a F#1:chromatic scale. So 0 (zero) represents the low F# on a bass guitar. I’m using the mini notation to create a pattern the alternates between 0 and one of two two-note phrases (E F# and C# E). Next I added some effects to the guitar and added a E# (the major 7th to F#) every four cycles. Then I added a vocal track. I tried singing to the reference song by Geese and I think the first note of the melody is the 5th, so the melody starts on number 7 (C#). Strudel does not have a voice generator I can find, so his lyrics won’t be included. The gm choir aahs synth gives a human like vocal quality but cannot be programmed with real words.

A bass line, vocal melody, and drum part inspired by Getting Killed by Geese

The vocal part I wanted to come in after 8 cycles. So I created a variable gain using mini notation and a .slow(8). This gives me a gain of 0 or 1, alternating every 8 cycles. So, I can hear the rest of the instruments first, then add the vocal melody after 8 measures. Doing this, the interpreter is playing the notes of the pattern, but they are not audible due to zero gain. Another way of achieving the same effect would be to write them as rests in the pattern. The actual notes I chose are not exactly the same as in the original song. They are inspired by it.

Dan Snyder

Data vis for my hobbies: vinyl records, plants, computers

Previous
Previous

Musical Intervals and Lissajous curves

Next
Next

An algorithm to detect chords