Intro/Ideas:
My original goal for this project was to create a (semi-)randomly generated classical piece in SuperCollider. However, as I began coding/trying to figure out how to use randomness, I decided to create a lofi-type piece instead because it’s more specific, (in my opinion) compositionally simpler, and there’s more opportunity for different SynthDefs.

I listened to a few random lofi songs from the Spotify playlist “lofi hip hop music” to get a better grasp of the chords, the structure, etc. Songs I listened to (with notes I wrote down):
- “Rewinding Memories” by Refeeld and Project AER: low/pulsing drum, higher clap-type around 0:36, bass, guitar around 0:36, shimmering sound around 0:57
- “Until The Morning Comes” by softy, no one’s perfect: nice acoustic guitar
- “Put” by kudo
- “Under Your Skin” by BluntOne and Baen Mow: interesting sound around 1:50
- “Morning Dreams” by Mondo Loops
After listening to the songs and playing around on the piano, I decided to only use 7th and 9th chords and to never have the base of a chord be the leading tone (7th note in the scale). I was also hesitant about the V chord because it’s so dominant (and the lofi I listened to was very calm/didn’t really have the typical tonic-subdominant-dominant chord progression), but I ultimately decided to include it with the caveat that it could not occur more than once within the progression. I also came up with a few other rules…
At this point I realized something — it’s hard to balance randomness and having a piece that sounds good! A fully random piece would sound terrible, but I also didn’t want it to sound too contrived (i.e. have the rules be so rigid that the piece barely changed with each iteration/generation). The chord rules (above) were definitely one of the more contrived sections.
Code!
Next, I started actually coding. I randomly generated a key — using rrand(1, 12) — and a tempo — using rrand(80, 135)/100.
Making Pbinds (generating notes & rhythms)
I decided to start by coding the notes/rhythms for all the different parts (e.g. bass, chords, melody, harmony, percussion). For the chord progression, I just used the .rand, if statements, while loops, and lists. This part wasn’t too bad — I had a few lines to randomly generate which chords would go in the ~chords variable, and then a few more lines for edge cases (ex. if one chord was repeated three times). For the bass (variable called ~bass), I created a ~n_bass (bass notes) variable and a ~r_bass (bass rhythm) variable to later use to create a Pbind. I randomly generated a slow rhythm for the bass (i.e. only quarter notes and slower) using a few lines heavily involving .rand, and then added the chord notes. to ~n_bass. I coded the piano chords (~pc) similarly, with a ~n_pc for notes and a ~r_pc for rhythm. One interesting thing I found out was that 3.rand randomly gives you 0, 1, or 2, but 3.0.rand gives you a random real number from 0 to 3 — this was messing me up because I was multiplying a variable by decimals at one point, but wanted to do (that variable).rand. To fix this, I used .round.
Afterwards, I created the melody (~mel1) Pbind (with the associated variables ~r_mel1 and ~r_mel1) — for this, my rules were that it would have 2-5 notes per measure and be all 8th notes or slower. I also wanted to create a melody’ (~mel1b) that was basically the same as the original melody but more active — i.e. with some added notes (2-4/measure) and a more active rhythm. I also ran into a problem here because I wanted to use .insert but it only works for Lists, so I had to go back to all my initializations and change the Arrays (the automatic class when you do something like ~variable = [1, 4, 0]; ) to Lists.
The following is an example recording of what I had at this point — bass, chords, and melody (so far, with a very basic Synth that I pulled from a previous project; no effects and no percussion).

The above picture is an example of what I had in my post window (not corresponding with the above recording): the key (+ 12 would be 12 semitones up from C, so still C); the chords (the progression is 3-3-0-5 (so IV-IV-I-vi), and the fifth note represents the inversion (here, since it’s 0, the chords are all in root position); the melody notes, and the harmony notes.
Making Synths
For the bass, I used PMOsc.ar and applied a low-pass filter. I wanted to have three other distinct melodic sounds: one for the chords, one for the melody, and one for the harmony. For the chords, I wanted the sound to be relatively muted/not too twangy (like the beginning of “Morning Dreams” or around 0:40 in “Under Your Skin”), so I mixed Formant.ar and SinOsc.ar, and then applied a low-pass filter at 400 and a high-pass filter at 200. For the melody, I used the same SynthDef as for the chords, but I changed the envelope, filter, and reverb settings. Lastly, I’d really liked the acoustic guitar in “Rewinding Memories”, so I used a mixture of SinOsc.ar and Pluck.ar to create a guitar-like SynthDef.
For the percussion, I also wanted to emulate the sounds in the songs I had listened to. I created a kick based off of the one in “Rewinding Memories” (see picture below).

I struggled for a long time on the higher, snare-type sound. I really wanted it to sound like the higher percussion in “Rewinding Memories” around 0:45 (which I realize probably isn’t a snare, but I called it a snare for lack of a better word), but mine ended up sounding pretty different. Overall, I was the happiest with my kick and my guitar sounds.
Other Synths
I created a “compression” SynthDef using Compander.ar, and a “dynamic” SynthDef that (per its name) takes a Pbind and changes its dynamic level.
Percussion Pbinds
After creating the percussion synths, I coded the rhythms similarly to how I did the bass — I didn’t want the drums to be too active (because the lofi beats were all pretty mellow), so I restricted the rhythms to 8th notes or slower. However, I did include the possibility for one 16th or 32nd in the kick (see picture).
In the picture to the left, there is a 3/5 probability that there is a 16th note or 32nd note — i.e. that we randomly choose one of the notes in ~r_kick and split it into a 16th or 32nd note and another duration (that when added to the 16th or 32nd note yields the duration of the original note we split).
The following is an example of what I had at this point: chords, kick, snare, bass, and melody.
Ordering/Structure:
I didn’t really know how to use randomness in the structure while still maintaining a semblance of a regular song progression, so this part also had a more rigid structure: I just completely wrote out two different possibilities (one starting with the chords, and one starting with the melody/bass), and then used .rand to randomly determine which one to use each time. The songs I listened to tended to start quietly, with just one or a few sounds, and then build, and then would suddenly drop out, build again, and then slowly fade out.
Option 1: starting with chords
Option 2: starting with melody/bass
Editing/Progression of Recordings
Note: if you’re going to listen to one, listen to recording 13 (my favorite of the ones below)! I also like the second halves of both 11 and 14.
Recording 7:
Recording 8: added a pan to the guitar/harmony (which comes in around 0:50)
note — needs more reverb/notes need to last longer
Recording 10: added quieter dynamics to the beginning/end, added compression around this point (might have been after this recording, not sure)
Recording 11 part 1: edited bass length
note — chords sound too gritty/full, especially during middle section — they’re detracting from the other instruments
Recording 11 part 2: I liked the harmony (technically melody 2) in this one, which comes in around 50 seconds to the end, or 30 seconds into this recording.
Recording 12: edited dynamics, added code to randomly remove 0-2 notes from each chord; I didn’t like the melody of this one as much, but I liked the chord progression
Recording 13: added more editing on the chords; one of my favorites!
Recording 14: just another example (split into 2 because too long)
Closing thoughts:
Like I brought up earlier, this project was definitely about striking a balance between true randomness and creating a piece that sounded good. I definitely think that choosing a lofi piece (rather than sticking with a more traditional/classical genre) made it easier to have randomness, since there was more freedom for the melodies and the chord progressions. Overall, the piece is far from random — it has my style/traces all over it in the choices that I made (for example, the rules for the chords, or the rhythm durations for each instrument).
Extensions
There were a few things I wanted to do that I either couldn’t figure out or ran out of time for/decided not to prioritize:
- using Markov chains: I was debating whether or not to use Markov chains (specifically, ShannonFinger, which is part of MathLib) from the beginning. My initial reluctance was because ShannonFinger is based off of some sort of data that you input, so whatever the product turned out to be would be very similar to the data I chose (and I didn’t want that — I wanted something entirely new/more unique). However, if I had more time, I think it could be beneficial (melodically) to use ShannonFinger for the melody and the harmony to make it sound more like real music — the only problem is that I would have to figure out how to use that while still keeping the notes primarily in that measure’s chords.
- fade effect: I wanted to figure out how to make the volume of a Synth fade without having to create a near-identical Synth where I edited the \amp. I tried creating a SynthDef (in fact, this is where my “dynamic” SynthDef originated), but couldn’t figure out how to change the argument in the midst of applying the effect to a sound (i.e. Pseq didn’t work like it does in Pbind). I also tried to figure out if I could apply an FX synth to the middle of another synth (nope), and even tried using CmdPeriod.run to completely break off the sound (but that threw errors).
- figuring out more randomness in terms of structure of the piece
- continue to clean up the sound of the instruments
- opening & closing ambience: a lot of the lofi pieces I listened to had atmospheric noises (air, creaking doors, etc.) in the beginnings and ends that I really liked. A SynthDef to make a creaking door sound or a rain sound would be an interesting project
- in a similar vein, some of the pieces I heard had sort of “shimmering” sounds that would be interesting to try to replicate in SuperCollider




















