Play Chord ========== *Example script* (scamp): `examples/Tutorial/04_play_chord.py `__ *Download:* :download:`04_play_chord.py ` Demonstrates `ScampInstrument.play_chord` by playing a famous progression, and then playing it a few more times randomly up and down the keyboard. *Topics:* :doc:`Time & clocks › Forking & simultaneity ` .. raw:: html
.. code-block:: python from scamp import * import random # fixed random seed for reproducibility random.seed(42) s = Session() s.tempo = 72 piano = s.new_part("piano") # a famous chord progression piano.play_chord([53, 59, 63, 68], 0.8, 2) piano.play_chord([52, 56, 62, 71], 0.6, 1) # and then the same progression bouncing up and down the piano # oh, and let's accelerate, why not set_tempo_target(144, Moment.after_beats(6)) for _ in range(8): t = random.randint(-24, 24) piano.play_chord([53 + t, 59 + t, 63 + t, 68 + t], 0.8, 0.5) piano.play_chord([52 + t, 56 + t, 62 + t, 71 + t], 0.6, 0.5, "staccato")