Play pattern of notes with specific times

play_pattern_timed  notes (list), times (list_or_number)

Play each note in a list of notes one after another with specified times between them. The notes should be a list of MIDI numbers, symbols such as :E4 or chords such as chord(:A3, :major) - identical to the first parameter of the play function. The times should be a list of times between the notes in beats.

If the list of times is smaller than the number of gaps between notes, the list is repeated again. If the list of times is longer than the number of gaps between notes, then some of the times are ignored. See examples for more detail.

Accepts optional args for modification of the synth being played. See each synth’s documentation for synth-specific opts. See use_synth and with_synth for changing the current synth.

Introduced in v2.0

Options

amp:

The amplitude of the note

amp_slide:

The duration in beats for amplitude changes to take place

pan:

The stereo position of the sound. -1 is left, 0 is in the middle and 1 is on the right. You may use a value in between -1 and 1 such as 0.25

pan_slide:

The duration in beats for the pan value to change

attack:

Amount of time (in beats) for sound to reach full amplitude (attack_level). A short attack (i.e. 0.01) makes the initial part of the sound very percussive like a sharp tap. A longer attack (i.e 1) fades the sound in gently.

decay:

Amount of time (in beats) for the sound to move from full amplitude (attack_level) to the sustain amplitude (sustain_level).

sustain:

Amount of time (in beats) for sound to remain at sustain level amplitude. Longer sustain values result in longer sounds. Full length of sound is attack + decay + sustain + release.

release:

Amount of time (in beats) for sound to move from sustain level amplitude to silent. A short release (i.e. 0.01) makes the final part of the sound very percussive (potentially resulting in a click). A longer release (i.e 1) fades the sound out gently.

attack_level:

Amplitude level reached after attack phase and immediately before decay phase

decay_level:

Amplitude level reached after decay phase and immediately before sustain phase. Defaults to sustain_level unless explicitly set

sustain_level:

Amplitude level reached after decay phase and immediately before release phase.

env_curve:

Select the shape of the curve between levels in the envelope. 1=linear, 2=exponential, 3=sine, 4=welch, 6=squared, 7=cubed

slide:

Default slide time in beats for all slide opts. Individually specified slide opts will override this value

pitch:

Pitch adjustment in semitones. 1 is up a semitone, 12 is up an octave, -12 is down an octave etc. Decimal numbers can be used for fine tuning.

on:

If specified and false/nil/0 will stop the synth from being played. Ensures all opts are evaluated.

Examples

# Example 1

play_pattern_timed [40, 42, 44, 46], [1, 2, 3]



play 40
sleep 1
play 42
sleep 2
play 44
sleep 3
play 46


 
 
# same as:
 
 
 
 
 
 
 
 



# Example 2

play_pattern_timed [40, 42, 44, 46, 49], [1, 0.5]



play 40
sleep 1
play 42
sleep 0.5
play 44
sleep 1
play 46
sleep 0.5
play 49


 
 
# same as:
 
 
 
 
 
 
 
 
 
 



# Example 3

play_pattern_timed [40, 42, 44, 46], [0.5]



play 40
sleep 0.5
play 42
sleep 0.5
play 44
sleep 0.5
play 46


 
 
# same as:
 
 
 
 
 
 
 
 



# Example 4

play_pattern_timed [40, 42, 44], [1, 2, 3, 4, 5]



play 40
sleep 1
play 42
sleep 2
play 44


 
 
#same as: