From 177fbd3da0a088f3dffa67ace37fa323b17ebae3 Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Sun, 27 Aug 2023 01:14:01 +0200 Subject: [PATCH] more examples --- src/Documentation.ts | 55 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/src/Documentation.ts b/src/Documentation.ts index 35237ec..3364bb4 100644 --- a/src/Documentation.ts +++ b/src/Documentation.ts @@ -231,16 +231,22 @@ Let's study two very simple rhythmic functions, mod(n: ...number[]) {return sound('sine').sustain(0.1).freq(freq)}; +mod(1) :: blip(200).out(); +mod(1/3) :: blip(400).out(); +div(3) :: mod(1/6) :: blip(800).out(); +mod([1,0.75].div(2)) :: blip([50, 100].div(2)).out(); +`, + false +)} - onbeat(...n: number[]): By default, the bar is set in 4/4 with four beats per bar. The onbeat function allows you to lock on to a specific beat to execute some code. It can accept multiple arguments. It's usage is very straightforward and not hard to understand. You can pass integers or floating point numbers. @@ -253,6 +259,17 @@ onbeat(1.5,2.5,3.5, 3.75)::snd('hat').out() // Cool high-hats true )} +${makeExample( + "Let's do something more complex", + `onbeat(0.5, 1.5, 2, 3, 3.75)::snd('kick').n(2).out() +onbeat(2, [1.5, 3].pick(), 4)::snd('snare').n(7).out() +mod([.25, 1/8].div(1.5))::snd('hat').n(2) + .gain(rand(0.4, 0.7)) + .pan(usine()).out() +`, + false +)} + ## Rhythm generators @@ -268,6 +285,30 @@ mod(.5) && euclid($(2), 2, 8) && snd('sd').out() `, true )} + +${makeExample( + "And now for more interesting rhythmic constructions", + ` +mod(.5) && euclid($(1), 5, 9) && snd('kick').out() +mod(.5) && euclid($(2), 2, 3, 1) && snd('pluck').end(0.5).n(5).out() +`, + false +)} + +${makeExample( + "Adding more rhythmic density", + ` +mod(.5) && euclid($(1), 5, 9) && snd('kick').out() +mod(.5) && euclid($(2), 2, 3, 1) && snd('pluck').end(0.5).n(5).out() +mod(.5) && euclid($(3), 6, 9, 1) && snd('pluck').end(0.5).n(5).freq(200).out() +mod(.25) && euclid($(4), 7, 9, 1) && snd('hh').out() + + +`, + false +)} + + - bin(iterator: number, n: number): boolean: a binary rhythm generator. It transforms the given number into its binary representation (_e.g_ 34 becomes 100010). It then returns a boolean value based on the iterator in order to generate a rhythm.