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:
No comments:
Post a Comment