From 168a7b47951a29381aba211813c6c085212452ef Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Mon, 28 Aug 2023 17:37:11 +0200 Subject: [PATCH] documenting modp --- src/API.ts | 2 +- src/Documentation.ts | 40 +++++++++++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/API.ts b/src/API.ts index a83cb15..aec9fd8 100644 --- a/src/API.ts +++ b/src/API.ts @@ -858,7 +858,7 @@ export class UserAPI { const results: boolean[] = n.map((value) => this.epulse() % value === 0); return results.some((value) => value === true); }; - pmod = this.modpulse; + modp = this.modpulse; public modbar = (...n: number[]): boolean => { const results: boolean[] = n.map( diff --git a/src/Documentation.ts b/src/Documentation.ts index 70ae0a8..0b463c2 100644 --- a/src/Documentation.ts +++ b/src/Documentation.ts @@ -282,7 +282,27 @@ mod([1,0.75].div(2)) :: blip([50, 100].div(2)).out(); `, false )} - + + +- modp(...n: number[]): extreme version of the mod function. Instead of being normalised, this function is returning a modulo of real pulses! It can be used to break out of ratios and play with real clock pulses for unexpected results. + +${makeExample( +"Intriguing rhythms", +` +modp(36) :: snd('east') + .n([2,4].div(1)).out() +modp([12, 36].div(4)) :: snd('east') + .n([2,4].add(5).div(1)).out() +`, + true +)} +${makeExample( +"modp is the OG rhythmic function in Topos", +` +modp([48, 24, 16].div(4)) :: sound('linnhats').out() +mod(1)::snd('bd').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. ${makeExample( @@ -466,6 +486,14 @@ divbar(3)::mod(.5)::snd('hat').out() `, true )} +${makeExample( + "Alternating over four bars", +` +divbar(2) + ? mod(.5) && snd(['kick', 'hh'].div(1)).out() + : mod(.5) && snd(['east', 'snare'].div(1)).out() +`, false)}; + - onbar(n: number, ...bar: number[]): The first argument, n, is used to divide the time in a period of n consecutive bars. The following arguments are bar numbers to play on. For example, onbar(5, 1, 4) will return true on bar 1 and 4 but return false the rest of the time. You can easily divide time that way. @@ -486,16 +514,6 @@ if (onbar(4, 1, 3)) { true )} - -- divbar(bar: number): return true or false alternatively every _n_ bars. -${makeExample( - "Alternating over four bars", -` -divbar(2) - ? mod(.5) && snd(['kick', 'hh'].div(1)).out() - : mod(.5) && snd(['east', 'snare'].div(1)).out() -`, true)}; - ## What are pulses? To make a beat, you need a certain number of time grains or **pulses**. The **pulse** is also known as the [PPQN](https://en.wikipedia.org/wiki/Pulses_per_quarter_note). By default, Topos is using a _pulses per quarter note_ of 48. You can change it by using the ppqn(number) function. It means that the lowest possible rhythmic value is 1/48 of a quarter note. That's plenty of time already.