Friday, October 30, 2009

Simple things simple

(1)

from music21 import serial

p = [8,1,7,9,0,2,3,5,4,11,6,10]
print serial.rowToMatrix(p)

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


(2) We want to graphically show correlations between the length of notes and their heights using a piece coded in musicxml or humdrum format (these are from our downloaded corpora):

for work in ['opus18no1', 'opus59no3']:
movementNumber = 3
score = corpus.parseWork(work, movementNumber)

for part in score:
instrumentName = part.getElementsByClass(instrument.Instrument)[0].findName()
grapher = correlate.NoteAnalysis(part.flat.sorted)
grapher.pitchToLengthScatter(title='%s, Movement %s, %s' % (work, movementNumber, instrumentName))
Displays 8 images, including:

No comments:

Post a Comment