Tempo Change
Example script (scamp): examples/Tutorial/02_tempo_change.py
Download: 02_tempo_change.py
Same as Hello World example, but repeatedly, with changing tempi.
Topics: Time & clocks › Setting & changing tempo
from scamp import *
s = Session()
# Start with an initial tempo of 100
s.tempo = 100
# add a new violin part to the session
violin = s.new_part("Violin")
for pitch in [60, 64, 67, 72]:
violin.play_note(pitch, 1, 0.5)
# you can change tempo at any time; not just at the beginning
s.tempo = 40
for pitch in [60, 64, 67, 72]:
violin.play_note(pitch, 1, 0.5)
# you can also do an accelerando/decelerando, specifying
# a moment at which to reach the goal tempo
set_tempo_target(150, Moment.after_beats(6))
for pitch in [60, 64, 67, 72] * 4:
violin.play_note(pitch, 1, 0.5)