mirror of
https://codeberg.org/uzu/strudel
synced 2026-12-05 05:21:10 -05:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e4bb11f031 | |||
| c2207b3f12 | |||
| ae202ac5bb | |||
| a82ebbeef6 | |||
| d4a1b571fd | |||
| d44f6d3ded | |||
| 3b8f309a22 |
@@ -136,15 +136,6 @@ There are also eslint extensions / plugins for most editors.
|
||||
|
||||
When opening a PR, the CI runner will (once approved by a human) check the code style and eslint, as well as run all tests. You can run the same check with `pnpm check`.
|
||||
|
||||
## Publishing a change live on *.strudel.cc
|
||||
|
||||
There are a few steps to a contribution to strudel making it to https://strudel.cc/
|
||||
|
||||
1. If a maintainer adds a 'serve-hot' label to a pull request on codeberg, it is built and exposed as http://pr-1000.hot.strudel.cc (where 1000 is the pr number). This allows changes to be tried out live, without building locally. However, because it's plain http, some webaudio things etc won't work. A maintainer with server access can assign a certificate for https via a manual process if needed.
|
||||
2. When a pull request is merged into the main branch by a maintainer, it is automatically built and served under https://hot.strudel.cc/
|
||||
3. Then a maintainer can trigger an action on codeberg to rebuild https://strudel.cc/ (also known as https://warm.strudel.cc/) from the main branch. This [currently makes strudel refresh for all users](https://codeberg.org/uzu/strudel/pulls/2130), and is intended to happen around once a week, early in the week (when fewer people will be performing with it!), or more often for urgent fixes.
|
||||
4. There is also https://cold.strudel.cc/, which is intended to reflect the last package release to npm.
|
||||
|
||||
## Package Workflow
|
||||
|
||||
The project is split into multiple [packages](https://codeberg.org/uzu/strudel/src/branch/main/packages) with independent versioning.
|
||||
|
||||
@@ -176,6 +176,7 @@ export class StrudelMirror {
|
||||
this.onDraw = onDraw || this.draw;
|
||||
this.id = id || s4();
|
||||
this.solo = solo;
|
||||
this.hasPainters = false;
|
||||
|
||||
this.drawer = new Drawer((haps, time, _, painters) => {
|
||||
const currentFrame = haps.filter((hap) => hap.isActive(time));
|
||||
@@ -191,7 +192,7 @@ export class StrudelMirror {
|
||||
onToggle: (started) => {
|
||||
replOptions?.onToggle?.(started);
|
||||
if (started) {
|
||||
this.drawer.start(this.repl.scheduler);
|
||||
this.shouldAnimate() && this.drawer.start(this.repl.scheduler);
|
||||
if (this.solo) {
|
||||
// stop other repls when this one is started
|
||||
document.dispatchEvent(
|
||||
@@ -206,10 +207,10 @@ export class StrudelMirror {
|
||||
cleanupDraw(true, id);
|
||||
}
|
||||
},
|
||||
beforeEval: async (bag) => {
|
||||
beforeEval: async () => {
|
||||
cleanupDraw(true, id);
|
||||
await this.prebaked;
|
||||
await replOptions?.beforeEval?.(bag);
|
||||
await replOptions?.beforeEval?.();
|
||||
},
|
||||
afterEval: (options) => {
|
||||
// remember for when highlighting is toggled on
|
||||
@@ -222,9 +223,10 @@ export class StrudelMirror {
|
||||
updateWidgets(this.editor, widgets);
|
||||
updateMiniLocations(this.editor, this.miniLocations);
|
||||
replOptions?.afterEval?.(options);
|
||||
this.hasPainters = options.pattern.getPainters().length > 0;
|
||||
// if no painters are set (.onPaint was not called), then we only need
|
||||
// the present moment (for highlighting)
|
||||
const drawTime = options.pattern.getPainters().length ? this.drawTime : [0, 0];
|
||||
const drawTime = this.hasPainters ? this.drawTime : [0, 0];
|
||||
this.drawer.setDrawTime(drawTime);
|
||||
// invalidate drawer after we've set the appropriate drawTime
|
||||
this.drawer.invalidate(this.repl.scheduler);
|
||||
@@ -252,6 +254,7 @@ export class StrudelMirror {
|
||||
cmEditor.style.backgroundColor = 'transparent';
|
||||
}
|
||||
const settings = codemirrorSettings.get();
|
||||
this.isPatternHighlightingEnabled = parseBooleans(settings.isPatternHighlightingEnabled);
|
||||
this.setFontSize(settings.fontSize);
|
||||
this.setFontFamily(settings.fontFamily);
|
||||
|
||||
@@ -300,8 +303,17 @@ export class StrudelMirror {
|
||||
flash(this.editor, ms);
|
||||
}
|
||||
highlight(haps, time) {
|
||||
if (!this.isPatternHighlightingEnabled) {
|
||||
return;
|
||||
}
|
||||
highlightMiniLocations(this.editor, time, haps);
|
||||
}
|
||||
shouldAnimate() {
|
||||
return (
|
||||
this.repl.scheduler.started &&
|
||||
(this.isPatternHighlightingEnabled || this.hasPainters || this.onDraw !== this.draw)
|
||||
);
|
||||
}
|
||||
setFontSize(size) {
|
||||
this.root.style.fontSize = size + 'px';
|
||||
}
|
||||
@@ -322,6 +334,11 @@ export class StrudelMirror {
|
||||
this.editor.dispatch({
|
||||
effects: compartments[key].reconfigure(newValue),
|
||||
});
|
||||
if (key === 'isPatternHighlightingEnabled') {
|
||||
this.isPatternHighlightingEnabled = value;
|
||||
this.drawer.stop();
|
||||
this.shouldAnimate() && this.drawer.start(this.repl.scheduler);
|
||||
}
|
||||
if (key === 'theme') {
|
||||
activateTheme(value);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/codemirror",
|
||||
"version": "1.4.0",
|
||||
"version": "1.3.0",
|
||||
"description": "Codemirror Extensions for Strudel",
|
||||
"main": "index.mjs",
|
||||
"publishConfig": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/core",
|
||||
"version": "1.3.0",
|
||||
"version": "1.2.6",
|
||||
"description": "Port of Tidal Cycles to JavaScript",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
@@ -31,8 +31,8 @@
|
||||
},
|
||||
"homepage": "https://strudel.cc",
|
||||
"dependencies": {
|
||||
"@strudel/pattern": "workspace:*",
|
||||
"fraction.js": "^5.2.1"
|
||||
"fraction.js": "^5.2.1",
|
||||
"@strudel/pattern": "workspace:*"
|
||||
},
|
||||
"gitHead": "0e26d4e741500f5bae35b023608f062a794905c2",
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/csound",
|
||||
"version": "1.4.0",
|
||||
"version": "1.3.0",
|
||||
"description": "csound bindings for strudel",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/dough",
|
||||
"version": "1.4.0",
|
||||
"version": "1.3.2",
|
||||
"description": "dough synth integration for strudel",
|
||||
"main": "dough.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -6,6 +6,8 @@ This program is free software: you can redistribute it and/or modify it under th
|
||||
|
||||
import { Pattern, getTime, State, TimeSpan } from '@strudel/core';
|
||||
|
||||
const ANIMATE_INTERVAL = 1000 / 15; // 15 FPS
|
||||
|
||||
export const getDrawContext = (id = 'test-canvas', options) => {
|
||||
let { contextType = '2d', pixelated = false, pixelRatio = window.devicePixelRatio } = options || {};
|
||||
let canvas = document.querySelector('#' + id);
|
||||
@@ -112,7 +114,13 @@ export class Framer {
|
||||
}
|
||||
start() {
|
||||
const self = this;
|
||||
let lastTime = 0;
|
||||
let frame = requestAnimationFrame(function updateHighlights(time) {
|
||||
if (time - lastTime < ANIMATE_INTERVAL) {
|
||||
frame = requestAnimationFrame(updateHighlights);
|
||||
return;
|
||||
}
|
||||
lastTime = time;
|
||||
try {
|
||||
self.onFrame(time);
|
||||
} catch (err) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/draw",
|
||||
"version": "1.3.0",
|
||||
"version": "1.2.6",
|
||||
"description": "Helpers for drawing with Strudel",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/edo",
|
||||
"version": "0.2.0",
|
||||
"version": "0.1.0",
|
||||
"description": "Equal division of the octave (EDO) scale functions for strudel",
|
||||
"main": "index.mjs",
|
||||
"publishConfig": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/gamepad",
|
||||
"version": "1.3.0",
|
||||
"version": "1.2.6",
|
||||
"description": "Gamepad Inputs for strudel",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/hydra",
|
||||
"version": "1.3.0",
|
||||
"version": "1.2.6",
|
||||
"description": "Hydra integration for strudel",
|
||||
"main": "hydra.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/kabelsalat",
|
||||
"version": "1.3.0",
|
||||
"version": "1.2.6",
|
||||
"description": "kabelsalat integration for superdough",
|
||||
"main": "kabelsalat.mjs",
|
||||
"type": "module",
|
||||
@@ -29,13 +29,13 @@
|
||||
},
|
||||
"homepage": "https://codeberg.org/uzu/strudel#readme",
|
||||
"dependencies": {
|
||||
"superdough": "workspace:*",
|
||||
"@kabelsalat/lib": "^0.4.1",
|
||||
"@kabelsalat/web": "^0.4.1",
|
||||
"superdough": "workspace:*"
|
||||
"@kabelsalat/web": "^0.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vite": "^6.0.11",
|
||||
"vite-plugin-bundle-audioworklet": "workspace:*"
|
||||
"vite-plugin-bundle-audioworklet":"workspace:*"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/midi",
|
||||
"version": "1.4.0",
|
||||
"version": "1.3.0",
|
||||
"description": "Midi API for strudel",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/mini",
|
||||
"version": "1.3.0",
|
||||
"version": "1.2.6",
|
||||
"description": "Mini notation for strudel",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/mondo",
|
||||
"version": "1.2.0",
|
||||
"version": "1.1.6",
|
||||
"description": "mondo notation for strudel",
|
||||
"main": "mondough.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/motion",
|
||||
"version": "1.3.0",
|
||||
"version": "1.2.6",
|
||||
"description": "DeviceMotion API for strudel",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/mqtt",
|
||||
"version": "1.3.0",
|
||||
"version": "1.2.6",
|
||||
"description": "MQTT API for strudel",
|
||||
"main": "mqtt.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/osc",
|
||||
"version": "1.4.0",
|
||||
"version": "1.3.2",
|
||||
"description": "OSC messaging for strudel",
|
||||
"main": "osc.mjs",
|
||||
"bin": "./server.js",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/pattern",
|
||||
"version": "1.3.0",
|
||||
"version": "1.2.6",
|
||||
"description": "Port of Tidal Cycles to JavaScript. This package contains only the pattern representation.",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/repl",
|
||||
"version": "1.4.0",
|
||||
"version": "1.3.0",
|
||||
"description": "Strudel REPL as a Web Component",
|
||||
"module": "index.mjs",
|
||||
"publishConfig": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/sampler",
|
||||
"version": "0.3.0",
|
||||
"version": "0.2.4",
|
||||
"description": "",
|
||||
"keywords": [
|
||||
"tidalcycles",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/serial",
|
||||
"version": "1.3.0",
|
||||
"version": "1.2.6",
|
||||
"description": "Webserial API for strudel",
|
||||
"main": "serial.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/soundfonts",
|
||||
"version": "1.4.0",
|
||||
"version": "1.3.0",
|
||||
"description": "Soundsfont support for strudel",
|
||||
"main": "index.mjs",
|
||||
"publishConfig": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "superdough",
|
||||
"version": "1.4.0",
|
||||
"version": "1.3.0",
|
||||
"description": "simple web audio synth and sampler intended for live coding. inspired by superdirt and webdirt.",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/tonal",
|
||||
"version": "1.3.0",
|
||||
"version": "1.2.6",
|
||||
"description": "Tonal functions for strudel",
|
||||
"main": "index.mjs",
|
||||
"publishConfig": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/transpiler",
|
||||
"version": "1.3.0",
|
||||
"version": "1.2.6",
|
||||
"description": "Transpiler for strudel user code. Converts syntactically correct but semantically meaningless JS into evaluatable strudel code.",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/web",
|
||||
"version": "1.4.0",
|
||||
"version": "1.3.0",
|
||||
"description": "Easy to setup, opiniated bundle of Strudel for the browser.",
|
||||
"module": "web.mjs",
|
||||
"publishConfig": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/webaudio",
|
||||
"version": "1.4.0",
|
||||
"version": "1.3.0",
|
||||
"description": "Web Audio helpers for Strudel",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/websocket",
|
||||
"version": "1.1.0",
|
||||
"version": "1.0.0",
|
||||
"description": "Websocket input for strudel",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/xen",
|
||||
"version": "1.3.0",
|
||||
"version": "1.2.6",
|
||||
"description": "Xenharmonic API for strudel",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -65,7 +65,7 @@ export default defineConfig({
|
||||
tailwind(),
|
||||
AstroPWA({
|
||||
experimental: { directoryAndTrailingSlashHandler: true },
|
||||
registerType: 'prompt', // see pwa.ts
|
||||
registerType: 'autoUpdate',
|
||||
injectRegister: 'auto',
|
||||
workbox: {
|
||||
maximumFileSizeToCacheInBytes: 4194304, // 4MB
|
||||
|
||||
+17
-63
@@ -2,23 +2,20 @@ import jsdoc from '../../../doc.json'; // doc.json is built with `npm run jsdoc-
|
||||
const docs = jsdoc.docs.reduce((acc, obj) => Object.assign(acc, { [obj.longname]: obj }), {});
|
||||
import { MiniRepl } from './MiniRepl';
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Object} arguments
|
||||
* @param {number} [arguments.h] Adds a heading (like 3 for h3). Deprecated, add the heading in MDX instead.
|
||||
* @returns
|
||||
*/
|
||||
export function JsDoc({ name, h = undefined, hideDescription, punchcard, canvasHeight, hideMiniRepl }) {
|
||||
export function JsDoc({ name, h = 3, hideDescription, punchcard, canvasHeight }) {
|
||||
const item = docs[name];
|
||||
if (!item) {
|
||||
console.warn(`JsDoc for ${name} not found`);
|
||||
return <div>Could not load docs for ${name}</div>;
|
||||
console.warn('Not found: ' + name);
|
||||
return <div />;
|
||||
}
|
||||
const CustomHeading = h ? `h${h}` : undefined;
|
||||
const description = parseAndReplaceLink(item.description ?? '');
|
||||
const CustomHeading = `h${h}`;
|
||||
const description =
|
||||
item.description?.replaceAll(/\{@link ([a-zA-Z\.]+)?#?([a-zA-Z]*)\}/g, (_, a, b) => {
|
||||
return `<a href="#${a.replaceAll('.', '').toLowerCase()}${b ? `-${b}` : ''}">${a}${b ? `#${b}` : ''}</a>`;
|
||||
}) || '';
|
||||
return (
|
||||
<>
|
||||
{!!h && <CustomHeading id={name}>{item.longname}</CustomHeading>}
|
||||
{!!h && <CustomHeading>{item.longname}</CustomHeading>}
|
||||
{!hideDescription && (
|
||||
<>
|
||||
{!!item.synonyms_text && (
|
||||
@@ -29,43 +26,19 @@ export function JsDoc({ name, h = undefined, hideDescription, punchcard, canvasH
|
||||
<div dangerouslySetInnerHTML={{ __html: description }} />
|
||||
</>
|
||||
)}
|
||||
{item.params && item.params.length > 0 && <p className="font-bold">Arguments</p>}
|
||||
<ul>
|
||||
{item.params?.map(({ name, type, description }, i) => {
|
||||
// Check if the param is actually the parameter of an object
|
||||
const objParamSeperator = name.indexOf('.');
|
||||
const isObjectParam = objParamSeperator !== -1;
|
||||
|
||||
return (
|
||||
<li key={i} className={isObjectParam ? 'list-none' : ''}>
|
||||
{isObjectParam ? name.substring(objParamSeperator + 1) : name} : {type?.names?.join(' | ')}{' '}
|
||||
{description ? <> - {removeHtmlTags(description)}</> : ''}
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
{item.params?.map((param, i) => (
|
||||
<li key={i}>
|
||||
{param.name} ({param.type?.names?.join('|')}): {param.description?.replace(/(<([^>]+)>)/gi, '')}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{item.returns && (
|
||||
<p>
|
||||
<span className="font-bold">Returns</span>{' '}
|
||||
{item.returns
|
||||
.map((returnValue) => {
|
||||
const description = returnValue.description ? `- ${removeHtmlTags(returnValue.description)}` : '';
|
||||
return `${returnValue.type?.names?.join(' | ')} ${description}`;
|
||||
})
|
||||
.join(' or ')}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{item.examples?.length ? (
|
||||
<div className="space-y-2">
|
||||
{item.examples?.map((example, k) => {
|
||||
const key = `${item.longname}_example_${k}`;
|
||||
return hideMiniRepl ? (
|
||||
<pre key={key}>{example}</pre>
|
||||
) : (
|
||||
<MiniRepl tune={example} key={key} {...{ punchcard, canvasHeight }} />
|
||||
);
|
||||
})}
|
||||
{item.examples?.map((example, k) => (
|
||||
<MiniRepl tune={example} key={k} {...{ punchcard, canvasHeight }} />
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div />
|
||||
@@ -73,22 +46,3 @@ export function JsDoc({ name, h = undefined, hideDescription, punchcard, canvasH
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the jsDocs link with something else.
|
||||
* @param {string} string
|
||||
* @param {(name:string,longname: string) => string} [replaceWith]
|
||||
*/
|
||||
export const parseAndReplaceLink = (string, replaceWith) => {
|
||||
const jsDocsLinkRegex = /\{@link ([a-zA-Z\.#]+)\}/g;
|
||||
const fun = replaceWith ?? ((name, longname) => `<a target="_blank" href="/reference#${longname}">${name}</a>`);
|
||||
|
||||
return string
|
||||
.replaceAll(/<a href="https:\/\//g, `<a target="_blank" href="https://`)
|
||||
.replaceAll(jsDocsLinkRegex, (_, longname) => {
|
||||
const name = [...longname.matchAll(/[a-zA-Z]+[\.#]([a-zA-Z]+)/g)].at(0)?.at(1); //take the string after . or #
|
||||
return fun(name ?? longname, longname);
|
||||
});
|
||||
};
|
||||
|
||||
const removeHtmlTags = (string) => string.replace(/(<([^>]+)>)/gi, '');
|
||||
|
||||
@@ -10,15 +10,11 @@ import { loadModules, setVersionDefaultsFrom } from '../repl/util.mjs';
|
||||
import Claviature from '@components/Claviature';
|
||||
import useClient from '@src/useClient.mjs';
|
||||
|
||||
let prebaked, modulesLoading, audioReady, initicated;
|
||||
|
||||
export function initMiniRepl() {
|
||||
if (typeof window !== 'undefined' && !initicated) {
|
||||
prebaked = prebake();
|
||||
modulesLoading = loadModules();
|
||||
audioReady = initAudioOnFirstClick();
|
||||
initicated = true;
|
||||
}
|
||||
let prebaked, modulesLoading, audioReady;
|
||||
if (typeof window !== 'undefined') {
|
||||
prebaked = prebake();
|
||||
modulesLoading = loadModules();
|
||||
audioReady = initAudioOnFirstClick();
|
||||
}
|
||||
|
||||
export function MiniRepl({
|
||||
@@ -48,7 +44,6 @@ export function MiniRepl({
|
||||
const [activeNotes, setActiveNotes] = useState([]);
|
||||
|
||||
const init = useCallback(({ code, autodraw }) => {
|
||||
initMiniRepl();
|
||||
const drawContext = canvasId ? document.querySelector('#' + canvasId)?.getContext('2d') : getDrawContext();
|
||||
|
||||
const editor = new StrudelMirror({
|
||||
@@ -90,7 +85,7 @@ export function MiniRepl({
|
||||
}
|
||||
},
|
||||
beforeStart: () => audioReady,
|
||||
beforeEval: ({ code }) => setVersionDefaultsFrom(code),
|
||||
afterEval: ({ code }) => setVersionDefaultsFrom(code),
|
||||
mondo,
|
||||
});
|
||||
// init settings
|
||||
|
||||
+66
-66
@@ -1,68 +1,67 @@
|
||||
export const examples = [
|
||||
`// "coastline" @by eddyflux
|
||||
// @version 1.0
|
||||
samples('github:eddyflux/crate')
|
||||
setcps(.75)
|
||||
let chords = chord("<Bbm9 Fm9>/4").dict('ireal')
|
||||
|
||||
// DRUMS
|
||||
$: stack(
|
||||
s("bd").struct("<[x*<1 2> [~@3 x]] x>"),
|
||||
s("~ [rim, sd:<2 3>]").room("<0 .2>"),
|
||||
n("[0 <1 3>]*<2!3 4>").s("hh"),
|
||||
s("rd:<1!3 2>*2").mask("<0 0 1 1>/16").gain(.5)
|
||||
).bank('crate')
|
||||
.mask("<[0 1] 1 1 1>/16".early(.5))
|
||||
// CHORDS
|
||||
$: chords.offset(-1).voicing().s("gm_epiano1:1")
|
||||
.phaser(4).room(.5)
|
||||
// BASS
|
||||
$: n("<0!3 1*2>").set(chords).mode("root:g1")
|
||||
.voicing().s("gm_acoustic_bass")
|
||||
// MELODY
|
||||
$: chords.n("[0 <4 3 <2 5>>*2](<3 5>,8)")
|
||||
.anchor("D5").voicing()
|
||||
.segment(4).clip(rand.range(.4,.8))
|
||||
.room(.75).shape(.3).delay(.25)
|
||||
.fm(sine.range(3,8).slow(8))
|
||||
.lpf(sine.range(500,1000).slow(8)).lpq(5)
|
||||
.rarely(ply("2")).chunk(4, fast(2))
|
||||
.gain(perlin.range(.6, .9))
|
||||
.mask("<0 1 1 0>/16")
|
||||
// swing everything
|
||||
all(x=>x.late("[0 .01]*4").late("[0 .01]*2").size(4))`,
|
||||
// @version 1.0
|
||||
samples('github:eddyflux/crate')
|
||||
setcps(.75)
|
||||
let chords = chord("<Bbm9 Fm9>/4").dict('ireal')
|
||||
stack(
|
||||
stack( // DRUMS
|
||||
s("bd").struct("<[x*<1 2> [~@3 x]] x>"),
|
||||
s("~ [rim, sd:<2 3>]").room("<0 .2>"),
|
||||
n("[0 <1 3>]*<2!3 4>").s("hh"),
|
||||
s("rd:<1!3 2>*2").mask("<0 0 1 1>/16").gain(.5)
|
||||
).bank('crate')
|
||||
.mask("<[0 1] 1 1 1>/16".early(.5))
|
||||
, // CHORDS
|
||||
chords.offset(-1).voicing().s("gm_epiano1:1")
|
||||
.phaser(4).room(.5)
|
||||
, // MELODY
|
||||
n("<0!3 1*2>").set(chords).mode("root:g2")
|
||||
.voicing().s("gm_acoustic_bass"),
|
||||
chords.n("[0 <4 3 <2 5>>*2](<3 5>,8)")
|
||||
.anchor("D5").voicing()
|
||||
.segment(4).clip(rand.range(.4,.8))
|
||||
.room(.75).shape(.3).delay(.25)
|
||||
.fm(sine.range(3,8).slow(8))
|
||||
.lpf(sine.range(500,1000).slow(8)).lpq(5)
|
||||
.rarely(ply("2")).chunk(4, fast(2))
|
||||
.gain(perlin.range(.6, .9))
|
||||
.mask("<0 1 1 0>/16")
|
||||
)
|
||||
.late("[0 .01]*4").late("[0 .01]*2").size(4)`,
|
||||
`// "broken cut 1" @by froos
|
||||
// @version 1.0
|
||||
|
||||
samples('github:tidalcycles/dirt-samples')
|
||||
samples({
|
||||
'slap': 'https://cdn.freesound.org/previews/495/495416_10350281-lq.mp3',
|
||||
'whirl': 'https://cdn.freesound.org/previews/495/495313_10350281-lq.mp3',
|
||||
'attack': 'https://cdn.freesound.org/previews/494/494947_10350281-lq.mp3'
|
||||
})
|
||||
|
||||
setcps(1.25)
|
||||
|
||||
$: note("[c2 ~](3,8)*2,eb,g,bb,d").s("sawtooth")
|
||||
.noise(0.3)
|
||||
.lpf(perlin.range(300,800).mul(0.6)).lpq(10)
|
||||
.lpenv(perlin.range(1,5)).lpa(.25).lpd(.1).lps(0)
|
||||
.add.mix(note("<0!3 [1 <4!3 12>]>")).late(.5)
|
||||
.vib("4:.2")
|
||||
.room(1).roomsize(4).slow(4)
|
||||
$: s("bd").late("<0.01 .251>")
|
||||
$: s("breaks165:1/2").fit()
|
||||
.chop(4).sometimesBy(.4, ply("2"))
|
||||
.sometimesBy(.1, ply("4")).release(.01)
|
||||
.gain(1.5).sometimes(mul(speed("1.05"))).cut(1)
|
||||
|
||||
$: s("<whirl attack>?").delay(".8:.1:.8").room(2).slow(8).cut(2)
|
||||
all(x=>x.reset("<x@30 [x*[8 [8 [16 32]]]]@2>".late(2)))`,
|
||||
// @version 1.0
|
||||
|
||||
samples('github:tidalcycles/dirt-samples')
|
||||
samples({
|
||||
'slap': 'https://cdn.freesound.org/previews/495/495416_10350281-lq.mp3',
|
||||
'whirl': 'https://cdn.freesound.org/previews/495/495313_10350281-lq.mp3',
|
||||
'attack': 'https://cdn.freesound.org/previews/494/494947_10350281-lq.mp3'
|
||||
})
|
||||
|
||||
setcps(1.25)
|
||||
|
||||
note("[c2 ~](3,8)*2,eb,g,bb,d").s("sawtooth")
|
||||
.noise(0.3)
|
||||
.lpf(perlin.range(800,2000).mul(0.6))
|
||||
.lpenv(perlin.range(1,5)).lpa(.25).lpd(.1).lps(0)
|
||||
.add.mix(note("<0!3 [1 <4!3 12>]>")).late(.5)
|
||||
.vib("4:.2")
|
||||
.room(1).roomsize(4).slow(4)
|
||||
.stack(
|
||||
s("bd").late("<0.01 .251>"),
|
||||
s("breaks165:1/2").fit()
|
||||
.chop(4).sometimesBy(.4, ply("2"))
|
||||
.sometimesBy(.1, ply("4")).release(.01)
|
||||
.gain(1.5).sometimes(mul(speed("1.05"))).cut(1)
|
||||
,
|
||||
s("<whirl attack>?").delay(".8:.1:.8").room(2).slow(8).cut(2),
|
||||
).reset("<x@30 [x*[8 [8 [16 32]]]]@2>".late(2))`,
|
||||
`// "acidic tooth" @by eddyflux
|
||||
// @version 1.0
|
||||
// @version 1.0
|
||||
setcps(1)
|
||||
|
||||
$: note("[<g1 f1>/8](<3 5>,8)")
|
||||
stack(
|
||||
note("[<g1 f1>/8](<3 5>,8)")
|
||||
.clip(perlin.range(.15,1.5))
|
||||
.release(.1)
|
||||
.s("sawtooth")
|
||||
@@ -75,10 +74,11 @@ export const examples = [
|
||||
.room(.2).shape(.3).postgain(.5)
|
||||
.superimpose(x=>x.add(note(12)).delay(.5).bpf(1000))
|
||||
.gain("[.2 1@3]*2") // fake sidechain
|
||||
|
||||
$: stack(
|
||||
s("bd*2").mask("<0@4 1@16>"),
|
||||
s("hh*8").gain(saw.mul(saw.fast(2))).clip(sine)
|
||||
.mask("<0@8 1@16>")
|
||||
).bank('RolandTR909')`,
|
||||
,
|
||||
stack(
|
||||
s("bd*2").mask("<0@4 1@16>"),
|
||||
s("hh*8").gain(saw.mul(saw.fast(2))).clip(sine)
|
||||
.mask("<0@8 1@16>")
|
||||
).bank('RolandTR909')
|
||||
)`,
|
||||
];
|
||||
|
||||
+2
-27
@@ -1,37 +1,12 @@
|
||||
// @ts-ignore
|
||||
import { registerSW } from 'virtual:pwa-register';
|
||||
|
||||
function h(html: string): HTMLElement {
|
||||
const template = document.createElement('template');
|
||||
template.innerHTML = html;
|
||||
return template.content.firstElementChild as HTMLElement;
|
||||
}
|
||||
|
||||
function showUpdateModal() {
|
||||
const hint = h(`
|
||||
<div style="position:fixed;bottom:8px;right:8px;z-index:99999;padding:10px;background:var(--background);color:var(--foreground);border:2px solid var(--gutterForeground)">
|
||||
<p style="margin-bottom:10px">A new strudel version is available. Update now?</p>
|
||||
<button style="border:1px solid var(--gutterForeground);padding:4px" id="updateButton">update</button>
|
||||
<button style="border:1px solid var(--gutterForeground);padding:4px" id="cancelButton">cancel</button>
|
||||
</div>`);
|
||||
document.body.appendChild(hint);
|
||||
hint.querySelector<HTMLButtonElement>('#updateButton')!.onclick = () => {
|
||||
updateSW();
|
||||
hint.remove();
|
||||
};
|
||||
hint.querySelector<HTMLButtonElement>('#cancelButton')!.onclick = () => {
|
||||
hint.remove();
|
||||
};
|
||||
}
|
||||
// https://vite-pwa-org.netlify.app/frameworks/#prompt-for-update
|
||||
const updateSW = registerSW({
|
||||
registerSW({
|
||||
immediate: true,
|
||||
onRegisteredSW(swScriptUrl) {
|
||||
// console.log('SW registered: ', swScriptUrl)
|
||||
},
|
||||
onOfflineReady() {
|
||||
// console.log('PWA application ready to work offline')
|
||||
},
|
||||
onNeedRefresh() {
|
||||
showUpdateModal();
|
||||
},
|
||||
});
|
||||
|
||||
@@ -3,7 +3,6 @@ import { memo, useEffect, useMemo, useState, Fragment } from 'react';
|
||||
import jsdocJson from '../../../../../doc.json';
|
||||
import { Textbox } from '@src/repl/components/panel/SettingsTab';
|
||||
import { settingsMap, useSettings } from '@src/settings.mjs';
|
||||
import { JsDoc } from '@src/docs/JsDoc';
|
||||
import { computeAvailableFunctions } from '@src/jsDocsUtils.mjs';
|
||||
|
||||
const availableFunctions = computeAvailableFunctions(jsdocJson);
|
||||
@@ -179,7 +178,48 @@ export const Reference = memo(function Reference() {
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<JsDoc name={entry.longname} hideMiniRepl></JsDoc>
|
||||
{!!entry.synonyms_text && (
|
||||
<p>
|
||||
Synonyms: <code>{entry.synonyms_text}</code>
|
||||
</p>
|
||||
)}
|
||||
|
||||
<p
|
||||
dangerouslySetInnerHTML={{
|
||||
// If we have an external url make sure it opens in another tab to not interrupt the player
|
||||
__html: entry.description.replaceAll(/<a href="https:\/\//g, `<a target="_blank" href="https://`),
|
||||
}}
|
||||
></p>
|
||||
{entry.params && entry.params.length > 0 && <p className="font-bold">Arguments</p>}
|
||||
<ul>
|
||||
{entry.params?.map(({ name, type, description }, i) => {
|
||||
// Check if the param is actually the parameter of an object
|
||||
const objParamSeperator = name.indexOf('.');
|
||||
const isObjectParam = objParamSeperator !== -1;
|
||||
|
||||
return (
|
||||
<li key={i} className={isObjectParam ? 'list-none' : ''}>
|
||||
{isObjectParam ? name.substring(objParamSeperator + 1) : name} : {type?.names?.join(' | ')}{' '}
|
||||
{description ? <> - {getInnerText(description)}</> : ''}
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
{entry.returns && (
|
||||
<p>
|
||||
<span className="font-bold">Returns</span>{' '}
|
||||
{entry.returns.map(({ type, description }) => (
|
||||
<>
|
||||
{type?.names?.join(' | ')} {description ? <> - {getInnerText(description)}</> : ''}
|
||||
</>
|
||||
))}
|
||||
</p>
|
||||
)}
|
||||
{entry.examples?.map((example, j) => (
|
||||
<pre className="bg-background border border-muted" key={j}>
|
||||
{example}
|
||||
</pre>
|
||||
))}
|
||||
</section>
|
||||
)) || <p className="font-sans">Search or select a tag to get started.</p>}
|
||||
{detailVisibleFunctions.length > 0 && <div className="h-screen" />}
|
||||
|
||||
@@ -101,10 +101,7 @@ export function useReplContext() {
|
||||
clearHydra();
|
||||
}
|
||||
},
|
||||
beforeEval: ({ code }) => {
|
||||
setVersionDefaultsFrom(code);
|
||||
return audioReady;
|
||||
},
|
||||
beforeEval: () => audioReady,
|
||||
afterEval: (all) => {
|
||||
const { code } = all;
|
||||
//post to iframe parent (like Udels) if it exists...
|
||||
@@ -118,6 +115,7 @@ export function useReplContext() {
|
||||
}
|
||||
setDocumentTitle(code);
|
||||
const viewingPatternData = getViewingPatternData();
|
||||
setVersionDefaultsFrom(code);
|
||||
const data = { ...viewingPatternData, code };
|
||||
let id = data.id;
|
||||
const isExamplePattern = viewingPatternData.collection !== userPattern.collection;
|
||||
|
||||
@@ -15,14 +15,6 @@ const { code2hash, errorLogger, evalScope, hash2code, logger } = strudelCore;
|
||||
export const supabase = createClient(
|
||||
'https://pidxdsxphlhzjnzmifth.supabase.co',
|
||||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBpZHhkc3hwaGxoempuem1pZnRoIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NTYyMzA1NTYsImV4cCI6MTk3MTgwNjU1Nn0.bqlw7802fsWRnqU5BLYtmXk_k-D1VFmbkHMywWc15NM',
|
||||
{
|
||||
// avoid "Uncaught (in promise) Error: Acquiring an exclusive Navigator LockManager lock ... immediately failed"
|
||||
auth: {
|
||||
persistSession: false,
|
||||
autoRefreshToken: false,
|
||||
detectSessionInUrl: false,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
let dbLoaded;
|
||||
|
||||
Reference in New Issue
Block a user