Tuesday, June 15, 2010

Mensural Canons and Other Applications of Stream Transformations


We have a number of powerful Stream transformation methods available now, including transpose() and augmentOrDiminish(). My favorite task with such utilities is creating mensural canons. The example below does just that, using a Bach soprano line as the melodic source.

Further explanation can be found here:

from music21 import *
src = corpus.parseWork('bach/bwv323.xml')
ex = src.getElementById('Soprano').flat.notes

s = stream.Score()
for scalar, t in [(1, 'p1'), (2, 'p-5'), (.5, 'p-11'), (1.5, -24)]:
part = ex.augmentOrDiminish(scalar, inPlace=False)
part.transpose(t, inPlace=True)
s.insert(0, part)
s.show()



















No comments:

Post a Comment