diff --git a/dev-dist/sw.js b/dev-dist/sw.js index 9c76a45..2b86b7a 100644 --- a/dev-dist/sw.js +++ b/dev-dist/sw.js @@ -36,22 +36,6 @@ if (!self.define) { } }) - .then(() => { - return registry[uri] || ( - - new Promise(resolve => { - if ("document" in self) { - const script = document.createElement("script"); - script.src = uri; - script.onload = resolve; - document.head.appendChild(script); - } else { - nextDefineUri = uri; - importScripts(uri); - resolve(); - } - }) - .then(() => { let promise = registry[uri]; if (!promise) { @@ -70,15 +54,11 @@ if (!self.define) { } let exports = {}; const require = depUri => singleRequire(depUri, uri); - const require = depUri => singleRequire(depUri, uri); const specialDeps = { module: { uri }, exports, require }; - registry[uri] = Promise.all(depsNames.map( - depName => specialDeps[depName] || require(depName) - )).then(deps => { registry[uri] = Promise.all(depsNames.map( depName => specialDeps[depName] || require(depName) )).then(deps => { @@ -87,7 +67,6 @@ if (!self.define) { }); }; } -define(['./workbox-b7fccfec'], (function (workbox) { 'use strict'; define(['./workbox-b7fccfec'], (function (workbox) { 'use strict'; self.skipWaiting(); @@ -103,7 +82,7 @@ define(['./workbox-b7fccfec'], (function (workbox) { 'use strict'; "revision": "3ca0b8505b4bec776b69afdba2768812" }, { "url": "index.html", - "revision": "0.93gcaii03k8" + "revision": "0.0ufj7f4tmog" }], {}); workbox.cleanupOutdatedCaches(); workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), { @@ -121,21 +100,5 @@ define(['./workbox-b7fccfec'], (function (workbox) { 'use strict'; })] }), 'GET'); -})); - workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), { - allowlist: [/^\/$/] - })); - workbox.registerRoute(({ - url - }) => [/^https:\/\/raw\.githubusercontent\.com\/.*/i, /^https:\/\/shabda\.ndre\.gr\/.*/i].some(regex => regex.test(url)), new workbox.CacheFirst({ - "cacheName": "external-samples", - plugins: [new workbox.ExpirationPlugin({ - maxEntries: 5000, - maxAgeSeconds: 2592000 - }), new workbox.CacheableResponsePlugin({ - statuses: [0, 200] - })] - }), 'GET'); - })); //# sourceMappingURL=sw.js.map diff --git a/dev-dist/sw.js.map b/dev-dist/sw.js.map index 46439c0..dc9bc86 100644 --- a/dev-dist/sw.js.map +++ b/dev-dist/sw.js.map @@ -1 +1 @@ -{"version":3,"file":"sw.js","sources":["../../../private/var/folders/zq/nwpwzg_s2rq87xq7zggqfvhw0000gn/T/9398254de3f8a3797e972f024bcf6869/sw.js"],"sourcesContent":["import {registerRoute as workbox_routing_registerRoute} from '/Users/bubo/Topos/node_modules/workbox-routing/registerRoute.mjs';\nimport {ExpirationPlugin as workbox_expiration_ExpirationPlugin} from '/Users/bubo/Topos/node_modules/workbox-expiration/ExpirationPlugin.mjs';\nimport {CacheableResponsePlugin as workbox_cacheable_response_CacheableResponsePlugin} from '/Users/bubo/Topos/node_modules/workbox-cacheable-response/CacheableResponsePlugin.mjs';\nimport {CacheFirst as workbox_strategies_CacheFirst} from '/Users/bubo/Topos/node_modules/workbox-strategies/CacheFirst.mjs';\nimport {clientsClaim as workbox_core_clientsClaim} from '/Users/bubo/Topos/node_modules/workbox-core/clientsClaim.mjs';\nimport {precacheAndRoute as workbox_precaching_precacheAndRoute} from '/Users/bubo/Topos/node_modules/workbox-precaching/precacheAndRoute.mjs';\nimport {cleanupOutdatedCaches as workbox_precaching_cleanupOutdatedCaches} from '/Users/bubo/Topos/node_modules/workbox-precaching/cleanupOutdatedCaches.mjs';\nimport {NavigationRoute as workbox_routing_NavigationRoute} from '/Users/bubo/Topos/node_modules/workbox-routing/NavigationRoute.mjs';\nimport {createHandlerBoundToURL as workbox_precaching_createHandlerBoundToURL} from '/Users/bubo/Topos/node_modules/workbox-precaching/createHandlerBoundToURL.mjs';/**\n * Welcome to your Workbox-powered service worker!\n *\n * You'll need to register this file in your web app.\n * See https://goo.gl/nhQhGp\n *\n * The rest of the code is auto-generated. Please don't update this file\n * directly; instead, make changes to your Workbox build configuration\n * and re-run your build process.\n * See https://goo.gl/2aRDsh\n */\n\n\n\n\n\n\n\n\nself.skipWaiting();\n\nworkbox_core_clientsClaim();\n\n\n/**\n * The precacheAndRoute() method efficiently caches and responds to\n * requests for URLs in the manifest.\n * See https://goo.gl/S9QRab\n */\nworkbox_precaching_precacheAndRoute([\n {\n \"url\": \"registerSW.js\",\n \"revision\": \"3ca0b8505b4bec776b69afdba2768812\"\n },\n {\n \"url\": \"index.html\",\n \"revision\": \"0.93gcaii03k8\"\n }\n], {});\nworkbox_precaching_cleanupOutdatedCaches();\nworkbox_routing_registerRoute(new workbox_routing_NavigationRoute(workbox_precaching_createHandlerBoundToURL(\"index.html\"), {\n allowlist: [/^\\/$/],\n \n}));\n\n\nworkbox_routing_registerRoute(({ url }) => [\n /^https:\\/\\/raw\\.githubusercontent\\.com\\/.*/i,\n /^https:\\/\\/shabda\\.ndre\\.gr\\/.*/i\n ].some((regex) => regex.test(url)), new workbox_strategies_CacheFirst({ \"cacheName\":\"external-samples\", plugins: [new workbox_expiration_ExpirationPlugin({ maxEntries: 5000, maxAgeSeconds: 2592000 }), new workbox_cacheable_response_CacheableResponsePlugin({ statuses: [ 0, 200 ] })] }), 'GET');\n\n\n\n\n"],"names":["self","skipWaiting","workbox_core_clientsClaim","workbox_precaching_precacheAndRoute","workbox_precaching_cleanupOutdatedCaches","workbox_routing_registerRoute","workbox_routing_NavigationRoute","workbox_precaching_createHandlerBoundToURL","allowlist","url","some","regex","test","workbox_strategies_CacheFirst","plugins","workbox_expiration_ExpirationPlugin","maxEntries","maxAgeSeconds","workbox_cacheable_response_CacheableResponsePlugin","statuses"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BAA,CAAI,CAAA,CAAA,CAAA,CAACC,CAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAE,CAAA;AAElBC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAA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CAAA;AAAG,CAAA,CAAA,CAAA,CAAA,CAAC,CAAC,CAAA;EAAE,CAAC,CAAC,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAK,CAAC,CAAA;;"} \ No newline at end of file +{"version":3,"file":"sw.js","sources":["../../../private/var/folders/zq/nwpwzg_s2rq87xq7zggqfvhw0000gn/T/64cbd6a2ae1a8b15bd88c606dc97a28a/sw.js"],"sourcesContent":["import {registerRoute as workbox_routing_registerRoute} from '/Users/bubo/Topos/node_modules/workbox-routing/registerRoute.mjs';\nimport {ExpirationPlugin as workbox_expiration_ExpirationPlugin} from '/Users/bubo/Topos/node_modules/workbox-expiration/ExpirationPlugin.mjs';\nimport {CacheableResponsePlugin as workbox_cacheable_response_CacheableResponsePlugin} from '/Users/bubo/Topos/node_modules/workbox-cacheable-response/CacheableResponsePlugin.mjs';\nimport {CacheFirst as workbox_strategies_CacheFirst} from '/Users/bubo/Topos/node_modules/workbox-strategies/CacheFirst.mjs';\nimport {clientsClaim as workbox_core_clientsClaim} from '/Users/bubo/Topos/node_modules/workbox-core/clientsClaim.mjs';\nimport {precacheAndRoute as workbox_precaching_precacheAndRoute} from '/Users/bubo/Topos/node_modules/workbox-precaching/precacheAndRoute.mjs';\nimport {cleanupOutdatedCaches as workbox_precaching_cleanupOutdatedCaches} from '/Users/bubo/Topos/node_modules/workbox-precaching/cleanupOutdatedCaches.mjs';\nimport {NavigationRoute as workbox_routing_NavigationRoute} from '/Users/bubo/Topos/node_modules/workbox-routing/NavigationRoute.mjs';\nimport {createHandlerBoundToURL as workbox_precaching_createHandlerBoundToURL} from '/Users/bubo/Topos/node_modules/workbox-precaching/createHandlerBoundToURL.mjs';/**\n * Welcome to your Workbox-powered service worker!\n *\n * You'll need to register this file in your web app.\n * See https://goo.gl/nhQhGp\n *\n * The rest of the code is auto-generated. Please don't update this file\n * directly; instead, make changes to your Workbox build configuration\n * and re-run your build process.\n * See https://goo.gl/2aRDsh\n */\n\n\n\n\n\n\n\n\nself.skipWaiting();\n\nworkbox_core_clientsClaim();\n\n\n/**\n * The precacheAndRoute() method efficiently caches and responds to\n * requests for URLs in the manifest.\n * See https://goo.gl/S9QRab\n */\nworkbox_precaching_precacheAndRoute([\n {\n \"url\": \"registerSW.js\",\n \"revision\": \"3ca0b8505b4bec776b69afdba2768812\"\n },\n {\n \"url\": \"index.html\",\n \"revision\": \"0.0ufj7f4tmog\"\n }\n], {});\nworkbox_precaching_cleanupOutdatedCaches();\nworkbox_routing_registerRoute(new workbox_routing_NavigationRoute(workbox_precaching_createHandlerBoundToURL(\"index.html\"), {\n allowlist: [/^\\/$/],\n \n}));\n\n\nworkbox_routing_registerRoute(({ url }) => [\n /^https:\\/\\/raw\\.githubusercontent\\.com\\/.*/i,\n /^https:\\/\\/shabda\\.ndre\\.gr\\/.*/i\n ].some((regex) => regex.test(url)), new workbox_strategies_CacheFirst({ \"cacheName\":\"external-samples\", plugins: [new workbox_expiration_ExpirationPlugin({ maxEntries: 5000, maxAgeSeconds: 2592000 }), new workbox_cacheable_response_CacheableResponsePlugin({ statuses: [ 0, 200 ] })] }), 'GET');\n\n\n\n\n"],"names":["self","skipWaiting","workbox_core_clientsClaim","workbox_precaching_precacheAndRoute","workbox_precaching_cleanupOutdatedCaches","workbox_routing_registerRoute","workbox_routing_NavigationRoute","workbox_precaching_createHandlerBoundToURL","allowlist","url","some","regex","test","workbox_strategies_CacheFirst","plugins","workbox_expiration_ExpirationPlugin","maxEntries","maxAgeSeconds","workbox_cacheable_response_CacheableResponsePlugin","statuses"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BAA,CAAI,CAAA,CAAA,CAAA,CAACC,CAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAE,CAAA;AAElBC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,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CAAA,CAAA,CAAC,CAAC,CAAA;EAAE,CAAC,CAAC,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAK,CAAC,CAAA;;"} \ No newline at end of file diff --git a/src/API.ts b/src/API.ts index 3c94853..6134353 100644 --- a/src/API.ts +++ b/src/API.ts @@ -707,8 +707,8 @@ export class UserAPI { this.app.api.patternCache.set(key, player); } - if(player.ziffers.generator && player.ziffers.generatorDone) { - this.removePatternFromCache(key); + if (player.ziffers.generator && player.ziffers.generatorDone) { + this.removePatternFromCache(key); } if (typeof id === "number") player.zid = zid; @@ -1322,6 +1322,12 @@ export class UserAPI { return results.some((value) => value === true); }; + public dur = (n: number | number[]): boolean => { + let nums: number[] = Array.isArray(n) ? n : [n]; + // @ts-ignore + return this.beat(nums.dur(...nums)); + }; + // ============================================================= // Modulo based time filters // ============================================================= diff --git a/src/WindowBehavior.ts b/src/WindowBehavior.ts index 8ae9e27..8ff067e 100644 --- a/src/WindowBehavior.ts +++ b/src/WindowBehavior.ts @@ -16,6 +16,11 @@ const handleResize = (canvas: HTMLCanvasElement) => { } }; +export const saveState = (app: Editor): null => { + app.settings.saveApplicationToLocalStorage(app.universes, app.settings); + return null; +}; + export const saveBeforeExit = (app: Editor): null => { // Iterate over all local files and set the candidate to the committed app.currentFile().candidate = app.view.state.doc.toString(); @@ -29,7 +34,6 @@ export const installWindowBehaviors = ( window: Window, preventMultipleTabs: boolean = false ) => { - window.addEventListener("resize", () => handleResize(app.interface.scope as HTMLCanvasElement) ); @@ -37,19 +41,19 @@ export const installWindowBehaviors = ( handleResize(app.interface.feedback as HTMLCanvasElement) ); window.addEventListener("beforeunload", (event) => { - event.preventDefault() - saveBeforeExit(app) + event.preventDefault(); + saveBeforeExit(app); }); window.addEventListener("visibilitychange", (event) => { event.preventDefault(); - saveBeforeExit(app) + saveBeforeExit(app); }); if (preventMultipleTabs) { localStorage.openpages = Date.now(); window.addEventListener( "storage", - function(e) { + function (e) { if (e.key == "openpages") { // Listen if anybody else is opening the same page! localStorage.page_available = Date.now(); @@ -65,11 +69,21 @@ export const installWindowBehaviors = ( ); } - window.addEventListener('error', e => { - console.log("Je suis bien installé !") - console.log(e.message - , '\n', e.filename, ':', e.lineno, (e.colno ? ':' + e.colno : '') - , e.error && e.error.stack ? '\n' : '', e.error ? e.error.stack : undefined - ); - }, false); + window.addEventListener( + "error", + (e) => { + console.log("Je suis bien installé !"); + console.log( + e.message, + "\n", + e.filename, + ":", + e.lineno, + e.colno ? ":" + e.colno : "", + e.error && e.error.stack ? "\n" : "", + e.error ? e.error.stack : undefined + ); + }, + false + ); }; diff --git a/src/documentation/cyclical_time.ts b/src/documentation/cyclical_time.ts index 46cfc95..acbd8eb 100644 --- a/src/documentation/cyclical_time.ts +++ b/src/documentation/cyclical_time.ts @@ -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 +)} ## Cyclical rhythm generators @@ -119,8 +119,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) @@ -129,38 +129,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() @@ -169,34 +169,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/extensions/ArrayExtensions.ts b/src/extensions/ArrayExtensions.ts index 1f4982d..bb1d078 100644 --- a/src/extensions/ArrayExtensions.ts +++ b/src/extensions/ArrayExtensions.ts @@ -1,6 +1,6 @@ import { type UserAPI } from "../API"; import { safeScale, stepsToScale } from "zifferjs"; -export { }; +export {}; declare global { interface Array { @@ -8,8 +8,8 @@ declare global { sub(amount: number): number[]; mult(amount: number): number[]; div(amount: number): number[]; - mouseX(): T[], - mouseY(): T[], + mouseX(): T[]; + mouseY(): T[]; palindrome(): T[]; random(index: number): T; rand(index: number): T; @@ -37,7 +37,6 @@ declare global { } export const makeArrayExtensions = (api: UserAPI) => { - Array.prototype.mouseX = function (this: T[]): T { /** * @returns Value from list based on mouse X position @@ -59,14 +58,14 @@ export const makeArrayExtensions = (api: UserAPI) => { return this[zoneIndex]; }; - Array.prototype.square = function(): number[] { + Array.prototype.square = function (): number[] { /** * @returns New array with squared values. */ return this.map((x: number) => x * x); }; - Array.prototype.sometimes = function(func: Function): number[] { + Array.prototype.sometimes = function (func: Function): number[] { if (api.randomGen() < 0.5) { return func(this); } else { @@ -74,11 +73,11 @@ export const makeArrayExtensions = (api: UserAPI) => { } }; - Array.prototype.apply = function(func: Function): number[] { + Array.prototype.apply = function (func: Function): number[] { return func(this); }; - Array.prototype.sqrt = function(): number[] { + Array.prototype.sqrt = function (): number[] { /** * @returns New array with square roots of values. Throws if any element is negative. */ @@ -87,7 +86,7 @@ export const makeArrayExtensions = (api: UserAPI) => { return this.map((x: number) => Math.sqrt(x)); }; - Array.prototype.add = function(amount: number): number[] { + Array.prototype.add = function (amount: number): number[] { /** * @param amount - The value to add to each element in the array. * @returns New array with added values. @@ -95,7 +94,7 @@ export const makeArrayExtensions = (api: UserAPI) => { return this.map((x: number) => x + amount); }; - Array.prototype.sub = function(amount: number): number[] { + Array.prototype.sub = function (amount: number): number[] { /** * @param amount - The value to subtract from each element in the array. * @returns New array with subtracted values. @@ -103,7 +102,7 @@ export const makeArrayExtensions = (api: UserAPI) => { return this.map((x: number) => x - amount); }; - Array.prototype.mult = function(amount: number): number[] { + Array.prototype.mult = function (amount: number): number[] { /** * @param amount - The value to multiply with each element in the array. * @returns New array with multiplied values. @@ -111,7 +110,7 @@ export const makeArrayExtensions = (api: UserAPI) => { return this.map((x: number) => x * amount); }; - Array.prototype.div = function(amount: number): number[] { + Array.prototype.div = function (amount: number): number[] { /** * @param amount - The value to divide each element in the array by. * @returns New array with divided values. Throws if division by zero. @@ -120,7 +119,7 @@ export const makeArrayExtensions = (api: UserAPI) => { return this.map((x: number) => x / amount); }; - Array.prototype.pick = function() { + Array.prototype.pick = function () { /** * Returns a random element from an array. * @@ -129,7 +128,7 @@ export const makeArrayExtensions = (api: UserAPI) => { return this[Math.floor(api.randomGen() * this.length)]; }; - Array.prototype.gen = function(min: number, max: number, times: number) { + Array.prototype.gen = function (min: number, max: number, times: number) { /** * Returns an array of random numbers. * @param min - The minimum value of the random numbers @@ -146,7 +145,7 @@ export const makeArrayExtensions = (api: UserAPI) => { ); }; - Array.prototype.bar = function(value: number = 1) { + Array.prototype.bar = function (value: number = 1) { /** * Returns an element from an array based on the current bar. * @@ -161,7 +160,7 @@ export const makeArrayExtensions = (api: UserAPI) => { } }; - Array.prototype.beat = function(divisor: number = 1) { + Array.prototype.beat = function (divisor: number = 1) { const chunk_size = divisor; // Get the first argument (chunk size) const timepos = api.app.clock.pulses_since_origin; const slice_count = Math.floor( @@ -171,47 +170,30 @@ export const makeArrayExtensions = (api: UserAPI) => { }; Array.prototype.b = Array.prototype.beat; - // Array.prototype.dur = function(...durations) { - // const timepos = api.app.clock.pulses_since_origin; - // const ppqn = api.ppqn(); - // let adjustedDurations = []; - // for (let i = 0; i < this.length; i++) { - // adjustedDurations.push(durations[i % durations.length]); - // } - // let cumulativeDuration = 0; - // let totalDuration = adjustedDurations.reduce((acc, duration) => acc + duration * ppqn, 0); - // let modulatedTimePos = timepos % totalDuration; - // for (let i = 0; i < this.length; i++) { - // const valueDuration = adjustedDurations[i] as any * ppqn; - // if (modulatedTimePos < cumulativeDuration + valueDuration) { - // return this[i]; - // } - // cumulativeDuration += valueDuration; - // } - // // This point should not be reached if durations are correctly specified - // throw new Error('Durations array does not match the pattern length.'); - // }; - - Array.prototype.dur = function(...durations) { + Array.prototype.dur = function (...durations) { const timepos = api.app.clock.pulses_since_origin; const ppqn = api.ppqn(); - const adjustedDurations = this.map((_, index) => durations[index % durations.length]); + const adjustedDurations = this.map( + (_, index) => durations[index % durations.length] + ); // @ts-ignore - const totalDurationInPulses = adjustedDurations.reduce((acc, duration) => acc + duration * ppqn, 0); + const totalDurationInPulses = adjustedDurations.reduce( + (acc, duration) => acc + duration * ppqn, + 0 + ); const loopPosition = timepos % totalDurationInPulses; let cumulativeDuration = 0; for (let i = 0; i < this.length; i++) { - const valueDurationInPulses = adjustedDurations[i] as any * ppqn; + const valueDurationInPulses = (adjustedDurations[i] as any) * ppqn; cumulativeDuration += valueDurationInPulses; if (loopPosition < cumulativeDuration) { return this[i]; } } - throw new Error('Durations array does not match the pattern length.'); + throw new Error("Durations array does not match the pattern length."); }; - - Array.prototype.shuffle = function() { + Array.prototype.shuffle = function () { /** * Shuffles the array in place. * @@ -230,7 +212,7 @@ export const makeArrayExtensions = (api: UserAPI) => { return this; }; - Array.prototype.rotate = function(steps: number) { + Array.prototype.rotate = function (steps: number) { /** * Rotates the array in place. * @@ -250,7 +232,7 @@ export const makeArrayExtensions = (api: UserAPI) => { return this; }; - Array.prototype.unique = function() { + Array.prototype.unique = function () { /** * Removes duplicate elements from the array in place. * @@ -283,7 +265,7 @@ export const makeArrayExtensions = (api: UserAPI) => { if (this.length <= 1) { return this; } - for (let i = 0; i < this.length;) { + for (let i = 0; i < this.length; ) { const rand = api.randomGen() * 100; if (rand < amount) { if (this.length > 1) { @@ -396,7 +378,7 @@ export const makeArrayExtensions = (api: UserAPI) => { return left_to_right.concat(right_to_left); }; - Array.prototype.loop = function(index: number) { + Array.prototype.loop = function (index: number) { /** * Returns an element from the array based on the index. * The index will wrap over the array. @@ -407,7 +389,7 @@ export const makeArrayExtensions = (api: UserAPI) => { return this[index % this.length]; }; - Array.prototype.random = function() { + Array.prototype.random = function () { /** * Returns a random element from the array. * @@ -418,7 +400,7 @@ export const makeArrayExtensions = (api: UserAPI) => { Array.prototype.rand = Array.prototype.random; }; -Array.prototype.scale = function( +Array.prototype.scale = function ( scale: string = "major", base_note: number = 0 ) { @@ -442,7 +424,7 @@ Array.prototype.scale = function( }); }; -Array.prototype.scaleArp = function( +Array.prototype.scaleArp = function ( scaleName: string = "major", boundary: number = 0 ) { diff --git a/src/main.ts b/src/main.ts index ca1e040..fa3dc3f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -16,8 +16,8 @@ import { documentation_factory } from "./Documentation"; import { EditorView } from "codemirror"; import { Clock } from "./Clock"; import { loadSamples, UserAPI } from "./API"; -import * as oeis from 'jisg' -import * as zpatterns from 'zifferjs/src/patterns.ts' +import * as oeis from "jisg"; +import * as zpatterns from "zifferjs/src/patterns.ts"; import { makeArrayExtensions } from "./extensions/ArrayExtensions"; import "./style.css"; import { Universes, File, template_universes } from "./FileManagement"; @@ -26,7 +26,7 @@ import { tryEvaluate } from "./Evaluator"; import showdown from "showdown"; import { makeStringExtensions } from "./extensions/StringExtensions"; import { installInterfaceLogic } from "./InterfaceLogic"; -import { installWindowBehaviors, saveBeforeExit } from "./WindowBehavior"; +import { installWindowBehaviors, saveState } from "./WindowBehavior"; import { drawEmptyBlinkers } from "./AudioVisualisation"; import { makeNumberExtensions } from "./extensions/NumberExtensions"; // @ts-ignore @@ -482,7 +482,7 @@ export class Editor { console.log("Hydra loaded successfully"); this.initializeHydra(); }; - script.onerror = function() { + script.onerror = function () { console.error("Error loading Hydra script"); }; document.head.appendChild(script); @@ -514,7 +514,7 @@ export class Editor { } private setPeriodicSave(interval: number): void { - setInterval(() => saveBeforeExit(this), interval) + setInterval(() => saveState(this), interval); } }