TimeVaryingParameter Extension
Example script (scamp_extensions): examples/Composition & form/Larger-scale form/time_varying_parameter_example.py
Download: time_varying_parameter_example.py
Requires the scamp_extensions package (pip install scamp_extensions).
A script using the context-sensitive Envelope wrapper TimeVaryingParameter, which reads into the underlying envelope at the current clock ‘s beat or time when called.
Topics: Envelopes › As compositional parameters, Composition & form › Larger-scale form
from scamp import *
from scamp_extensions.utilities import TimeVaryingParameter
s = Session()
piano = s.new_part("piano")
def play_gesture(center_pitch, width, length):
pitch_shape = TimeVaryingParameter.from_levels([0, width, -width, -width/2, -width, 0], length=length)
volume_shape = TimeVaryingParameter([1, 0.4, 1], [length * 0.1, length * 0.9])
while current_clock().beat < length:
piano.play_note(int(center_pitch + pitch_shape()), volume_shape(), 0.25)
width_param = TimeVaryingParameter([4, 20, 0], [30, 30])
center_pitch_param = TimeVaryingParameter([60, 80, 40, 60], [20, 20, 20])
length_param = TimeVaryingParameter([10, 1], [60])
while s.beat < 65:
fork(play_gesture, args=(center_pitch_param(), width_param(), length_param()), initial_tempo=180)
wait_for_children_to_finish()