From 9fecea05f8d3a60ade91f2c547c91531347d250d Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Fri, 17 Nov 2023 17:18:10 +0100 Subject: [PATCH 01/11] beginning --- package.json | 2 +- src/classes/SoundEvent.ts | 8 ++++++-- yarn.lock | 8 ++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index c36bf26..f9e04f7 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "postcss": "^8.4.27", "showdown": "^2.1.0", "showdown-highlight": "^3.1.0", - "superdough": "^0.9.10", + "superdough": "^0.9.11", "tailwind-highlightjs": "^2.0.1", "tailwindcss": "^3.3.3", "tone": "^14.8.49", diff --git a/src/classes/SoundEvent.ts b/src/classes/SoundEvent.ts index d516d87..477a620 100644 --- a/src/classes/SoundEvent.ts +++ b/src/classes/SoundEvent.ts @@ -62,6 +62,10 @@ export class SoundEvent extends AudibleEvent { fmrelease: ["fmrelease", "fmrel"], fmvelocity: ["fmvelocity", "fmvel"], fmwave: ["fmwave", "fmw"], + phaser: ["phaser", "phas"], + phaserDepth: ["phaserDepth", "phasdepth"], + phaserSweep: ["phaserSweep", "phassweep"], + phaserCenter: ["phaserCenter", "phascenter"], fmadsr: (a: number, d: number, s: number, r: number) => { this.updateValue("fmattack", a); this.updateValue("fmdecay", d); @@ -254,7 +258,7 @@ export class SoundEvent extends AudibleEvent { roomfade: ["roomfade", "rfade"], roomlp: ["roomlp", "rlp"], roomdim: ["roomdim", "rdim"], - sound: ["s","sound"], + sound: ["s", "sound"], size: (value: number) => { this.updateValue("roomsize", value); return this; @@ -442,7 +446,7 @@ export class SoundEvent extends AudibleEvent { // const filteredEvent = filterObject(event, ["analyze","note","dur","freq","s"]); const filteredEvent = event; // No need for note if there is freq - if(filteredEvent.freq) { delete filteredEvent.note; } + if (filteredEvent.freq) { delete filteredEvent.note; } superdough(filteredEvent, this.nudge - this.app.clock.deviation, filteredEvent.dur); } }; diff --git a/yarn.lock b/yarn.lock index 12f2b7c..3829cbc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3319,10 +3319,10 @@ sucrase@^3.32.0: pirates "^4.0.1" ts-interface-checker "^0.1.9" -superdough@^0.9.10: - version "0.9.10" - resolved "https://registry.yarnpkg.com/superdough/-/superdough-0.9.10.tgz#9554964741c508b4c5d596fa8acbb2efea822250" - integrity sha512-IGu0+fBXpSS4l4Q+4ATRhSFXnas7t2G6uc5Ry+keQ4G+nc6uK6twAP0YyBlSB4RUdGpZCIS1o0t8qJ7MaBg4gw== +superdough@^0.9.11: + version "0.9.11" + resolved "https://registry.yarnpkg.com/superdough/-/superdough-0.9.11.tgz#3a3842a47d6340477f77d39077303f05e15274dd" + integrity sha512-s0SNSg/EJHwp2sUnE2A7pTZ0G2luiSEq9NVKJvodjJw11Tn0fOp9XcnegNXINYz3U6mAsUYRoeaj4NmuTL13fA== dependencies: nanostores "^0.8.1" From f27b20bbb18db6be9c59e57576a5454443de3ad4 Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Sat, 18 Nov 2023 00:54:10 +0100 Subject: [PATCH 02/11] move files around --- src/Documentation.ts | 10 +++++----- src/documentation/{ => basics}/code.ts | 4 ++-- src/documentation/{ => basics}/interface.ts | 4 ++-- src/documentation/{ => basics}/keyboard.ts | 6 +++--- src/documentation/{ => basics}/many_universes.svg | 0 src/documentation/{ => basics}/mouse.ts | 4 ++-- src/documentation/{ => basics}/topos_arch.svg | 0 .../{introduction.ts => basics/welcome.ts} | 6 +++--- src/documentation/probabilities.ts | 4 ++-- vite.config.js | 2 ++ 10 files changed, 21 insertions(+), 19 deletions(-) rename src/documentation/{ => basics}/code.ts (97%) rename src/documentation/{ => basics}/interface.ts (97%) rename src/documentation/{ => basics}/keyboard.ts (94%) rename src/documentation/{ => basics}/many_universes.svg (100%) rename src/documentation/{ => basics}/mouse.ts (95%) rename src/documentation/{ => basics}/topos_arch.svg (100%) rename src/documentation/{introduction.ts => basics/welcome.ts} (94%) diff --git a/src/Documentation.ts b/src/Documentation.ts index 67ba5a9..2014f56 100644 --- a/src/Documentation.ts +++ b/src/Documentation.ts @@ -1,21 +1,21 @@ import { type Editor } from "./main"; -import { introduction } from "./documentation/introduction"; +import { introduction } from "./documentation/basics/welcome"; +import { software_interface } from "./documentation/basics/interface"; +import { shortcuts } from "./documentation/basics/keyboard"; +import { code } from "./documentation/basics/code"; +import { mouse } from "./documentation/basics/mouse"; import { oscilloscope } from "./documentation/oscilloscope"; import { synchronisation } from "./documentation/synchronisation"; import { samples } from "./documentation/samples"; import { chaining } from "./documentation/chaining"; -import { software_interface } from "./documentation/interface"; 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 { long_forms } from "./documentation/long_forms"; import { midi } from "./documentation/midi"; -import { code } from "./documentation/code"; import { about } from "./documentation/about"; import { sound } from "./documentation/engine"; -import { shortcuts } from "./documentation/keyboard"; -import { mouse } from "./documentation/mouse"; import { patterns } from "./documentation/patterns"; import { functions } from "./documentation/functions"; import { variables } from "./documentation/variables"; diff --git a/src/documentation/code.ts b/src/documentation/basics/code.ts similarity index 97% rename from src/documentation/code.ts rename to src/documentation/basics/code.ts index 4415a67..07ce4ab 100644 --- a/src/documentation/code.ts +++ b/src/documentation/basics/code.ts @@ -1,5 +1,5 @@ -import { type Editor } from "../main"; -import { makeExampleFactory, key_shortcut } from "../Documentation"; +import { type Editor } from "../../main"; +import { makeExampleFactory, key_shortcut } from "../../Documentation"; export const code = (application: Editor): string => { const makeExample = makeExampleFactory(application); diff --git a/src/documentation/interface.ts b/src/documentation/basics/interface.ts similarity index 97% rename from src/documentation/interface.ts rename to src/documentation/basics/interface.ts index ba22351..13f0cd5 100644 --- a/src/documentation/interface.ts +++ b/src/documentation/basics/interface.ts @@ -1,5 +1,5 @@ -import { key_shortcut, makeExampleFactory } from "../Documentation"; -import { type Editor } from "../main"; +import { key_shortcut, makeExampleFactory } from "../../Documentation"; +import { type Editor } from "../../main"; import topos_arch from "./topos_arch.svg"; import many_universes from "./many_universes.svg"; diff --git a/src/documentation/keyboard.ts b/src/documentation/basics/keyboard.ts similarity index 94% rename from src/documentation/keyboard.ts rename to src/documentation/basics/keyboard.ts index 12db899..adf2dc0 100644 --- a/src/documentation/keyboard.ts +++ b/src/documentation/basics/keyboard.ts @@ -1,6 +1,6 @@ -import { key_shortcut } from "../Documentation"; -import { type Editor } from "../main"; -import { makeExampleFactory } from "../Documentation"; +import { key_shortcut } from "../../Documentation"; +import { type Editor } from "../../main"; +import { makeExampleFactory } from "../../Documentation"; export const shortcuts = (app: Editor): string => { let makeExample = makeExampleFactory(app); diff --git a/src/documentation/many_universes.svg b/src/documentation/basics/many_universes.svg similarity index 100% rename from src/documentation/many_universes.svg rename to src/documentation/basics/many_universes.svg diff --git a/src/documentation/mouse.ts b/src/documentation/basics/mouse.ts similarity index 95% rename from src/documentation/mouse.ts rename to src/documentation/basics/mouse.ts index c6b99a0..f6ad3fd 100644 --- a/src/documentation/mouse.ts +++ b/src/documentation/basics/mouse.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 mouse = (app: Editor): string => { let makeExample = makeExampleFactory(app); diff --git a/src/documentation/topos_arch.svg b/src/documentation/basics/topos_arch.svg similarity index 100% rename from src/documentation/topos_arch.svg rename to src/documentation/basics/topos_arch.svg diff --git a/src/documentation/introduction.ts b/src/documentation/basics/welcome.ts similarity index 94% rename from src/documentation/introduction.ts rename to src/documentation/basics/welcome.ts index 13090bb..3844c6b 100644 --- a/src/documentation/introduction.ts +++ b/src/documentation/basics/welcome.ts @@ -1,6 +1,6 @@ -import { makeExampleFactory, key_shortcut } from "../Documentation"; -import { type Editor } from "../main"; -import { examples } from "../examples/excerpts"; +import { makeExampleFactory, key_shortcut } from "../../Documentation"; +import { type Editor } from "../../main"; +import { examples } from "../../examples/excerpts"; export const introduction = (application: Editor): string => { const makeExample = makeExampleFactory(application); diff --git a/src/documentation/probabilities.ts b/src/documentation/probabilities.ts index 14dae0a..f48b4f2 100644 --- a/src/documentation/probabilities.ts +++ b/src/documentation/probabilities.ts @@ -9,8 +9,8 @@ export const probabilities = (application: Editor): string => { There are some simple functions to play with probabilities. -- rand(min: number, max:number): returns a random number between min and max. Shorthand _r()_. -- irand(min: number, max:number): returns a random integer between min and max. Shorthands _ir()_ or _rI()_. +- rand(min: number, max:number): returns a random number between min and max. Shorthand r(). +- irand(min: number, max:number): returns a random integer between min and max. Shorthands ir() or rI(). ${makeExample( "Bleep bloop, what were you expecting?", diff --git a/vite.config.js b/vite.config.js index ffdfc9b..5a088f8 100644 --- a/vite.config.js +++ b/vite.config.js @@ -26,7 +26,9 @@ const webManifest = { const vitePWAconfiguration = { devOptions: { enabled: true, + suppressWarnings: true, }, + workbox: { sourcemap: false, cleanupOutdatedCaches: true, From 741513ddf09900a082842ef019a2e631c1d61fef Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Sat, 18 Nov 2023 00:57:02 +0100 Subject: [PATCH 03/11] 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 From 8278e2206ffe3d8b8f5dd058557b22e7f94a8fab Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Sat, 18 Nov 2023 01:02:20 +0100 Subject: [PATCH 04/11] moving more files around --- src/Documentation.ts | 10 ++++++---- src/documentation/{ => more}/about.ts | 0 src/documentation/{ => more}/bonus.ts | 4 ++-- src/documentation/{ => more}/oscilloscope.ts | 20 +++++++++---------- .../{ => more}/synchronisation.ts | 4 ++-- 5 files changed, 20 insertions(+), 18 deletions(-) rename src/documentation/{ => more}/about.ts (100%) rename src/documentation/{ => more}/bonus.ts (96%) rename src/documentation/{ => more}/oscilloscope.ts (88%) rename src/documentation/{ => more}/synchronisation.ts (93%) diff --git a/src/Documentation.ts b/src/Documentation.ts index 5c2128b..63874d6 100644 --- a/src/Documentation.ts +++ b/src/Documentation.ts @@ -1,11 +1,15 @@ import { type Editor } from "./main"; +// Basics import { introduction } from "./documentation/basics/welcome"; import { software_interface } from "./documentation/basics/interface"; import { shortcuts } from "./documentation/basics/keyboard"; import { code } from "./documentation/basics/code"; import { mouse } from "./documentation/basics/mouse"; -import { oscilloscope } from "./documentation/oscilloscope"; -import { synchronisation } from "./documentation/synchronisation"; +// More +import { oscilloscope } from "./documentation/more/oscilloscope"; +import { synchronisation } from "./documentation/more/synchronisation"; +import { about } from "./documentation/more/about"; +import { bonus } from "./documentation/more/bonus"; import { samples } from "./documentation/samples"; import { chaining } from "./documentation/chaining"; import { interaction } from "./documentation/interaction"; @@ -14,7 +18,6 @@ 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"; import { sound } from "./documentation/engine"; import { patterns } from "./documentation/patterns"; import { functions } from "./documentation/functions"; @@ -24,7 +27,6 @@ import { lfos } from "./documentation/lfos"; import { ziffers } from "./documentation/ziffers"; import { reference } from "./documentation/reference"; import { synths } from "./documentation/synths"; -import { bonus } from "./documentation/bonus"; // Setting up the Markdown converter with syntax highlighting import showdown from "showdown"; diff --git a/src/documentation/about.ts b/src/documentation/more/about.ts similarity index 100% rename from src/documentation/about.ts rename to src/documentation/more/about.ts diff --git a/src/documentation/bonus.ts b/src/documentation/more/bonus.ts similarity index 96% rename from src/documentation/bonus.ts rename to src/documentation/more/bonus.ts index 193b56d..f3901b6 100644 --- a/src/documentation/bonus.ts +++ b/src/documentation/more/bonus.ts @@ -1,5 +1,5 @@ -import { type Editor } from "../main"; -import { key_shortcut, makeExampleFactory } from "../Documentation"; +import { type Editor } from "../../main"; +import { key_shortcut, makeExampleFactory } from "../../Documentation"; export const bonus = (application: Editor): string => { const makeExample = makeExampleFactory(application); diff --git a/src/documentation/oscilloscope.ts b/src/documentation/more/oscilloscope.ts similarity index 88% rename from src/documentation/oscilloscope.ts rename to src/documentation/more/oscilloscope.ts index 4c7eea0..b75cf3d 100644 --- a/src/documentation/oscilloscope.ts +++ b/src/documentation/more/oscilloscope.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 oscilloscope = (application: Editor): string => { const makeExample = makeExampleFactory(application); @@ -8,8 +8,8 @@ export const oscilloscope = (application: Editor): string => { You can turn on the oscilloscope to generate interesting visuals or to inspect audio. Use the scope() function to turn it on and off. The oscilloscope is off by default. ${makeExample( - "Oscilloscope configuration", - ` + "Oscilloscope configuration", + ` scope({ enabled: true, // off by default color: "#fdba74", // any valid CSS color or "random" @@ -23,12 +23,12 @@ scope({ refresh: 1 // refresh rate (in pulses) }) `, - true -)} + true + )} ${makeExample( - "Demo with multiple scope mode", - ` + "Demo with multiple scope mode", + ` rhythm(.5, [4,5].dur(4*3, 4*1), 8)::sound('fhardkick').out() beat(0.25)::sound('square').freq([ [250, 250/2, 250/4].pick(), @@ -44,8 +44,8 @@ scope({enabled: true, thickness: 8, color: ['purple', 'green', 'random'].beat(), size: 0.5, fftSize: 2048}) `, - true -)} + true + )} Note that these values can be patterned as well! You can transform the oscilloscope into its own light show if you want. The picture is not stable anyway so you won't have much use of it for precision work :) diff --git a/src/documentation/synchronisation.ts b/src/documentation/more/synchronisation.ts similarity index 93% rename from src/documentation/synchronisation.ts rename to src/documentation/more/synchronisation.ts index 78ee462..b2a7db8 100644 --- a/src/documentation/synchronisation.ts +++ b/src/documentation/more/synchronisation.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 synchronisation = (app: Editor): string => { // @ts-ignore From 97166139c43a0805277d651f47fdb504f467e1ad Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Sat, 18 Nov 2023 01:28:05 +0100 Subject: [PATCH 05/11] Allow universe renaming --- index.html | 3 ++- src/FileManagement.ts | 4 ++-- src/InterfaceLogic.ts | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index e420bb2..f704c7d 100644 --- a/index.html +++ b/index.html @@ -76,7 +76,8 @@ - + +