setTempo¶
- maelzel.core.workspace.setTempo(tempo, reference=1, measureIndex=0)[source]¶
Set the current tempo.
- Parameters:
tempo (
float
) – the new tempo.reference – the reference value (1=quarternote, 2=halfnote, 0.5: 8th note)
measureIndex – the measure number to modify. The scorestruct’s tempo is modified until the next tempo
- Return type:
None
See also
Example
from maelzel.core import * # A chromatic scale of eighth notes scale = Chain(Note(m, dur=0.5) for m in range(60, 72)) # Will play 8th notes at 60 scale.play() setTempo(120) # Will play at twice the speed scale.play() # setTempo is a shortcut to ScoreStruct's setTempo method struct = getScoreStruct() struct.setTempo(40)
>>> setScoreStruct(ScoreStruct(r''' ... 3/4, 120 ... 4/4, 66 ... 5/8, 132 ... ''')) >>> setTempo(40) >>> getScoreStruct().dump() 0, 3/4, 40 1, 4/4, 66 2, 5/8, 132