Composing 12-Tone Music with Genetic Algorithm - An Exploration
This annotated excerpt delves into the world of 12-tone music composition using a genetic algorithm approach. The essence of 12-tone music, its historical roots, and the simplifications made for the algorithm's purposes are discussed. The piece structure, transformations, and an initial task involving note-row generation are detailed, offering a glimpse into the intricate process of creating music through artificial intelligence.
Download Presentation
Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
E N D
Presentation Transcript
COMPOSING 12-TONE MUSIC WITH A GENETIC ALGORITHM IAN WHITE CSC-416 ARTIFICIAL INTELLIGENCE 2 | SPRING 2019 Annotated excerpt from Schoenberg sWind Quartet, Op. 26
WHAT IS 12-TONE MUSIC? For reference, https://youtu.be/bQHR_Z8XVvI?t=1m1s (Suite for Piano, Op. 25 ) Arose from the modernist ideal of post-tonalism Credited to Arnold Schoenberg (1874-1951), but initially devised by Josef Matthias Hauer Centered around the concept of a tone row a string of pitches that includes all notes a uniform number of times Formulaic, but much of the formula lies in the pitches (indeed, Schoenberg was called an expressionist) Much more mathematic than I capture in my program!
HOW TO STRIP IT DOWN FOR THE PURPOSES OF THIS PROGRAM In traditional 12-tone composition, it is not the case that a note can be played only once in a tone row before it is repeated ensuring that all 12 notes of the chromatic scale are sounded as often as one another in a piece of music while preventing the emphasis of any one note For my purposes, I do adopt this simplification a fit tone row should feature each pitch played only once Inversion instead of inverting each interval, I assigned a given pitch to another pitch (e.g C -> B) I did this to keep my tone rows within one octave so as not to have wildly large intervals I avoided transposition for the same reason Obviously harmony is not present in the system This does not really look like a 12-tone composition! I gave myself a framework outside of a normal key Important part is whether my tone row can be distinguished from a random string of notes by a human
WHAT A PIECE SHOULD LOOK LIKE A piece is a note row followed by 1 to 3 of its transformations These can be: retrograde ( total or pitch-only ), inversion, or retrograde-inversion I want my most fit note row to be 12, 18, or 24 beats long so that it fits nicely into four measures upon composition 12 beats = 3 transformations; 18 = 3; 24 = 2
TASK 1: THE 12-NOTE LINE In this task, (note-row) generates a list of random pairs of pitches and durations ((A# . S) (G . S) (B . I) (F . I) (G . I) (D# . I) (D . I) (G . H.) (G . H.) (D . S) (F# . I) (A# . I)) S = sixteenth note (.5) ; I = eighth note (1); Q. = dotted quarter note (3); H. = dotted half note (6)
TASK 2: RENDERING IN JFUGUE First, (jf-notation) converts the tone row to a string that JFugue can read This is the note row from the previous slide: "A#s Gs Bi Fi Gi D#i Di Gh. Gh. Ds F#i A#i" Next, the string can be brought to a Java program that plays the string and stores it as a playable audio file
TASK 3: MUTATION AND CROSSOVER (mutation) takes a chooses a random note from the list and replaces it with a random note that does not share the same pitch or duration ((C# . I) (F# . H.) (D# . I) (G# . Q.) (A# . H.) (G . Q.) (A# . I) (B . I) (G . I) (G . I) (C# . I) (E . I) (A . I)) ((C# . I) (F# . H.) (D# . I) (G# . Q.) (A# . H.) (G . Q.) (A# . I) (B . I) (F . S) (F . S) (C# . I) (E . I) (A . I)) (crossover) works just like you might expect it to, but different points are selected for pitch and duration ((C# . I) (D . S) (B . Q.) (C# . H.) (G . S) (E . S) (A# . S) (C . I) (G . I) (A . I) (C# . S) (D# . S)) ((B . S) (F . I) (C# . I) (D# . Q.) (F# . S) (C# . I) (D# . I) (G . S) (D# . I) (F . I) (G# . S) (D# . S)) ((C# . I) (D . S) (B . Q.) (D# . H.) (F# . S) (C# . S) (D# . S) (G . I) (D# . I) (F . I) (G# . S) (D# . S))
TASK 4: THE FITNESS METRIC FOR PITCH The most obvious thing to capture is in pitch fitness is that no pitch is repeated in a note row (and thus all are sounded exactly once) The additional pitch constraint I suggest is that pitch cannot rise or fall across more than 3 notes C E F A D has a fitness of 1 because there are four consecutive rising pitches Lower fitness is better; the ideal fitness is 0
TASK 5: THE FITNESS METRIC FOR DURATION The fitness metric for duration gives a better fitness for note rows that have a fitness closer to 12, 18, or 24, and the value generated is the distance between the row s duration and one of those points Overall fitness is the sum of pitch and duration fitness "A#h. G#s Ci Gq. D#s Aq. Ei D#q. G#i F#s Es G#s ( defmethod duration-fitness ( ( nr list ) &aux dur ) ( setf dur ( duration nr ) ) ( cond ( ( or ( = dur 12 ) ( = dur 18 ) ( = dur 24 ) ) 0 ) ( ( or ( < dur 12 ) ( <= dur 15 ) ) ( abs ( - dur 12 ) ) ) ( ( or ( < dur 18 ) ( <= dur 21 ) ) ( abs ( - dur 18 ) ) ) ( T ( abs ( - dur 24 ) ) ) ) ) Pitch fitness: 4 Duration fitness: 2.5 Overall fitness: 6.5
TASKS 6-8: THE GENETIC ALGORITHM Nothing new here, this GA features mutation, copy, and crossover I used 75 generations because I felt anything less did not give the GA enough time for improvement, and anything more took a long time Overall, the most fit individuals produced by this are not really sufficient tone rows
THE GENETIC ALGORITHM DOES IT WORK? My initial concern when running the GA was the very small improvement in fitness over 75 generations The final most fit individual does boast a fitness between 0 and 2.5, which is good considering my fitness metric However, this is still not great and I believe it s due to the interaction between pitch/duration fitness metrics Additionally, my initial framework for further composition relied on the MFI having a duration of either 12, 18, or 24 but this doesn t always happen Example MFI: "Fs A#q. Gs As Di Bs Fi C#q. F#i Ei G#h. As" Pitch fitness: 2 Duration Fitness: .5
TASK 9: FURTHER COMPOSITION (compose) takes a note row and generates a (hopefully) four measure piece with randomly selected transformations The number of transformations is based on the duration of the initial row of notes (random-piece) calls compose on a random note row Both of these can (and do) result it pieces that are not a whole number of measures is this a problem?
CAN YOU TELL THE DIFFERENCE? I ll play 2 different pieces and ask you if you can distinguish which was generated by the genetic algorithm
SOME REFLECTION Program still isn t done I still have some cleaning up to do, and maybe I can adjust aspects of the GA to make it produce a more favorable result 12-tone composition is formulaic this is not to say it cannot be written expressively and uniquely However, its rigidity its difficult to capture with a genetic algorithm I should ve separated pitch and duration for the GA, or created some external constraints Rests would have created more interest There are a lot of other aspects of 12-tone music that would be fun to capture computationally, but I don t know if a genetic algorithm is the best medium for that