An Introduction to Collective Algorithmic Music Composition

Sieves

Every well-ordered set can be represented as points on a line, if it is given a reference point for the origin and a length u for the unit distance, and this is a sieve. - Iannis Xenakis

Musical Fizz Buzz

Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".

For the musical version of Fizz Buzz, instead of printing Fizz, Buzz or FizzBuzz we're going to replace it for a rest (-1).

First, lets define a function that takes a number x and if it's a multiple of 3, 5 and 15 (3 times 5) it returns a -1, else it would return the number. We'll need to use a Modulo operation. Given two positive numbers, a(the dividend) and n (the divisor), a modulo n (abbreviated as a mod n) is the remainder of the Euclidian division of a by n.

(define (fizzbuzz x)
 (cond 
 ((= (mod x 15) 0) -1)
 ((= (mod x 3) 0) -1)
 ((= (mod x 5) 0) -1)
 (else x)))

Now we can map the fizzbuzz function and apply a sequence of integers using the iota function.

(define pitches (map fizzbuzz (iota 127)))

For the durations, lets keep it simple. We'll multiply the same sequence by 3.

(define lengths (map (lambda (x) (* x 3)) (iota 127)))

Finally, lets create constant velocities and save it to a MIDI file.

(define vels (create-constant-velocities pitches 96))
(save-midi (create-events 0 pitches lengths vels 1))
; Musical Fizz Buzz
(define (fizzbuzz x)
 (cond 
 ((= (mod x 15) 0) -1)
 ((= (mod x 3) 0) -1)
 ((= (mod x 5) 0) -1)
 (else x)))

(define pitches (map fizzbuzz (iota 127)))
(define lengths (map (lambda (x) (* x 3)) (iota 127)))
(define vels (create-constant-velocities pitches 96))
(save-midi (create-events 0 pitches lengths vels 1))

Sieves in Scripthica

To create a sieve in Scripthica, use the sieve procedure.

(sieve 2 1 0 20)

Sieve union

To make a sieve union use the sieve-union procedure.

(sieve-union (sieve 2 1 0 20)(sieve 3 1 0 20))

Intervallic succesion

An intervallic succession lists an intervallic sequence of the sieve.

(delta (sieve-union (sieve 2 1 0 20)(sieve 3 1 0 20)))

Musical example

(define seq (sieve-union (sieve 2 0 20 100) (sieve 5 0 20 100)))
(define pitches (palindrome seq))
(define lengths (constant-value (length pitches) 125))
(define vels (create-constant-velocities pitches 96))
(define evs (create-events 0 pitches lengths vels 1))
(save-midi evs)