From 741513ddf09900a082842ef019a2e631c1d61fef Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Sat, 18 Nov 2023 00:57:02 +0100 Subject: [PATCH] continue organising documentation files --- src/Documentation.ts | 6 +- src/documentation/{ => time}/cyclical_time.ts | 140 +++++++++--------- src/documentation/{ => time}/linear_time.ts | 68 ++++----- src/documentation/{ => time}/pulses.svg | 0 src/documentation/{ => time}/time.ts | 4 +- src/documentation/{ => time}/times.svg | 0 6 files changed, 109 insertions(+), 109 deletions(-) rename src/documentation/{ => time}/cyclical_time.ts (87%) rename src/documentation/{ => time}/linear_time.ts (92%) rename src/documentation/{ => time}/pulses.svg (100%) rename src/documentation/{ => time}/time.ts (92%) rename src/documentation/{ => time}/times.svg (100%) diff --git a/src/Documentation.ts b/src/Documentation.ts index 2014f56..5c2128b 100644 --- a/src/Documentation.ts +++ b/src/Documentation.ts @@ -9,9 +9,9 @@ import { synchronisation } from "./documentation/synchronisation"; import { samples } from "./documentation/samples"; import { chaining } from "./documentation/chaining"; import { interaction } from "./documentation/interaction"; -import { time } from "./documentation/time"; -import { linear_time } from "./documentation/linear_time"; -import { cyclical_time } from "./documentation/cyclical_time"; +import { time } from "./documentation/time/time"; +import { linear_time } from "./documentation/time/linear_time"; +import { cyclical_time } from "./documentation/time/cyclical_time"; import { long_forms } from "./documentation/long_forms"; import { midi } from "./documentation/midi"; import { about } from "./documentation/about"; diff --git a/src/documentation/cyclical_time.ts b/src/documentation/time/cyclical_time.ts similarity index 87% rename from src/documentation/cyclical_time.ts rename to src/documentation/time/cyclical_time.ts index fc496d0..14f7c6f 100644 --- a/src/documentation/cyclical_time.ts +++ b/src/documentation/time/cyclical_time.ts @@ -1,5 +1,5 @@ -import { type Editor } from "../main"; -import { makeExampleFactory } from "../Documentation"; +import { type Editor } from "../../main"; +import { makeExampleFactory } from "../../Documentation"; export const cyclical_time = (app: Editor): string => { // @ts-ignore @@ -16,17 +16,17 @@ Time as a cycle. A cycle can be quite long (a few bars) or very short (a few pul - offset: offset (in beats) to apply. An offset of 0.5 will return true against the beat. ${makeExample( - "Using different mod values", - ` + "Using different mod values", + ` // This code is alternating between different mod values beat([1,1/2,1/4,1/8].beat(2)) :: sound('hat').n(0).out() `, - true -)} + true + )} ${makeExample( - "Some sort of ringtone", - ` + "Some sort of ringtone", + ` // Blip generator :) let blip = (freq) => { return sound('wt_piano') @@ -41,16 +41,16 @@ 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(); `, - false -)} + false + )} ${makeExample( - "Beat can match multiple values", - ` + "Beat can match multiple values", + ` beat([.5, 1.25])::sound('hat').out() `, - false -)} + false + )} - pulse(n: number | number[] = 1, offset: number = 1): return true every _n_ pulses. A pulse is the tiniest possible rhythmic value. - number: if number = 1, the function will return true every pulse. Lists can be used too. @@ -58,21 +58,21 @@ beat([.5, 1.25])::sound('hat').out() ${makeExample( - "Intriguing rhythms", - ` + "Intriguing rhythms", + ` pulse([24, 16])::sound('hat').ad(0, .02).out() pulse([48, [36,24].dur(4, 1)])::sound('fhardkick').ad(0, .1).out() `, - true -)} + true + )} ${makeExample( - "pulse is the OG rhythmic function in Topos", - ` + "pulse is the OG rhythmic function in Topos", + ` pulse([48, 24, 16].beat(4)) :: sound('linnhats').out() beat(1)::snd(['bd', '808oh'].beat(1)).out() `, - false -)} + false + )} - bar(n: number | number[] = 1, offset: number = 1): return true every _n_ bars. @@ -80,37 +80,37 @@ beat(1)::snd(['bd', '808oh'].beat(1)).out() - offset: offset (in bars) to apply. ${makeExample( - "Four beats per bar: proof", - ` + "Four beats per bar: proof", + ` bar(1)::sound('kick').out() beat(1)::sound('hat').speed(2).out() `, - true -)} + true + )} ${makeExample( - "Offsetting beat and bar", - ` + "Offsetting beat and bar", + ` bar(1)::sound('kick').out() beat(1)::sound('hat').speed(2).out() beat(1, 0.5)::sound('hat').speed(4).out() bar(1, 0.5)::sound('sn').out() `, - false -)} + false + )} - onbeat(...n: number[]): The onbeat function allows you to lock on to a specific beat from the clock to execute code. It can accept multiple arguments. It's usage is very straightforward and not hard to understand. You can pass either integers or floating point numbers. By default, topos is using a 4/4 bar meaning that you can target any of these beats (or in-between) with this function. ${makeExample( - "Some simple yet detailed rhythms", - ` + "Some simple yet detailed rhythms", + ` onbeat(1,2,3,4)::snd('kick').out() // Bassdrum on each beat onbeat(2,4)::snd('snare').n([8,4].beat(4)).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 `, - true -)} + true + )} ## XOX Style sequencers @@ -119,32 +119,32 @@ onbeat(1.5,2.5,3.5, 3.75)::snd('hat').gain(r(0.9,1.1)).out() // Cool high-hats - duration: number: an optional duration (in beats) like 1 or 4. It can be patterned. ${makeExample( - "Sequence built using a classic XOX sequencer style", - ` + "Sequence built using a classic XOX sequencer style", + ` seq('xoxo')::sound('fhardkick').out() seq('ooxo')::sound('fsoftsnare').out() seq('xoxo', 0.25)::sound('fhh').out() `, - true -)} + true + )} ${makeExample( - "Another sequence using more complex parameters", - ` + "Another sequence using more complex parameters", + ` seq('xoxooxxoo', [0.5, 0.25].dur(2, 1))::sound('fhardkick').out() seq('ooxo', [1, 2].bar())::sound('fsoftsnare').speed(0.5).out() seq(['xoxoxoxx', 'xxoo'].bar())::sound('fhh').out() `, - true -)} + true + )} - fullseq(expr: string, duration: number = 0.5): boolean : a variant. Will return true or false for a whole period, depending on the symbol. Useful for long structure patterns. - expr: string: any string composed of x or o like so: "xooxoxxoxoo". - duration: number: an optional duration (in beats) like 1 or 4. It can be patterned. ${makeExample( - "Long structured patterns", - ` + "Long structured patterns", + ` function simplePat() { log('Simple pattern playing!') seq('xoxooxxoo', [0.5, 0.25].dur(2, 1))::sound('fhardkick').out() @@ -159,8 +159,8 @@ function complexPat() { } fullseq('xooxooxx', 4) ? simplePat() : complexPat() `, - true -)} + true + )} @@ -171,8 +171,8 @@ We included a bunch of popular rhythm generators in Topos such as the euclidian - rhythm(divisor: number, pulses: number, length: number, rotate: number): boolean: generates true or false values from an euclidian rhythm sequence. This is another version of euclid that does not take an iterator. ${makeExample( - "rhythm is a beginner friendly rhythmic function!", - ` + "rhythm is a beginner friendly rhythmic function!", + ` rhythm(.5, 4, 8)::sound('sine') .fmi(2) .room(0.5).size(8) @@ -181,38 +181,38 @@ rhythm(.5, 7, 8)::sound('sine') .freq(125).ad(0, .2).out() rhythm(.5, 3, 8)::sound('sine').freq(500).ad(0, .5).out() `, - true -)} + true + )} - oneuclid(pulses: number, length: number, rotate: number): boolean: generates true or false values from an euclidian rhythm sequence. This is another version of euclid that does not take an iterator. ${makeExample( - "Using oneuclid to create a rhythm without iterators", - ` + "Using oneuclid to create a rhythm without iterators", + ` // Change speed using bpm bpm(250) oneuclid(5, 9) :: snd('kick').out() oneuclid(7,16) :: snd('east').end(0.5).n(irand(3,5)).out() `, - true -)} + true + )} - 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. - binrhythm(divisor: number, n: number): boolean: boolean: iterator-less version of the binary rhythm generator. ${makeExample( - "Change the integers for a surprise rhythm!", - ` + "Change the integers for a surprise rhythm!", + ` bpm(135); beat(.5) && bin($(1), 12) && snd('kick').n([4,9].beat(1.5)).out() beat(.5) && bin($(2), 34) && snd('snare').n([3,5].beat(1)).out() `, - true -)} + true + )} ${makeExample( - "binrhythm for fast cool binary rhythms!", - ` + "binrhythm for fast cool binary rhythms!", + ` let a = 0; a = beat(4) ? irand(1,20) : a; binrhythm(.5, 6) && snd(['kick', 'snare'].beat(0.5)).n(11).out() @@ -221,34 +221,34 @@ binrhythm([.5, .25].beat(1), 30) && snd('wt_granular').n(a) .adsr(0, r(.1, .4), 0, 0).freq([50, 60, 72].beat(4)) .room(1).size(1).out() `, - true -)} + true + )} ${makeExample( - "Submarine jungle music", - ` + "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) .room(1).size(1).out() beat(.5) && sound('amencutup').n(irand(2,7)).shape(0.3).out() `, - false -)} + false + )} 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. ${makeExample( - "Probablistic drums in one line!", - ` + "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('mash') .n([1,2,3].beat(1)) .pan(usine(1/4)).out() prob(80)::beat(.5) && sound(['hh', 'hat'].pick()).out() `, - true -)} + true + )} diff --git a/src/documentation/linear_time.ts b/src/documentation/time/linear_time.ts similarity index 92% rename from src/documentation/linear_time.ts rename to src/documentation/time/linear_time.ts index c1aad90..81470bb 100644 --- a/src/documentation/linear_time.ts +++ b/src/documentation/time/linear_time.ts @@ -1,5 +1,5 @@ -import { type Editor } from "../main"; -import { makeExampleFactory } from "../Documentation"; +import { type Editor } from "../../main"; +import { makeExampleFactory } from "../../Documentation"; import pulses from "./pulses.svg"; export const linear_time = (app: Editor): string => { @@ -22,12 +22,12 @@ export const linear_time = (app: Editor): string => { There is a tiny widget at the bottom right of the screen showing you the current BPM and the status of the transport. You can turn it on or off in the settings menu. ${makeExample( - "Printing the transport", - ` + "Printing the transport", + ` log(\`\$\{cbar()}\, \$\{cbeat()\}, \$\{cpulse()\}\`) `, - true -)} + true + )} ### BPM and PPQN @@ -64,8 +64,8 @@ These values are **extremely useful** to craft more complex syntax or to write m You can use time primitives as conditionals. The following example will play a pattern A for 2 bars and a pattern B for 2 bars: ${makeExample( - "Manual mode: using time primitives!", - ` + "Manual mode: using time primitives!", + ` // Manual time condition if((cbar() % 4) > 1) { beat(2) && sound('kick').out() @@ -83,8 +83,8 @@ if((cbar() % 4) > 1) { // This is always playing no matter what happens beat([.5, .5, 1, .25].beat(0.5)) :: sound('shaker').out() `, - true -)} + true + )} ## Time Warping @@ -94,8 +94,8 @@ Time generally flows from the past to the future. However, you can manipulate it ${makeExample( - "Time is now super elastic!", - ` + "Time is now super elastic!", + ` // Obscure Shenanigans - Bubobubobubo beat([1/4,1/8,1/16].beat(8)):: sound('sine') .freq([100,50].beat(16) + 50 * ($(1)%10)) @@ -108,14 +108,14 @@ flip(3) :: beat([.25,.5].beat(.5)) :: sound('dr') // Jumping back and forth in time beat(.25) :: warp([12, 48, 24, 1, 120, 30].pick()) `, - true -)} + true + )} - beat_warp(beat: number): this function jumps to the _n_ beat of the clock. The first beat is 1. ${makeExample( - "Jumping back and forth with beats", - ` + "Jumping back and forth with beats", + ` // Resonance bliss - Bubobubobubo beat(.25)::snd('arpy') .note(30 + [0,3,7,10].beat()) @@ -130,40 +130,40 @@ beat(.5) :: snd('arpy').note( // Comment me to stop warping! beat(1) :: beat_warp([2,4,5,10,11].pick()) `, - true -)} + true + )} ## Transport-based rhythm generators - onbeat(...n: number[]): The onbeat function allows you to lock on to a specific beat from the clock to execute code. It can accept multiple arguments. It's usage is very straightforward and not hard to understand. You can pass either integers or floating point numbers. By default, topos is using a 4/4 bar meaning that you can target any of these beats (or in-between) with this function. ${makeExample( - "Some simple yet detailed rhythms", - ` + "Some simple yet detailed rhythms", + ` onbeat(1,2,3,4)::snd('kick').out() // Bassdrum on each beat onbeat(2,4)::snd('snare').n([8,4].beat(4)).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 `, - true -)} + true + )} ${makeExample( - "Let's do something more complex", - ` + "Let's do something more complex", + ` 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)).end(0.05) .pan(usine()).out() `, - false -)} + false + )} - oncount(beats: number[], meter: number): This function is similar to onbeat but it allows you to specify a custom number of beats as the last argument. ${makeExample( - "Using oncount to create more variation in the rhythm", - ` + "Using oncount to create more variation in the rhythm", + ` z1('1/16 (0 2 3 4)+(0 2 4 6)').scale('pentatonic').sound('sawtooth') .cutoff([400,500,1000,2000].beat(1)) .lpadsr(2, 0, .2, 0, 0) @@ -171,20 +171,20 @@ z1('1/16 (0 2 3 4)+(0 2 4 6)').scale('pentatonic').sound('sawtooth') 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() `, - true -)} + true + )} ${makeExample( - "Using oncount to create rhythms with a custom meter", - ` + "Using oncount to create rhythms with a custom meter", + ` bpm(200) oncount([1, 5, 9, 13],16) :: sound('808bd').n(4).shape(0.5).gain(1.0).out() oncount([5, 6, 13],16) :: sound('shaker').room(0.25).gain(0.9).out() oncount([2, 3, 3.5, 6, 7, 10, 15],16) :: sound('hh').n(8).gain(0.8).out() oncount([1, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16],16) :: sound('hh').out() `, - true -)} + true + )} diff --git a/src/documentation/pulses.svg b/src/documentation/time/pulses.svg similarity index 100% rename from src/documentation/pulses.svg rename to src/documentation/time/pulses.svg diff --git a/src/documentation/time.ts b/src/documentation/time/time.ts similarity index 92% rename from src/documentation/time.ts rename to src/documentation/time/time.ts index 757b566..538b8a2 100644 --- a/src/documentation/time.ts +++ b/src/documentation/time/time.ts @@ -1,5 +1,5 @@ -import { makeExampleFactory } from "../Documentation"; -import { type Editor } from "../main"; +import { makeExampleFactory } from "../../Documentation"; +import { type Editor } from "../../main"; import times from "./times.svg"; export const time = (application: Editor): string => { diff --git a/src/documentation/times.svg b/src/documentation/time/times.svg similarity index 100% rename from src/documentation/times.svg rename to src/documentation/time/times.svg