samaaron/sonic-pi — pull request #261 by xavriley (2014-12-08 15:16:09+00:00)
Title: Add function `play_pattern_relative`

This adds a new function that automatically scales and sets params on a
given pattern of notes. It is similar to play pattern timed but the
optional arguments take on slightly different behaviours in order to
give a more musical set of defaults

- `attack` and `decay`: These are scaled to the shortest time in the
list. `0.1` becomes 10% of the shortest note time and so on. This is
to maintain a consistent attack across the whole pattern which is
the obvious choice from a musical perspective
- `sustain` and `release`: Whatever is left of a note length after the
AD params have been set, `sustain` is again scaled to that length.
Ergo `sustain: 0.4` would set the sustain to be 40% of the note
length with the rest being set as release

This function has a few other tricks up its sleeve

- `legato`: a value of 1 means the note sounds for the full length
(100%) of time specified in the pattern. However, lower values result in more
staccato sounds by cutting the note short. This gives a lot of
musical control over the feel of the pattern
- `note_slide`: if this is set, the function will slide the pitch to
the next note in the pattern. Again this is scaled to the given time
for a note from 0 to 1 meaning 0 to 100% of the time.
- `slur`: If the `slur` param is `>= 0.5` then the pattern will sound
as one note that slides to each of the pitches in the given times.
This is similar to the portamento effect found on many synths