top of page
Search
  • Peter Ivan Edwards

Shuffled: Part 1, in which random permutation is introduced

It is well known that computers assist musicians daily in creating music. Every song on the radio today is the result of recording, editing, mixing, and processing tracks in a computer, which ultimately yields a WAV file that's uploaded to Spotify. Mixing "in the box", as digital mixing on a computer is called, is the de facto way to make songs. For those who write acoustic music, the computer is also a common tool. Composers today largely no longer write scores by hand. They use software like Finale, Sibelius, and Dorico. There is an enormous industry of virtual synthesizers and FX processors. There are websites dedicated to downloadable loops and samples for music production. The computer is where most music is made today. But the above are examples of the computer assisting musicians in recording their music, that is, putting the musical ideas into a retrievable form like a WAV or PDF file. The computer isn't composing the melodies or selecting the harmony. Instead, that work remains the domain of the composer.


There are some composers who use the computer to determine the pitches, rhythms, dynamics, and other elements of their music. This approach is called algorithmic music or computer-assisted music, and it will be the focus of this blog. So, while it's completely accurate to say that your favorite song on the radio has been created using computer-assisted means, that's not the kind of computer assistance dealt with here.


My goal in this blog is to write works or at least passages of music over a series of posts. I will start with the commonplace instrumentation of solo piano. Additionally, I hope to focus on a specific issue or approach with each work. With this first piece, it will be random permutation.


Random permutation is the random ordering of a series of values. If [0, 1, 2] is randomly permuted, then a few possible outcomes, aside from the original, would be [2, 0, 1] and [1, 2, 0]. Note that there are no repeated values. We are not randomly selecting 3 values. Instead, we are randomly ordering the 3 values. (I'll look at random selection in the next piece.) In music we commonly use the 12-note equal-tempered system, that is, C, C#, D, D#, etc. We can represent this abstractly with numbers [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].


The computer can generate a randomly permuted series of all 12 notes.


(rnd-order '(0 1 2 3 4 5 6 7 8 9 10 11))

Above we have a function - a small computer program - called rnd-order and a list of integers from 0 to 11. The rnd-order function takes this list and simply returns a new list with all of the same values in a different order. A result might look something like the following:


'(2 1 9 8 3 5 4 10 0 11 6 7)

Note that the apostrophe just defines what follows as data rather than a function that needs to be evaluated. I work within a music programming environment called OpusModus, which is based on the programming language Common Lisp. This is the syntax to create a list of elements within that language.


The task we've handed the computer is very simple. We could do this ourselves. But what if we wanted to do it 300 times? The computer would be better for this task for several reasons. First, it will be much faster. Second, it won't make a mistake. (Trust me, if you did this simple task 300 times, some of your lists would have repeated values in them or be missing values.) Third, the computer won't complain about how tedious and mundane the work is. Parents out there will all recognize the value of this last point. What would that look like? Writing the code to create 300 versions must be a lot of work! Nope.


(loop repeat 300 collecting 
  (rnd-order '(0 1 2 3 4 5 6 7 8 9 10 11)))

A loop repeats 300 times. With each repetition, the code for creating a randomly permuted list is run and the result is stored with all of the other randomly permuted lists generated. After the program creates 300 lists, it spits them out as a list of sublists. The result is quite nice to look at, especially as you scroll. It's like something out of The Matrix.


'((6 5 10 11 4 9 2 0 3 7 8 1) (8 5 4 6 11 10 3 9 2 1 7 0) (6 1 2 8 4 0 9 3 7 10 11 5) (3 7 11 8 10 5 2 1 0 4 6 9) (10 3 4 6 2 9 0 5 7 1 8 11) (3 6 9 2 0 1 5 7 8 10 11 4) (3 2 10 0 5 4 9 8 1 11 7 6) (3 4 5 2 11 10 1 0 8 9 6 7) (6 8 0 3 4 1 11 5 7 2 10 9) (2 4 10 7 5 6 0 9 3 11 1 8) (4 2 8 10 11 1 9 7 0 3 5 6) (7 9 5 8 0 11 6 2 4 3 10 1) (0 1 6 11 4 9 2 10 7 3 5 8) (5 4 1 11 10 2 6 0 3 9 7 8) (3 1 6 5 11 9 8 10 4 7 2 0) (0 4 3 7 1 5 2 8 10 9 11 6) (9 3 11 4 8 0 2 7 10 6 1 5) (4 0 9 6 1 10 3 2 7 8 11 5) (7 2 9 11 8 1 5 0 10 4 6 3) (7 11 2 1 6 8 3 10 9 0 4 5) (6 9 4 10 7 5 8 11 0 2 1 3) (8 7 1 11 2 4 6 0 10 5 9 3) (11 7 8 5 3 0 6 1 2 4 10 9) (11 3 9 8 1 2 4 5 7 0 6 10) (11 4 5 0 8 10 9 3 7 1 2 6) (11 9 2 7 0 6 10 5 8 4 1 3) (1 11 9 8 4 6 7 2 5 0 3 10) (9 5 6 4 11 7 10 8 0 2 1 3) (10 3 2 7 0 8 11 5 4 6 9 1) (7 6 3 1 11 0 10 5 8 9 2 4) (8 4 3 5 2 11 0 7 1 9 6 10) (10 1 8 0 6 5 9 7 2 3 4 11) (10 2 11 3 0 8 9 7 4 6 1 5) (5 7 8 3 11 0 1 2 9 6 10 4) (2 6 11 8 5 1 3 10 9 7 4 0) (7 2 6 0 10 9 8 11 3 5 4 1) (2 1 3 9 4 0 11 10 7 6 5 8) (4 9 10 6 7 3 11 2 8 1 5 0) (0 8 6 2 10 9 3 5 7 11 1 4) (7 9 2 11 8 1 0 4 6 3 10 5) (8 7 1 0 4 3 6 9 11 2 5 10) (0 7 11 4 10 2 8 3 6 9 1 5) (1 5 4 8 6 0 9 2 7 10 11 3) (6 11 7 5 8 1 9 10 3 2 0 4) (9 6 8 5 11 2 4 0 7 1 3 10) (6 9 8 2 5 7 3 0 1 11 10 4) (7 4 5 9 8 11 10 1 6 0 3 2) (10 3 7 2 6 11 8 9 0 4 1 5) (4 6 11 10 8 0 3 7 2 5 1 9) (1 0 4 6 2 5 11 3 10 8 9 7) (10 0 9 4 6 3 1 2 11 8 7 5) (8 3 10 11 2 9 0 6 4 1 5 7) (6 8 2 4 5 10 9 1 11 3 7 0) (4 6 11 9 10 1 5 2 8 7 0 3) (10 1 7 3 6 2 9 11 5 0 4 8) (9 3 10 6 7 5 4 2 1 0 8 11) (1 5 0 3 7 6 4 8 9 10 11 2) (9 2 1 0 3 10 7 5 4 6 11 8) (11 6 2 10 9 4 0 8 1 7 5 3) (5 9 2 8 4 10 11 7 6 0 3 1) (11 6 2 7 9 1 5 4 8 3 0 10) (8 6 11 4 7 5 0 2 9 1 3 10) (11 3 5 2 4 9 6 7 8 0 10 1) (2 4 8 9 1 7 11 0 6 5 10 3) (11 9 0 6 10 1 7 4 3 2 5 8) (7 3 9 0 5 2 10 11 8 1 4 6) (0 3 1 5 9 4 2 8 6 11 10 7) (2 5 6 8 0 4 1 3 11 9 7 10) (4 5 11 8 10 7 1 2 3 6 9 0) (11 0 9 7 1 10 4 5 8 6 2 3) (0 11 7 4 3 8 6 2 1 9 5 10) (9 10 4 3 11 6 8 7 1 5 0 2) (9 0 1 10 4 7 5 6 2 8 11 3) (2 10 11 4 5 3 8 0 7 9 6 1) (9 6 11 10 4 0 8 7 3 1 5 2) (9 10 3 0 8 7 5 6 4 1 11 2) (2 4 6 9 11 3 10 1 7 8 0 5) (1 9 3 2 4 7 8 6 5 10 11 0) (1 2 5 4 6 11 10 7 9 8 0 3) (8 7 4 10 11 1 3 5 0 6 9 2) (10 1 6 9 5 11 8 3 7 4 0 2) (9 8 7 10 1 4 11 2 5 3 0 6) (6 7 9 11 0 8 5 3 4 1 10 2) (3 10 8 6 1 7 2 0 4 9 11 5) (5 11 2 10 3 9 1 6 4 7 8 0) (2 0 6 1 10 9 5 4 7 8 3 11) (2 4 5 11 9 7 8 10 6 0 1 3) (2 1 9 10 11 7 3 8 0 5 6 4) (11 8 4 9 6 7 5 3 0 10 2 1) (8 1 0 7 6 4 11 9 3 2 10 5) (9 5 0 11 1 3 4 6 2 10 7 8) (5 2 3 9 6 0 10 7 11 1 8 4) (3 9 4 6 8 7 11 2 5 0 1 10) (7 3 9 0 8 10 6 11 5 2 1 4) (2 3 0 10 11 9 6 1 8 7 5 4) (5 11 7 9 2 4 6 8 10 1 3 0) (3 2 1 10 9 6 7 11 5 4 0 8) (3 11 2 7 8 10 0 1 9 4 5 6) (7 4 5 0 9 6 11 2 10 3 8 1) (1 6 4 5 2 7 10 0 8 11 3 9) (2 11 0 7 4 10 8 6 1 9 3 5) (4 1 5 9 11 8 10 3 2 6 0 7) (2 6 9 3 8 1 10 11 7 5 0 4) (6 10 3 5 2 7 8 11 1 0 9 4) (3 4 2 10 0 1 11 7 5 9 6 8) (11 8 3 6 10 4 7 0 5 2 1 9) (9 1 8 5 0 10 2 7 4 6 3 11) (1 11 9 4 6 3 5 2 10 8 0 7) (9 3 8 1 10 2 11 5 6 7 0 4) (6 0 3 7 9 8 11 10 5 1 4 2) (3 10 2 8 7 1 5 0 4 11 9 6) (8 1 4 2 5 0 3 9 6 11 10 7) (3 4 10 2 6 11 1 5 7 9 0 8) (11 8 5 0 9 10 7 2 1 3 6 4) (7 4 8 11 1 0 2 3 10 6 5 9) (6 4 8 5 0 2 11 3 10 7 9 1) (2 1 8 3 9 11 10 6 5 7 0 4) (6 1 3 7 5 9 0 2 11 4 8 10) (9 7 5 0 10 2 4 6 11 3 1 8) (11 2 7 6 0 4 9 8 10 5 3 1) (3 5 11 10 6 4 1 2 0 9 8 7) (7 11 5 1 6 2 9 0 10 3 8 4) (2 1 8 9 0 5 7 11 4 10 3 6) (9 3 4 6 8 2 11 1 5 0 10 7) (3 5 8 2 4 7 11 10 1 6 9 0) (5 6 1 3 4 10 9 2 8 11 0 7) (8 10 4 1 0 11 2 9 5 6 3 7) (2 5 3 0 11 4 9 10 1 8 7 6) (11 2 4 0 6 1 7 5 10 9 8 3) (4 2 0 1 7 8 5 10 6 3 11 9) (2 1 11 0 3 8 4 10 5 6 7 9) (1 3 4 9 5 8 11 0 10 2 7 6) (2 1 9 0 10 7 8 11 5 3 6 4) (7 5 11 10 1 8 3 4 9 6 2 0) (8 2 4 3 10 7 0 9 11 6 5 1) (5 1 0 2 9 6 7 11 10 3 4 8) (9 4 8 10 5 2 3 6 0 1 11 7) (4 6 10 9 8 0 1 3 7 2 5 11) (0 3 10 1 5 11 9 7 4 6 2 8) (9 5 8 0 1 6 4 7 11 2 10 3) (7 1 3 4 6 0 8 11 10 5 9 2) (1 10 9 6 5 4 3 7 2 8 0 11) (0 6 2 5 8 11 3 10 1 9 7 4) (0 4 2 7 6 8 9 10 11 5 1 3) (8 4 7 9 10 0 6 2 5 1 3 11) (6 7 5 9 11 1 10 8 2 4 3 0) (2 11 6 3 1 8 9 7 10 4 0 5) (9 3 1 5 0 6 7 4 11 10 8 2) (6 10 4 8 5 7 0 11 2 9 1 3) (6 11 4 0 3 8 2 10 7 9 5 1) (2 9 11 3 5 10 8 4 0 6 1 7) (7 0 1 9 11 8 5 2 4 10 6 3) (2 10 0 7 11 8 3 9 4 6 5 1) (2 0 7 6 4 1 3 11 9 5 8 10) (0 4 3 10 9 2 1 11 6 8 5 7) (8 0 11 9 7 3 2 6 5 4 10 1) (9 10 4 2 8 7 1 11 3 5 0 6) (9 4 5 3 8 1 10 2 11 7 0 6) (8 9 4 2 3 5 7 1 6 0 11 10) (1 9 7 6 5 3 0 2 8 11 10 4) (3 8 0 10 5 9 2 6 7 1 11 4) (8 5 6 2 1 0 10 9 3 7 11 4) (10 11 2 1 9 5 8 3 0 4 7 6) (7 3 10 8 0 1 9 6 5 11 4 2) (3 1 6 7 8 11 9 10 0 4 5 2) (7 10 4 5 11 3 8 0 2 6 9 1) (1 5 0 4 9 8 7 2 3 10 11 6) (10 6 2 3 9 11 1 8 4 7 0 5) (11 6 7 8 10 3 2 5 9 1 0 4) (1 8 5 2 6 11 3 4 0 9 7 10) (3 10 7 1 2 8 11 4 6 5 0 9) (7 5 1 8 9 4 10 2 0 11 3 6) (9 11 7 2 10 1 3 0 6 5 8 4) (0 10 5 3 1 9 4 8 2 7 11 6) (0 3 5 6 1 9 2 11 8 7 4 10) (5 4 9 0 11 10 2 1 7 8 3 6) (9 11 8 5 0 10 1 7 3 2 4 6) (6 3 9 11 1 5 8 2 0 4 7 10) (5 11 10 8 4 7 1 2 3 6 0 9) (10 4 6 8 7 11 5 2 1 9 0 3) (9 3 11 2 5 1 4 10 6 7 0 8) (0 3 2 11 8 10 1 9 6 5 4 7) (4 8 7 9 1 2 6 5 0 3 10 11) (1 11 7 5 2 3 10 9 8 6 0 4) (5 3 7 1 8 6 10 11 0 4 2 9) (5 10 8 1 11 9 7 3 2 6 4 0) (1 5 9 2 6 3 0 10 11 8 7 4) (11 10 9 1 7 6 4 3 8 5 2 0) (8 7 10 5 11 9 6 3 1 0 4 2) (6 7 2 11 8 1 5 9 4 10 3 0) (7 5 10 2 6 1 0 4 11 8 3 9) (2 1 10 5 6 4 7 0 3 11 9 8) (11 10 2 6 4 9 7 3 0 8 5 1) (11 8 4 10 0 7 5 3 6 1 2 9) (5 3 8 4 9 7 0 1 10 11 2 6) (11 4 2 1 10 9 6 7 3 5 0 8) (0 11 8 2 5 9 10 4 7 1 3 6) (11 0 7 1 5 4 8 3 2 6 9 10) (0 9 4 10 7 3 8 1 11 2 5 6) (8 7 6 1 10 0 5 2 4 9 3 11) (8 11 7 4 9 0 10 5 1 3 2 6) (1 6 2 10 0 11 5 7 8 9 3 4) (3 0 5 6 4 11 2 9 7 10 8 1) (0 2 4 9 7 1 11 5 10 6 8 3) (11 7 9 5 0 2 6 10 3 4 8 1) (5 0 4 8 9 6 1 11 10 7 3 2) (3 0 11 4 5 10 8 2 9 6 1 7) (3 6 11 2 7 9 1 4 8 5 10 0) (11 10 6 7 3 8 0 5 1 9 4 2) (9 11 1 0 8 7 3 6 10 4 5 2) (0 9 4 6 10 3 2 11 7 8 5 1) (10 6 0 7 5 3 8 1 11 2 4 9) (0 7 11 6 5 10 9 3 1 8 4 2) (11 1 6 4 2 0 7 10 8 5 9 3) (8 2 10 0 1 9 5 7 6 11 3 4) (1 2 4 11 7 0 8 6 3 9 10 5) (11 10 5 4 1 9 3 6 7 8 0 2) (0 10 7 5 1 2 8 6 4 9 11 3) (9 6 0 1 4 11 8 7 2 3 10 5) (9 10 6 1 0 5 2 3 11 4 7 8) (5 6 10 2 3 7 1 0 9 4 8 11) (6 0 11 4 1 10 9 2 5 8 7 3) (5 7 2 9 11 3 1 4 6 10 0 8) (3 4 5 8 9 6 0 11 7 1 10 2) (10 4 0 3 11 1 2 7 9 6 8 5) (5 8 2 9 3 0 10 4 1 7 6 11) (6 1 4 8 11 0 2 3 7 5 10 9) (3 1 0 2 7 11 9 6 10 8 4 5) (0 2 1 10 8 11 7 6 4 5 3 9) (1 9 6 10 3 8 11 7 0 4 2 5) (3 9 11 7 6 1 8 2 5 10 4 0) (6 8 10 1 11 9 7 4 5 3 2 0) (11 10 1 8 9 0 7 3 4 5 2 6) (11 0 5 8 1 2 9 7 3 4 10 6) (2 11 1 6 10 0 5 4 3 8 9 7) (2 1 6 4 9 3 10 7 5 0 8 11) (0 6 3 1 7 9 4 11 8 10 5 2) (2 7 11 3 4 9 0 8 5 1 6 10) (8 3 1 11 9 5 0 2 4 7 6 10) (7 5 8 3 2 10 6 0 1 9 11 4) (2 7 9 5 11 1 3 4 6 0 8 10) (8 4 3 10 0 1 5 11 2 6 9 7) (7 9 10 6 2 3 4 1 11 5 8 0) (1 4 0 2 9 5 11 8 7 3 6 10) (6 9 3 2 11 7 10 5 1 0 4 8) (7 3 4 9 0 2 8 1 11 6 5 10) (4 5 8 10 6 9 11 2 3 1 7 0) (0 6 1 7 4 3 2 8 10 9 5 11) (9 10 0 8 2 7 11 3 5 4 6 1) (7 8 5 3 0 4 2 10 11 1 9 6) (2 6 7 0 5 3 11 8 10 4 1 9) (4 5 2 0 10 8 6 9 3 11 1 7) (10 5 3 8 7 1 4 6 0 11 9 2) (10 1 2 11 0 7 8 9 5 4 3 6) (10 3 4 9 6 2 1 8 0 11 7 5) (0 11 4 6 3 8 10 5 2 7 9 1) (5 8 10 4 9 3 1 0 6 7 11 2) (1 2 4 11 7 9 0 10 5 8 3 6) (6 1 3 2 11 9 7 4 8 0 10 5) (7 4 9 10 8 11 5 6 3 0 2 1) (1 6 3 4 10 8 11 9 0 7 5 2) (0 1 6 11 3 9 8 7 2 4 5 10) (10 3 9 4 6 5 2 11 8 0 7 1) (7 1 2 10 9 11 0 3 4 6 5 8) (7 8 0 2 11 6 4 10 1 5 9 3) (2 7 1 6 4 8 10 5 11 3 0 9) (6 0 7 1 10 5 3 2 8 4 9 11) (7 0 6 10 5 9 4 3 11 2 1 8) (10 1 2 0 8 9 3 7 5 6 4 11) (3 6 11 9 2 5 8 4 0 7 10 1) (8 9 7 11 10 3 0 1 4 5 2 6) (4 3 6 9 0 5 1 7 2 11 10 8) (0 3 6 5 1 4 2 11 8 9 7 10) (9 10 1 4 8 0 6 3 2 11 5 7) (8 4 7 6 2 3 5 9 11 1 0 10) (2 8 9 7 5 11 0 1 10 6 3 4) (8 4 3 1 10 11 2 5 9 6 7 0) (10 1 5 8 3 7 11 4 0 6 2 9) (3 5 0 11 1 9 6 4 8 10 7 2) (5 11 2 7 3 1 0 6 9 4 8 10) (3 1 5 9 4 7 0 8 11 10 2 6) (1 8 2 5 10 4 7 0 11 3 6 9) (5 11 3 7 2 0 8 1 6 4 9 10) (5 8 11 6 0 9 2 1 4 10 3 7) (9 7 1 4 3 10 5 6 11 0 2 8) (6 7 4 2 9 8 1 5 0 10 3 11) (3 2 11 1 0 7 5 10 8 9 4 6) (9 6 0 3 1 4 5 2 8 10 7 11) (2 5 8 6 1 10 7 3 9 0 11 4) (0 4 7 6 11 9 1 3 10 8 2 5) (2 7 4 5 11 1 3 9 10 6 0 8) (10 2 7 11 0 8 6 3 9 1 5 4) (6 1 3 2 4 8 11 0 5 10 7 9) (1 0 8 6 7 11 10 5 3 9 4 2) (2 6 10 4 0 3 9 7 11 1 5 8) (3 10 1 2 5 7 0 6 9 8 4 11) (10 4 0 7 6 9 1 5 8 3 11 2) (7 4 3 10 2 8 1 6 5 11 0 9) (7 5 6 9 11 10 2 0 1 8 4 3) (4 7 11 10 6 1 3 8 2 9 0 5))

In reality, I don't want 300 of them, instead only 6. But I've now decided that I want these notes to be played in the lowest octave of the piano. Remember that the values [0, 1, 2, ..., 11] are just representations for notes. These notes haven't been placed in a register. You might think that I need to find a way to turn these numbers into letters like C, Db, and D#, but we can actually stay in numbers because electronic music already has a numbering system for notes called MIDI. These values range from 0-127. Middle C on the piano is 60. The lowest C on the piano is 24. To transpose the randomly permuted values to this octave, I add 24 to each of them. So, I take each integer in each list and do this simple addition operation with it.


(loop repeat 6 collecting 
  (loop for x in (rnd-order '(0 1 2 3 4 5 6 7 8 9 10 11))
    collecting
    (+ x 24)))

There are now 2 loops. The outer loop repeats the inner loop 6 times. The inner loop has a variable x, which loops through the values of each newly created, randomly permuted list, adding 24 to each value. Once the process of the inner loop is completed, the resulting, transposed list is added to the collected results of the outer loop. When the whole process is complete, we see something like the following:


'((28 24 26 25 33 34 30 32 31 29 35 27) 
  (31 29 25 28 27 32 30 34 26 24 35 33) 
  (33 27 34 32 35 24 28 26 29 30 31 25) 
  (32 26 29 30 25 31 33 34 28 27 24 35) 
  (32 33 29 35 34 25 27 31 26 28 24 30) 
  (28 25 35 31 26 30 34 33 27 29 32 24))

Some details beyond the notes are needed in order to turn this into a small musical passage. Let's keep things simple and use only sixteenth notes. The dynamic will be piano, the articulation will be staccato, and the tempo will be rather fast at 112 BPM. Finally, in order to distinguish between each series, 2 beats of rest will be placed between each. So, there will be 3 beats of sixteenth notes and then 2 beats of rest.




Although this isn't much music, there is a lot of potential to it. Why? Because many elements - dynamics, articulation, length of rest, note value of performed notes, tempo, and register - are already fixed. All of our attention is on the movement of the notes, and this is also very limited. You can think of each 12-note event as a variation. They are all essentially the same, but the surface details are different. Now, we can begin to ask questions about each components. For instance, should we use different dynamics? Should there be crescendo and decrescendo? Should there be more or fewer than 12 notes in each event? Should we change register? Should the length of the rest change? Future sections of the work will be built off of answers to these questions. We'll explore some of the answers in the next post.


111 views0 comments

Recent Posts

See All
bottom of page