Tuesday, August 30, 2011

Nancarrow level tempo changes in music21

The newest SVN releases (pre-alpha 12) of music21 include tempo change information to/from MIDI (we've already supported tempo i/o from musicxml since previous versions and read it in from Humdrum/Kern, Noteworthy, abc, Musedata and probably others. And newest releases export it to Braille Music Notation). Here's an example of using a tempo change after each note (default = quarter note) to create a smooth change of tempo (tracing a sine wave) from 60 bpm to 600 bpm over 60 notes.


from music21 import tempo, note, stream
import math
min = 60
max = 600
period = 50
s = stream.Stream()
for i in range(100):
    scalar = (math.sin(i * (math.pi*2) / period) + 1) * .5
    n = ((max-min) * scalar) + min
    s.append(tempo.MetronomeMark(number=n))
    s.append(note.Note('g3'))
s.show('midi')



And the output:



This feature lets you create pieces with the types of precise changes of tempo that Conlon Nancarrow painstakingly created in his piano-roll compositions. We'll soon have demos to show how you can use these features to create independent tempo marks in different parts to weave independent strands of music in your works. On the analytical side, importing precise tempo marks can open up new avenues for research on performance and interpretation, comparing the tempos chosen with those marked in the score.

To use the latest (not thoroughly tested) releases of music21 via SVN, we recommend developing using Eclipse. See Using Music21's SVN version with Eclipse. Otherwise, wait a few weeks for the latest release with lots of other improvements.

No comments:

Post a Comment