Skip to content

Time shorthand

When dealing with time functions, many times we need to specify times shorter than a cycle by using fractions or decimal numbers.

Alternately, we can use textual shorthands to refer to the most common durations.

For example, we can swap 0.25 or 1/4 for the shorthand q, which stands for a quarter of a cycle.

These three examples are equivalent:

d1 $ off 0.25 (|+ n 7) $ n "c e" # sound "supermandolin"
d1 $ off (1/4) (|+ n 7) $ n "c e" # sound "supermandolin"
d1 $ off "q" (|+ n 7) $ n "c e" # sound "supermandolin"

Here’s the current list of shorthands available:

FractionDecimalMnemonic
w1whole
h1/20.5half
t1/3third
q1/40.25quarter
f1/50.2fifth
x1/6sixth
e1/80.125eighth
s1/160.0624sixteenth

We can prefix these shorthand with a number to have multiples. These two examples sound the same:

d1 $ stack [
s "[bd,co sd bd sd]",
pressBy "<0 0.25 0.5 0.75>" $ s "cp"
]
d1 $ stack [
s "[bd,co sd bd sd]",
pressBy "<0 q h 3q>" $ s "cp"
]

For a 32nd, you could do 0.5s:

d1 $ echo 4 "0.5s" 0.9 $ sound "hh"

You can only use these shorthands on any function that receives a Pattern. This will work:

d1 $ s "bd" # delaytime "x" # delay 0.8 # delayfb 0.4

But this won’t (as compress needs a Time, not a Pattern Time):

d1 $ compress ("q", "3q") $ s "[bd sn]!" -- ERROR