Last active
June 15, 2021 15:59
-
-
Save eamonnbell/5796150 to your computer and use it in GitHub Desktop.
Generate a performance of Terry Riley's In C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import music21 | |
import itertools | |
from random import randint | |
MIN_REPETITIONS = 4 | |
MAX_REPETITIONS = 10 | |
NUMBER_OF_PARTS = 10 | |
motives = ['e4 e e', 'e8 f8 e4', 'r8 e f e', 'r8 e f g', 'e8 f g r', | |
"c'1~ c'1", 'r4 r r r8 c16 c c8 r r4 r r r', 'g1. f1~ f1', | |
'b16 g r8 r4 r r', 'b16 g', 'f16 g b g b g', "e8 f b1 c'4", | |
'b16 g8. g16 f g8 r8. g16~ g2.', "c'1 b g f#", 'g16 r8. r4 r r', | |
"g16 a c' a", "b16 c' b c' b r", 'e16 f# e f# e8. e16', "r4. g'.", | |
'e16 f# e f# G8. d16 f# e f# e', 'f#2.', 'e4. e e e e f# g a b8', | |
'e8 f#4. f# f# f# f# g a b4', 'e8 f# g4. g g g g a b8', | |
'e8 f# g a4. a a a a b', 'e8 f# g a b4. b b b b', 'e16 f# e f# g8 e16 g f# e f# e', | |
'e16 f# e f# e8. e16', "e2. g c'", "c'1.", 'g16 f g b g b', | |
'f16 g f g b f~ f2. g4.', 'g16 f r8', 'g16 f', | |
"f16 g b g b g b g b g r8 r4 r r b- g'2. a'8 g'~ g' b'n a'4. g'8 e'2. f'8 f'#8~ f'#2. r4 r4 r8 e'8~ e'4 f'n1.", | |
'f16 g b g b g', 'f16 g', 'f16 g b', "b16 g f g b c'", 'b16 f', | |
'b16 g', "c'1 b a c'", "f'16 e' f' e' e'8 e' e' f'16 e'", | |
"f'8 e'8~ e' e' c'4", "d'4 d' g", "g16 d' e' d' r8 g r g r g g16 d' e' d'", | |
"d'16 e'16 d'8", 'g1. g1 f~ f4', 'f16 g b- g b- g', 'f16 g', 'f16 g b-', 'g16 b-', 'b-16 g'] | |
scoremotives = [] | |
for tinymotive in motives: | |
tinyStream = music21.tinyNotation.TinyNotationStream(tinymotive) | |
realStream = music21.stream.Stream() | |
for n in tinyStream: | |
realStream.append(n) | |
scoremotives.append(realStream) | |
score = music21.stream.Score() | |
def generatePart(): | |
part = music21.stream.Part() | |
for motive in scoremotives: | |
duration = randint(MIN_REPETITIONS, MAX_REPETITIONS) | |
part.repeatAppend(motive, duration) | |
return part | |
for i in range(NUMBER_OF_PARTS): | |
score.insert(0, generatePart()) | |
score.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment