This commit is contained in:
Bubobubobubobubo
2023-10-03 21:15:11 +00:00
parent 5098ae1c72
commit d8eaba1003
2 changed files with 54 additions and 37 deletions

View File

@ -437,24 +437,33 @@ Let's study two very simple rhythmic functions, <ic>mod(n: ...number[])</ic> and
${e("Using different mod values",`
// This code is alternating between different mod values
beat([1,1/2,1/4,1/8].beat(2)) :: sound('bd').n(0).out()
beat([1,1/2,1/4,1/8].beat(2)) :: sound('hat').n(0).out()
`,!0)}
${e("Some sort of ringtone",`
let blip = (freq) => {return sound('sine').sustain(0.1).freq(freq)};
beat(1) :: blip(200).out();
beat(1/3) :: blip(400).out();
flip(3) :: beat(1/6) :: blip(800).out();
beat([1,0.75].beat(2)) :: blip([50, 100].beat(2)).out();
// Blip generator :)
let blip = (freq) => {
return sound('wt_piano')
.gain(1)
.sustain(0.1)
.freq(freq)
.cutoff(1500)
.lpadsr(4, 0, .25, 0, 0)
};
beat(1) :: blip(200).pan(r(0,1)).vib(0.5).vibmod(2).out();
beat(1/3) :: blip(400).pan(r(0,1)).out();
flip(3) :: beat(1/6) :: blip(800).pan(r(0,1)).out();
beat([1,0.75].beat(2)) :: blip([50, 100].beat(2)).pan(r(0,1)).out();
`,!1)}
- <ic>pulse(...n: number[])</ic>: faster version of the <ic>beat</ic> function. Instead of returning true for every beat, this function is returning true every _n_ clock ticks! It can be used to generate very unexpected results or to sequence by using your arithmetic ninja skills.
- <ic>pulse(...n: number[])</ic>: faster version of the <ic>beat</ic> function. Instead of returning true for every beat, this function is returning true every _n_ clock ticks! It can be used to generate very unexpected rhythms.
${e("Intriguing rhythms",`
pulse(36) :: snd('east')
.n([2,4].beat(1)).out()
pulse([12, 36].beat(4)) :: snd('east')
pulse([24,48].beat(2)) :: snd('hand')
.cut(1).room(0.9).size(0.9)
.n([2,4].beat(2)).out()
pulse([48/2, 48/3].beat(4)) :: snd('hand')
.n([2,4].add(5).beat(1)).out()
`,!0)}
${e("pulse is the OG rhythmic function in Topos",`
@ -466,15 +475,15 @@ beat(1)::snd('bd').out()
${e("Some simple yet detailed rhythms",`
onbeat(1,2,3,4)::snd('kick').out() // Bassdrum on each beat
onbeat(2,4)::snd('snare').out() // Snare on acccentuated beats
onbeat(1.5,2.5,3.5, 3.75)::snd('hat').out() // Cool high-hats
onbeat(2,4)::snd('snare').n([0,2].beat(2.5)).out() // Snare on acccentuated beats
onbeat(1.5,2.5,3.5, 3.75)::snd('hat').gain(r(0.9,1.1)).out() // Cool high-hats
`,!0)}
${e("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()
onbeat(0.5, 2, 3, 3.75)::snd('kick').n(2).out()
onbeat(2, [1.5, 3, 4].pick(), 4)::snd('snare').n(8).out()
beat([.25, 1/8].beat(1.5))::snd('hat').n(2)
.gain(rand(0.4, 0.7))
.gain(rand(0.4, 0.7)).end(0.05)
.pan(usine()).out()
`,!1)}
@ -482,7 +491,9 @@ beat([.25, 1/8].beat(1.5))::snd('hat').n(2)
${e("Using oncount to create more variation in the rhythm",`
bpm(120)
z1('q (0 4 2 9)+(0 3 1 5)').sound('sawtooth').cutoff([400,500,1000,2000].beat(1))
z1('0.125 (0 2 3 4)+(0 2 4 6)').sound('sawtooth')
.cutoff([400,500,1000,2000].beat(1))
.lpadsr(2, 0, .2, 0, 0)
.delay(0.5).delayt(0.25).room(0.9).size(0.9).out()
onbeat(1,1.5,2,3,4) :: sound('bd').gain(2.0).out()
oncount([1,3,5.5,7,7.5,8],8) :: sound('hh').gain(irand(1.0,4.0)).out()
@ -509,10 +520,11 @@ beat(.5) && euclid($(2), 2, 8) && snd('sd').out()
beat(4) :: sound('cp').out()
`,!0)}
${e("And now for more interesting rhythmic constructions",`
${e("And now something a bit more complex",`
bpm(145); // Setting a faster BPM
beat(.5) && euclid($(1), 5, 8) :: sound('bd').out()
beat(.5) && euclid($(2), [1,0].beat(8), 8) :: sound('sd').out()
beat(.5) && euclid($(2), [1,0].beat(8), 8)
:: sound('ST03').n(3).room(1).size(1).o(1).out()
beat(.5) && euclid($(6), [6,7].beat(8), 8) :: sound('hh').out()
`,!1)}
@ -535,10 +547,10 @@ ${e("Using oneuclid to create a rhythm without iterators",`
- <ic>rhythm(divisor: number, pulses: number, length: number, rotate: number): boolean</ic>: generates <ic>true</ic> or <ic>false</ic> values from an euclidian rhythm sequence. This is another version of <ic>euclid</ic> that does not take an iterator.
${e("rhythm is a beginner friendly rhythmic function!",`
let speed = [0.5, 0.25].beat(8); bpm(140);
rhythm(speed, 5, 12) :: snd('east').n(2).out()
let speed = [1, 0.5].beat(8); bpm(140);
rhythm(speed, 5, 12) :: snd('linnhats').n(2).pan(noise()).out()
rhythm(speed, 2, 12) :: snd('east').out()
rhythm(speed, 3, 12) :: snd('east').n(4).out()
rhythm(speed, 3, 12) :: snd('linnhats').n(4).pan(noise()).out()
rhythm(speed, 7, 12) :: snd('east').n(9).out()
`,!0)}
@ -546,33 +558,37 @@ rhythm(speed, 7, 12) :: snd('east').n(9).out()
- <ic>binrhythm(divisor: number, n: number): boolean: boolean</ic>: iterator-less version of the binary rhythm generator.
${e("Change the integers for a surprise rhythm!",`
beat(.5) && bin($(1), 34) && snd('kick').out()
beat(.5) && bin($(2), 48) && snd('sd').out()
bpm(135);
beat(.5) && bin($(1), 34) && snd('kick').n([1,3].beat(1)).out()
beat(.5) && bin($(2), 48) && snd('snare').n([1,4].beat(1)).out()
`,!0)}
${e("binrhythm for fast cool binary rhythms!",`
binrhythm(.5, 13) && snd('kick').out()
binrhythm(.5, 18) && snd('sd').out()
let a = 0;
a = beat(4) ? irand(1,20) : a;
binrhythm(.5, 6) && snd(['kick', 'snare'].beat(0.5)).n(11).out()
binrhythm([.5, .25].beat(1), 30) && snd('wt_granular').n(a)
.cutoff(800).lpadsr(4, 0, 0.125, 0.5, 0.25)
.adsr(0, r(.1, .4), 0, 0).freq([50, 60, 72].beat(4))
.room(1).size(1).out()
`,!0)}
${e("Submarine jungle music",`
bpm(145);
beat(.5) && bin($(1), 911) && snd('ST69').n([2,3,4].beat())
.delay(0.125).delayt(0.25).end(0.25).speed(1/3).out()
.delay(0.125).delayt(0.25).end(0.25).speed(1/3)
.room(1).size(1).out()
beat(.5) && sound('amencutup').n(irand(2,7)).shape(0.3).out()
`,!1)}
${e("Using tabla to play unpredictable rhythms",`
beat(.5) && bin($(1), [123, 456, 789].beat(4))
&& snd('tabla').n($(2)).delay(0.5).delayt(0.25).out()
beat(1) && sound('kick').shape(0.5).out()
`,!1)}
If you don't find it spicy enough, you can add some more probabilities to your rhythms by taking advantage of the probability functions. See the functions documentation page to learn more about them.
${e("Probablistic drums in one line!",`
prob(60)::beat(.5) && euclid($(1), 5, 8) && snd('kick').out()
prob(60)::beat(.5) && euclid($(2), 3, 8) && snd('sd').out()
prob(80)::beat(.5) && sound('hh').out()
prob(60)::beat(.5) && euclid($(2), 3, 8) && snd('mash')
.n([1,2,3].beat(1))
.pan(usine(1/4)).out()
prob(80)::beat(.5) && sound(['hh', 'hat'].pick()).out()
`,!0)}
## Time Warping
@ -627,9 +643,10 @@ flip(4) :: beat(1) :: snd('kick').out()
${e("Clapping on the edge",`
flip(2.5, 10) :: beat(.25) :: snd('cp').out()
flip(2.5, 75) :: beat(.25) :: snd('click').speed(2).end(0.2).out()
flip(2.5, 75) :: beat(.25) :: snd('click')
.speed(2).end(0.2).out()
flip(2.5) :: beat(.5) :: snd('bd').out()
beat(.25) :: sound('hh').out()
beat(.25) :: sound('hat').end(0.1).cutoff(1200).pan(usine(1/4)).out()
`,!1)}
${e("Good old true and false",`

View File

@ -8,7 +8,7 @@
<script src="https://unpkg.com/hydra-synth"></script>
<script type="module" crossorigin src="/assets/index-1b0e11c3.js"></script>
<script type="module" crossorigin src="/assets/index-e462ef15.js"></script>
<link rel="stylesheet" href="/assets/index-9b1f99fe.css">
</head>
<style>