This commit is contained in:
Bubobubobubobubo
2023-12-17 22:37:09 +00:00
parent f239a099a4
commit d4762715f3
6 changed files with 55 additions and 10 deletions

View File

@ -2430,7 +2430,7 @@ flip(2) :: beat(2) :: delayr(150, 4, () => sound('east').speed([0.5,.25].beat()
JavaScript <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator" target="_blank">generators</a> are powerful functions for generating value sequences. They can be used to generate melodies, rhythms or control parameters.
In Topos generator functions should be called using the <ic>cache(key, function)</ic> function to store the current state of the generator. This function takes two arguments: the name for the cache and the generator instance.
In Topos generator functions should be called using the <ic>cache(key, function)</ic> function to store the current state of the generator. This function takes two arguments: the name for the cache and the generator instance.
Once the generator is cached the values will be returned from the named cache even if the generator function is modified. To clear the current cache and to re-evaluate the modified generator use the **Shift+Ctrl+Backspace** shortcut. Alternatively you can cache the modified generator using a different name.
@ -2454,37 +2454,82 @@ ${e("Infinite frequency generator",`
const s = Math.tan(x/10)+Math.sin(x/20);
yield 2 * Math.pow(s, 3) - 6 * Math.pow(s, 2) + 5 * s + 200;
x++;
}
}
}
beat(.125) && sound("triangle").freq(cache("mathyshit",poly())).out()
`,!0)};
When you want to dance with a dynamic system in controlled musical chaos, Topos is waiting for you:
${e("Truly scale free chaos inspired by Lorentz attractor",`
function* strange(x = 0.1, y = 0, z = 0, rho = 28, beta = 8 / 3, zeta = 10) {
while (true) {
const dx = 10 * (y - x);
const dy = x * (rho - z) - y;
const dz = x * y - beta * z;
x += dx * 0.01;
y += dy * 0.01;
z += dz * 0.01;
const value = 300 + 30 * (Math.sin(x) + Math.tan(y) + Math.cos(z))
yield value;
}
}
beat(0.25) :: sound("triangle")
.freq(cache("stranger",strange(3,5,2)))
.adsr(.15,.1,.1,.1)
.log("freq").out()
`,!0)};
${e("Henon and his discrete music",`
function* henonmap(x = 0, y = 0, a = 1.4, b = 0.3) {
while (true) {
const newX = 1 - a * x ** 2 + y;
const newY = b * x;
const fusionPoint = newX + newY
yield fusionPoint * 300;
[x, y] = [newX, newY]
}
}
beat(0.25) :: sound("sawtooth")
.semitones(1,1,2,2,2,1,2,1)
.freq(cache("henonSynth", henonmap()))
.adsr(0, 0.1, 0.1, 0.5).out()
z0('1 {-2}').octave(-2).sound('bd').out()
z1('e. 1 s 3!2 e 3!2 s 9 8 1')
.sound('dr').gain(0.3).octave(-5).out()
`,!0)};
${e("1970s fractal dream",`
function* rossler(x = 0.1, y = 0.1, z = 0.1, a = 0.2, b = 0.2, c = 5.7) {
while (true) {
const dx = - y - z;
const dy = x + (a * y);
const dz = b + (x * z) - (c * z);
x += dx * 0.01;
y += dy * 0.01;
z += dz * 0.01;
const value = 250 * (Math.cosh(x*z) + Math.sinh(y*z))
yield value % 120 + 100;
}
}
beat(0.25) :: sound("triangle")
.freq(cache("rossler attractor", rossler(3,4,1)))
.adsr(0,.1,.1,.1)
.log("freq").out()
`,!0)};
## OEIS integer sequences
To find some inspiration - or to enter into the void - one can visit <a href="https://oeis.org/" target="_blank">The On-Line Encyclopedia of Integer Sequences (OEIS)</a> to find some interesting integer sequences.
To find some inspiration - or to enter into the void - one can visit <a href="https://oeis.org/" target="_blank">The On-Line Encyclopedia of Integer Sequences (OEIS)</a> to find some interesting integer sequences.
Many of the sequences are implemented by <a href="https://github.com/acerix/jisg/tree/main/src/oeis" target="_blank">JISG</a> (Javascript Integer Sequence Generators) project. Those sequences can be referenced directly with the identifiers using the cache function.
@ -2510,7 +2555,7 @@ function* poly(x) {
x++;
}
}
z0(poly(1)).noteLength(0.5).semitones(2,2,3,2,2,2).sound("sine").out()
z1(poly(8)).noteLength(0.25).semitones(2,1,2,1,2,2).sound("sine").out()
z2(poly(-3)).noteLength(1.0).semitones(2,2,2,1,3,2).sound("sine").out()

BIN
assets/index-97483df2.js.gz Normal file

Binary file not shown.

Binary file not shown.

View File

@ -14,7 +14,7 @@
<script src="https://unpkg.com/hydra-synth"></script>
<script type="module" crossorigin src="/assets/index-abdd0bb6.js"></script>
<script type="module" crossorigin src="/assets/index-97483df2.js"></script>
<link rel="stylesheet" href="/assets/index-e5dc6b43.css">
<link rel="manifest" href="/manifest.webmanifest"></head>
<style>

Binary file not shown.

2
sw.js
View File

@ -1 +1 @@
if(!self.define){let s,e={};const l=(l,o)=>(l=new URL(l+".js",o).href,e[l]||new Promise((e=>{if("document"in self){const s=document.createElement("script");s.src=l,s.onload=e,document.head.appendChild(s)}else s=l,importScripts(l),e()})).then((()=>{let s=e[l];if(!s)throw new Error(`Module ${l} didnt register its module`);return s})));self.define=(o,n)=>{const r=s||("document"in self?document.currentScript.src:"")||location.href;if(e[r])return;let i={};const u=s=>l(s,r),a={module:{uri:r},exports:i,require:u};e[r]=Promise.all(o.map((s=>a[s]||u(s)))).then((s=>(n(...s),i)))}}define(["./workbox-80358384"],(function(s){"use strict";self.skipWaiting(),s.clientsClaim(),s.precacheAndRoute([{url:"assets/apple-touch-icon-77f1cce1.png",revision:null},{url:"assets/ComicMono-742af5ad.woff",revision:null},{url:"assets/ComicMono-bed2c2b5.woff2",revision:null},{url:"assets/ComicMono-Bold-2350c6c1.woff",revision:null},{url:"assets/IBMPlexMono-Bold-3152ee89.woff2",revision:null},{url:"assets/IBMPlexMono-Bold-6bb3fd98.woff",revision:null},{url:"assets/IBMPlexMono-BoldItalic-5cd662b9.woff",revision:null},{url:"assets/IBMPlexMono-BoldItalic-6f4d360c.woff2",revision:null},{url:"assets/IBMPlexMono-Italic-30cb963d.woff2",revision:null},{url:"assets/IBMPlexMono-Italic-fc3301da.woff",revision:null},{url:"assets/IBMPlexMono-Regular-06ba2f2e.woff",revision:null},{url:"assets/IBMPlexMono-Regular-82ad22f5.woff2",revision:null},{url:"assets/index-abdd0bb6.js.gz",revision:null},{url:"assets/index-e5dc6b43.css",revision:null},{url:"assets/JetBrainsMono-Bold-c503cc5e.woff2",revision:null},{url:"assets/JetBrainsMono-Regular-a9cb1cd8.woff2",revision:null},{url:"assets/jgs_vecto-e7fb4a88.woff2",revision:null},{url:"assets/jgs5-0e03e537.woff2",revision:null},{url:"assets/jgs5-9f26a38a.woff",revision:null},{url:"assets/jgs7-a69a9a5d.woff2",revision:null},{url:"assets/jgs7-d3f51478.woff",revision:null},{url:"assets/jgs9-0c41ef37.woff",revision:null},{url:"assets/jgs9-dc75d6ab.woff2",revision:null},{url:"assets/many_universes-d74e86dc.svg",revision:null},{url:"assets/pulses-30df7a48.svg",revision:null},{url:"assets/safari-pinned-tab-61a1253d.svg",revision:null},{url:"assets/Steps-Mono-aff9e933.woff2",revision:null},{url:"assets/Steps-Mono-Thin-b82a0d7e.woff2",revision:null},{url:"assets/times-1426387b.svg",revision:null},{url:"assets/topos_arch-db355d32.svg",revision:null},{url:"assets/topos_frog-e8ab87d1.svg",revision:null},{url:"assets/TransportProcessor-d5d50b30.js",revision:null},{url:"assets/TransportProcessor-d5d50b30.js.gz",revision:null},{url:"assets/workbox-window.prod.es5-a7b12eab.js",revision:null},{url:"assets/workbox-window.prod.es5-a7b12eab.js.gz",revision:null},{url:"index.html",revision:"394c62c1d289616b5e319057b52d6e4f"},{url:"manifest.webmanifest",revision:"57ee5fb60f9f17e5897fa9d47daea92a"}],{}),s.registerRoute(new s.NavigationRoute(s.createHandlerBoundToURL("index.html"))),s.registerRoute((({url:s})=>[/^https:\/\/raw\.githubusercontent\.com\/.*/i,/^https:\/\/shabda\.ndre\.gr\/.*/i].some((e=>e.test(s)))),new s.CacheFirst({cacheName:"external-samples",plugins:[new s.ExpirationPlugin({maxEntries:5e3,maxAgeSeconds:2592e3}),new s.CacheableResponsePlugin({statuses:[0,200]})]}),"GET")}));
if(!self.define){let s,e={};const l=(l,o)=>(l=new URL(l+".js",o).href,e[l]||new Promise((e=>{if("document"in self){const s=document.createElement("script");s.src=l,s.onload=e,document.head.appendChild(s)}else s=l,importScripts(l),e()})).then((()=>{let s=e[l];if(!s)throw new Error(`Module ${l} didnt register its module`);return s})));self.define=(o,n)=>{const r=s||("document"in self?document.currentScript.src:"")||location.href;if(e[r])return;let i={};const u=s=>l(s,r),a={module:{uri:r},exports:i,require:u};e[r]=Promise.all(o.map((s=>a[s]||u(s)))).then((s=>(n(...s),i)))}}define(["./workbox-80358384"],(function(s){"use strict";self.skipWaiting(),s.clientsClaim(),s.precacheAndRoute([{url:"assets/apple-touch-icon-77f1cce1.png",revision:null},{url:"assets/ComicMono-742af5ad.woff",revision:null},{url:"assets/ComicMono-bed2c2b5.woff2",revision:null},{url:"assets/ComicMono-Bold-2350c6c1.woff",revision:null},{url:"assets/IBMPlexMono-Bold-3152ee89.woff2",revision:null},{url:"assets/IBMPlexMono-Bold-6bb3fd98.woff",revision:null},{url:"assets/IBMPlexMono-BoldItalic-5cd662b9.woff",revision:null},{url:"assets/IBMPlexMono-BoldItalic-6f4d360c.woff2",revision:null},{url:"assets/IBMPlexMono-Italic-30cb963d.woff2",revision:null},{url:"assets/IBMPlexMono-Italic-fc3301da.woff",revision:null},{url:"assets/IBMPlexMono-Regular-06ba2f2e.woff",revision:null},{url:"assets/IBMPlexMono-Regular-82ad22f5.woff2",revision:null},{url:"assets/index-97483df2.js.gz",revision:null},{url:"assets/index-e5dc6b43.css",revision:null},{url:"assets/JetBrainsMono-Bold-c503cc5e.woff2",revision:null},{url:"assets/JetBrainsMono-Regular-a9cb1cd8.woff2",revision:null},{url:"assets/jgs_vecto-e7fb4a88.woff2",revision:null},{url:"assets/jgs5-0e03e537.woff2",revision:null},{url:"assets/jgs5-9f26a38a.woff",revision:null},{url:"assets/jgs7-a69a9a5d.woff2",revision:null},{url:"assets/jgs7-d3f51478.woff",revision:null},{url:"assets/jgs9-0c41ef37.woff",revision:null},{url:"assets/jgs9-dc75d6ab.woff2",revision:null},{url:"assets/many_universes-d74e86dc.svg",revision:null},{url:"assets/pulses-30df7a48.svg",revision:null},{url:"assets/safari-pinned-tab-61a1253d.svg",revision:null},{url:"assets/Steps-Mono-aff9e933.woff2",revision:null},{url:"assets/Steps-Mono-Thin-b82a0d7e.woff2",revision:null},{url:"assets/times-1426387b.svg",revision:null},{url:"assets/topos_arch-db355d32.svg",revision:null},{url:"assets/topos_frog-e8ab87d1.svg",revision:null},{url:"assets/TransportProcessor-d5d50b30.js",revision:null},{url:"assets/TransportProcessor-d5d50b30.js.gz",revision:null},{url:"assets/workbox-window.prod.es5-a7b12eab.js",revision:null},{url:"assets/workbox-window.prod.es5-a7b12eab.js.gz",revision:null},{url:"index.html",revision:"28ae7eb01035d6a42e4b413c8036c19f"},{url:"manifest.webmanifest",revision:"57ee5fb60f9f17e5897fa9d47daea92a"}],{}),s.registerRoute(new s.NavigationRoute(s.createHandlerBoundToURL("index.html"))),s.registerRoute((({url:s})=>[/^https:\/\/raw\.githubusercontent\.com\/.*/i,/^https:\/\/shabda\.ndre\.gr\/.*/i].some((e=>e.test(s)))),new s.CacheFirst({cacheName:"external-samples",plugins:[new s.ExpirationPlugin({maxEntries:5e3,maxAgeSeconds:2592e3}),new s.CacheableResponsePlugin({statuses:[0,200]})]}),"GET")}));