mirror of
https://codeberg.org/uzu/strudel
synced 2026-12-01 19:57:07 -05:00
Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8b1d68e494 | |||
| 1686ff877c | |||
| 83b1c89d25 | |||
| 1743f65e61 | |||
| bb4b8bb27e | |||
| bdac0eccbd | |||
| 6333fa1ddf | |||
| 41e6084823 | |||
| fe9a75c9b6 | |||
| cd7c1dbd97 | |||
| 25b9fd991a | |||
| 375b25afd7 | |||
| afc7f1aab1 | |||
| 5e82110522 | |||
| 4616b374f3 | |||
| 98b71bcb4d | |||
| cf7dae5d7f | |||
| b3d9eab3b6 | |||
| 067f002d93 | |||
| c799a686c0 | |||
| 3c32b3b0aa | |||
| c492e21e1d |
@@ -0,0 +1,41 @@
|
||||
name: Build and Deploy labeled serve-hot PRs
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [labeled]
|
||||
|
||||
# Allow one concurrent deployment
|
||||
concurrency:
|
||||
group: "warm-pages"
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
build:
|
||||
if: ${{ github.event.label.name == 'serve-hot' }}
|
||||
runs-on: docker
|
||||
container: node:22-bookworm
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
allow-unsafe-pr-checkout: true
|
||||
- uses: pnpm/action-setup@v4
|
||||
|
||||
- name: Install Dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Build
|
||||
run: pnpm build
|
||||
|
||||
- name: Deploy
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
run: |
|
||||
eval $(ssh-agent -s)
|
||||
echo "$SSH_PRIVATE_KEY" | ssh-add -
|
||||
apt update && apt install -y rsync
|
||||
mkdir -p ~/.ssh
|
||||
ssh-keyscan matrix.toplap.org > ~/.ssh/known_hosts
|
||||
rsync -atv --delete --delete-after --progress \
|
||||
./website/dist/ \
|
||||
strudel@matrix.toplap.org:/home/strudel/deploy/pr-${{ github.event.pull_request.number }}.hot.strudel.cc
|
||||
@@ -1,23 +1,23 @@
|
||||
name: Build and Deploy hot PRs
|
||||
name: Build and Deploy to hot.strudel.cc on merge
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [labeled]
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
# Allow one concurrent deployment
|
||||
concurrency:
|
||||
group: "warm-pages"
|
||||
cancel-in-progress: false
|
||||
group: "pages"
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
if: ${{ github.event.label.name == 'serve-hot' }}
|
||||
runs-on: docker
|
||||
container: node:22-bookworm
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- uses: pnpm/action-setup@v4
|
||||
|
||||
- name: Install Dependencies
|
||||
@@ -27,14 +27,10 @@ jobs:
|
||||
run: pnpm build
|
||||
|
||||
- name: Deploy
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
run: |
|
||||
eval $(ssh-agent -s)
|
||||
echo "$SSH_PRIVATE_KEY" | ssh-add -
|
||||
apt update && apt install -y rsync
|
||||
mkdir -p ~/.ssh
|
||||
ssh-keyscan matrix.toplap.org > ~/.ssh/known_hosts
|
||||
rsync -atv --delete --delete-after --progress \
|
||||
./website/dist/ \
|
||||
strudel@matrix.toplap.org:/home/strudel/deploy/pr-${{ github.event.pull_request.number }}.hot.strudel.cc
|
||||
mkdir ~/.ssh
|
||||
ssh-keyscan matrix.toplap.org > ~/.ssh/known_hosts
|
||||
rsync -atv --delete --delete-after --progress ./website/dist/ strudel@matrix.toplap.org:/home/strudel/deploy/hot.strudel.cc
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
name: Build and Deploy to warm (strudel.cc)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
on: [workflow_dispatch]
|
||||
|
||||
# Allow one concurrent deployment
|
||||
concurrency:
|
||||
@@ -1308,6 +1308,16 @@ export const { channel } = registerControl('channel');
|
||||
*
|
||||
*/
|
||||
export const { cut } = registerControl('cut');
|
||||
/**
|
||||
* Similar to 'cut', but notes that begin at the same time don't cut eachother off.
|
||||
*
|
||||
* @name scut
|
||||
* @tags superdough
|
||||
* @param {number | Pattern} group scut group number
|
||||
* @example
|
||||
* chord("C G").voicing().s("piano").scut(1)
|
||||
*/
|
||||
export const { scut, stackcut } = registerControl('scut', 'stackCut');
|
||||
/**
|
||||
* Applies the cutoff frequency of the **l**ow-**p**ass **f**ilter.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import { registerChainEffect, getFrequencyFromValue, getWorklet, logger, registerWorklet } from 'superdough';
|
||||
import workletUrl from './worklet.mjs?audioworklet';
|
||||
|
||||
let kabel;
|
||||
async function initKabelsalat() {
|
||||
const { SalatRepl } = await import('@kabelsalat/web');
|
||||
logger('[kabelsalat] ready');
|
||||
kabel = new SalatRepl({ localScope: true });
|
||||
return kabel;
|
||||
}
|
||||
|
||||
initKabelsalat().catch((err) => {
|
||||
logger(`kabelsalat init failed: ${err}`);
|
||||
});
|
||||
|
||||
const compileKabel = (code) => {
|
||||
if (!kabel) {
|
||||
throw new Error('kabelsalat still loading');
|
||||
}
|
||||
const node = kabel.evaluate(code);
|
||||
return node.compile({ log: false });
|
||||
};
|
||||
|
||||
registerWorklet(workletUrl);
|
||||
|
||||
registerChainEffect('workletSrc', ({ audioContext, fx, value, chainID, start, gateEnd, releaseEnd }) => {
|
||||
const workletSrc = fx.workletSrc
|
||||
.replace(/\bpat\[(\d+)\]/g, (_, i) => fx.workletInputs[i])
|
||||
.replaceAll('sFreq', getFrequencyFromValue(value))
|
||||
.replaceAll('sGate', `cc('strudel-gate-${chainID}')`);
|
||||
const { src, ugens, registers } = compileKabel(workletSrc);
|
||||
const workletNode = getWorklet(audioContext, 'generic-processor', {}, { outputChannelCount: [2] });
|
||||
workletNode.port.postMessage({
|
||||
src,
|
||||
schema: { ugens, registers },
|
||||
start,
|
||||
gateEnd,
|
||||
end: releaseEnd,
|
||||
});
|
||||
return workletNode;
|
||||
});
|
||||
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "@strudel/kabelsalat",
|
||||
"version": "1.2.6",
|
||||
"description": "kabelsalat integration for superdough",
|
||||
"main": "kabelsalat.mjs",
|
||||
"type": "module",
|
||||
"publishConfig": {
|
||||
"main": "dist/kabelsalat.mjs"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://codeberg.org/uzu/strudel.git"
|
||||
},
|
||||
"keywords": [
|
||||
"titdalcycles",
|
||||
"strudel",
|
||||
"pattern",
|
||||
"livecoding",
|
||||
"algorave"
|
||||
],
|
||||
"author": "Felix Roos <flix91@gmail.com>",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"bugs": {
|
||||
"url": "https://codeberg.org/uzu/strudel/issues"
|
||||
},
|
||||
"homepage": "https://codeberg.org/uzu/strudel#readme",
|
||||
"dependencies": {
|
||||
"superdough": "workspace:*",
|
||||
"@kabelsalat/lib": "^0.4.1",
|
||||
"@kabelsalat/web": "^0.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vite": "^6.0.11",
|
||||
"vite-plugin-bundle-audioworklet":"workspace:*"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import { resolve } from 'path';
|
||||
import bundleAudioWorkletPlugin from 'vite-plugin-bundle-audioworklet';
|
||||
import { dependencies } from './package.json';
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [bundleAudioWorkletPlugin()],
|
||||
build: {
|
||||
lib: {
|
||||
entry: resolve(__dirname, 'kabelsalat.mjs'),
|
||||
formats: ['es'],
|
||||
fileName: (ext) => ({ es: 'kabelsalat.mjs' })[ext],
|
||||
},
|
||||
rollupOptions: {
|
||||
external: [...Object.keys(dependencies)],
|
||||
},
|
||||
target: 'esnext',
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,83 @@
|
||||
import * as ugens from '@kabelsalat/lib/src/ugens.js';
|
||||
|
||||
const blockSize = 128;
|
||||
|
||||
const UGENS = new Map(Object.entries(ugens));
|
||||
|
||||
class GenericProcessor extends AudioWorkletProcessor {
|
||||
constructor() {
|
||||
super();
|
||||
this.playPos = 0;
|
||||
const channels = 16;
|
||||
this.outputs = new Array(channels).fill(0);
|
||||
this.sources = new Array(channels).fill(0);
|
||||
this.gateEnded = false;
|
||||
this.started = false;
|
||||
this.port.onmessage = (event) => {
|
||||
let {
|
||||
src,
|
||||
schema: { ugens, registers },
|
||||
start,
|
||||
gateEnd,
|
||||
end,
|
||||
} = event.data;
|
||||
this.start = start;
|
||||
this.gateEnd = gateEnd;
|
||||
this.end = end;
|
||||
this.registers = new Array(registers).fill(0);
|
||||
this.src = `o.fill(0); // reset outputs\n${src}`;
|
||||
this.nodes = [];
|
||||
for (let i = 0; i < ugens.length; i++) {
|
||||
const ugen = ugens[i];
|
||||
const nodeClass = UGENS.get(ugen.type);
|
||||
const node = new nodeClass(i, ugen, sampleRate);
|
||||
if (node.type === 'cc' && ugen.inputs?.[0]?.includes('strudel-gate')) {
|
||||
node.setValue(1);
|
||||
this.gateNode = node;
|
||||
}
|
||||
this.nodes[i] = node;
|
||||
}
|
||||
this.genSample = new Function(
|
||||
'time',
|
||||
'nodes',
|
||||
'input',
|
||||
'r', // registers
|
||||
'o', // outputs
|
||||
's', // sources
|
||||
this.src,
|
||||
);
|
||||
};
|
||||
}
|
||||
process(inputs, outputs) {
|
||||
const input = inputs[0]?.[0];
|
||||
if (currentTime >= this.end) {
|
||||
return false;
|
||||
} else if (this.genSample === undefined || currentTime < this.start) {
|
||||
// pending
|
||||
return true;
|
||||
}
|
||||
this.started = true;
|
||||
if (!this.gateEnded && currentTime > this.gateEnd) {
|
||||
this.gateNode?.setValue(0);
|
||||
this.gateEnded = true;
|
||||
}
|
||||
const output = outputs[0];
|
||||
const outL = output[0];
|
||||
const outR = output[1];
|
||||
for (let n = 0; n < blockSize; n++) {
|
||||
this.genSample(this.playPos, this.nodes, input ? input[n] : 0, this.registers, this.outputs, this.sources);
|
||||
const left = this.outputs[0];
|
||||
const right = this.outputs[1];
|
||||
// Spread to stereo if possible; else mixdown to mono
|
||||
if (outR) {
|
||||
outL[n] = left;
|
||||
outR[n] = right;
|
||||
} else {
|
||||
outL[n] = 0.5 * (left + right);
|
||||
}
|
||||
this.playPos += 1 / sampleRate;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
registerProcessor('generic-processor', GenericProcessor);
|
||||
@@ -2719,7 +2719,9 @@ export const { segment, seg } = register(['segment', 'seg'], function (rate, pat
|
||||
* @example
|
||||
* s("hh*8").swingBy(1/3, 4)
|
||||
*/
|
||||
export const swingBy = register('swingBy', (swing, n, pat) => pat.inside(n, late(seq(0, swing / 2))));
|
||||
export const swingBy = register('swingBy', (swing, n, pat) =>
|
||||
pat.inside(n, late(stack(seq(0, silence), seq(silence, swing / 2).late(swing / 2)))),
|
||||
);
|
||||
|
||||
/**
|
||||
* Shorthand for swingBy with 1/3:
|
||||
|
||||
@@ -6,10 +6,11 @@ This program is free software: you can redistribute it and/or modify it under th
|
||||
|
||||
import { Hap } from './hap.mjs';
|
||||
import { Pattern, fastcat, pure, register, reify, silence, stack, sequenceP, isPattern } from './pattern.mjs';
|
||||
import { _mod } from './util.mjs';
|
||||
import { _mod, noteToMidi } from './util.mjs';
|
||||
import Fraction from './fraction.mjs';
|
||||
|
||||
import { id, keyAlias, getCurrentKeyboardState } from './util.mjs';
|
||||
import TimeSpan from './timespan.mjs';
|
||||
|
||||
export function steady(value) {
|
||||
// A continuous value
|
||||
@@ -1181,3 +1182,93 @@ export const open = signal((t) => t.min(1));
|
||||
* .restart("x/4") // restart every 4 cycles
|
||||
*/
|
||||
export const close = signal((t) => Fraction(1).sub(t).max(0));
|
||||
|
||||
/**
|
||||
* Turns a pattern of numbers into a continuous signal.
|
||||
* Each number in the pattern specifies the value at its onset, and over the
|
||||
* duration of the hap, it will linearly transition to the value of the next hap.
|
||||
*
|
||||
* Alternatively, the end value of a hap can be specified explicitly using
|
||||
* array notation, in which case there will be a hard jump from the end value
|
||||
* of the hap, and the begin value of the next hap.
|
||||
*
|
||||
* Similar to other signals like `saw` or `perlin`, this signal should be sampled
|
||||
* at regular intervals to actually get the desired result.
|
||||
*
|
||||
* @name smooth
|
||||
* @tags generators
|
||||
* @example
|
||||
* n(smooth("0 8").seg(16))
|
||||
* .scale('C major')
|
||||
* @example
|
||||
* n(smooth("0:8").seg(8))
|
||||
* .scale('C major')
|
||||
* @example
|
||||
* n("<0 0 0 3 0 4 0 7>*16").scale("e2:phrygian")
|
||||
* .s("saw").lpf(100).lpq(7)
|
||||
* .lpenv(smooth("<0 1@3 2 3 5 [8 [3 5] 2]*4@4 2:8 2:8 2:8 8>"))
|
||||
*
|
||||
*/
|
||||
export const smooth = register('smooth', (pat) => {
|
||||
return new Pattern((state) => {
|
||||
const haps = pat.query(state);
|
||||
if (!haps.length) {
|
||||
return haps;
|
||||
}
|
||||
// Find the last hap in the query
|
||||
const lastHap = haps.reduce((max, hap) => (hap.whole.end.gt(max.whole.end) ? hap : max));
|
||||
|
||||
let onsetHaps = [
|
||||
...haps,
|
||||
// Because the last hap in our query also needs to transition to the next value,
|
||||
// we query to find the next hap after the current last hap.
|
||||
// If that hap is outside of the smooth margin, we simply assume that there is no next hap (e.g. a rest).
|
||||
...pat.query(state.withSpan((span) => new TimeSpan(lastHap.whole.end, lastHap.whole.end))),
|
||||
]
|
||||
// sort by onsets
|
||||
.sort((a, b) => a.whole.begin.compare(b.whole.begin))
|
||||
// Make onsets unique
|
||||
.filter((x, i, arr) => i === arr.length - 1 || x.whole.begin.ne(arr[i + 1].whole.begin));
|
||||
|
||||
const newHaps = [];
|
||||
|
||||
for (const hap of haps) {
|
||||
// Find the next onset
|
||||
const next = onsetHaps.find((onsetHap) => onsetHap.whole.begin.eq(hap.whole.end));
|
||||
|
||||
newHaps.push(__smoothHap(state.span.begin, hap, next));
|
||||
}
|
||||
return newHaps;
|
||||
});
|
||||
});
|
||||
|
||||
function __smoothHap(time, hapA, hapB) {
|
||||
let a, b, context;
|
||||
if (Array.isArray(hapA.value)) {
|
||||
// Hap with array notation determines both start and end values.
|
||||
a = hapA.value[0];
|
||||
b = hapA.value[1];
|
||||
context = hapA.context;
|
||||
} else {
|
||||
a = hapA.value;
|
||||
if (hapB === undefined) {
|
||||
// With no hapB given, we simply copy the value of hapA so the value
|
||||
// remains the same throughout the hap.
|
||||
// E.g. smooth("0 1 -") will transition from 0 to 1 and then stay at 1 until the rest.
|
||||
b = hapA.value;
|
||||
context = hapA.context;
|
||||
} else {
|
||||
// Otherwise, transition to the value at the start of hapB.
|
||||
b = Array.isArray(hapB.value) ? hapB.value[0] : hapB.value;
|
||||
context = hapA.combineContext(hapB);
|
||||
}
|
||||
}
|
||||
if (typeof a === 'string') {
|
||||
a = noteToMidi(a);
|
||||
}
|
||||
if (typeof b === 'string') {
|
||||
b = noteToMidi(b);
|
||||
}
|
||||
const progress = time.sub(hapA.whole.begin).div(hapA.whole.end.sub(hapA.whole.begin));
|
||||
return new Hap(hapA.whole, hapA.part, a + (b - a) * (progress.lt(0) ? 0 : progress), context);
|
||||
}
|
||||
|
||||
@@ -24,8 +24,9 @@ import {
|
||||
per,
|
||||
perx,
|
||||
cyclesPer,
|
||||
smooth,
|
||||
} from '../signal.mjs';
|
||||
import { fastcat, sequence, State, TimeSpan, Hap, seq } from '../index.mjs';
|
||||
import { fastcat, sequence, State, TimeSpan, Hap, seq, pure, silence } from '../index.mjs';
|
||||
|
||||
const st = (begin, end) => new State(ts(begin, end));
|
||||
const ts = (begin, end) => new TimeSpan(Fraction(begin), Fraction(end));
|
||||
@@ -125,3 +126,18 @@ describe('shuffle', () => {
|
||||
expect(seq(1, 2, 3, 4).shuffle(1).firstCycle()).toEqual(seq(1, 2, 3, 4).firstCycle());
|
||||
});
|
||||
});
|
||||
|
||||
describe('smooth', () => {
|
||||
it('"0 1" equals a tri wave', () => {
|
||||
sameFirst(smooth(fastcat(0, 1)).seg(64), tri.seg(64));
|
||||
});
|
||||
it('"0:1" equals a saw wave', () => {
|
||||
sameFirst(smooth(pure([0, 1])).seg(64), saw.seg(64));
|
||||
});
|
||||
it('supports rests', () => {
|
||||
sameFirst(smooth(fastcat(0, 1, silence)).seg(64), fastcat(saw, 1, silence).seg(64));
|
||||
});
|
||||
it('supports notes', () => {
|
||||
sameFirst(smooth(fastcat('c2', 'c3')).seg(64), fastcat(tri.range(36, 48)).seg(64));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -36,8 +36,6 @@
|
||||
"vite-plugin-bundle-audioworklet": "workspace:*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@kabelsalat/lib": "^0.4.1",
|
||||
"@kabelsalat/web": "^0.4.1",
|
||||
"nanostores": "^0.11.3"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
@@ -288,12 +288,14 @@ export const samples = async (sampleMap, baseUrl = sampleMap._base || '', option
|
||||
};
|
||||
|
||||
const cutGroups = [];
|
||||
const scutGroups = [];
|
||||
|
||||
export async function onTriggerSample(t, value, onended, bank, resolveUrl) {
|
||||
let {
|
||||
s,
|
||||
nudge = 0, // TODO: is this in seconds?
|
||||
cut,
|
||||
scut,
|
||||
loop,
|
||||
clip = undefined, // if set, samples will be cut off when the hap ends
|
||||
n = 0,
|
||||
@@ -372,6 +374,23 @@ export async function onTriggerSample(t, value, onended, bank, resolveUrl) {
|
||||
cutGroups[cut] = handle;
|
||||
}
|
||||
|
||||
// scut groups
|
||||
if (scut !== undefined) {
|
||||
if (scutGroups[scut] === undefined) {
|
||||
scutGroups[scut] = { t, handles: [] };
|
||||
}
|
||||
const prevGroup = scutGroups[scut];
|
||||
if (prevGroup.t !== t) {
|
||||
for (const prev of prevGroup.handles) {
|
||||
prev.node.gain.setValueAtTime(1, time);
|
||||
prev.node.gain.linearRampToValueAtTime(0, time + 0.01);
|
||||
}
|
||||
|
||||
scutGroups[scut] = { t, handles: [] };
|
||||
}
|
||||
scutGroups[scut].handles.push(handle);
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
gainNode,
|
||||
getCompressor,
|
||||
getDistortion,
|
||||
getFrequencyFromValue,
|
||||
getLfo,
|
||||
getWorklet,
|
||||
releaseAudioNode,
|
||||
@@ -63,6 +62,11 @@ export function registerSound(key, onTrigger, data = {}) {
|
||||
soundMap.setKey(key, { onTrigger, data });
|
||||
}
|
||||
|
||||
const chainEffects = {};
|
||||
export function registerChainEffect(name, effect) {
|
||||
chainEffects[name] = effect;
|
||||
}
|
||||
|
||||
let gainCurveFunc = (val) => val;
|
||||
|
||||
export function applyGainCurve(val) {
|
||||
@@ -259,14 +263,6 @@ export function loadWorklets() {
|
||||
return workletsLoading;
|
||||
}
|
||||
|
||||
let kabel;
|
||||
async function initKabelsalat() {
|
||||
const { SalatRepl } = await import('@kabelsalat/web');
|
||||
logger('[kabelsalat] ready');
|
||||
kabel = new SalatRepl({ localScope: true });
|
||||
return kabel;
|
||||
}
|
||||
|
||||
// this function should be called on first user interaction (to avoid console warning)
|
||||
export async function initAudio(options = {}) {
|
||||
const {
|
||||
@@ -313,7 +309,6 @@ export async function initAudio(options = {}) {
|
||||
} catch (err) {
|
||||
console.warn('could not load AudioWorklet effects', err);
|
||||
}
|
||||
await initKabelsalat();
|
||||
logger('[superdough] ready');
|
||||
}
|
||||
let audioReady;
|
||||
@@ -449,14 +444,6 @@ class Chain {
|
||||
}
|
||||
}
|
||||
|
||||
const compileKabel = (code) => {
|
||||
if (!kabel) {
|
||||
throw new Error('kabelsalat not loaded');
|
||||
}
|
||||
const node = kabel.evaluate(code);
|
||||
return node.compile({ log: false });
|
||||
};
|
||||
|
||||
export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5) => {
|
||||
// mapping from main FX and numbered FX chains to nodes
|
||||
const nodes = { main: {} };
|
||||
@@ -632,17 +619,21 @@ export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5)
|
||||
gain *= velocity; // velocity currently only multiplies with gain. it might do other things in the future
|
||||
delaytime = delaytime ?? cycleToSeconds(delaysync, cps);
|
||||
|
||||
// Kabelsalat
|
||||
if (fx.workletSrc !== undefined) {
|
||||
const workletNode = getWorklet(ac, 'generic-processor', {}, { outputChannelCount: [2] });
|
||||
chain.connect(workletNode);
|
||||
const workletSrc = fx.workletSrc
|
||||
.replace(/\bpat\[(\d+)\]/g, (_, i) => fx.workletInputs[i])
|
||||
.replaceAll('sFreq', getFrequencyFromValue(value))
|
||||
.replaceAll('sGate', `cc('strudel-gate-${chainID}')`);
|
||||
/* global compileKabel */
|
||||
const { src, ugens, registers } = compileKabel(workletSrc);
|
||||
workletNode.port.postMessage({ src, schema: { ugens, registers }, start: t, gateEnd: end, end: endWithRelease });
|
||||
// custom chain effect sink (used for kabelsalat)
|
||||
for (let key in chainEffects) {
|
||||
const effect = chainEffects[key];
|
||||
if (fx[key] !== undefined) {
|
||||
const node = effect({
|
||||
audioContext: ac,
|
||||
fx,
|
||||
chainID,
|
||||
value,
|
||||
start: t,
|
||||
gateEnd: end,
|
||||
releaseEnd: endWithRelease,
|
||||
});
|
||||
node && chain.connect(node);
|
||||
}
|
||||
}
|
||||
|
||||
if (fx.stretch !== undefined) {
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
import OLAProcessor from './ola-processor';
|
||||
import FFT from './fft.js';
|
||||
import { getDistortionAlgorithm } from './helpers.mjs';
|
||||
import * as ugens from '@kabelsalat/lib/src/ugens.js';
|
||||
|
||||
const UGENS = new Map(Object.entries(ugens));
|
||||
|
||||
const blockSize = 128;
|
||||
const PI = Math.PI;
|
||||
@@ -1494,81 +1491,3 @@ class TransientProcessor extends AudioWorkletProcessor {
|
||||
}
|
||||
|
||||
registerProcessor('transient-processor', TransientProcessor);
|
||||
|
||||
class GenericProcessor extends AudioWorkletProcessor {
|
||||
constructor() {
|
||||
super();
|
||||
this.playPos = 0;
|
||||
const channels = 16;
|
||||
this.outputs = new Array(channels).fill(0);
|
||||
this.sources = new Array(channels).fill(0);
|
||||
this.gateEnded = false;
|
||||
this.started = false;
|
||||
this.port.onmessage = (event) => {
|
||||
let {
|
||||
src,
|
||||
schema: { ugens, registers },
|
||||
start,
|
||||
gateEnd,
|
||||
end,
|
||||
} = event.data;
|
||||
this.start = start;
|
||||
this.gateEnd = gateEnd;
|
||||
this.end = end;
|
||||
this.registers = new Array(registers).fill(0);
|
||||
this.src = `o.fill(0); // reset outputs\n${src}`;
|
||||
this.nodes = [];
|
||||
for (let i = 0; i < ugens.length; i++) {
|
||||
const ugen = ugens[i];
|
||||
const nodeClass = UGENS.get(ugen.type);
|
||||
const node = new nodeClass(i, ugen, sampleRate);
|
||||
if (node.type === 'cc' && ugen.inputs?.[0]?.includes('strudel-gate')) {
|
||||
node.setValue(1);
|
||||
this.gateNode = node;
|
||||
}
|
||||
this.nodes[i] = node;
|
||||
}
|
||||
this.genSample = new Function(
|
||||
'time',
|
||||
'nodes',
|
||||
'input',
|
||||
'r', // registers
|
||||
'o', // outputs
|
||||
's', // sources
|
||||
this.src,
|
||||
);
|
||||
};
|
||||
}
|
||||
process(inputs, outputs) {
|
||||
const input = inputs[0]?.[0];
|
||||
if (currentTime >= this.end) {
|
||||
return false;
|
||||
} else if (this.genSample === undefined || currentTime < this.start) {
|
||||
// pending
|
||||
return true;
|
||||
}
|
||||
this.started = true;
|
||||
if (!this.gateEnded && currentTime > this.gateEnd) {
|
||||
this.gateNode?.setValue(0);
|
||||
this.gateEnded = true;
|
||||
}
|
||||
const output = outputs[0];
|
||||
const outL = output[0];
|
||||
const outR = output[1];
|
||||
for (let n = 0; n < blockSize; n++) {
|
||||
this.genSample(this.playPos, this.nodes, input ? input[n] : 0, this.registers, this.outputs, this.sources);
|
||||
const left = this.outputs[0];
|
||||
const right = this.outputs[1];
|
||||
// Spread to stereo if possible; else mixdown to mono
|
||||
if (outR) {
|
||||
outL[n] = left;
|
||||
outR[n] = right;
|
||||
} else {
|
||||
outL[n] = 0.5 * (left + right);
|
||||
}
|
||||
this.playPos += 1 / sampleRate;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
registerProcessor('generic-processor', GenericProcessor);
|
||||
|
||||
@@ -35,10 +35,12 @@
|
||||
"dependencies": {
|
||||
"@strudel/core": "workspace:*",
|
||||
"@strudel/draw": "workspace:*",
|
||||
"@strudel/pattern": "workspace:*",
|
||||
"superdough": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vite": "^6.0.11"
|
||||
"vite": "^6.0.11",
|
||||
"vitest": "^3.0.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
import { calculateContextLength, getExportCheckpoints } from '../util.mjs';
|
||||
import { cps } from '@strudel/core';
|
||||
import { slowcat, silence, fastcat } from '@strudel/pattern';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
describe('getCheckpoints()', () => {
|
||||
it('Should return the start and end checkpoints for an empty pattern', () => {
|
||||
expect(getExportCheckpoints(silence, 0.5, 1, 10)).toStrictEqual([
|
||||
{ cycle: 1, cps: 0.5 },
|
||||
{ cycle: 10, cps: 0.5 },
|
||||
]);
|
||||
});
|
||||
it('Should break up checkpoints for an empty pattern into chunks when a max duration is specified', () => {
|
||||
expect(getExportCheckpoints(silence, 0.5, 1, 10, 2)).toStrictEqual([
|
||||
{ cycle: 1, cps: 0.5 },
|
||||
{ cycle: 3, cps: 0.5 },
|
||||
{ cycle: 5, cps: 0.5 },
|
||||
{ cycle: 7, cps: 0.5 },
|
||||
{ cycle: 9, cps: 0.5 },
|
||||
{ cycle: 10, cps: 0.5 },
|
||||
]);
|
||||
});
|
||||
it('Should create checkpoints for cps changes', () => {
|
||||
expect(getExportCheckpoints(cps(fastcat(1, 2, 3, 4)), 0.5, 0, 2)).toStrictEqual([
|
||||
{ cycle: 0, cps: 1 },
|
||||
{ cycle: 0.25, cps: 2 },
|
||||
{ cycle: 0.5, cps: 3 },
|
||||
{ cycle: 0.75, cps: 4 },
|
||||
{ cycle: 1, cps: 1 },
|
||||
{ cycle: 1.25, cps: 2 },
|
||||
{ cycle: 1.5, cps: 3 },
|
||||
{ cycle: 1.75, cps: 4 },
|
||||
{ cycle: 2, cps: 0.5 },
|
||||
]);
|
||||
});
|
||||
it('Should create checkpoints for cps changes and split into chunks when a max duration is specified', () => {
|
||||
expect(getExportCheckpoints(cps(slowcat(1, 2, 3, 4)), 0.5, 1, 5, 0.75)).toStrictEqual([
|
||||
{ cycle: 1, cps: 2 },
|
||||
{ cycle: 1.75, cps: 2 },
|
||||
{ cycle: 2, cps: 3 },
|
||||
{ cycle: 2.75, cps: 3 },
|
||||
{ cycle: 3, cps: 4 },
|
||||
{ cycle: 3.75, cps: 4 },
|
||||
{ cycle: 4, cps: 1 },
|
||||
{ cycle: 4.75, cps: 1 },
|
||||
{ cycle: 5, cps: 0.5 },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('calculateContextLength()', () => {
|
||||
it('Should work when there are only the start and end checkpoints', () => {
|
||||
expect(
|
||||
calculateContextLength(
|
||||
[
|
||||
{ cycle: 1, cps: 0.5 },
|
||||
{ cycle: 10, cps: 0.5 },
|
||||
],
|
||||
1000,
|
||||
),
|
||||
).toBe(18000);
|
||||
});
|
||||
it('Should calculate the context length correctly', () => {
|
||||
expect(
|
||||
calculateContextLength(
|
||||
[
|
||||
{ cycle: 1, cps: 1 },
|
||||
{ cycle: 2, cps: 0.5 },
|
||||
{ cycle: 3, cps: 2 },
|
||||
{ cycle: 5, cps: 1 },
|
||||
{ cycle: 6, cps: 0.5 },
|
||||
],
|
||||
1000,
|
||||
),
|
||||
).toBe(5000);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
* @typedef {object} ExportCheckpoint
|
||||
* @property {number} cycle The point in time that the cps changes happens
|
||||
* @property {number} cps The new target cps (cycles per second)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Queries the pattern from `begin` to `end` and returns a list of checkpoints
|
||||
* that signify the places in the pattern where the `cps` changes.
|
||||
* If `maxCheckpointDuration` is specified, additional checkpoints will be
|
||||
* inserted if the time difference between two checkpoints is longer than the
|
||||
* specified value.
|
||||
*
|
||||
* The returned list of checkpoints will always have at least 2 checkpoints,
|
||||
* signifying the start and end of the query.
|
||||
*
|
||||
* @param {Pattern} pattern The pattern to query
|
||||
* @param {number} cps The starting cps
|
||||
* @param {number} begin The start of the query
|
||||
* @param {number} end The end of the query
|
||||
* @param {number} maxCheckpointDuration The maximum time difference between checkpoints
|
||||
* @returns {ExportCheckpoint[]} A list of at least 2 checkpoints
|
||||
*/
|
||||
export function getExportCheckpoints(pattern, cps, begin, end, maxCheckpointDuration = Number.MAX_VALUE) {
|
||||
const cpsHaps = pattern
|
||||
.queryArc(0, end, { _cps: cps })
|
||||
.filter((hap) => hap.value.cps !== undefined)
|
||||
.sort((a, b) => {
|
||||
const aBegin = a.whole.begin.valueOf();
|
||||
const bBegin = b.whole.begin.valueOf();
|
||||
if (aBegin === bBegin) {
|
||||
// With multiple simultaneous haps that set the cps,
|
||||
// there must be an order for determinism.
|
||||
return a.value.cps - b.value.cps;
|
||||
}
|
||||
return aBegin - bBegin;
|
||||
})
|
||||
.map((hap) => {
|
||||
return {
|
||||
cycle: hap.whole.begin.valueOf(),
|
||||
cps: hap.value.cps,
|
||||
};
|
||||
});
|
||||
|
||||
// Insert starting checkpoint with the default cps
|
||||
cpsHaps.splice(0, 0, { cycle: 0, cps: cps });
|
||||
// Insert an ending checkpoint after the target end-time with the default cps
|
||||
cpsHaps.push({ cycle: end + 1, cps: cps });
|
||||
|
||||
const checkpoints = [];
|
||||
|
||||
for (var i = 0; i < cpsHaps.length - 1; i++) {
|
||||
const checkpointA = cpsHaps[i];
|
||||
const checkpointB = cpsHaps[i + 1];
|
||||
if (checkpointA.cycle === checkpointB.cycle) {
|
||||
// With multiple checkpoints at the same cycle, we only use the last one.
|
||||
continue;
|
||||
}
|
||||
if (checkpointB.cycle < begin) {
|
||||
// Not at the start yet
|
||||
continue;
|
||||
}
|
||||
var newCheckpoint;
|
||||
if (checkpointA.cycle <= begin && begin < checkpointB.cycle) {
|
||||
// Found the first checkpoint
|
||||
newCheckpoint = { cycle: begin, cps: checkpointA.cps };
|
||||
checkpoints.push(newCheckpoint);
|
||||
} else if (begin <= checkpointA.cycle) {
|
||||
newCheckpoint = { cycle: checkpointA.cycle, cps: checkpointA.cps };
|
||||
checkpoints.push(newCheckpoint);
|
||||
}
|
||||
if (newCheckpoint !== undefined) {
|
||||
while (maxCheckpointDuration < Math.min(checkpointB.cycle, end) - newCheckpoint.cycle) {
|
||||
newCheckpoint = { cycle: newCheckpoint.cycle + maxCheckpointDuration, cps: newCheckpoint.cps };
|
||||
checkpoints.push(newCheckpoint);
|
||||
}
|
||||
}
|
||||
if (end <= checkpointB.cycle) {
|
||||
checkpoints.push({ cycle: end, cps: checkpointB.cps });
|
||||
}
|
||||
}
|
||||
|
||||
return checkpoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the context length in number of samples based on a list of
|
||||
* checkpoints and the samplerate per second.
|
||||
*
|
||||
* @param {ExportCheckpoint[]} checkpoints
|
||||
* @param {number} sampleRate
|
||||
* @returns {number}
|
||||
*/
|
||||
export function calculateContextLength(checkpoints, sampleRate) {
|
||||
console.assert(checkpoints.length >= 2, 'checkpoints must contain at least two entries');
|
||||
|
||||
var total = 0;
|
||||
|
||||
for (let i = 0; i < checkpoints.length - 1; i++) {
|
||||
const changeA = checkpoints[i];
|
||||
const changeB = checkpoints[i + 1];
|
||||
const duration = changeB.cycle - changeA.cycle;
|
||||
total += duration / changeA.cps;
|
||||
}
|
||||
|
||||
return total * sampleRate;
|
||||
}
|
||||
+104
-47
@@ -10,7 +10,6 @@ import {
|
||||
getAudioContext,
|
||||
setLogger,
|
||||
rawdspOutput,
|
||||
registerWorklet,
|
||||
setAudioContext,
|
||||
initAudio,
|
||||
setSuperdoughAudioController,
|
||||
@@ -18,9 +17,14 @@ import {
|
||||
errorLogger,
|
||||
} from 'superdough';
|
||||
import { SuperdoughAudioController } from 'superdough/superdoughoutput.mjs';
|
||||
import { getExportCheckpoints, calculateContextLength } from './util.mjs';
|
||||
|
||||
const { Pattern, logger, repl } = strudel;
|
||||
|
||||
/**
|
||||
* @import { ExportCheckpoint } from '@strudel/core'
|
||||
*/
|
||||
|
||||
setLogger(logger);
|
||||
|
||||
const hap2value = (hap) => {
|
||||
@@ -46,7 +50,13 @@ export async function renderPatternAudio(
|
||||
) {
|
||||
let audioContext = getAudioContext();
|
||||
await audioContext.close();
|
||||
audioContext = new OfflineAudioContext(2, ((end - begin) / cps) * sampleRate, sampleRate);
|
||||
|
||||
const chunkSize = 1;
|
||||
|
||||
const checkpoints = getExportCheckpoints(pattern, cps, begin, end, chunkSize);
|
||||
const contextLength = calculateContextLength(checkpoints, sampleRate);
|
||||
|
||||
audioContext = new OfflineAudioContext(2, contextLength, sampleRate);
|
||||
setAudioContext(audioContext);
|
||||
setSuperdoughAudioController(new SuperdoughAudioController(audioContext));
|
||||
await initAudio({
|
||||
@@ -58,8 +68,8 @@ export async function renderPatternAudio(
|
||||
// so no chunked rendering. Bad performance, but at least it works.
|
||||
return (
|
||||
audioContext.suspend === undefined
|
||||
? renderPatternAudioWhole(audioContext, pattern, cps, begin, end)
|
||||
: renderPatternAudioInChunks(audioContext, pattern, cps, begin, end, 1)
|
||||
? renderPatternAudioWhole(audioContext, pattern, checkpoints)
|
||||
: renderPatternAudioInChunks(audioContext, pattern, checkpoints)
|
||||
)
|
||||
.then((renderedBuffer) => {
|
||||
const wavBuffer = audioBufferToWav(renderedBuffer);
|
||||
@@ -81,52 +91,89 @@ export async function renderPatternAudio(
|
||||
});
|
||||
}
|
||||
|
||||
async function renderPatternAudioWhole(audioContext, pattern, cps, begin, end) {
|
||||
/**
|
||||
* Renders a whole pattern to an OfflineAudioContext in one go.
|
||||
*
|
||||
* @param {OfflineAudioContext} audioContext The OfflineAudioContext to render to
|
||||
* @param {Pattern} pattern The pattern to render
|
||||
* @param {ExportCheckpoint[]} checkpoints A list of checkpoints indicating the cps changes throughout the song
|
||||
* @returns {Promise<AudioBuffer>}
|
||||
*/
|
||||
async function renderPatternAudioWhole(audioContext, pattern, checkpoints) {
|
||||
logger(`[webaudio] preloading`);
|
||||
|
||||
await scheduleHapsChunk(pattern, cps, begin, begin, end);
|
||||
var seconds = 0;
|
||||
|
||||
for (var i = 0; i < checkpoints.length - 1; i++) {
|
||||
const checkpointA = checkpoints[i];
|
||||
const checkpointB = checkpoints[i + 1];
|
||||
|
||||
seconds += await scheduleHapsChunk(pattern, seconds, checkpointA, checkpointB);
|
||||
}
|
||||
|
||||
logger('[webaudio] start rendering');
|
||||
|
||||
return audioContext.startRendering();
|
||||
}
|
||||
|
||||
async function renderPatternAudioInChunks(audioContext, pattern, cps, begin, end, chunkSizeInCycles) {
|
||||
let currentCycle = begin;
|
||||
let renderPromise = null;
|
||||
/**
|
||||
* Renders a whole pattern to an OfflineAudioContext in small chunks.
|
||||
* Rendering in chunks provides better rendering performance by keeping the
|
||||
* overall audio graph smaller.
|
||||
*
|
||||
* Not suppoerted on Firefox
|
||||
*
|
||||
* @param {OfflineAudioContext} audioContext
|
||||
* @param {Pattern} pattern
|
||||
* @param {ExportCheckpoint[]} checkpoints
|
||||
* @returns {Promise<AudioBuffer>}
|
||||
*/
|
||||
async function renderPatternAudioInChunks(audioContext, pattern, checkpoints) {
|
||||
let renderPromise;
|
||||
|
||||
// The grace period is used to suspend rendering before the next haps are scheduled.
|
||||
const gracePeriod = 1;
|
||||
|
||||
logger('[webaudio] start rendering');
|
||||
|
||||
while (currentCycle <= end) {
|
||||
const chunkStart = currentCycle;
|
||||
const chunkEnd = Math.min(currentCycle + chunkSizeInCycles, end);
|
||||
var lastSuspend = 0;
|
||||
var seconds = 0;
|
||||
|
||||
logger(`[webaudio] preloading cycles ${chunkStart} - ${chunkEnd}`);
|
||||
for (var i = 0; i < checkpoints.length - 1; i++) {
|
||||
const checkpointA = checkpoints[i];
|
||||
const checkpointB = checkpoints[i + 1];
|
||||
|
||||
await scheduleHapsChunk(pattern, cps, begin, chunkStart, chunkEnd);
|
||||
logger(`[webaudio] preloading cycles ${checkpointA.cycle} - ${checkpointB.cycle}`);
|
||||
|
||||
logger(`[webaudio] rendering cycles ${chunkStart} - ${chunkEnd}`);
|
||||
seconds += await scheduleHapsChunk(pattern, seconds, checkpointA, checkpointB);
|
||||
|
||||
currentCycle += chunkSizeInCycles;
|
||||
const lastCycle = i === checkpoints.length - 2;
|
||||
|
||||
// According to the MDN docs, suspends should be scheduled while
|
||||
// the audioContext is not currently running for better precision.
|
||||
// So we schedule the suspend first, and await after resuming.
|
||||
var suspendPromise;
|
||||
if (currentCycle < end) {
|
||||
// Make sure to suspend one cycle before the next currentCycle
|
||||
// so the next haps can be scheduled on time.
|
||||
suspendPromise = audioContext.suspend((currentCycle - begin - 1) / cps);
|
||||
}
|
||||
if (lastSuspend < seconds - gracePeriod || lastCycle) {
|
||||
if (lastCycle) {
|
||||
logger(`[webaudio] rendering seconds ${lastSuspend} - ${seconds}`);
|
||||
} else {
|
||||
logger(`[webaudio] rendering seconds ${lastSuspend} - ${seconds - gracePeriod}`);
|
||||
}
|
||||
|
||||
if (renderPromise === null) {
|
||||
renderPromise = audioContext.startRendering();
|
||||
} else {
|
||||
await audioContext.resume();
|
||||
}
|
||||
// According to the MDN docs, suspends should be scheduled while
|
||||
// the audioContext is not currently running for better precision.
|
||||
// So we schedule the suspend first, and await after resuming.
|
||||
var suspendPromise;
|
||||
if (!lastCycle) {
|
||||
suspendPromise = audioContext.suspend(seconds - gracePeriod);
|
||||
lastSuspend = seconds - gracePeriod;
|
||||
}
|
||||
|
||||
if (currentCycle < end) {
|
||||
await suspendPromise;
|
||||
if (renderPromise === undefined) {
|
||||
renderPromise = audioContext.startRendering();
|
||||
} else {
|
||||
await audioContext.resume();
|
||||
}
|
||||
|
||||
if (suspendPromise !== undefined) {
|
||||
await suspendPromise;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,28 +182,38 @@ async function renderPatternAudioInChunks(audioContext, pattern, cps, begin, end
|
||||
return renderPromise;
|
||||
}
|
||||
|
||||
async function scheduleHapsChunk(pattern, cps, begin, chunkStart, chunkEnd) {
|
||||
/**
|
||||
* Schedule all haps between 2 checkpoints
|
||||
*
|
||||
* @param {Pattern} pattern The pattern to render
|
||||
* @param {number} chunkStartTime The time in seconds where the chunk starts
|
||||
* @param {ExportCheckpoint} checkpointA The starting checkpoint of the chunk
|
||||
* @param {ExportCheckpoint} checkpointB The ending checkpoint of the chunk
|
||||
* @returns {number} The length of the scheduled chunk in seconds.
|
||||
*/
|
||||
async function scheduleHapsChunk(pattern, chunkStartTime, checkpointA, checkpointB) {
|
||||
// Calling superdough(...) in ascending onset time order is important
|
||||
// for controls that depend on the audio graph state like `cut`
|
||||
let haps = pattern
|
||||
.queryArc(chunkStart, chunkEnd, { _cps: cps })
|
||||
const haps = pattern
|
||||
.queryArc(checkpointA.cycle, checkpointB.cycle, { _cps: checkpointA.cps })
|
||||
.filter((hap) => hap.hasOnset())
|
||||
.sort((a, b) => a.whole.begin.valueOf() - b.whole.begin.valueOf());
|
||||
|
||||
for (const hap of haps) {
|
||||
if (hap.hasOnset()) {
|
||||
try {
|
||||
await superdough(
|
||||
hap2value(hap),
|
||||
(hap.whole.begin.valueOf() - begin) / cps,
|
||||
hap.duration / cps,
|
||||
cps,
|
||||
(hap.whole?.begin.valueOf() - begin) / cps,
|
||||
);
|
||||
} catch (err) {
|
||||
errorLogger(err, 'webaudio');
|
||||
}
|
||||
try {
|
||||
await superdough(
|
||||
hap2value(hap),
|
||||
(hap.whole.begin.valueOf() - checkpointA.cycle) / checkpointA.cps + chunkStartTime,
|
||||
hap.duration / checkpointA.cps,
|
||||
checkpointA.cps,
|
||||
(hap.whole?.begin.valueOf() - checkpointA.cycle) / checkpointA.cps + chunkStartTime,
|
||||
);
|
||||
} catch (err) {
|
||||
errorLogger(err, 'webaudio');
|
||||
}
|
||||
}
|
||||
|
||||
return (checkpointB.cycle - checkpointA.cycle) / checkpointA.cps;
|
||||
}
|
||||
|
||||
export function webaudioRepl(options = {}) {
|
||||
|
||||
@@ -20,7 +20,6 @@ function connect(addr) {
|
||||
});
|
||||
ws.addEventListener('message', (event) => {
|
||||
try {
|
||||
console.log(event.data);
|
||||
values[addr] = JSON.parse(event.data);
|
||||
} catch {
|
||||
logger(`[websocket] received invalid json on ${addr}`);
|
||||
|
||||
Generated
+28
-6
@@ -395,6 +395,25 @@ importers:
|
||||
specifier: ^6.0.11
|
||||
version: 6.0.11(@types/node@22.10.10)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(yaml@2.7.0)
|
||||
|
||||
packages/kabelsalat:
|
||||
dependencies:
|
||||
'@kabelsalat/lib':
|
||||
specifier: ^0.4.1
|
||||
version: 0.4.1
|
||||
'@kabelsalat/web':
|
||||
specifier: ^0.4.1
|
||||
version: 0.4.1
|
||||
superdough:
|
||||
specifier: workspace:*
|
||||
version: link:../superdough
|
||||
devDependencies:
|
||||
vite:
|
||||
specifier: ^6.0.11
|
||||
version: 6.0.11(@types/node@22.10.10)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(yaml@2.7.0)
|
||||
vite-plugin-bundle-audioworklet:
|
||||
specifier: workspace:*
|
||||
version: link:../vite-plugin-bundle-audioworklet
|
||||
|
||||
packages/midi:
|
||||
dependencies:
|
||||
'@strudel/core':
|
||||
@@ -611,12 +630,6 @@ importers:
|
||||
|
||||
packages/superdough:
|
||||
dependencies:
|
||||
'@kabelsalat/lib':
|
||||
specifier: ^0.4.1
|
||||
version: 0.4.1
|
||||
'@kabelsalat/web':
|
||||
specifier: ^0.4.1
|
||||
version: 0.4.1
|
||||
nanostores:
|
||||
specifier: ^0.11.3
|
||||
version: 0.11.3
|
||||
@@ -736,6 +749,9 @@ importers:
|
||||
'@strudel/draw':
|
||||
specifier: workspace:*
|
||||
version: link:../draw
|
||||
'@strudel/pattern':
|
||||
specifier: workspace:*
|
||||
version: link:../pattern
|
||||
superdough:
|
||||
specifier: workspace:*
|
||||
version: link:../superdough
|
||||
@@ -743,6 +759,9 @@ importers:
|
||||
vite:
|
||||
specifier: ^6.0.11
|
||||
version: 6.0.11(@types/node@22.10.10)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(yaml@2.7.0)
|
||||
vitest:
|
||||
specifier: ^3.0.4
|
||||
version: 3.0.4(@types/debug@4.1.12)(@types/node@22.10.10)(@vitest/ui@3.0.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(yaml@2.7.0)
|
||||
|
||||
packages/websocket:
|
||||
dependencies:
|
||||
@@ -853,6 +872,9 @@ importers:
|
||||
'@strudel/hydra':
|
||||
specifier: workspace:*
|
||||
version: link:../packages/hydra
|
||||
'@strudel/kabelsalat':
|
||||
specifier: workspace:*
|
||||
version: link:../packages/kabelsalat
|
||||
'@strudel/midi':
|
||||
specifier: workspace:*
|
||||
version: link:../packages/midi
|
||||
|
||||
@@ -11751,6 +11751,47 @@ exports[`runs examples > example "scrub" example index 1 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "scut" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/2 | note:E3 s:piano scut:1 ]",
|
||||
"[ 0/1 → 1/2 | note:C4 s:piano scut:1 ]",
|
||||
"[ 0/1 → 1/2 | note:E4 s:piano scut:1 ]",
|
||||
"[ 0/1 → 1/2 | note:G4 s:piano scut:1 ]",
|
||||
"[ 0/1 → 1/2 | note:C5 s:piano scut:1 ]",
|
||||
"[ 1/2 → 1/1 | note:G3 s:piano scut:1 ]",
|
||||
"[ 1/2 → 1/1 | note:D4 s:piano scut:1 ]",
|
||||
"[ 1/2 → 1/1 | note:G4 s:piano scut:1 ]",
|
||||
"[ 1/2 → 1/1 | note:B4 s:piano scut:1 ]",
|
||||
"[ 1/1 → 3/2 | note:E3 s:piano scut:1 ]",
|
||||
"[ 1/1 → 3/2 | note:C4 s:piano scut:1 ]",
|
||||
"[ 1/1 → 3/2 | note:E4 s:piano scut:1 ]",
|
||||
"[ 1/1 → 3/2 | note:G4 s:piano scut:1 ]",
|
||||
"[ 1/1 → 3/2 | note:C5 s:piano scut:1 ]",
|
||||
"[ 3/2 → 2/1 | note:G3 s:piano scut:1 ]",
|
||||
"[ 3/2 → 2/1 | note:D4 s:piano scut:1 ]",
|
||||
"[ 3/2 → 2/1 | note:G4 s:piano scut:1 ]",
|
||||
"[ 3/2 → 2/1 | note:B4 s:piano scut:1 ]",
|
||||
"[ 2/1 → 5/2 | note:E3 s:piano scut:1 ]",
|
||||
"[ 2/1 → 5/2 | note:C4 s:piano scut:1 ]",
|
||||
"[ 2/1 → 5/2 | note:E4 s:piano scut:1 ]",
|
||||
"[ 2/1 → 5/2 | note:G4 s:piano scut:1 ]",
|
||||
"[ 2/1 → 5/2 | note:C5 s:piano scut:1 ]",
|
||||
"[ 5/2 → 3/1 | note:G3 s:piano scut:1 ]",
|
||||
"[ 5/2 → 3/1 | note:D4 s:piano scut:1 ]",
|
||||
"[ 5/2 → 3/1 | note:G4 s:piano scut:1 ]",
|
||||
"[ 5/2 → 3/1 | note:B4 s:piano scut:1 ]",
|
||||
"[ 3/1 → 7/2 | note:E3 s:piano scut:1 ]",
|
||||
"[ 3/1 → 7/2 | note:C4 s:piano scut:1 ]",
|
||||
"[ 3/1 → 7/2 | note:E4 s:piano scut:1 ]",
|
||||
"[ 3/1 → 7/2 | note:G4 s:piano scut:1 ]",
|
||||
"[ 3/1 → 7/2 | note:C5 s:piano scut:1 ]",
|
||||
"[ 7/2 → 4/1 | note:G3 s:piano scut:1 ]",
|
||||
"[ 7/2 → 4/1 | note:D4 s:piano scut:1 ]",
|
||||
"[ 7/2 → 4/1 | note:G4 s:piano scut:1 ]",
|
||||
"[ 7/2 → 4/1 | note:B4 s:piano scut:1 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "seed" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/4 | s:bd ]",
|
||||
@@ -12831,6 +12872,181 @@ exports[`runs examples > example "slowcat" example index 0 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "smooth" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/16 | note:C3 ]",
|
||||
"[ 1/16 → 1/8 | note:D3 ]",
|
||||
"[ 1/8 → 3/16 | note:E3 ]",
|
||||
"[ 3/16 → 1/4 | note:F3 ]",
|
||||
"[ 1/4 → 5/16 | note:G3 ]",
|
||||
"[ 5/16 → 3/8 | note:A3 ]",
|
||||
"[ 3/8 → 7/16 | note:B3 ]",
|
||||
"[ 7/16 → 1/2 | note:C4 ]",
|
||||
"[ 1/2 → 9/16 | note:D4 ]",
|
||||
"[ 9/16 → 5/8 | note:C4 ]",
|
||||
"[ 5/8 → 11/16 | note:B3 ]",
|
||||
"[ 11/16 → 3/4 | note:A3 ]",
|
||||
"[ 3/4 → 13/16 | note:G3 ]",
|
||||
"[ 13/16 → 7/8 | note:F3 ]",
|
||||
"[ 7/8 → 15/16 | note:E3 ]",
|
||||
"[ 15/16 → 1/1 | note:D3 ]",
|
||||
"[ 1/1 → 17/16 | note:C3 ]",
|
||||
"[ 17/16 → 9/8 | note:D3 ]",
|
||||
"[ 9/8 → 19/16 | note:E3 ]",
|
||||
"[ 19/16 → 5/4 | note:F3 ]",
|
||||
"[ 5/4 → 21/16 | note:G3 ]",
|
||||
"[ 21/16 → 11/8 | note:A3 ]",
|
||||
"[ 11/8 → 23/16 | note:B3 ]",
|
||||
"[ 23/16 → 3/2 | note:C4 ]",
|
||||
"[ 3/2 → 25/16 | note:D4 ]",
|
||||
"[ 25/16 → 13/8 | note:C4 ]",
|
||||
"[ 13/8 → 27/16 | note:B3 ]",
|
||||
"[ 27/16 → 7/4 | note:A3 ]",
|
||||
"[ 7/4 → 29/16 | note:G3 ]",
|
||||
"[ 29/16 → 15/8 | note:F3 ]",
|
||||
"[ 15/8 → 31/16 | note:E3 ]",
|
||||
"[ 31/16 → 2/1 | note:D3 ]",
|
||||
"[ 2/1 → 33/16 | note:C3 ]",
|
||||
"[ 33/16 → 17/8 | note:D3 ]",
|
||||
"[ 17/8 → 35/16 | note:E3 ]",
|
||||
"[ 35/16 → 9/4 | note:F3 ]",
|
||||
"[ 9/4 → 37/16 | note:G3 ]",
|
||||
"[ 37/16 → 19/8 | note:A3 ]",
|
||||
"[ 19/8 → 39/16 | note:B3 ]",
|
||||
"[ 39/16 → 5/2 | note:C4 ]",
|
||||
"[ 5/2 → 41/16 | note:D4 ]",
|
||||
"[ 41/16 → 21/8 | note:C4 ]",
|
||||
"[ 21/8 → 43/16 | note:B3 ]",
|
||||
"[ 43/16 → 11/4 | note:A3 ]",
|
||||
"[ 11/4 → 45/16 | note:G3 ]",
|
||||
"[ 45/16 → 23/8 | note:F3 ]",
|
||||
"[ 23/8 → 47/16 | note:E3 ]",
|
||||
"[ 47/16 → 3/1 | note:D3 ]",
|
||||
"[ 3/1 → 49/16 | note:C3 ]",
|
||||
"[ 49/16 → 25/8 | note:D3 ]",
|
||||
"[ 25/8 → 51/16 | note:E3 ]",
|
||||
"[ 51/16 → 13/4 | note:F3 ]",
|
||||
"[ 13/4 → 53/16 | note:G3 ]",
|
||||
"[ 53/16 → 27/8 | note:A3 ]",
|
||||
"[ 27/8 → 55/16 | note:B3 ]",
|
||||
"[ 55/16 → 7/2 | note:C4 ]",
|
||||
"[ 7/2 → 57/16 | note:D4 ]",
|
||||
"[ 57/16 → 29/8 | note:C4 ]",
|
||||
"[ 29/8 → 59/16 | note:B3 ]",
|
||||
"[ 59/16 → 15/4 | note:A3 ]",
|
||||
"[ 15/4 → 61/16 | note:G3 ]",
|
||||
"[ 61/16 → 31/8 | note:F3 ]",
|
||||
"[ 31/8 → 63/16 | note:E3 ]",
|
||||
"[ 63/16 → 4/1 | note:D3 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "smooth" example index 1 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/8 | note:C3 ]",
|
||||
"[ 1/8 → 1/4 | note:D3 ]",
|
||||
"[ 1/4 → 3/8 | note:E3 ]",
|
||||
"[ 3/8 → 1/2 | note:F3 ]",
|
||||
"[ 1/2 → 5/8 | note:G3 ]",
|
||||
"[ 5/8 → 3/4 | note:A3 ]",
|
||||
"[ 3/4 → 7/8 | note:B3 ]",
|
||||
"[ 7/8 → 1/1 | note:C4 ]",
|
||||
"[ 1/1 → 9/8 | note:C3 ]",
|
||||
"[ 9/8 → 5/4 | note:D3 ]",
|
||||
"[ 5/4 → 11/8 | note:E3 ]",
|
||||
"[ 11/8 → 3/2 | note:F3 ]",
|
||||
"[ 3/2 → 13/8 | note:G3 ]",
|
||||
"[ 13/8 → 7/4 | note:A3 ]",
|
||||
"[ 7/4 → 15/8 | note:B3 ]",
|
||||
"[ 15/8 → 2/1 | note:C4 ]",
|
||||
"[ 2/1 → 17/8 | note:C3 ]",
|
||||
"[ 17/8 → 9/4 | note:D3 ]",
|
||||
"[ 9/4 → 19/8 | note:E3 ]",
|
||||
"[ 19/8 → 5/2 | note:F3 ]",
|
||||
"[ 5/2 → 21/8 | note:G3 ]",
|
||||
"[ 21/8 → 11/4 | note:A3 ]",
|
||||
"[ 11/4 → 23/8 | note:B3 ]",
|
||||
"[ 23/8 → 3/1 | note:C4 ]",
|
||||
"[ 3/1 → 25/8 | note:C3 ]",
|
||||
"[ 25/8 → 13/4 | note:D3 ]",
|
||||
"[ 13/4 → 27/8 | note:E3 ]",
|
||||
"[ 27/8 → 7/2 | note:F3 ]",
|
||||
"[ 7/2 → 29/8 | note:G3 ]",
|
||||
"[ 29/8 → 15/4 | note:A3 ]",
|
||||
"[ 15/4 → 31/8 | note:B3 ]",
|
||||
"[ 31/8 → 4/1 | note:C4 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "smooth" example index 2 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:0 ]",
|
||||
"[ 1/16 → 1/8 | note:E2 s:saw cutoff:100 resonance:7 lpenv:0.0625 ]",
|
||||
"[ 1/8 → 3/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:0.125 ]",
|
||||
"[ 3/16 → 1/4 | note:A2 s:saw cutoff:100 resonance:7 lpenv:0.1875 ]",
|
||||
"[ 1/4 → 5/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:0.25 ]",
|
||||
"[ 5/16 → 3/8 | note:B2 s:saw cutoff:100 resonance:7 lpenv:0.3125 ]",
|
||||
"[ 3/8 → 7/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:0.375 ]",
|
||||
"[ 7/16 → 1/2 | note:E3 s:saw cutoff:100 resonance:7 lpenv:0.4375 ]",
|
||||
"[ 1/2 → 9/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:0.5 ]",
|
||||
"[ 9/16 → 5/8 | note:E2 s:saw cutoff:100 resonance:7 lpenv:0.5625 ]",
|
||||
"[ 5/8 → 11/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:0.625 ]",
|
||||
"[ 11/16 → 3/4 | note:A2 s:saw cutoff:100 resonance:7 lpenv:0.6875 ]",
|
||||
"[ 3/4 → 13/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:0.75 ]",
|
||||
"[ 13/16 → 7/8 | note:B2 s:saw cutoff:100 resonance:7 lpenv:0.8125 ]",
|
||||
"[ 7/8 → 15/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:0.875 ]",
|
||||
"[ 15/16 → 1/1 | note:E3 s:saw cutoff:100 resonance:7 lpenv:0.9375 ]",
|
||||
"[ 1/1 → 17/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1 ]",
|
||||
"[ 17/16 → 9/8 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.0208333333333333 ]",
|
||||
"[ 9/8 → 19/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.0416666666666667 ]",
|
||||
"[ 19/16 → 5/4 | note:A2 s:saw cutoff:100 resonance:7 lpenv:1.0625 ]",
|
||||
"[ 5/4 → 21/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.0833333333333333 ]",
|
||||
"[ 21/16 → 11/8 | note:B2 s:saw cutoff:100 resonance:7 lpenv:1.1041666666666667 ]",
|
||||
"[ 11/8 → 23/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.125 ]",
|
||||
"[ 23/16 → 3/2 | note:E3 s:saw cutoff:100 resonance:7 lpenv:1.1458333333333333 ]",
|
||||
"[ 3/2 → 25/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.1666666666666667 ]",
|
||||
"[ 25/16 → 13/8 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.1875 ]",
|
||||
"[ 13/8 → 27/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.2083333333333333 ]",
|
||||
"[ 27/16 → 7/4 | note:A2 s:saw cutoff:100 resonance:7 lpenv:1.2291666666666667 ]",
|
||||
"[ 7/4 → 29/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.25 ]",
|
||||
"[ 29/16 → 15/8 | note:B2 s:saw cutoff:100 resonance:7 lpenv:1.2708333333333333 ]",
|
||||
"[ 15/8 → 31/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.2916666666666667 ]",
|
||||
"[ 31/16 → 2/1 | note:E3 s:saw cutoff:100 resonance:7 lpenv:1.3125 ]",
|
||||
"[ 2/1 → 33/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.3333333333333333 ]",
|
||||
"[ 33/16 → 17/8 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.3541666666666667 ]",
|
||||
"[ 17/8 → 35/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.375 ]",
|
||||
"[ 35/16 → 9/4 | note:A2 s:saw cutoff:100 resonance:7 lpenv:1.3958333333333333 ]",
|
||||
"[ 9/4 → 37/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.4166666666666667 ]",
|
||||
"[ 37/16 → 19/8 | note:B2 s:saw cutoff:100 resonance:7 lpenv:1.4375 ]",
|
||||
"[ 19/8 → 39/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.4583333333333333 ]",
|
||||
"[ 39/16 → 5/2 | note:E3 s:saw cutoff:100 resonance:7 lpenv:1.4791666666666667 ]",
|
||||
"[ 5/2 → 41/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.5 ]",
|
||||
"[ 41/16 → 21/8 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.5208333333333335 ]",
|
||||
"[ 21/8 → 43/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.5416666666666665 ]",
|
||||
"[ 43/16 → 11/4 | note:A2 s:saw cutoff:100 resonance:7 lpenv:1.5625 ]",
|
||||
"[ 11/4 → 45/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.5833333333333335 ]",
|
||||
"[ 45/16 → 23/8 | note:B2 s:saw cutoff:100 resonance:7 lpenv:1.6041666666666665 ]",
|
||||
"[ 23/8 → 47/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.625 ]",
|
||||
"[ 47/16 → 3/1 | note:E3 s:saw cutoff:100 resonance:7 lpenv:1.6458333333333335 ]",
|
||||
"[ 3/1 → 49/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.6666666666666665 ]",
|
||||
"[ 49/16 → 25/8 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.6875 ]",
|
||||
"[ 25/8 → 51/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.7083333333333335 ]",
|
||||
"[ 51/16 → 13/4 | note:A2 s:saw cutoff:100 resonance:7 lpenv:1.7291666666666665 ]",
|
||||
"[ 13/4 → 53/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.75 ]",
|
||||
"[ 53/16 → 27/8 | note:B2 s:saw cutoff:100 resonance:7 lpenv:1.7708333333333335 ]",
|
||||
"[ 27/8 → 55/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.7916666666666665 ]",
|
||||
"[ 55/16 → 7/2 | note:E3 s:saw cutoff:100 resonance:7 lpenv:1.8125 ]",
|
||||
"[ 7/2 → 57/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.8333333333333335 ]",
|
||||
"[ 57/16 → 29/8 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.8541666666666665 ]",
|
||||
"[ 29/8 → 59/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.875 ]",
|
||||
"[ 59/16 → 15/4 | note:A2 s:saw cutoff:100 resonance:7 lpenv:1.8958333333333335 ]",
|
||||
"[ 15/4 → 61/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.9166666666666665 ]",
|
||||
"[ 61/16 → 31/8 | note:B2 s:saw cutoff:100 resonance:7 lpenv:1.9375 ]",
|
||||
"[ 31/8 → 63/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.9583333333333335 ]",
|
||||
"[ 63/16 → 4/1 | note:E3 s:saw cutoff:100 resonance:7 lpenv:1.9791666666666665 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "someCycles" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/8 | s:hh speed:0.5 ]",
|
||||
@@ -14108,106 +14324,76 @@ exports[`runs examples > example "sustain" example index 0 1`] = `
|
||||
|
||||
exports[`runs examples > example "swing" example index 0 1`] = `
|
||||
[
|
||||
"[ -1/12 ⇜ (0/1 → 1/24) | s:hh ]",
|
||||
"[ 0/1 → 1/8 | s:hh ]",
|
||||
"[ 1/24 ⇜ (1/8 → 1/6) | s:hh ]",
|
||||
"[ (1/6 → 1/4) ⇝ 7/24 | s:hh ]",
|
||||
"[ 1/6 → 7/24 | s:hh ]",
|
||||
"[ 1/4 → 3/8 | s:hh ]",
|
||||
"[ 7/24 ⇜ (3/8 → 5/12) | s:hh ]",
|
||||
"[ (5/12 → 1/2) ⇝ 13/24 | s:hh ]",
|
||||
"[ 5/12 → 13/24 | s:hh ]",
|
||||
"[ 1/2 → 5/8 | s:hh ]",
|
||||
"[ 13/24 ⇜ (5/8 → 2/3) | s:hh ]",
|
||||
"[ (2/3 → 3/4) ⇝ 19/24 | s:hh ]",
|
||||
"[ 2/3 → 19/24 | s:hh ]",
|
||||
"[ 3/4 → 7/8 | s:hh ]",
|
||||
"[ 19/24 ⇜ (7/8 → 11/12) | s:hh ]",
|
||||
"[ (11/12 → 1/1) ⇝ 25/24 | s:hh ]",
|
||||
"[ 11/12 → 25/24 | s:hh ]",
|
||||
"[ 1/1 → 9/8 | s:hh ]",
|
||||
"[ 25/24 ⇜ (9/8 → 7/6) | s:hh ]",
|
||||
"[ (7/6 → 5/4) ⇝ 31/24 | s:hh ]",
|
||||
"[ 7/6 → 31/24 | s:hh ]",
|
||||
"[ 5/4 → 11/8 | s:hh ]",
|
||||
"[ 31/24 ⇜ (11/8 → 17/12) | s:hh ]",
|
||||
"[ (17/12 → 3/2) ⇝ 37/24 | s:hh ]",
|
||||
"[ 17/12 → 37/24 | s:hh ]",
|
||||
"[ 3/2 → 13/8 | s:hh ]",
|
||||
"[ 37/24 ⇜ (13/8 → 5/3) | s:hh ]",
|
||||
"[ (5/3 → 7/4) ⇝ 43/24 | s:hh ]",
|
||||
"[ 5/3 → 43/24 | s:hh ]",
|
||||
"[ 7/4 → 15/8 | s:hh ]",
|
||||
"[ 43/24 ⇜ (15/8 → 23/12) | s:hh ]",
|
||||
"[ (23/12 → 2/1) ⇝ 49/24 | s:hh ]",
|
||||
"[ 23/12 → 49/24 | s:hh ]",
|
||||
"[ 2/1 → 17/8 | s:hh ]",
|
||||
"[ 49/24 ⇜ (17/8 → 13/6) | s:hh ]",
|
||||
"[ (13/6 → 9/4) ⇝ 55/24 | s:hh ]",
|
||||
"[ 13/6 → 55/24 | s:hh ]",
|
||||
"[ 9/4 → 19/8 | s:hh ]",
|
||||
"[ 55/24 ⇜ (19/8 → 29/12) | s:hh ]",
|
||||
"[ (29/12 → 5/2) ⇝ 61/24 | s:hh ]",
|
||||
"[ 29/12 → 61/24 | s:hh ]",
|
||||
"[ 5/2 → 21/8 | s:hh ]",
|
||||
"[ 61/24 ⇜ (21/8 → 8/3) | s:hh ]",
|
||||
"[ (8/3 → 11/4) ⇝ 67/24 | s:hh ]",
|
||||
"[ 8/3 → 67/24 | s:hh ]",
|
||||
"[ 11/4 → 23/8 | s:hh ]",
|
||||
"[ 67/24 ⇜ (23/8 → 35/12) | s:hh ]",
|
||||
"[ (35/12 → 3/1) ⇝ 73/24 | s:hh ]",
|
||||
"[ 35/12 → 73/24 | s:hh ]",
|
||||
"[ 3/1 → 25/8 | s:hh ]",
|
||||
"[ 73/24 ⇜ (25/8 → 19/6) | s:hh ]",
|
||||
"[ (19/6 → 13/4) ⇝ 79/24 | s:hh ]",
|
||||
"[ 19/6 → 79/24 | s:hh ]",
|
||||
"[ 13/4 → 27/8 | s:hh ]",
|
||||
"[ 79/24 ⇜ (27/8 → 41/12) | s:hh ]",
|
||||
"[ (41/12 → 7/2) ⇝ 85/24 | s:hh ]",
|
||||
"[ 41/12 → 85/24 | s:hh ]",
|
||||
"[ 7/2 → 29/8 | s:hh ]",
|
||||
"[ 85/24 ⇜ (29/8 → 11/3) | s:hh ]",
|
||||
"[ (11/3 → 15/4) ⇝ 91/24 | s:hh ]",
|
||||
"[ 11/3 → 91/24 | s:hh ]",
|
||||
"[ 15/4 → 31/8 | s:hh ]",
|
||||
"[ 91/24 ⇜ (31/8 → 47/12) | s:hh ]",
|
||||
"[ (47/12 → 4/1) ⇝ 97/24 | s:hh ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "swingBy" example index 0 1`] = `
|
||||
[
|
||||
"[ -1/12 ⇜ (0/1 → 1/24) | s:hh ]",
|
||||
"[ 0/1 → 1/8 | s:hh ]",
|
||||
"[ 1/24 ⇜ (1/8 → 1/6) | s:hh ]",
|
||||
"[ (1/6 → 1/4) ⇝ 7/24 | s:hh ]",
|
||||
"[ 1/6 → 7/24 | s:hh ]",
|
||||
"[ 1/4 → 3/8 | s:hh ]",
|
||||
"[ 7/24 ⇜ (3/8 → 5/12) | s:hh ]",
|
||||
"[ (5/12 → 1/2) ⇝ 13/24 | s:hh ]",
|
||||
"[ 5/12 → 13/24 | s:hh ]",
|
||||
"[ 1/2 → 5/8 | s:hh ]",
|
||||
"[ 13/24 ⇜ (5/8 → 2/3) | s:hh ]",
|
||||
"[ (2/3 → 3/4) ⇝ 19/24 | s:hh ]",
|
||||
"[ 2/3 → 19/24 | s:hh ]",
|
||||
"[ 3/4 → 7/8 | s:hh ]",
|
||||
"[ 19/24 ⇜ (7/8 → 11/12) | s:hh ]",
|
||||
"[ (11/12 → 1/1) ⇝ 25/24 | s:hh ]",
|
||||
"[ 11/12 → 25/24 | s:hh ]",
|
||||
"[ 1/1 → 9/8 | s:hh ]",
|
||||
"[ 25/24 ⇜ (9/8 → 7/6) | s:hh ]",
|
||||
"[ (7/6 → 5/4) ⇝ 31/24 | s:hh ]",
|
||||
"[ 7/6 → 31/24 | s:hh ]",
|
||||
"[ 5/4 → 11/8 | s:hh ]",
|
||||
"[ 31/24 ⇜ (11/8 → 17/12) | s:hh ]",
|
||||
"[ (17/12 → 3/2) ⇝ 37/24 | s:hh ]",
|
||||
"[ 17/12 → 37/24 | s:hh ]",
|
||||
"[ 3/2 → 13/8 | s:hh ]",
|
||||
"[ 37/24 ⇜ (13/8 → 5/3) | s:hh ]",
|
||||
"[ (5/3 → 7/4) ⇝ 43/24 | s:hh ]",
|
||||
"[ 5/3 → 43/24 | s:hh ]",
|
||||
"[ 7/4 → 15/8 | s:hh ]",
|
||||
"[ 43/24 ⇜ (15/8 → 23/12) | s:hh ]",
|
||||
"[ (23/12 → 2/1) ⇝ 49/24 | s:hh ]",
|
||||
"[ 23/12 → 49/24 | s:hh ]",
|
||||
"[ 2/1 → 17/8 | s:hh ]",
|
||||
"[ 49/24 ⇜ (17/8 → 13/6) | s:hh ]",
|
||||
"[ (13/6 → 9/4) ⇝ 55/24 | s:hh ]",
|
||||
"[ 13/6 → 55/24 | s:hh ]",
|
||||
"[ 9/4 → 19/8 | s:hh ]",
|
||||
"[ 55/24 ⇜ (19/8 → 29/12) | s:hh ]",
|
||||
"[ (29/12 → 5/2) ⇝ 61/24 | s:hh ]",
|
||||
"[ 29/12 → 61/24 | s:hh ]",
|
||||
"[ 5/2 → 21/8 | s:hh ]",
|
||||
"[ 61/24 ⇜ (21/8 → 8/3) | s:hh ]",
|
||||
"[ (8/3 → 11/4) ⇝ 67/24 | s:hh ]",
|
||||
"[ 8/3 → 67/24 | s:hh ]",
|
||||
"[ 11/4 → 23/8 | s:hh ]",
|
||||
"[ 67/24 ⇜ (23/8 → 35/12) | s:hh ]",
|
||||
"[ (35/12 → 3/1) ⇝ 73/24 | s:hh ]",
|
||||
"[ 35/12 → 73/24 | s:hh ]",
|
||||
"[ 3/1 → 25/8 | s:hh ]",
|
||||
"[ 73/24 ⇜ (25/8 → 19/6) | s:hh ]",
|
||||
"[ (19/6 → 13/4) ⇝ 79/24 | s:hh ]",
|
||||
"[ 19/6 → 79/24 | s:hh ]",
|
||||
"[ 13/4 → 27/8 | s:hh ]",
|
||||
"[ 79/24 ⇜ (27/8 → 41/12) | s:hh ]",
|
||||
"[ (41/12 → 7/2) ⇝ 85/24 | s:hh ]",
|
||||
"[ 41/12 → 85/24 | s:hh ]",
|
||||
"[ 7/2 → 29/8 | s:hh ]",
|
||||
"[ 85/24 ⇜ (29/8 → 11/3) | s:hh ]",
|
||||
"[ (11/3 → 15/4) ⇝ 91/24 | s:hh ]",
|
||||
"[ 11/3 → 91/24 | s:hh ]",
|
||||
"[ 15/4 → 31/8 | s:hh ]",
|
||||
"[ 91/24 ⇜ (31/8 → 47/12) | s:hh ]",
|
||||
"[ (47/12 → 4/1) ⇝ 97/24 | s:hh ]",
|
||||
]
|
||||
`;
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
"@strudel/websocket": "workspace:*",
|
||||
"@strudel/mondo": "workspace:*",
|
||||
"@strudel/xen": "workspace:*",
|
||||
"@strudel/kabelsalat": "workspace:*",
|
||||
"@supabase/supabase-js": "^2.48.1",
|
||||
"@tailwindcss/forms": "^0.5.10",
|
||||
"@tailwindcss/postcss": "^4.0.0",
|
||||
|
||||
@@ -37,8 +37,11 @@ export function WelcomeTab({ context }) {
|
||||
tidalcycles
|
||||
</a>
|
||||
, which is a popular live coding language for music, written in Haskell. Strudel is free/open source software,
|
||||
with copyright owned by its [contributors](https://codeberg.org/uzu/strudel/activity/contributors). You can
|
||||
redistribute and/or modify it under the terms of the{' '}
|
||||
with copyright owned by its{' '}
|
||||
<a href="https://codeberg.org/uzu/strudel/activity/contributors" target="_blank">
|
||||
contributors
|
||||
</a>
|
||||
. You can redistribute and/or modify it under the terms of the{' '}
|
||||
<a href="https://codeberg.org/uzu/strudel/src/branch/main/LICENSE" target="_blank">
|
||||
GNU Affero General Public License
|
||||
</a>
|
||||
|
||||
@@ -89,6 +89,7 @@ export function loadModules() {
|
||||
import('@strudel/mqtt'),
|
||||
import('@strudel/mondo'),
|
||||
import('@strudel/dough'),
|
||||
import('@strudel/kabelsalat'),
|
||||
];
|
||||
if (isTauri()) {
|
||||
modules = modules.concat([
|
||||
|
||||
Reference in New Issue
Block a user