:orphan: TimeVaryingParameter Extension ============================== *Example script* (scamp_extensions): `examples/Composition & form/Larger-scale form/time_varying_parameter_example.py `__ *Download:* :download:`time_varying_parameter_example.py ` **Requires the** ``scamp_extensions`` **package** (``pip install scamp_extensions``). A script using the context-sensitive :class:`~expenvelope.envelope.Envelope` wrapper :class:`TimeVaryingParameter`, which reads into the underlying envelope at the current clock 's beat or time when called. *Topics:* :doc:`Envelopes › As compositional parameters `, :doc:`Composition & form › Larger-scale form ` .. raw:: html
.. code-block:: python 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()