move supradough to separate package
This commit is contained in:
parent
ccc90d547c
commit
43c05cb504
15 changed files with 102 additions and 33 deletions
|
|
@ -42,7 +42,7 @@ export default [
|
||||||
'**/hydra.mjs',
|
'**/hydra.mjs',
|
||||||
'**/jsdoc-synonyms.js',
|
'**/jsdoc-synonyms.js',
|
||||||
'packages/hs2js/src/hs2js.mjs',
|
'packages/hs2js/src/hs2js.mjs',
|
||||||
'packages/superdough/dough-export.mjs',
|
'packages/supradough/dough-export.mjs',
|
||||||
'**/samples',
|
'**/samples',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,7 @@
|
||||||
"homepage": "https://github.com/tidalcycles/strudel#readme",
|
"homepage": "https://github.com/tidalcycles/strudel#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite": "^6.0.11",
|
"vite": "^6.0.11",
|
||||||
"vite-plugin-bundle-audioworklet": "workspace:*",
|
"vite-plugin-bundle-audioworklet": "workspace:*"
|
||||||
"wav-encoder": "^1.3.0"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"nanostores": "^0.11.3"
|
"nanostores": "^0.11.3"
|
||||||
|
|
|
||||||
|
|
@ -190,11 +190,18 @@ export function getAudioContextCurrentTime() {
|
||||||
return getAudioContext().currentTime;
|
return getAudioContext().currentTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let externalWorklets = [];
|
||||||
|
export function registerWorklet(url) {
|
||||||
|
externalWorklets.push(url);
|
||||||
|
}
|
||||||
|
|
||||||
let workletsLoading;
|
let workletsLoading;
|
||||||
function loadWorklets() {
|
function loadWorklets() {
|
||||||
if (!workletsLoading) {
|
if (!workletsLoading) {
|
||||||
const audioCtx = getAudioContext();
|
const audioCtx = getAudioContext();
|
||||||
workletsLoading = audioCtx.audioWorklet.addModule(workletsUrl);
|
const allWorkletURLs = externalWorklets.concat([workletsUrl]);
|
||||||
|
console.log('allWorkletURLs', allWorkletURLs);
|
||||||
|
workletsLoading = Promise.all(allWorkletURLs.map((workletURL) => audioCtx.audioWorklet.addModule(workletURL)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return workletsLoading;
|
return workletsLoading;
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import {
|
||||||
} from './helpers.mjs';
|
} from './helpers.mjs';
|
||||||
import { getNoiseMix, getNoiseOscillator } from './noise.mjs';
|
import { getNoiseMix, getNoiseOscillator } from './noise.mjs';
|
||||||
|
|
||||||
export const getFrequencyFromValue = (value) => {
|
const getFrequencyFromValue = (value) => {
|
||||||
let { note, freq } = value;
|
let { note, freq } = value;
|
||||||
note = note || 36;
|
note = note || 36;
|
||||||
if (typeof note === 'string') {
|
if (typeof note === 'string') {
|
||||||
|
|
@ -25,7 +25,7 @@ export const getFrequencyFromValue = (value) => {
|
||||||
|
|
||||||
return Number(freq);
|
return Number(freq);
|
||||||
};
|
};
|
||||||
export function destroyAudioWorkletNode(node) {
|
function destroyAudioWorkletNode(node) {
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
import OLAProcessor from './ola-processor';
|
import OLAProcessor from './ola-processor';
|
||||||
import FFT from './fft.js';
|
import FFT from './fft.js';
|
||||||
import { Dough } from './dough.mjs';
|
|
||||||
|
|
||||||
const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
|
const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
|
||||||
const _mod = (n, m) => ((n % m) + m) % m;
|
const _mod = (n, m) => ((n % m) + m) % m;
|
||||||
|
|
@ -896,27 +895,3 @@ class ByteBeatProcessor extends AudioWorkletProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
registerProcessor('byte-beat-processor', ByteBeatProcessor);
|
registerProcessor('byte-beat-processor', ByteBeatProcessor);
|
||||||
|
|
||||||
class DoughProcessor extends AudioWorkletProcessor {
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
this.dough = new Dough(sampleRate, currentTime);
|
|
||||||
this.port.onmessage = (event) => this.dough.scheduleSpawn(event.data);
|
|
||||||
}
|
|
||||||
process(inputs, outputs, params) {
|
|
||||||
if (this.disconnected) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const output = outputs[0];
|
|
||||||
for (let i = 0; i < output[0].length; i++) {
|
|
||||||
this.dough.update();
|
|
||||||
for (let c = 0; c < output.length; c++) {
|
|
||||||
//prevent speaker blowout via clipping if threshold exceeds
|
|
||||||
output[c][i] = clamp(this.dough.channels[c], -1, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true; // keep the audio processing going
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
registerProcessor('dough-processor', DoughProcessor);
|
|
||||||
|
|
|
||||||
3
packages/supradough/README.md
Normal file
3
packages/supradough/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# supradough
|
||||||
|
|
||||||
|
platform agnostic synth and sampler intended for live coding. a reimplementation of superdough.
|
||||||
27
packages/supradough/dough-worklet.mjs
Normal file
27
packages/supradough/dough-worklet.mjs
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
import { Dough } from './dough.mjs';
|
||||||
|
|
||||||
|
const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
|
||||||
|
|
||||||
|
class DoughProcessor extends AudioWorkletProcessor {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.dough = new Dough(sampleRate, currentTime);
|
||||||
|
this.port.onmessage = (event) => this.dough.scheduleSpawn(event.data);
|
||||||
|
}
|
||||||
|
process(inputs, outputs, params) {
|
||||||
|
if (this.disconnected) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const output = outputs[0];
|
||||||
|
for (let i = 0; i < output[0].length; i++) {
|
||||||
|
this.dough.update();
|
||||||
|
for (let c = 0; c < output.length; c++) {
|
||||||
|
//prevent speaker blowout via clipping if threshold exceeds
|
||||||
|
output[c][i] = clamp(this.dough.channels[c], -1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true; // keep the audio processing going
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
registerProcessor('dough-processor', DoughProcessor);
|
||||||
4
packages/supradough/index.mjs
Normal file
4
packages/supradough/index.mjs
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
import _workletUrl from './dough-worklet.mjs?audioworklet';
|
||||||
|
|
||||||
|
export * from './dough.mjs';
|
||||||
|
export const workletUrl = _workletUrl;
|
||||||
37
packages/supradough/package.json
Normal file
37
packages/supradough/package.json
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
{
|
||||||
|
"name": "supradough",
|
||||||
|
"version": "1.2.3",
|
||||||
|
"description": "platform agnostic synth and sampler intended for live coding. a reimplementation of superdough.",
|
||||||
|
"main": "index.mjs",
|
||||||
|
"type": "module",
|
||||||
|
"publishConfig": {
|
||||||
|
"main": "dist/index.mjs"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "vite build",
|
||||||
|
"prepublishOnly": "npm run build"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/tidalcycles/strudel.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"tidalcycles",
|
||||||
|
"strudel",
|
||||||
|
"pattern",
|
||||||
|
"livecoding",
|
||||||
|
"algorave"
|
||||||
|
],
|
||||||
|
"author": "Felix Roos <flix91@gmail.com>",
|
||||||
|
"license": "AGPL-3.0-or-later",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/tidalcycles/strudel/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/tidalcycles/strudel#readme",
|
||||||
|
"devDependencies": {
|
||||||
|
"vite": "^6.0.11",
|
||||||
|
"vite-plugin-bundle-audioworklet": "workspace:*",
|
||||||
|
"wav-encoder": "^1.3.0"
|
||||||
|
},
|
||||||
|
"dependencies": {}
|
||||||
|
}
|
||||||
|
|
@ -35,7 +35,8 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@strudel/core": "workspace:*",
|
"@strudel/core": "workspace:*",
|
||||||
"@strudel/draw": "workspace:*",
|
"@strudel/draw": "workspace:*",
|
||||||
"superdough": "workspace:*"
|
"superdough": "workspace:*",
|
||||||
|
"supradough": "workspace:*"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite": "^6.0.11"
|
"vite": "^6.0.11"
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,12 @@ This program is free software: you can redistribute it and/or modify it under th
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as strudel from '@strudel/core';
|
import * as strudel from '@strudel/core';
|
||||||
import { superdough, getAudioContext, setLogger, doughTrigger } from 'superdough';
|
import { superdough, getAudioContext, setLogger, doughTrigger, registerWorklet } from 'superdough';
|
||||||
import './supradough.mjs';
|
import './supradough.mjs';
|
||||||
|
import { workletUrl } from 'supradough';
|
||||||
|
|
||||||
|
registerWorklet(workletUrl);
|
||||||
|
|
||||||
const { Pattern, logger, repl } = strudel;
|
const { Pattern, logger, repl } = strudel;
|
||||||
|
|
||||||
setLogger(logger);
|
setLogger(logger);
|
||||||
|
|
|
||||||
12
pnpm-lock.yaml
generated
12
pnpm-lock.yaml
generated
|
|
@ -485,6 +485,15 @@ importers:
|
||||||
vite-plugin-bundle-audioworklet:
|
vite-plugin-bundle-audioworklet:
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../vite-plugin-bundle-audioworklet
|
version: link:../vite-plugin-bundle-audioworklet
|
||||||
|
|
||||||
|
packages/supradough:
|
||||||
|
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
|
||||||
wav-encoder:
|
wav-encoder:
|
||||||
specifier: ^1.3.0
|
specifier: ^1.3.0
|
||||||
version: 1.3.0
|
version: 1.3.0
|
||||||
|
|
@ -597,6 +606,9 @@ importers:
|
||||||
superdough:
|
superdough:
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../superdough
|
version: link:../superdough
|
||||||
|
supradough:
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../supradough
|
||||||
devDependencies:
|
devDependencies:
|
||||||
vite:
|
vite:
|
||||||
specifier: ^6.0.11
|
specifier: ^6.0.11
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue