mirror of
https://codeberg.org/uzu/strudel
synced 2026-07-23 21:47:16 -04:00
Compare commits
59 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 301fb5e59a | |||
| 9ac691c19e | |||
| 6e7512016c | |||
| 3bbd808783 | |||
| 7b245abd1a | |||
| 9e5c9c7539 | |||
| d14194db6a | |||
| 0960741156 | |||
| bbb977afcc | |||
| 81a4981a68 | |||
| 90d82c8988 | |||
| 15f7b7c1a2 | |||
| b6e382508f | |||
| 3e7ae88043 | |||
| 897a2016d0 | |||
| 7a1c1a75b1 | |||
| 7f06f11e96 | |||
| 5acb00795e | |||
| f4b68fa2e6 | |||
| 1b37f1ed1d | |||
| f8943dbc94 | |||
| a3f82f90a9 | |||
| 670f75b7e8 | |||
| 79875ebc50 | |||
| a1bd905c06 | |||
| 247bf9b930 | |||
| 8f24ce223f | |||
| 51648d3e6e | |||
| d4e67e1c20 | |||
| edf4739cc6 | |||
| 3e636bd6f0 | |||
| 4df2cc3086 | |||
| 809eb7132c | |||
| dd6429007e | |||
| e211d5a6bb | |||
| 404d9999f3 | |||
| bc1c83ed64 | |||
| 91e1cc136e | |||
| 92e3a80e65 | |||
| a036c4f921 | |||
| c0e7971be7 | |||
| b491c42af5 | |||
| ee43d85f29 | |||
| fcd83cce55 | |||
| fddf2ff2a7 | |||
| 6d4787ee33 | |||
| 1a362bd8ea | |||
| 20bbda30f8 | |||
| a8c613b7eb | |||
| fd0a910bfb | |||
| ac7e9c6978 | |||
| c13a726129 | |||
| 99b3c04a76 | |||
| 57fac57677 | |||
| a3b803c3f3 | |||
| 4d39f36868 | |||
| c64aa3bf01 | |||
| a0c2edad30 | |||
| 82c9047195 |
@@ -13,7 +13,7 @@ https://strudel.cc/
|
|||||||
|
|
||||||
After cloning the project, you can run the REPL locally:
|
After cloning the project, you can run the REPL locally:
|
||||||
|
|
||||||
1. Install [Node.js](https://nodejs.org/)
|
1. Install [Node.js](https://nodejs.org/) 18 or newer
|
||||||
2. Install [pnpm](https://pnpm.io/installation)
|
2. Install [pnpm](https://pnpm.io/installation)
|
||||||
3. Install dependencies by running the following command:
|
3. Install dependencies by running the following command:
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<script src="https://unpkg.com/@strudel/web@1.0.3"></script>
|
<script src="https://unpkg.com/@strudel/web@1.2.6"></script>
|
||||||
<button id="play">PLAY</button>
|
<button id="play">PLAY</button>
|
||||||
<script>
|
<script>
|
||||||
initStrudel({
|
initStrudel({
|
||||||
|
|||||||
@@ -12,13 +12,16 @@
|
|||||||
"vite": "^6.0.11"
|
"vite": "^6.0.11"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@strudel/codemirror": "workspace:*",
|
"@strudel/codemirror": "1.2.6",
|
||||||
"@strudel/core": "workspace:*",
|
"@strudel/core": "1.2.5",
|
||||||
"@strudel/draw": "workspace:*",
|
"@strudel/draw": "1.2.5",
|
||||||
"@strudel/mini": "workspace:*",
|
"@strudel/mini": "1.2.5",
|
||||||
"@strudel/soundfonts": "workspace:*",
|
"@strudel/soundfonts": "1.2.6",
|
||||||
"@strudel/tonal": "workspace:*",
|
"@strudel/tonal": "1.2.5",
|
||||||
"@strudel/transpiler": "workspace:*",
|
"@strudel/transpiler": "1.2.5",
|
||||||
"@strudel/webaudio": "workspace:*"
|
"@strudel/webaudio": "1.2.6"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
export const bumpStreet = `// froos - "22 bump street", licensed with CC BY-NC-SA 4.0
|
export const bumpStreet = `// froos - "22 bump street", licensed with CC BY-NC-SA 4.0
|
||||||
samples('github:felixroos/samples')
|
samples('github:felixroos/samples')
|
||||||
samples('https://strudel.cc/tidal-drum-machines.json', 'github:ritchse/tidal-drum-machines/main/machines/')
|
samples('https://strudel.b-cdn.net/tidal-drum-machines.json', 'github:ritchse/tidal-drum-machines/main/machines/')
|
||||||
|
|
||||||
"<[0,<6 7 9>,13,<17 20 22 26>]!2>/2"
|
"<[0,<6 7 9>,13,<17 20 22 26>]!2>/2"
|
||||||
// make it 22 edo
|
// make it 22 edo
|
||||||
@@ -28,13 +28,12 @@ samples('https://strudel.cc/tidal-drum-machines.json', 'github:ritchse/tidal-dru
|
|||||||
.mask("<0@4 1@12>/4")
|
.mask("<0@4 1@12>/4")
|
||||||
.reset("<x@15 [x(3,8) x*[4 8]]>")
|
.reset("<x@15 [x(3,8) x*[4 8]]>")
|
||||||
// wait for it...
|
// wait for it...
|
||||||
).fast(2/3)
|
).fast(4/3)
|
||||||
//.crush(6) // remove "//" if you dare`;
|
//.crush(6) // remove "//" if you dare`;
|
||||||
|
|
||||||
export const trafficFlam = `// froos - "traffic flam", licensed with CC BY-NC-SA 4.0
|
export const trafficFlam = `// froos - "traffic flam", licensed with CC BY-NC-SA 4.0
|
||||||
|
|
||||||
samples('github:felixroos/samples')
|
samples('https://strudel.b-cdn.net/tidal-drum-machines.json', 'github:ritchse/tidal-drum-machines/main/machines/')
|
||||||
samples('https://strudel.cc/tidal-drum-machines.json', 'github:ritchse/tidal-drum-machines/main/machines/')
|
|
||||||
|
|
||||||
addVoicings('hip', {
|
addVoicings('hip', {
|
||||||
m11: ['2M 3m 4P 7m'],
|
m11: ['2M 3m 4P 7m'],
|
||||||
@@ -61,16 +60,14 @@ stack(
|
|||||||
s("rim*4").end(.05).bank('RolandTR808').speed(.8).room(.2)
|
s("rim*4").end(.05).bank('RolandTR808').speed(.8).room(.2)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.late("[0 .05]*2").late(12)
|
.late("[0 .05]*2").late(12).fast(2)
|
||||||
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const funk42 = `// froos - how to funk in 42 lines of code
|
export const funk42 = `// froos - how to funk in 42 lines of code
|
||||||
// adapted from "how to funk in two minutes" by marc rebillet https://www.youtube.com/watch?v=3vBwRfQbXkg
|
// adapted from "how to funk in two minutes" by marc rebillet https://www.youtube.com/watch?v=3vBwRfQbXkg
|
||||||
// thanks to peach for the transcription: https://www.youtube.com/watch?v=8eiPXvIgda4
|
// thanks to peach for the transcription: https://www.youtube.com/watch?v=8eiPXvIgda4
|
||||||
|
|
||||||
samples('github:felixroos/samples')
|
samples('https://strudel.b-cdn.net/tidal-drum-machines.json', 'github:ritchse/tidal-drum-machines/main/machines/')
|
||||||
samples('https://strudel.cc/tidal-drum-machines.json', 'github:ritchse/tidal-drum-machines/main/machines/')
|
|
||||||
|
|
||||||
setcps(.5)
|
setcps(.5)
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<button id="c">C</button>
|
<button id="c">C</button>
|
||||||
<button id="stop">stop</button>
|
<button id="stop">stop</button>
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import { initStrudel } from '@strudel/web';
|
import { initStrudel, hush } from '@strudel/web';
|
||||||
initStrudel({
|
initStrudel({
|
||||||
prebake: () => samples('github:tidalcycles/dirt-samples'),
|
prebake: () => samples('github:tidalcycles/dirt-samples'),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,6 +13,9 @@
|
|||||||
"vite": "^6.0.11"
|
"vite": "^6.0.11"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@strudel/web": "workspace:*"
|
"@strudel/web": "1.2.6"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,5 +18,8 @@
|
|||||||
"@strudel/transpiler": "workspace:*",
|
"@strudel/transpiler": "workspace:*",
|
||||||
"@strudel/webaudio": "workspace:*",
|
"@strudel/webaudio": "workspace:*",
|
||||||
"@strudel/tonal": "workspace:*"
|
"@strudel/tonal": "workspace:*"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,5 +13,8 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite": "^6.0.11"
|
"vite": "^6.0.11"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,5 +32,8 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite": "^6.0.11"
|
"vite": "^6.0.11"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,5 +73,8 @@
|
|||||||
"prettier": "^3.4.2",
|
"prettier": "^3.4.2",
|
||||||
"vitest": "^3.0.4",
|
"vitest": "^3.0.4",
|
||||||
"vite-plugin-bundle-audioworklet": "workspace:*"
|
"vite-plugin-bundle-audioworklet": "workspace:*"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,5 +54,8 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite": "^6.0.11"
|
"vite": "^6.0.11"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+198
-6
@@ -1288,6 +1288,151 @@ export const { fanchor } = registerControl('fanchor');
|
|||||||
*/
|
*/
|
||||||
// currently an alias of 'hcutoff' https://codeberg.org/uzu/strudel/issues/496
|
// currently an alias of 'hcutoff' https://codeberg.org/uzu/strudel/issues/496
|
||||||
// ['hpf'],
|
// ['hpf'],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rate of the LFO for the lowpass filter
|
||||||
|
*
|
||||||
|
* @name lprate
|
||||||
|
* @param {number | Pattern} rate rate in hertz
|
||||||
|
*/
|
||||||
|
export const { lprate } = registerControl('lprate');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cycle-synced rate of the LFO for the lowpass filter
|
||||||
|
*
|
||||||
|
* @name lpsync
|
||||||
|
* @param {number | Pattern} rate rate in cycles
|
||||||
|
*/
|
||||||
|
export const { lpsync } = registerControl('lpsync');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Depth of the LFO for the lowpass filter
|
||||||
|
*
|
||||||
|
* @name lpdepth
|
||||||
|
* @param {number | Pattern} depth depth of modulation
|
||||||
|
*/
|
||||||
|
export const { lpdepth } = registerControl('lpdepth');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shape of the LFO for the lowpass filter
|
||||||
|
*
|
||||||
|
* @name lpshape
|
||||||
|
* @param {number | Pattern} shape Shape of the lfo (0, 1, 2, ..)
|
||||||
|
*/
|
||||||
|
export const { lpshape } = registerControl('lpshape');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DC offset of the LFO for the lowpass filter
|
||||||
|
*
|
||||||
|
* @name lpdc
|
||||||
|
* @param {number | Pattern} dcoffset dc offset. set to 0 for unipolar
|
||||||
|
*/
|
||||||
|
export const { lpdc } = registerControl('lpdc');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skew of the LFO for the lowpass filter
|
||||||
|
*
|
||||||
|
* @name lpskew
|
||||||
|
* @param {number | Pattern} skew How much to bend the LFO shape
|
||||||
|
*/
|
||||||
|
export const { lpskew } = registerControl('lpskew');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rate of the LFO for the bandpass filter
|
||||||
|
*
|
||||||
|
* @name bprate
|
||||||
|
* @param {number | Pattern} rate rate in hertz
|
||||||
|
*/
|
||||||
|
export const { bprate } = registerControl('bprate');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cycle-synced rate of the LFO for the bandpass filter
|
||||||
|
*
|
||||||
|
* @name bpsync
|
||||||
|
* @param {number | Pattern} rate rate in cycles
|
||||||
|
*/
|
||||||
|
export const { bpsync } = registerControl('bpsync');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Depth of the LFO for the bandpass filter
|
||||||
|
*
|
||||||
|
* @name bpdepth
|
||||||
|
* @param {number | Pattern} depth depth of modulation
|
||||||
|
*/
|
||||||
|
export const { bpdepth } = registerControl('bpdepth');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shape of the LFO for the bandpass filter
|
||||||
|
*
|
||||||
|
* @name bpshape
|
||||||
|
* @param {number | Pattern} shape Shape of the lfo (0, 1, 2, ..)
|
||||||
|
*/
|
||||||
|
export const { bpshape } = registerControl('bpshape');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DC offset of the LFO for the bandpass filter
|
||||||
|
*
|
||||||
|
* @name bpdc
|
||||||
|
* @param {number | Pattern} dcoffset dc offset. set to 0 for unipolar
|
||||||
|
*/
|
||||||
|
export const { bpdc } = registerControl('bpdc');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skew of the LFO for the bandpass filter
|
||||||
|
*
|
||||||
|
* @name bpskew
|
||||||
|
* @param {number | Pattern} skew How much to bend the LFO shape
|
||||||
|
*/
|
||||||
|
export const { bpskew } = registerControl('bpskew');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rate of the LFO for the highpass filter
|
||||||
|
*
|
||||||
|
* @name hprate
|
||||||
|
* @param {number | Pattern} rate rate in hertz
|
||||||
|
*/
|
||||||
|
export const { hprate } = registerControl('hprate');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cycle-synced rate of the LFO for the highpass filter
|
||||||
|
*
|
||||||
|
* @name hpsync
|
||||||
|
* @param {number | Pattern} rate rate in cycles
|
||||||
|
*/
|
||||||
|
export const { hpsync } = registerControl('hpsync');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Depth of the LFO for the highpass filter
|
||||||
|
*
|
||||||
|
* @name hpdepth
|
||||||
|
* @param {number | Pattern} depth depth of modulation
|
||||||
|
*/
|
||||||
|
export const { hpdepth } = registerControl('hpdepth');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shape of the LFO for the highpass filter
|
||||||
|
*
|
||||||
|
* @name hpshape
|
||||||
|
* @param {number | Pattern} shape Shape of the lfo (0, 1, 2, ..)
|
||||||
|
*/
|
||||||
|
export const { hpshape } = registerControl('hpshape');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DC offset of the LFO for the highpass filter
|
||||||
|
*
|
||||||
|
* @name hpdc
|
||||||
|
* @param {number | Pattern} dcoffset dc offset. set to 0 for unipolar
|
||||||
|
*/
|
||||||
|
export const { hpdc } = registerControl('hpdc');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skew of the LFO for the highpass filter
|
||||||
|
*
|
||||||
|
* @name hpskew
|
||||||
|
* @param {number | Pattern} skew How much to bend the LFO shape
|
||||||
|
*/
|
||||||
|
export const { hpskew } = registerControl('hpskew');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies a vibrato to the frequency of the oscillator.
|
* Applies a vibrato to the frequency of the oscillator.
|
||||||
*
|
*
|
||||||
@@ -1750,17 +1895,64 @@ export const { semitone } = registerControl('semitone');
|
|||||||
// TODO: synth param
|
// TODO: synth param
|
||||||
export const { voice } = registerControl('voice');
|
export const { voice } = registerControl('voice');
|
||||||
// voicings // https://codeberg.org/uzu/strudel/issues/506
|
// voicings // https://codeberg.org/uzu/strudel/issues/506
|
||||||
// chord to voice, like C Eb Fm7 G7. the symbols can be defined via addVoicings
|
/**
|
||||||
|
* The chord to voice
|
||||||
|
* @name chord
|
||||||
|
* @param {string | Pattern} symbols chord symbols to voice e.g., C, Eb, Fm7, G7. The symbols can be defined via addVoicings
|
||||||
|
* @example
|
||||||
|
* chord("<Am C D F Am E Am E>").voicing()
|
||||||
|
**/
|
||||||
export const { chord } = registerControl('chord');
|
export const { chord } = registerControl('chord');
|
||||||
// which dictionary to use for the voicings
|
/**
|
||||||
|
* Which dictionary to use for the voicings. This falls back to the default dictionary if not provided
|
||||||
|
*
|
||||||
|
* @name dictionary
|
||||||
|
* @param {string} dictionaryName which dictionary (having been defined with `addVoicings`) to use
|
||||||
|
* @example
|
||||||
|
* addVoicings('house', {
|
||||||
|
'': ['7 12 16', '0 7 16', '4 7 12'],
|
||||||
|
'm': ['0 3 7']
|
||||||
|
})
|
||||||
|
chord("<Am C D F Am E Am E>")
|
||||||
|
.dict('house').anchor(66)
|
||||||
|
.voicing().room(.5)
|
||||||
|
**/
|
||||||
export const { dictionary, dict } = registerControl('dictionary', 'dict');
|
export const { dictionary, dict } = registerControl('dictionary', 'dict');
|
||||||
// the top note to align the voicing to, defaults to c5
|
/** The top note to align the voicing to. Defaults to c5
|
||||||
|
*
|
||||||
|
* @name anchor
|
||||||
|
* @param {string | Pattern} anchorNote the note to align the voicings to
|
||||||
|
* @example
|
||||||
|
* anchor("<c4 g4 c5 g5>").chord("C").voicing()
|
||||||
|
**/
|
||||||
export const { anchor } = registerControl('anchor');
|
export const { anchor } = registerControl('anchor');
|
||||||
// how the voicing is offset from the anchored position
|
/**
|
||||||
|
* Sets how the voicing is offset from the anchored position
|
||||||
|
*
|
||||||
|
* @name offset
|
||||||
|
* @param {number | Pattern} shift the amount to shift the voicing up or down
|
||||||
|
* @example
|
||||||
|
* chord("<Am C D F Am E Am E>").offset("<0 1 2 3 4 5>") // alter the voicing each time
|
||||||
|
**/
|
||||||
export const { offset } = registerControl('offset');
|
export const { offset } = registerControl('offset');
|
||||||
// how many octaves are voicing steps spread apart, defaults to 1
|
/**
|
||||||
|
* How many octaves are voicing steps spread apart, defaults to 1
|
||||||
|
*
|
||||||
|
* @name octaves
|
||||||
|
* @param {number | Pattern} count the number of octaves
|
||||||
|
* @example
|
||||||
|
* chord("<Am C D F Am E Am E>").octaves("<2 4>").voicing()
|
||||||
|
**/
|
||||||
export const { octaves } = registerControl('octaves');
|
export const { octaves } = registerControl('octaves');
|
||||||
// below = anchor note will be removed from the voicing, useful for melody harmonization
|
/**
|
||||||
|
* Remove anchor note from the voicing. Useful for melody harmonization
|
||||||
|
*
|
||||||
|
* @name mode
|
||||||
|
* @param {string | Pattern} modeName one of {below | above | duck | root}
|
||||||
|
* @example
|
||||||
|
* mode("<below above duck root>").chord("C").voicing()
|
||||||
|
*
|
||||||
|
**/
|
||||||
export const { mode } = registerControl(['mode', 'anchor']);
|
export const { mode } = registerControl(['mode', 'anchor']);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -37,5 +37,8 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite": "^6.0.11",
|
"vite": "^6.0.11",
|
||||||
"vitest": "^3.0.4"
|
"vitest": "^3.0.4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,5 +38,8 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite": "^6.0.11"
|
"vite": "^6.0.11"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,5 +25,8 @@
|
|||||||
"@strudel/core": "workspace:*",
|
"@strudel/core": "workspace:*",
|
||||||
"@tauri-apps/api": "^2.2.0"
|
"@tauri-apps/api": "^2.2.0"
|
||||||
},
|
},
|
||||||
"homepage": "https://codeberg.org/uzu/strudel#readme"
|
"homepage": "https://codeberg.org/uzu/strudel#readme",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
# @strudel/canvas
|
# @strudel/draw
|
||||||
|
|
||||||
Helpers for drawing with the Canvas API and Strudel
|
Helpers for drawing with the Canvas API and Strudel
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm i @strudel/canvas --save
|
npm i @strudel/draw --save
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -33,5 +33,8 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite": "^6.0.11"
|
"vite": "^6.0.11"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,5 +20,8 @@
|
|||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://codeberg.org/uzu/strudel/issues"
|
"url": "https://codeberg.org/uzu/strudel/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://codeberg.org/uzu/strudel#readme"
|
"homepage": "https://codeberg.org/uzu/strudel#readme",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,12 @@ const pattern = sequence([
|
|||||||
- D-Pad
|
- D-Pad
|
||||||
- `up`, `down`, `left`, `right` (or `u`, `d`, `l`, `r` or uppercase)
|
- `up`, `down`, `left`, `right` (or `u`, `d`, `l`, `r` or uppercase)
|
||||||
- Toggle versions: `tglUp`, `tglDown`, `tglLeft`, `tglRight`(or `tglU`, `tglD`, `tglL`, `tglR`)
|
- Toggle versions: `tglUp`, `tglDown`, `tglLeft`, `tglRight`(or `tglU`, `tglD`, `tglL`, `tglR`)
|
||||||
|
- Stick Buttons
|
||||||
|
- `l3`, `r3` (or `ls`, `rs`)
|
||||||
|
- Toggle versions: `tglL3`, `tglR3` (or `tglLS`, `tglRS`)
|
||||||
|
- System Buttons
|
||||||
|
- `start`, `back` (or uppercase `START`, `BACK`)
|
||||||
|
- Toggle versions: `tglStart`, `tglBack` (or `tglSTART`, `tglBACK`)
|
||||||
|
|
||||||
### Analog Sticks
|
### Analog Sticks
|
||||||
- Left Stick
|
- Left Stick
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ The gamepad module provides access to buttons and analog sticks as normalized si
|
|||||||
| | Toggle versions: `tglLB`, `tglRB`, `tglLT`, `tglRT` |
|
| | Toggle versions: `tglLB`, `tglRB`, `tglLT`, `tglRT` |
|
||||||
| D-Pad | `up`, `down`, `left`, `right` (or `u`, `d`, `l`, `r` or uppercase) |
|
| D-Pad | `up`, `down`, `left`, `right` (or `u`, `d`, `l`, `r` or uppercase) |
|
||||||
| | Toggle versions: `tglUp`, `tglDown`, `tglLeft`, `tglRight` (or `tglU`, `tglD`, `tglL`, `tglR`) |
|
| | Toggle versions: `tglUp`, `tglDown`, `tglLeft`, `tglRight` (or `tglU`, `tglD`, `tglL`, `tglR`) |
|
||||||
|
| Stick Buttons | `l3`, 'r3' (or `ls`, `rs`) |
|
||||||
|
| | Toggle versions: `tglL3`, 'tglR3' (or `tglLs`, `tglRs`) |
|
||||||
|
| System Buttons | `start`, `back` (or uppercase `START`, `BACK`) |
|
||||||
|
| | Toggle versions: `tglStart`, `tglBack` (or `tglSTART`, `tglBACK`) |
|
||||||
|
|
||||||
### Analog Sticks
|
### Analog Sticks
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ export const buttonMap = {
|
|||||||
rt: 7,
|
rt: 7,
|
||||||
back: 8,
|
back: 8,
|
||||||
start: 9,
|
start: 9,
|
||||||
|
l3: 10,
|
||||||
|
ls: 10,
|
||||||
|
r3: 11,
|
||||||
|
rs: 11,
|
||||||
u: 12,
|
u: 12,
|
||||||
up: 12,
|
up: 12,
|
||||||
d: 13,
|
d: 13,
|
||||||
|
|||||||
@@ -33,5 +33,8 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite": "^6.0.11"
|
"vite": "^6.0.11"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,5 +34,8 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"tree-sitter-haskell": "^0.23.1",
|
"tree-sitter-haskell": "^0.23.1",
|
||||||
"vite": "^6.0.11"
|
"vite": "^6.0.11"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,5 +40,8 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"pkg": "^5.8.1",
|
"pkg": "^5.8.1",
|
||||||
"vite": "^6.0.11"
|
"vite": "^6.0.11"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+59
-42
@@ -5,9 +5,10 @@ This program is free software: you can redistribute it and/or modify it under th
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import * as _WebMidi from 'webmidi';
|
import * as _WebMidi from 'webmidi';
|
||||||
import { Pattern, getEventOffsetMs, isPattern, logger, ref } from '@strudel/core';
|
import { Pattern, isPattern, logger, ref } from '@strudel/core';
|
||||||
import { noteToMidi, getControlName } from '@strudel/core';
|
import { noteToMidi, getControlName } from '@strudel/core';
|
||||||
import { Note } from 'webmidi';
|
import { Note } from 'webmidi';
|
||||||
|
import { scheduleAtTime } from '../superdough/helpers.mjs';
|
||||||
|
|
||||||
// if you use WebMidi from outside of this package, make sure to import that instance:
|
// if you use WebMidi from outside of this package, make sure to import that instance:
|
||||||
export const { WebMidi } = _WebMidi;
|
export const { WebMidi } = _WebMidi;
|
||||||
@@ -190,7 +191,7 @@ function mapCC(mapping, value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sends a cc message to the given device on the given channel
|
// sends a cc message to the given device on the given channel
|
||||||
function sendCC(ccn, ccv, device, midichan, timeOffsetString) {
|
function sendCC(ccn, ccv, device, midichan, targetTime) {
|
||||||
if (typeof ccv !== 'number' || ccv < 0 || ccv > 1) {
|
if (typeof ccv !== 'number' || ccv < 0 || ccv > 1) {
|
||||||
throw new Error('expected ccv to be a number between 0 and 1');
|
throw new Error('expected ccv to be a number between 0 and 1');
|
||||||
}
|
}
|
||||||
@@ -198,19 +199,23 @@ function sendCC(ccn, ccv, device, midichan, timeOffsetString) {
|
|||||||
throw new Error('expected ccn to be a number or a string');
|
throw new Error('expected ccn to be a number or a string');
|
||||||
}
|
}
|
||||||
const scaled = Math.round(ccv * 127);
|
const scaled = Math.round(ccv * 127);
|
||||||
device.sendControlChange(ccn, scaled, midichan, { time: timeOffsetString });
|
scheduleAtTime(() => {
|
||||||
|
device.sendControlChange(ccn, scaled, midichan);
|
||||||
|
}, targetTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// sends a program change message to the given device on the given channel
|
// sends a program change message to the given device on the given channel
|
||||||
function sendProgramChange(progNum, device, midichan, timeOffsetString) {
|
function sendProgramChange(progNum, device, midichan, targetTime) {
|
||||||
if (typeof progNum !== 'number' || progNum < 0 || progNum > 127) {
|
if (typeof progNum !== 'number' || progNum < 0 || progNum > 127) {
|
||||||
throw new Error('expected progNum (program change) to be a number between 0 and 127');
|
throw new Error('expected progNum (program change) to be a number between 0 and 127');
|
||||||
}
|
}
|
||||||
device.sendProgramChange(progNum, midichan, { time: timeOffsetString });
|
scheduleAtTime(() => {
|
||||||
|
device.sendProgramChange(progNum, midichan);
|
||||||
|
}, targetTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// sends a sysex message to the given device on the given channel
|
// sends a sysex message to the given device on the given channel
|
||||||
function sendSysex(sysexid, sysexdata, device, timeOffsetString) {
|
function sendSysex(sysexid, sysexdata, device, targetTime) {
|
||||||
if (Array.isArray(sysexid)) {
|
if (Array.isArray(sysexid)) {
|
||||||
if (!sysexid.every((byte) => Number.isInteger(byte) && byte >= 0 && byte <= 255)) {
|
if (!sysexid.every((byte) => Number.isInteger(byte) && byte >= 0 && byte <= 255)) {
|
||||||
throw new Error('all sysexid bytes must be integers between 0 and 255');
|
throw new Error('all sysexid bytes must be integers between 0 and 255');
|
||||||
@@ -225,11 +230,13 @@ function sendSysex(sysexid, sysexdata, device, timeOffsetString) {
|
|||||||
if (!sysexdata.every((byte) => Number.isInteger(byte) && byte >= 0 && byte <= 255)) {
|
if (!sysexdata.every((byte) => Number.isInteger(byte) && byte >= 0 && byte <= 255)) {
|
||||||
throw new Error('all sysex bytes must be integers between 0 and 255');
|
throw new Error('all sysex bytes must be integers between 0 and 255');
|
||||||
}
|
}
|
||||||
device.sendSysex(sysexid, sysexdata, { time: timeOffsetString });
|
scheduleAtTime(() => {
|
||||||
|
device.sendSysex(sysexid, sysexdata);
|
||||||
|
}, targetTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// sends a NRPN message to the given device on the given channel
|
// sends a NRPN message to the given device on the given channel
|
||||||
function sendNRPN(nrpnn, nrpv, device, midichan, timeOffsetString) {
|
function sendNRPN(nrpnn, nrpv, device, midichan, targetTime) {
|
||||||
if (Array.isArray(nrpnn)) {
|
if (Array.isArray(nrpnn)) {
|
||||||
if (!nrpnn.every((byte) => Number.isInteger(byte) && byte >= 0 && byte <= 255)) {
|
if (!nrpnn.every((byte) => Number.isInteger(byte) && byte >= 0 && byte <= 255)) {
|
||||||
throw new Error('all nrpnn bytes must be integers between 0 and 255');
|
throw new Error('all nrpnn bytes must be integers between 0 and 255');
|
||||||
@@ -237,28 +244,34 @@ function sendNRPN(nrpnn, nrpv, device, midichan, timeOffsetString) {
|
|||||||
} else if (!Number.isInteger(nrpv) || nrpv < 0 || nrpv > 255) {
|
} else if (!Number.isInteger(nrpv) || nrpv < 0 || nrpv > 255) {
|
||||||
throw new Error('A:sysexid must be an number between 0 and 255 or an array of such integers');
|
throw new Error('A:sysexid must be an number between 0 and 255 or an array of such integers');
|
||||||
}
|
}
|
||||||
|
scheduleAtTime(() => {
|
||||||
device.sendNRPN(nrpnn, nrpv, midichan, { time: timeOffsetString });
|
device.sendNRPN(nrpnn, nrpv, midichan);
|
||||||
|
}, targetTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// sends a pitch bend message to the given device on the given channel
|
// sends a pitch bend message to the given device on the given channel
|
||||||
function sendPitchBend(midibend, device, midichan, timeOffsetString) {
|
function sendPitchBend(midibend, device, midichan, targetTime) {
|
||||||
if (typeof midibend !== 'number' || midibend < -1 || midibend > 1) {
|
if (typeof midibend !== 'number' || midibend < -1 || midibend > 1) {
|
||||||
throw new Error('expected midibend to be a number between -1 and 1');
|
throw new Error('expected midibend to be a number between -1 and 1');
|
||||||
}
|
}
|
||||||
device.sendPitchBend(midibend, midichan, { time: timeOffsetString });
|
scheduleAtTime(() => {
|
||||||
|
device.sendPitchBend(midibend, midichan);
|
||||||
|
}, targetTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// sends a channel aftertouch message to the given device on the given channel
|
// sends a channel aftertouch message to the given device on the given channel
|
||||||
function sendAftertouch(miditouch, device, midichan, timeOffsetString) {
|
function sendAftertouch(miditouch, device, midichan, targetTime) {
|
||||||
if (typeof miditouch !== 'number' || miditouch < 0 || miditouch > 1) {
|
if (typeof miditouch !== 'number' || miditouch < 0 || miditouch > 1) {
|
||||||
throw new Error('expected miditouch to be a number between 0 and 1');
|
throw new Error('expected miditouch to be a number between 0 and 1');
|
||||||
}
|
}
|
||||||
device.sendChannelAftertouch(miditouch, midichan, { time: timeOffsetString });
|
|
||||||
|
scheduleAtTime(() => {
|
||||||
|
device.sendChannelAftertouch(miditouch, midichan);
|
||||||
|
}, targetTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// sends a note message to the given device on the given channel
|
// sends a note message to the given device on the given channel
|
||||||
function sendNote(note, velocity, duration, device, midichan, timeOffsetString) {
|
function sendNote(note, velocity, duration, device, midichan, targetTime) {
|
||||||
if (note == null || note === '') {
|
if (note == null || note === '') {
|
||||||
throw new Error('note cannot be null or empty');
|
throw new Error('note cannot be null or empty');
|
||||||
}
|
}
|
||||||
@@ -268,12 +281,12 @@ function sendNote(note, velocity, duration, device, midichan, timeOffsetString)
|
|||||||
if (duration != null && (typeof duration !== 'number' || duration < 0)) {
|
if (duration != null && (typeof duration !== 'number' || duration < 0)) {
|
||||||
throw new Error('duration must be a positive number');
|
throw new Error('duration must be a positive number');
|
||||||
}
|
}
|
||||||
|
|
||||||
const midiNumber = typeof note === 'number' ? note : noteToMidi(note);
|
const midiNumber = typeof note === 'number' ? note : noteToMidi(note);
|
||||||
const midiNote = new Note(midiNumber, { attack: velocity, duration });
|
const midiNote = new Note(midiNumber, { attack: velocity, duration });
|
||||||
device.playNote(midiNote, midichan, {
|
|
||||||
time: timeOffsetString,
|
scheduleAtTime(() => {
|
||||||
});
|
device.playNote(midiNote, midichan);
|
||||||
|
}, targetTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -309,7 +322,6 @@ Pattern.prototype.midi = function (midiport, options = {}) {
|
|||||||
let midiConfig = {
|
let midiConfig = {
|
||||||
// Default configuration values
|
// Default configuration values
|
||||||
isController: false, // Disable sending notes for midi controllers
|
isController: false, // Disable sending notes for midi controllers
|
||||||
latencyMs: 34, // Default latency to get audio engine to line up in ms
|
|
||||||
noteOffsetMs: 10, // Default note-off offset to prevent glitching in ms
|
noteOffsetMs: 10, // Default note-off offset to prevent glitching in ms
|
||||||
midichannel: 1, // Default MIDI channel
|
midichannel: 1, // Default MIDI channel
|
||||||
velocity: 0.9, // Default velocity
|
velocity: 0.9, // Default velocity
|
||||||
@@ -333,18 +345,13 @@ Pattern.prototype.midi = function (midiport, options = {}) {
|
|||||||
logger(`Midi device disconnected! Available: ${getMidiDeviceNamesString(outputs)}`),
|
logger(`Midi device disconnected! Available: ${getMidiDeviceNamesString(outputs)}`),
|
||||||
});
|
});
|
||||||
|
|
||||||
return this.onTrigger((hap, currentTime, cps, targetTime) => {
|
return this.onTrigger((hap, _currentTime, cps, targetTime) => {
|
||||||
if (!WebMidi.enabled) {
|
if (!WebMidi.enabled) {
|
||||||
logger('Midi not enabled');
|
logger('Midi not enabled');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
hap.ensureObjectValue();
|
hap.ensureObjectValue();
|
||||||
|
|
||||||
//magic number to get audio engine to line up, can probably be calculated somehow
|
|
||||||
const latencyMs = midiConfig.latencyMs;
|
|
||||||
// passing a string with a +num into the webmidi api adds an offset to the current time https://webmidijs.org/api/classes/Output
|
|
||||||
const timeOffsetString = `+${getEventOffsetMs(targetTime, currentTime) + latencyMs}`;
|
|
||||||
|
|
||||||
// midi event values from hap with configurable defaults
|
// midi event values from hap with configurable defaults
|
||||||
let {
|
let {
|
||||||
note,
|
note,
|
||||||
@@ -380,7 +387,7 @@ Pattern.prototype.midi = function (midiport, options = {}) {
|
|||||||
// if midimap is set, send a cc messages from defined controls
|
// if midimap is set, send a cc messages from defined controls
|
||||||
if (midicontrolMap.has(midimap)) {
|
if (midicontrolMap.has(midimap)) {
|
||||||
const ccs = mapCC(midicontrolMap.get(midimap), hap.value);
|
const ccs = mapCC(midicontrolMap.get(midimap), hap.value);
|
||||||
ccs.forEach(({ ccn, ccv }) => sendCC(ccn, ccv, device, midichan, timeOffsetString));
|
ccs.forEach(({ ccn, ccv }) => sendCC(ccn, ccv, device, midichan, targetTime));
|
||||||
} else if (midimap !== 'default') {
|
} else if (midimap !== 'default') {
|
||||||
// Add warning when a non-existent midimap is specified
|
// Add warning when a non-existent midimap is specified
|
||||||
logger(`[midi] midimap "${midimap}" not found! Available maps: ${[...midicontrolMap.keys()].join(', ')}`);
|
logger(`[midi] midimap "${midimap}" not found! Available maps: ${[...midicontrolMap.keys()].join(', ')}`);
|
||||||
@@ -392,12 +399,12 @@ Pattern.prototype.midi = function (midiport, options = {}) {
|
|||||||
// try to prevent glitching by subtracting noteOffsetMs from the duration length
|
// try to prevent glitching by subtracting noteOffsetMs from the duration length
|
||||||
const duration = (hap.duration.valueOf() / cps) * 1000 - midiConfig.noteOffsetMs;
|
const duration = (hap.duration.valueOf() / cps) * 1000 - midiConfig.noteOffsetMs;
|
||||||
|
|
||||||
sendNote(note, velocity, duration, device, midichan, timeOffsetString);
|
sendNote(note, velocity, duration, device, midichan, targetTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle program change
|
// Handle program change
|
||||||
if (progNum !== undefined) {
|
if (progNum !== undefined) {
|
||||||
sendProgramChange(progNum, device, midichan, timeOffsetString);
|
sendProgramChange(progNum, device, midichan, targetTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle sysex
|
// Handle sysex
|
||||||
@@ -407,53 +414,63 @@ Pattern.prototype.midi = function (midiport, options = {}) {
|
|||||||
// if sysexid is an array the first byte is 0x00
|
// if sysexid is an array the first byte is 0x00
|
||||||
|
|
||||||
if (sysexid !== undefined && sysexdata !== undefined) {
|
if (sysexid !== undefined && sysexdata !== undefined) {
|
||||||
sendSysex(sysexid, sysexdata, device, timeOffsetString);
|
sendSysex(sysexid, sysexdata, device, targetTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle control change
|
// Handle control change
|
||||||
if (ccv !== undefined && ccn !== undefined) {
|
if (ccv !== undefined && ccn !== undefined) {
|
||||||
sendCC(ccn, ccv, device, midichan, timeOffsetString);
|
sendCC(ccn, ccv, device, midichan, targetTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle NRPN non-registered parameter number
|
// Handle NRPN non-registered parameter number
|
||||||
if (nrpnn !== undefined && nrpv !== undefined) {
|
if (nrpnn !== undefined && nrpv !== undefined) {
|
||||||
sendNRPN(nrpnn, nrpv, device, midichan, timeOffsetString);
|
sendNRPN(nrpnn, nrpv, device, midichan, targetTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle midibend
|
// Handle midibend
|
||||||
if (midibend !== undefined) {
|
if (midibend !== undefined) {
|
||||||
sendPitchBend(midibend, device, midichan, timeOffsetString);
|
sendPitchBend(midibend, device, midichan, targetTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle miditouch
|
// Handle miditouch
|
||||||
if (miditouch !== undefined) {
|
if (miditouch !== undefined) {
|
||||||
sendAftertouch(miditouch, device, midichan, timeOffsetString);
|
sendAftertouch(miditouch, device, midichan, targetTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle midicmd
|
// Handle midicmd
|
||||||
if (hap.whole.begin + 0 === 0) {
|
if (hap.whole.begin + 0 === 0) {
|
||||||
// we need to start here because we have the timing info
|
// we need to start here because we have the timing info
|
||||||
device.sendStart({ time: timeOffsetString });
|
scheduleAtTime(() => {
|
||||||
|
device.sendStart();
|
||||||
|
}, targetTime);
|
||||||
}
|
}
|
||||||
if (['clock', 'midiClock'].includes(midicmd)) {
|
if (['clock', 'midiClock'].includes(midicmd)) {
|
||||||
device.sendClock({ time: timeOffsetString });
|
scheduleAtTime(() => {
|
||||||
|
device.sendClock();
|
||||||
|
}, targetTime);
|
||||||
} else if (['start'].includes(midicmd)) {
|
} else if (['start'].includes(midicmd)) {
|
||||||
device.sendStart({ time: timeOffsetString });
|
scheduleAtTime(() => {
|
||||||
|
device.sendStart();
|
||||||
|
}, targetTime);
|
||||||
} else if (['stop'].includes(midicmd)) {
|
} else if (['stop'].includes(midicmd)) {
|
||||||
device.sendStop({ time: timeOffsetString });
|
scheduleAtTime(() => {
|
||||||
|
device.sendStop();
|
||||||
|
}, targetTime);
|
||||||
} else if (['continue'].includes(midicmd)) {
|
} else if (['continue'].includes(midicmd)) {
|
||||||
device.sendContinue({ time: timeOffsetString });
|
scheduleAtTime(() => {
|
||||||
|
device.sendContinue();
|
||||||
|
}, targetTime);
|
||||||
} else if (Array.isArray(midicmd)) {
|
} else if (Array.isArray(midicmd)) {
|
||||||
if (midicmd[0] === 'progNum') {
|
if (midicmd[0] === 'progNum') {
|
||||||
sendProgramChange(midicmd[1], device, midichan, timeOffsetString);
|
sendProgramChange(midicmd[1], device, midichan, targetTime);
|
||||||
} else if (midicmd[0] === 'cc') {
|
} else if (midicmd[0] === 'cc') {
|
||||||
if (midicmd.length === 2) {
|
if (midicmd.length === 2) {
|
||||||
sendCC(midicmd[0], midicmd[1] / 127, device, midichan, timeOffsetString);
|
sendCC(midicmd[0], midicmd[1] / 127, device, midichan, targetTime);
|
||||||
}
|
}
|
||||||
} else if (midicmd[0] === 'sysex') {
|
} else if (midicmd[0] === 'sysex') {
|
||||||
if (midicmd.length === 3) {
|
if (midicmd.length === 3) {
|
||||||
const [_, id, data] = midicmd;
|
const [_, id, data] = midicmd;
|
||||||
sendSysex(id, data, device, timeOffsetString);
|
sendSysex(id, data, device, targetTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,5 +35,8 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite": "^6.0.11"
|
"vite": "^6.0.11"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,5 +38,8 @@
|
|||||||
"peggy": "^4.2.0",
|
"peggy": "^4.2.0",
|
||||||
"vite": "^6.0.11",
|
"vite": "^6.0.11",
|
||||||
"vitest": "^3.0.4"
|
"vitest": "^3.0.4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,5 +33,8 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite": "^6.0.11",
|
"vite": "^6.0.11",
|
||||||
"vitest": "^3.0.4"
|
"vitest": "^3.0.4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,5 +40,8 @@
|
|||||||
"mondo": "*",
|
"mondo": "*",
|
||||||
"vite": "^6.0.11",
|
"vite": "^6.0.11",
|
||||||
"vitest": "^3.0.4"
|
"vitest": "^3.0.4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,5 +33,8 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite": "^6.0.11"
|
"vite": "^6.0.11"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,5 +34,8 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite": "^6.0.11"
|
"vite": "^6.0.11"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,5 +44,8 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"pkg": "^5.8.1",
|
"pkg": "^5.8.1",
|
||||||
"vite": "^6.0.11"
|
"vite": "^6.0.11"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,5 +33,8 @@
|
|||||||
"homepage": "https://codeberg.org/uzu/strudel#readme",
|
"homepage": "https://codeberg.org/uzu/strudel#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite": "^6.0.11"
|
"vite": "^6.0.11"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,5 +48,8 @@
|
|||||||
"@rollup/plugin-replace": "^6.0.2",
|
"@rollup/plugin-replace": "^6.0.2",
|
||||||
"vite": "^6.0.11",
|
"vite": "^6.0.11",
|
||||||
"vite-plugin-bundle-audioworklet": "workspace:*"
|
"vite-plugin-bundle-audioworklet": "workspace:*"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,5 +15,8 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cowsay": "^1.6.0"
|
"cowsay": "^1.6.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,5 +33,8 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite": "^6.0.11"
|
"vite": "^6.0.11"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,5 +37,8 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"node-fetch": "^3.3.2",
|
"node-fetch": "^3.3.2",
|
||||||
"vite": "^6.0.11"
|
"vite": "^6.0.11"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,6 +154,24 @@ export const getADSRValues = (params, curve = 'linear', defaultValues) => {
|
|||||||
return [Math.max(a ?? 0, envmin), Math.max(d ?? 0, envmin), Math.min(sustain, envmax), Math.max(r ?? 0, releaseMin)];
|
return [Math.max(a ?? 0, envmin), Math.max(d ?? 0, envmin), Math.min(sustain, envmax), Math.max(r ?? 0, releaseMin)];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function getParamLfo(audioContext, param, start, end, lfoValues) {
|
||||||
|
let { defaultDepth = 1, depth, dcoffset, ...getLfoInputs } = lfoValues;
|
||||||
|
if (depth == null) {
|
||||||
|
const hasLFOParams = Object.values(getLfoInputs).some((v) => v != null);
|
||||||
|
depth = hasLFOParams ? defaultDepth : 0;
|
||||||
|
}
|
||||||
|
let lfo;
|
||||||
|
if (depth) {
|
||||||
|
lfo = getLfo(audioContext, start, end, {
|
||||||
|
depth,
|
||||||
|
dcoffset,
|
||||||
|
...getLfoInputs,
|
||||||
|
});
|
||||||
|
lfo.connect(param);
|
||||||
|
}
|
||||||
|
return lfo;
|
||||||
|
}
|
||||||
|
|
||||||
// helper utility for applying standard modulators to a parameter
|
// helper utility for applying standard modulators to a parameter
|
||||||
export function applyParameterModulators(audioContext, param, start, end, envelopeValues, lfoValues) {
|
export function applyParameterModulators(audioContext, param, start, end, envelopeValues, lfoValues) {
|
||||||
let { amount, offset, defaultAmount = 1, curve = 'linear', values, holdEnd, defaultValues } = envelopeValues;
|
let { amount, offset, defaultAmount = 1, curve = 'linear', values, holdEnd, defaultValues } = envelopeValues;
|
||||||
@@ -170,55 +188,58 @@ export function applyParameterModulators(audioContext, param, start, end, envelo
|
|||||||
const [attack, decay, sustain, release] = getADSRValues(values, curve, defaultValues);
|
const [attack, decay, sustain, release] = getADSRValues(values, curve, defaultValues);
|
||||||
getParamADSR(param, attack, decay, sustain, release, min, max, start, holdEnd, curve);
|
getParamADSR(param, attack, decay, sustain, release, min, max, start, holdEnd, curve);
|
||||||
}
|
}
|
||||||
let lfo;
|
const lfo = getParamLfo(audioContext, param, start, end, lfoValues);
|
||||||
let { defaultDepth = 1, depth, dcoffset, ...getLfoInputs } = lfoValues;
|
|
||||||
|
|
||||||
if (depth == null) {
|
|
||||||
const hasLFOParams = Object.values(getLfoInputs).some((v) => v != null);
|
|
||||||
depth = hasLFOParams ? defaultDepth : 0;
|
|
||||||
}
|
|
||||||
if (depth) {
|
|
||||||
lfo = getLfo(audioContext, start, end, {
|
|
||||||
depth,
|
|
||||||
dcoffset,
|
|
||||||
...getLfoInputs,
|
|
||||||
});
|
|
||||||
lfo.connect(param);
|
|
||||||
}
|
|
||||||
|
|
||||||
return { lfo, disconnect: () => lfo?.disconnect() };
|
return { lfo, disconnect: () => lfo?.disconnect() };
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createFilter(context, type, frequency, Q, att, dec, sus, rel, fenv, start, end, fanchor, model, drive) {
|
export function createFilter(context, start, end, params, cps) {
|
||||||
const curve = 'exponential';
|
let {
|
||||||
const [attack, decay, sustain, release] = getADSRValues([att, dec, sus, rel], curve, [0.005, 0.14, 0, 0.1]);
|
frequency,
|
||||||
let filter;
|
anchor,
|
||||||
let frequencyParam;
|
env,
|
||||||
|
type,
|
||||||
|
model,
|
||||||
|
q = 1,
|
||||||
|
drive = 0.69,
|
||||||
|
depth,
|
||||||
|
dcoffset = -0.5,
|
||||||
|
skew,
|
||||||
|
shape,
|
||||||
|
rate,
|
||||||
|
sync,
|
||||||
|
} = params;
|
||||||
|
let frequencyParam, filter;
|
||||||
if (model === 'ladder') {
|
if (model === 'ladder') {
|
||||||
filter = getWorklet(context, 'ladder-processor', { frequency, q: Q, drive });
|
filter = getWorklet(context, 'ladder-processor', { frequency, q, drive });
|
||||||
frequencyParam = filter.parameters.get('frequency');
|
frequencyParam = filter.parameters.get('frequency');
|
||||||
} else {
|
} else {
|
||||||
filter = context.createBiquadFilter();
|
filter = context.createBiquadFilter();
|
||||||
filter.type = type;
|
filter.type = type;
|
||||||
filter.Q.value = Q;
|
filter.Q.value = q;
|
||||||
filter.frequency.value = frequency;
|
filter.frequency.value = frequency;
|
||||||
frequencyParam = filter.frequency;
|
frequencyParam = filter.frequency;
|
||||||
}
|
}
|
||||||
|
const envelopeValues = [params.attack, params.decay, params.sustain, params.release];
|
||||||
|
const [attack, decay, sustain, release] = getADSRValues(envelopeValues, 'exponential', [0.005, 0.14, 0, 0.1]);
|
||||||
// envelope is active when any of these values is set
|
// envelope is active when any of these values is set
|
||||||
const hasEnvelope = att ?? dec ?? sus ?? rel ?? fenv;
|
const hasEnvelope = [...envelopeValues, env].some((v) => v !== undefined);
|
||||||
// Apply ADSR to filter frequency
|
// Apply ADSR to filter frequency
|
||||||
if (hasEnvelope !== undefined) {
|
if (hasEnvelope) {
|
||||||
fenv = nanFallback(fenv, 1, true);
|
env = nanFallback(env, 1, true);
|
||||||
fanchor = nanFallback(fanchor, 0, true);
|
anchor = nanFallback(anchor, 0, true);
|
||||||
const fenvAbs = Math.abs(fenv);
|
const envAbs = Math.abs(env);
|
||||||
const offset = fenvAbs * fanchor;
|
const offset = envAbs * anchor;
|
||||||
let min = clamp(2 ** -offset * frequency, 0, 20000);
|
let min = clamp(2 ** -offset * frequency, 0, 20000);
|
||||||
let max = clamp(2 ** (fenvAbs - offset) * frequency, 0, 20000);
|
let max = clamp(2 ** (envAbs - offset) * frequency, 0, 20000);
|
||||||
if (fenv < 0) [min, max] = [max, min];
|
if (env < 0) [min, max] = [max, min];
|
||||||
getParamADSR(frequencyParam, attack, decay, sustain, release, min, max, start, end, curve);
|
getParamADSR(frequencyParam, attack, decay, sustain, release, min, max, start, end, 'exponential');
|
||||||
return filter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sync != null) {
|
||||||
|
rate = cps * sync;
|
||||||
|
}
|
||||||
|
const lfoValues = { depth, dcoffset, skew, shape, frequency: rate };
|
||||||
|
getParamLfo(context, frequencyParam, start, end, lfoValues);
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,6 +301,11 @@ export function getVibratoOscillator(param, value, t) {
|
|||||||
return vibratoOscillator;
|
return vibratoOscillator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function scheduleAtTime(callback, targetTime, audioContext = getAudioContext()) {
|
||||||
|
const currentTime = audioContext.currentTime;
|
||||||
|
webAudioTimeout(audioContext, callback, currentTime, targetTime);
|
||||||
|
}
|
||||||
// ConstantSource inherits AudioScheduledSourceNode, which has scheduling abilities
|
// ConstantSource inherits AudioScheduledSourceNode, which has scheduling abilities
|
||||||
// a bit of a hack, but it works very well :)
|
// a bit of a hack, but it works very well :)
|
||||||
export function webAudioTimeout(audioContext, onComplete, startTime, stopTime) {
|
export function webAudioTimeout(audioContext, onComplete, startTime, stopTime) {
|
||||||
|
|||||||
@@ -37,5 +37,8 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"nanostores": "^0.11.3"
|
"nanostores": "^0.11.3"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ This program is free software: you can redistribute it and/or modify it under th
|
|||||||
import './feedbackdelay.mjs';
|
import './feedbackdelay.mjs';
|
||||||
import './reverb.mjs';
|
import './reverb.mjs';
|
||||||
import './vowel.mjs';
|
import './vowel.mjs';
|
||||||
import { nanFallback, _mod, cycleToSeconds } from './util.mjs';
|
import { nanFallback, _mod, cycleToSeconds, pickAndRename } from './util.mjs';
|
||||||
import workletsUrl from './worklets.mjs?audioworklet';
|
import workletsUrl from './worklets.mjs?audioworklet';
|
||||||
import { createFilter, gainNode, getCompressor, getDistortion, getLfo, getWorklet, effectSend } from './helpers.mjs';
|
import { createFilter, gainNode, getCompressor, getDistortion, getLfo, getWorklet, effectSend } from './helpers.mjs';
|
||||||
import { map } from 'nanostores';
|
import { map } from 'nanostores';
|
||||||
@@ -146,11 +146,6 @@ let defaultDefaultValues = {
|
|||||||
gain: 0.8,
|
gain: 0.8,
|
||||||
postgain: 1,
|
postgain: 1,
|
||||||
density: '.03',
|
density: '.03',
|
||||||
ftype: '12db',
|
|
||||||
fanchor: 0,
|
|
||||||
resonance: 1,
|
|
||||||
hresonance: 1,
|
|
||||||
bandq: 1,
|
|
||||||
channels: [1, 2],
|
channels: [1, 2],
|
||||||
phaserdepth: 0.75,
|
phaserdepth: 0.75,
|
||||||
shapevol: 1,
|
shapevol: 1,
|
||||||
@@ -415,32 +410,7 @@ export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5)
|
|||||||
djf,
|
djf,
|
||||||
// filters
|
// filters
|
||||||
fanchor = getDefaultValue('fanchor'),
|
fanchor = getDefaultValue('fanchor'),
|
||||||
drive = 0.69,
|
|
||||||
release = 0,
|
release = 0,
|
||||||
// low pass
|
|
||||||
cutoff,
|
|
||||||
lpenv,
|
|
||||||
lpattack,
|
|
||||||
lpdecay,
|
|
||||||
lpsustain,
|
|
||||||
lprelease,
|
|
||||||
resonance = getDefaultValue('resonance'),
|
|
||||||
// high pass
|
|
||||||
hpenv,
|
|
||||||
hcutoff,
|
|
||||||
hpattack,
|
|
||||||
hpdecay,
|
|
||||||
hpsustain,
|
|
||||||
hprelease,
|
|
||||||
hresonance = getDefaultValue('hresonance'),
|
|
||||||
// band pass
|
|
||||||
bpenv,
|
|
||||||
bandf,
|
|
||||||
bpattack,
|
|
||||||
bpdecay,
|
|
||||||
bpsustain,
|
|
||||||
bprelease,
|
|
||||||
bandq = getDefaultValue('bandq'),
|
|
||||||
|
|
||||||
//phaser
|
//phaser
|
||||||
phaserrate: phaser,
|
phaserrate: phaser,
|
||||||
@@ -565,57 +535,87 @@ export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5)
|
|||||||
// gain stage
|
// gain stage
|
||||||
chain.push(gainNode(gain));
|
chain.push(gainNode(gain));
|
||||||
|
|
||||||
//filter
|
// filter
|
||||||
const ftype = getFilterType(value.ftype);
|
const ftype = getFilterType(value.ftype);
|
||||||
if (cutoff !== undefined) {
|
|
||||||
let lp = () =>
|
if (value.cutoff !== undefined) {
|
||||||
createFilter(
|
const lpMap = {
|
||||||
ac,
|
frequency: 'cutoff',
|
||||||
'lowpass',
|
q: 'resonance',
|
||||||
cutoff,
|
attack: 'lpattack',
|
||||||
resonance,
|
decay: 'lpdecay',
|
||||||
lpattack,
|
sustain: 'lpsustain',
|
||||||
lpdecay,
|
release: 'lprelease',
|
||||||
lpsustain,
|
env: 'lpenv',
|
||||||
lprelease,
|
anchor: 'fanchor',
|
||||||
lpenv,
|
model: 'ftype',
|
||||||
t,
|
drive: 'drive',
|
||||||
end,
|
rate: 'lprate',
|
||||||
fanchor,
|
sync: 'lpsync',
|
||||||
ftype,
|
depth: 'lpdepth',
|
||||||
drive,
|
shape: 'lpshape',
|
||||||
);
|
dcoffset: 'lpdc',
|
||||||
|
skew: 'lpskew',
|
||||||
|
};
|
||||||
|
const lpParams = pickAndRename(value, lpMap);
|
||||||
|
lpParams.type = 'lowpass';
|
||||||
|
let lp = () => createFilter(ac, t, end, lpParams, cps);
|
||||||
chain.push(lp());
|
chain.push(lp());
|
||||||
if (ftype === '24db') {
|
if (ftype === '24db') {
|
||||||
chain.push(lp());
|
chain.push(lp());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hcutoff !== undefined) {
|
if (value.hcutoff !== undefined) {
|
||||||
let hp = () =>
|
const hpMap = {
|
||||||
createFilter(
|
frequency: 'hcutoff',
|
||||||
ac,
|
q: 'hresonance',
|
||||||
'highpass',
|
attack: 'hpattack',
|
||||||
hcutoff,
|
decay: 'hpdecay',
|
||||||
hresonance,
|
sustain: 'hpsustain',
|
||||||
hpattack,
|
release: 'hprelease',
|
||||||
hpdecay,
|
env: 'hpenv',
|
||||||
hpsustain,
|
anchor: 'fanchor',
|
||||||
hprelease,
|
model: 'ftype',
|
||||||
hpenv,
|
drive: 'drive',
|
||||||
t,
|
rate: 'hprate',
|
||||||
end,
|
sync: 'hpsync',
|
||||||
fanchor,
|
depth: 'hpdepth',
|
||||||
);
|
shape: 'hpshape',
|
||||||
|
dcoffset: 'hpdc',
|
||||||
|
skew: 'hpskew',
|
||||||
|
};
|
||||||
|
const hpParams = pickAndRename(value, hpMap);
|
||||||
|
hpParams.type = 'highpass';
|
||||||
|
let hp = () => createFilter(ac, t, end, hpParams, cps);
|
||||||
chain.push(hp());
|
chain.push(hp());
|
||||||
if (ftype === '24db') {
|
if (ftype === '24db') {
|
||||||
chain.push(hp());
|
chain.push(hp());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bandf !== undefined) {
|
if (value.bandf !== undefined) {
|
||||||
let bp = () =>
|
const bpMap = {
|
||||||
createFilter(ac, 'bandpass', bandf, bandq, bpattack, bpdecay, bpsustain, bprelease, bpenv, t, end, fanchor);
|
frequency: 'bandf',
|
||||||
|
q: 'bandq',
|
||||||
|
attack: 'bpattack',
|
||||||
|
decay: 'bpdecay',
|
||||||
|
sustain: 'bpsustain',
|
||||||
|
release: 'bprelease',
|
||||||
|
env: 'bpenv',
|
||||||
|
anchor: 'fanchor',
|
||||||
|
model: 'ftype',
|
||||||
|
drive: 'drive',
|
||||||
|
rate: 'bprate',
|
||||||
|
sync: 'bpsync',
|
||||||
|
depth: 'bpdepth',
|
||||||
|
shape: 'bpshape',
|
||||||
|
dcoffset: 'bpdc',
|
||||||
|
skew: 'bpskew',
|
||||||
|
};
|
||||||
|
const bpParams = pickAndRename(value, bpMap);
|
||||||
|
bpParams.type = 'bandpass';
|
||||||
|
let bp = () => createFilter(ac, t, end, bpParams, cps);
|
||||||
chain.push(bp());
|
chain.push(bp());
|
||||||
if (ftype === '24db') {
|
if (ftype === '24db') {
|
||||||
chain.push(bp());
|
chain.push(bp());
|
||||||
|
|||||||
@@ -109,3 +109,8 @@ export function getCommonSampleInfo(hapValue, bank) {
|
|||||||
const label = `${s}:${index}`;
|
const label = `${s}:${index}`;
|
||||||
return { transpose, url, index, midi, label };
|
return { transpose, url, index, midi, label };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Selects entries from `source` and renames them via `map` */
|
||||||
|
export const pickAndRename = (source, map) => {
|
||||||
|
return Object.fromEntries(Object.entries(map).map(([newKey, oldKey]) => [newKey, source[oldKey]]));
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
// this is dough, the superdough without dependencies
|
// this is dough, the superdough without dependencies
|
||||||
// @ts-check
|
// @ts-nocheck
|
||||||
// @ts-ignore ignore next line because sampleRate is unknown
|
// @ts-ignore ignore next line because sampleRate is unknown
|
||||||
const SAMPLE_RATE = typeof sampleRate !== 'undefined' ? sampleRate : 48000;
|
const SAMPLE_RATE = typeof sampleRate !== 'undefined' ? sampleRate : 48000;
|
||||||
const PI_DIV_SR = Math.PI / SAMPLE_RATE;
|
const PI_DIV_SR = Math.PI / SAMPLE_RATE;
|
||||||
const ISR = 1 / SAMPLE_RATE;
|
const ISR = 1 / SAMPLE_RATE;
|
||||||
|
|
||||||
let gainCurveFunc = (val) => Math.pow(val, 2);
|
let gainCurveFunc = (val) => Math.pow(val, 2);
|
||||||
|
const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
|
||||||
|
|
||||||
function applyGainCurve(val) {
|
function applyGainCurve(val) {
|
||||||
return gainCurveFunc(val);
|
return gainCurveFunc(val);
|
||||||
@@ -151,7 +152,8 @@ export class TwoPoleFilter {
|
|||||||
resonance = Math.max(resonance, 0);
|
resonance = Math.max(resonance, 0);
|
||||||
|
|
||||||
cutoff = Math.min(cutoff, 20000);
|
cutoff = Math.min(cutoff, 20000);
|
||||||
const c = 2 * Math.sin(cutoff * PI_DIV_SR);
|
let c = 2 * Math.sin(cutoff * PI_DIV_SR);
|
||||||
|
c = clamp(c, 0, 1.14); // this line prevents instability TODO: test
|
||||||
|
|
||||||
const r = Math.pow(0.5, (resonance + 0.125) / 0.125);
|
const r = Math.pow(0.5, (resonance + 0.125) / 0.125);
|
||||||
const mrc = 1 - r * c;
|
const mrc = 1 - r * c;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/tidalcycles/strudel.git"
|
"url": "git+https://codeberg.org/uzu/strudel.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"tidalcycles",
|
"tidalcycles",
|
||||||
@@ -25,12 +25,15 @@
|
|||||||
"author": "Felix Roos <flix91@gmail.com>",
|
"author": "Felix Roos <flix91@gmail.com>",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/tidalcycles/strudel/issues"
|
"url": "https://codeberg.org/uzu/strudel/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/tidalcycles/strudel#readme",
|
"homepage": "https://codeberg.org/uzu/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"
|
"wav-encoder": "^1.3.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { defineConfig } from 'vite';
|
||||||
|
import { resolve } from 'path';
|
||||||
|
import bundleAudioWorkletPlugin from 'vite-plugin-bundle-audioworklet';
|
||||||
|
|
||||||
|
// https://vitejs.dev/config/
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [bundleAudioWorkletPlugin()],
|
||||||
|
build: {
|
||||||
|
lib: {
|
||||||
|
entry: resolve(__dirname, 'index.mjs'),
|
||||||
|
formats: ['es'],
|
||||||
|
fileName: (ext) => ({ es: 'index.mjs' })[ext],
|
||||||
|
},
|
||||||
|
target: 'esnext',
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -25,5 +25,8 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite": "^6.0.11"
|
"vite": "^6.0.11"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,5 +38,8 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite": "^6.0.11",
|
"vite": "^6.0.11",
|
||||||
"vitest": "^3.0.4"
|
"vitest": "^3.0.4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -229,6 +229,9 @@ function _getNearestScaleNote(scaleName, note, preferHigher = true) {
|
|||||||
*
|
*
|
||||||
* A scale consists of a root note (e.g. `c4`, `c`, `f#`, `bb4`) followed by semicolon (':') and then a [scale type](https://github.com/tonaljs/tonal/blob/main/packages/scale-type/data.ts).
|
* A scale consists of a root note (e.g. `c4`, `c`, `f#`, `bb4`) followed by semicolon (':') and then a [scale type](https://github.com/tonaljs/tonal/blob/main/packages/scale-type/data.ts).
|
||||||
*
|
*
|
||||||
|
* The scale name must be written without spaces (because it would be interpreted as a multi-step pattern otherwise).
|
||||||
|
* If your scale name includes spaces, replace them with colons.
|
||||||
|
*
|
||||||
* The root note defaults to octave 3, if no octave number is given.
|
* The root note defaults to octave 3, if no octave number is given.
|
||||||
*
|
*
|
||||||
* @name scale
|
* @name scale
|
||||||
@@ -250,6 +253,8 @@ function _getNearestScaleNote(scaleName, note, preferHigher = true) {
|
|||||||
* .s("piano")
|
* .s("piano")
|
||||||
* @example
|
* @example
|
||||||
* note("C1*16").transpose(irand(36)).scale('Cb2 major').scaleTranspose(3)
|
* note("C1*16").transpose(irand(36)).scale('Cb2 major').scaleTranspose(3)
|
||||||
|
* @example
|
||||||
|
* n("[0 0] [1 2] [3 4] [5 6]").scale("C:major:blues")
|
||||||
*/
|
*/
|
||||||
export const scale = register(
|
export const scale = register(
|
||||||
'scale',
|
'scale',
|
||||||
|
|||||||
@@ -39,5 +39,8 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite": "^6.0.11",
|
"vite": "^6.0.11",
|
||||||
"vitest": "^3.0.4"
|
"vitest": "^3.0.4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,5 +12,8 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite": "^6.0.11"
|
"vite": "^6.0.11"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ initStrudel();
|
|||||||
document.getElementById('play').addEventListener('click',
|
document.getElementById('play').addEventListener('click',
|
||||||
() => evaluate('note("c a f e").jux(rev)')
|
() => evaluate('note("c a f e").jux(rev)')
|
||||||
);
|
);
|
||||||
document.getElementById('play').addEventListener('stop',
|
document.getElementById('stop').addEventListener('click',
|
||||||
() => hush()
|
() => hush()
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -43,5 +43,8 @@
|
|||||||
"@rollup/plugin-replace": "^6.0.2",
|
"@rollup/plugin-replace": "^6.0.2",
|
||||||
"vite": "^6.0.11",
|
"vite": "^6.0.11",
|
||||||
"vite-plugin-bundle-audioworklet": "workspace:*"
|
"vite-plugin-bundle-audioworklet": "workspace:*"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,5 +40,8 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite": "^6.0.11"
|
"vite": "^6.0.11"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,5 +35,8 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite": "^6.0.11",
|
"vite": "^6.0.11",
|
||||||
"vitest": "^3.0.4"
|
"vitest": "^3.0.4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ Tune.prototype.tonicize = function(newTonic) {
|
|||||||
this.tonic = newTonic
|
this.tonic = newTonic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Return data in the mode you are in (freq, ratio, or midi) */
|
/* Return data in the mode you are in (freq, ratio, or midi) */
|
||||||
|
|
||||||
Tune.prototype.note = function(input,octave){
|
Tune.prototype.note = function(input,octave){
|
||||||
|
|||||||
Generated
+132
-20
@@ -41,7 +41,7 @@ importers:
|
|||||||
version: 2.2.7
|
version: 2.2.7
|
||||||
'@vitest/coverage-v8':
|
'@vitest/coverage-v8':
|
||||||
specifier: 3.0.4
|
specifier: 3.0.4
|
||||||
version: 3.0.4(vitest@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))
|
version: 3.0.4(vitest@3.0.4)
|
||||||
'@vitest/ui':
|
'@vitest/ui':
|
||||||
specifier: ^3.0.4
|
specifier: ^3.0.4
|
||||||
version: 3.0.4(vitest@3.0.4)
|
version: 3.0.4(vitest@3.0.4)
|
||||||
@@ -85,29 +85,29 @@ importers:
|
|||||||
examples/codemirror-repl:
|
examples/codemirror-repl:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@strudel/codemirror':
|
'@strudel/codemirror':
|
||||||
specifier: workspace:*
|
specifier: 1.2.6
|
||||||
version: link:../../packages/codemirror
|
version: 1.2.6(@codemirror/lint@6.8.4)
|
||||||
'@strudel/core':
|
'@strudel/core':
|
||||||
specifier: workspace:*
|
specifier: 1.2.5
|
||||||
version: link:../../packages/core
|
version: 1.2.5
|
||||||
'@strudel/draw':
|
'@strudel/draw':
|
||||||
specifier: workspace:*
|
specifier: 1.2.5
|
||||||
version: link:../../packages/draw
|
version: 1.2.5
|
||||||
'@strudel/mini':
|
'@strudel/mini':
|
||||||
specifier: workspace:*
|
specifier: 1.2.5
|
||||||
version: link:../../packages/mini
|
version: 1.2.5
|
||||||
'@strudel/soundfonts':
|
'@strudel/soundfonts':
|
||||||
specifier: workspace:*
|
specifier: 1.2.6
|
||||||
version: link:../../packages/soundfonts
|
version: 1.2.6
|
||||||
'@strudel/tonal':
|
'@strudel/tonal':
|
||||||
specifier: workspace:*
|
specifier: 1.2.5
|
||||||
version: link:../../packages/tonal
|
version: 1.2.5
|
||||||
'@strudel/transpiler':
|
'@strudel/transpiler':
|
||||||
specifier: workspace:*
|
specifier: 1.2.5
|
||||||
version: link:../../packages/transpiler
|
version: 1.2.5
|
||||||
'@strudel/webaudio':
|
'@strudel/webaudio':
|
||||||
specifier: workspace:*
|
specifier: 1.2.6
|
||||||
version: link:../../packages/webaudio
|
version: 1.2.6
|
||||||
devDependencies:
|
devDependencies:
|
||||||
vite:
|
vite:
|
||||||
specifier: ^6.0.11
|
specifier: ^6.0.11
|
||||||
@@ -116,8 +116,8 @@ importers:
|
|||||||
examples/headless-repl:
|
examples/headless-repl:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@strudel/web':
|
'@strudel/web':
|
||||||
specifier: workspace:*
|
specifier: 1.2.6
|
||||||
version: link:../../packages/web
|
version: 1.2.6
|
||||||
devDependencies:
|
devDependencies:
|
||||||
vite:
|
vite:
|
||||||
specifier: ^6.0.11
|
specifier: ^6.0.11
|
||||||
@@ -2544,6 +2544,33 @@ packages:
|
|||||||
'@sinclair/typebox@0.27.8':
|
'@sinclair/typebox@0.27.8':
|
||||||
resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==}
|
resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==}
|
||||||
|
|
||||||
|
'@strudel/codemirror@1.2.6':
|
||||||
|
resolution: {integrity: sha512-zjKbnbnOY40dlIAQu1poq28rcngYliLsuDwXXVnJsaXzCZSVuXEOMq91LqY4IGz/2QUOIDGm663ziz6Nb4IXeg==}
|
||||||
|
|
||||||
|
'@strudel/core@1.2.5':
|
||||||
|
resolution: {integrity: sha512-XO6ICbfuGfvaQ4sZmfIFsPDcjFez/+AVpNgJnmks5gtMMQNXpr0reuee61tvMiu2k5QYKzxWgzDl2FF9pJeIgA==}
|
||||||
|
|
||||||
|
'@strudel/draw@1.2.5':
|
||||||
|
resolution: {integrity: sha512-ZI4WPxUsVsxgDoeZMHo6VfFf+S1tsj8ubKBeSLcf6lH29JqPp7Nz6tPmbomOV1fzazZ7+xpkC7z772MdtgWy2g==}
|
||||||
|
|
||||||
|
'@strudel/mini@1.2.5':
|
||||||
|
resolution: {integrity: sha512-GmTWSBt49C3ogBy0hjM3bmf6K12PaJ1JJLsEvQu7j5J+lUd2n7GmLYR1UL6fntY4yVqT8ZwMhfUf6vIgUCTNbw==}
|
||||||
|
|
||||||
|
'@strudel/soundfonts@1.2.6':
|
||||||
|
resolution: {integrity: sha512-F7eBhohkCXCMo8WiufSAhD3JCfL5GTgCh9RlOJVT+1swiFeIss1vUAWJR3WjonB6moL8BiuNpcYOqO6i6cFy4A==}
|
||||||
|
|
||||||
|
'@strudel/tonal@1.2.5':
|
||||||
|
resolution: {integrity: sha512-mX3uW0nWH8Sa52HTLwnxlR5BrejFX77abeaiMbp+kQCMrX9I+XRdf8rEr7gdeInB6f/y2TzTVFpnsNsB5jLdoA==}
|
||||||
|
|
||||||
|
'@strudel/transpiler@1.2.5':
|
||||||
|
resolution: {integrity: sha512-mBZWfQBzknvnIYsjjzR8D67A+uIZ1iZ60U2WoXT21q5luXKz2c95RcTpqdx3oOGpLK9K00lDzcKjhQDJtj4OKw==}
|
||||||
|
|
||||||
|
'@strudel/web@1.2.6':
|
||||||
|
resolution: {integrity: sha512-e6VltuX90zZz8JVe1FtN23DCaXA9p8zGDakp5OuUb5kZ5hC6cySFkkOsHdGC6dJ0EAsZSCKXMihRxgk9GhBwKA==}
|
||||||
|
|
||||||
|
'@strudel/webaudio@1.2.6':
|
||||||
|
resolution: {integrity: sha512-4LnyNvyeAXYNmXQGGw2f0chIkDr9Rbwo+SK6Y0p8C3W8juDiOfKq2ihSVph95yaBBPRYFJ5Kttj1kLknRHYsog==}
|
||||||
|
|
||||||
'@supabase/auth-js@2.67.3':
|
'@supabase/auth-js@2.67.3':
|
||||||
resolution: {integrity: sha512-NJDaW8yXs49xMvWVOkSIr8j46jf+tYHV0wHhrwOaLLMZSFO4g6kKAf+MfzQ2RaD06OCUkUHIzctLAxjTgEVpzw==}
|
resolution: {integrity: sha512-NJDaW8yXs49xMvWVOkSIr8j46jf+tYHV0wHhrwOaLLMZSFO4g6kKAf+MfzQ2RaD06OCUkUHIzctLAxjTgEVpzw==}
|
||||||
|
|
||||||
@@ -7094,6 +7121,9 @@ packages:
|
|||||||
engines: {node: '>=16 || 14 >=14.17'}
|
engines: {node: '>=16 || 14 >=14.17'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
|
superdough@1.2.6:
|
||||||
|
resolution: {integrity: sha512-zHEFfG+N4zhxJ9lUDf8p4Oj4sdGGQ5SrOPksdc0cKv5Yn0hzlNlMehEa5TkeIfDCiR27Y4H81ks7S8/CGSByhQ==}
|
||||||
|
|
||||||
supports-color@7.2.0:
|
supports-color@7.2.0:
|
||||||
resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==}
|
resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
@@ -7102,6 +7132,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==}
|
resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
|
|
||||||
|
supradough@1.2.4:
|
||||||
|
resolution: {integrity: sha512-/v3cL9fq05QCQVwbttLHNZcjyyFFz5wdKvg3j6V6moRXpDlQG89l8dQtUIpQvHsxYI5sXNod9rh5bf+Y4NMGeA==}
|
||||||
|
|
||||||
tabbable@6.2.0:
|
tabbable@6.2.0:
|
||||||
resolution: {integrity: sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew==}
|
resolution: {integrity: sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew==}
|
||||||
|
|
||||||
@@ -10019,6 +10052,79 @@ snapshots:
|
|||||||
|
|
||||||
'@sinclair/typebox@0.27.8': {}
|
'@sinclair/typebox@0.27.8': {}
|
||||||
|
|
||||||
|
'@strudel/codemirror@1.2.6(@codemirror/lint@6.8.4)':
|
||||||
|
dependencies:
|
||||||
|
'@codemirror/autocomplete': 6.18.4
|
||||||
|
'@codemirror/commands': 6.8.0
|
||||||
|
'@codemirror/lang-javascript': 6.2.2
|
||||||
|
'@codemirror/language': 6.10.8
|
||||||
|
'@codemirror/search': 6.5.8
|
||||||
|
'@codemirror/state': 6.5.1
|
||||||
|
'@codemirror/view': 6.36.2
|
||||||
|
'@lezer/highlight': 1.2.1
|
||||||
|
'@nanostores/persistent': 0.10.2(nanostores@0.11.3)
|
||||||
|
'@replit/codemirror-emacs': 6.1.0(@codemirror/autocomplete@6.18.4)(@codemirror/commands@6.8.0)(@codemirror/search@6.5.8)(@codemirror/state@6.5.1)(@codemirror/view@6.36.2)
|
||||||
|
'@replit/codemirror-vim': 6.3.0(@codemirror/commands@6.8.0)(@codemirror/language@6.10.8)(@codemirror/search@6.5.8)(@codemirror/state@6.5.1)(@codemirror/view@6.36.2)
|
||||||
|
'@replit/codemirror-vscode-keymap': 6.0.2(@codemirror/autocomplete@6.18.4)(@codemirror/commands@6.8.0)(@codemirror/language@6.10.8)(@codemirror/lint@6.8.4)(@codemirror/search@6.5.8)(@codemirror/state@6.5.1)(@codemirror/view@6.36.2)
|
||||||
|
'@strudel/core': 1.2.5
|
||||||
|
'@strudel/draw': 1.2.5
|
||||||
|
'@strudel/tonal': 1.2.5
|
||||||
|
'@strudel/transpiler': 1.2.5
|
||||||
|
'@tonaljs/tonal': 4.10.0
|
||||||
|
nanostores: 0.11.3
|
||||||
|
superdough: 1.2.6
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- '@codemirror/lint'
|
||||||
|
|
||||||
|
'@strudel/core@1.2.5':
|
||||||
|
dependencies:
|
||||||
|
fraction.js: 5.2.1
|
||||||
|
|
||||||
|
'@strudel/draw@1.2.5':
|
||||||
|
dependencies:
|
||||||
|
'@strudel/core': 1.2.5
|
||||||
|
|
||||||
|
'@strudel/mini@1.2.5':
|
||||||
|
dependencies:
|
||||||
|
'@strudel/core': 1.2.5
|
||||||
|
|
||||||
|
'@strudel/soundfonts@1.2.6':
|
||||||
|
dependencies:
|
||||||
|
'@strudel/core': 1.2.5
|
||||||
|
'@strudel/webaudio': 1.2.6
|
||||||
|
sfumato: 0.1.2
|
||||||
|
soundfont2: 0.5.0
|
||||||
|
|
||||||
|
'@strudel/tonal@1.2.5':
|
||||||
|
dependencies:
|
||||||
|
'@strudel/core': 1.2.5
|
||||||
|
'@tonaljs/tonal': 4.10.0
|
||||||
|
chord-voicings: 0.0.1
|
||||||
|
webmidi: 3.1.12
|
||||||
|
|
||||||
|
'@strudel/transpiler@1.2.5':
|
||||||
|
dependencies:
|
||||||
|
'@strudel/core': 1.2.5
|
||||||
|
'@strudel/mini': 1.2.5
|
||||||
|
acorn: 8.14.0
|
||||||
|
escodegen: 2.1.0
|
||||||
|
estree-walker: 3.0.3
|
||||||
|
|
||||||
|
'@strudel/web@1.2.6':
|
||||||
|
dependencies:
|
||||||
|
'@strudel/core': 1.2.5
|
||||||
|
'@strudel/mini': 1.2.5
|
||||||
|
'@strudel/tonal': 1.2.5
|
||||||
|
'@strudel/transpiler': 1.2.5
|
||||||
|
'@strudel/webaudio': 1.2.6
|
||||||
|
|
||||||
|
'@strudel/webaudio@1.2.6':
|
||||||
|
dependencies:
|
||||||
|
'@strudel/core': 1.2.5
|
||||||
|
'@strudel/draw': 1.2.5
|
||||||
|
superdough: 1.2.6
|
||||||
|
supradough: 1.2.4
|
||||||
|
|
||||||
'@supabase/auth-js@2.67.3':
|
'@supabase/auth-js@2.67.3':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@supabase/node-fetch': 2.6.15
|
'@supabase/node-fetch': 2.6.15
|
||||||
@@ -10554,7 +10660,7 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@vitest/coverage-v8@3.0.4(vitest@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))':
|
'@vitest/coverage-v8@3.0.4(vitest@3.0.4)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@ampproject/remapping': 2.3.0
|
'@ampproject/remapping': 2.3.0
|
||||||
'@bcoe/v8-coverage': 1.0.2
|
'@bcoe/v8-coverage': 1.0.2
|
||||||
@@ -15665,12 +15771,18 @@ snapshots:
|
|||||||
pirates: 4.0.6
|
pirates: 4.0.6
|
||||||
ts-interface-checker: 0.1.13
|
ts-interface-checker: 0.1.13
|
||||||
|
|
||||||
|
superdough@1.2.6:
|
||||||
|
dependencies:
|
||||||
|
nanostores: 0.11.3
|
||||||
|
|
||||||
supports-color@7.2.0:
|
supports-color@7.2.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
has-flag: 4.0.0
|
has-flag: 4.0.0
|
||||||
|
|
||||||
supports-preserve-symlinks-flag@1.0.0: {}
|
supports-preserve-symlinks-flag@1.0.0: {}
|
||||||
|
|
||||||
|
supradough@1.2.4: {}
|
||||||
|
|
||||||
tabbable@6.2.0: {}
|
tabbable@6.2.0: {}
|
||||||
|
|
||||||
tailwindcss@3.4.17:
|
tailwindcss@3.4.17:
|
||||||
|
|||||||
@@ -840,6 +840,31 @@ exports[`runs examples > example "amp" example index 0 1`] = `
|
|||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`runs examples > example "anchor" example index 0 1`] = `
|
||||||
|
[
|
||||||
|
"[ 0/1 → 1/1 | note:E2 ]",
|
||||||
|
"[ 0/1 → 1/1 | note:C3 ]",
|
||||||
|
"[ 0/1 → 1/1 | note:E3 ]",
|
||||||
|
"[ 0/1 → 1/1 | note:G3 ]",
|
||||||
|
"[ 0/1 → 1/1 | note:C4 ]",
|
||||||
|
"[ 1/1 → 2/1 | note:C3 ]",
|
||||||
|
"[ 1/1 → 2/1 | note:G3 ]",
|
||||||
|
"[ 1/1 → 2/1 | note:C4 ]",
|
||||||
|
"[ 1/1 → 2/1 | note:E4 ]",
|
||||||
|
"[ 1/1 → 2/1 | note:G4 ]",
|
||||||
|
"[ 2/1 → 3/1 | note:E3 ]",
|
||||||
|
"[ 2/1 → 3/1 | note:C4 ]",
|
||||||
|
"[ 2/1 → 3/1 | note:E4 ]",
|
||||||
|
"[ 2/1 → 3/1 | note:G4 ]",
|
||||||
|
"[ 2/1 → 3/1 | note:C5 ]",
|
||||||
|
"[ 3/1 → 4/1 | note:C4 ]",
|
||||||
|
"[ 3/1 → 4/1 | note:G4 ]",
|
||||||
|
"[ 3/1 → 4/1 | note:C5 ]",
|
||||||
|
"[ 3/1 → 4/1 | note:E5 ]",
|
||||||
|
"[ 3/1 → 4/1 | note:G5 ]",
|
||||||
|
]
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`runs examples > example "apply" example index 0 1`] = `
|
exports[`runs examples > example "apply" example index 0 1`] = `
|
||||||
[
|
[
|
||||||
"[ 0/1 → 1/1 | note:C3 ]",
|
"[ 0/1 → 1/1 | note:C3 ]",
|
||||||
@@ -1847,6 +1872,31 @@ exports[`runs examples > example "chop" example index 0 1`] = `
|
|||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`runs examples > example "chord" example index 0 1`] = `
|
||||||
|
[
|
||||||
|
"[ 0/1 → 1/1 | note:A3 ]",
|
||||||
|
"[ 0/1 → 1/1 | note:C4 ]",
|
||||||
|
"[ 0/1 → 1/1 | note:E4 ]",
|
||||||
|
"[ 0/1 → 1/1 | note:A4 ]",
|
||||||
|
"[ 0/1 → 1/1 | note:C5 ]",
|
||||||
|
"[ 1/1 → 2/1 | note:E3 ]",
|
||||||
|
"[ 1/1 → 2/1 | note:C4 ]",
|
||||||
|
"[ 1/1 → 2/1 | note:E4 ]",
|
||||||
|
"[ 1/1 → 2/1 | note:G4 ]",
|
||||||
|
"[ 1/1 → 2/1 | note:C5 ]",
|
||||||
|
"[ 2/1 → 3/1 | note:D3 ]",
|
||||||
|
"[ 2/1 → 3/1 | note:A3 ]",
|
||||||
|
"[ 2/1 → 3/1 | note:D4 ]",
|
||||||
|
"[ 2/1 → 3/1 | note:Gb4 ]",
|
||||||
|
"[ 2/1 → 3/1 | note:A4 ]",
|
||||||
|
"[ 3/1 → 4/1 | note:F3 ]",
|
||||||
|
"[ 3/1 → 4/1 | note:C4 ]",
|
||||||
|
"[ 3/1 → 4/1 | note:F4 ]",
|
||||||
|
"[ 3/1 → 4/1 | note:A4 ]",
|
||||||
|
"[ 3/1 → 4/1 | note:C5 ]",
|
||||||
|
]
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`runs examples > example "chorus" example index 0 1`] = `
|
exports[`runs examples > example "chorus" example index 0 1`] = `
|
||||||
[
|
[
|
||||||
"[ 0/1 → 1/4 | note:d s:sawtooth chorus:0.5 ]",
|
"[ 0/1 → 1/4 | note:d s:sawtooth chorus:0.5 ]",
|
||||||
@@ -2739,6 +2789,23 @@ exports[`runs examples > example "detune" example index 0 1`] = `
|
|||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`runs examples > example "dictionary" example index 0 1`] = `
|
||||||
|
[
|
||||||
|
"[ 0/1 → 1/1 | note:A3 room:0.5 ]",
|
||||||
|
"[ 0/1 → 1/1 | note:C4 room:0.5 ]",
|
||||||
|
"[ 0/1 → 1/1 | note:E4 room:0.5 ]",
|
||||||
|
"[ 1/1 → 2/1 | note:G3 room:0.5 ]",
|
||||||
|
"[ 1/1 → 2/1 | note:C4 room:0.5 ]",
|
||||||
|
"[ 1/1 → 2/1 | note:E4 room:0.5 ]",
|
||||||
|
"[ 2/1 → 3/1 | note:A3 room:0.5 ]",
|
||||||
|
"[ 2/1 → 3/1 | note:D4 room:0.5 ]",
|
||||||
|
"[ 2/1 → 3/1 | note:Gb4 room:0.5 ]",
|
||||||
|
"[ 3/1 → 4/1 | note:A3 room:0.5 ]",
|
||||||
|
"[ 3/1 → 4/1 | note:C4 room:0.5 ]",
|
||||||
|
"[ 3/1 → 4/1 | note:F4 room:0.5 ]",
|
||||||
|
]
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`runs examples > example "distort" example index 0 1`] = `
|
exports[`runs examples > example "distort" example index 0 1`] = `
|
||||||
[
|
[
|
||||||
"[ 0/1 → 1/8 | s:hh distort:0 ]",
|
"[ 0/1 → 1/8 | s:hh distort:0 ]",
|
||||||
@@ -6496,6 +6563,28 @@ exports[`runs examples > example "miditouch" example index 0 1`] = `
|
|||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`runs examples > example "mode" example index 0 1`] = `
|
||||||
|
[
|
||||||
|
"[ 0/1 → 1/1 | note:E3 ]",
|
||||||
|
"[ 0/1 → 1/1 | note:C4 ]",
|
||||||
|
"[ 0/1 → 1/1 | note:E4 ]",
|
||||||
|
"[ 0/1 → 1/1 | note:G4 ]",
|
||||||
|
"[ 0/1 → 1/1 | note:C5 ]",
|
||||||
|
"[ 1/1 → 2/1 | note:C5 ]",
|
||||||
|
"[ 1/1 → 2/1 | note:G5 ]",
|
||||||
|
"[ 1/1 → 2/1 | note:C6 ]",
|
||||||
|
"[ 1/1 → 2/1 | note:E6 ]",
|
||||||
|
"[ 2/1 → 3/1 | note:E3 ]",
|
||||||
|
"[ 2/1 → 3/1 | note:C4 ]",
|
||||||
|
"[ 2/1 → 3/1 | note:E4 ]",
|
||||||
|
"[ 2/1 → 3/1 | note:G4 ]",
|
||||||
|
"[ 3/1 → 4/1 | note:C5 ]",
|
||||||
|
"[ 3/1 → 4/1 | note:G5 ]",
|
||||||
|
"[ 3/1 → 4/1 | note:C6 ]",
|
||||||
|
"[ 3/1 → 4/1 | note:E6 ]",
|
||||||
|
]
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`runs examples > example "morph" example index 0 1`] = `
|
exports[`runs examples > example "morph" example index 0 1`] = `
|
||||||
[
|
[
|
||||||
"[ 0/1 → 1/8 | s:hh ]",
|
"[ 0/1 → 1/8 | s:hh ]",
|
||||||
@@ -6814,6 +6903,31 @@ exports[`runs examples > example "octave" example index 0 1`] = `
|
|||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`runs examples > example "octaves" example index 0 1`] = `
|
||||||
|
[
|
||||||
|
"[ 0/1 → 1/1 | note:A3 ]",
|
||||||
|
"[ 0/1 → 1/1 | note:C4 ]",
|
||||||
|
"[ 0/1 → 1/1 | note:E4 ]",
|
||||||
|
"[ 0/1 → 1/1 | note:A4 ]",
|
||||||
|
"[ 0/1 → 1/1 | note:C5 ]",
|
||||||
|
"[ 1/1 → 2/1 | note:E3 ]",
|
||||||
|
"[ 1/1 → 2/1 | note:C4 ]",
|
||||||
|
"[ 1/1 → 2/1 | note:E4 ]",
|
||||||
|
"[ 1/1 → 2/1 | note:G4 ]",
|
||||||
|
"[ 1/1 → 2/1 | note:C5 ]",
|
||||||
|
"[ 2/1 → 3/1 | note:D3 ]",
|
||||||
|
"[ 2/1 → 3/1 | note:A3 ]",
|
||||||
|
"[ 2/1 → 3/1 | note:D4 ]",
|
||||||
|
"[ 2/1 → 3/1 | note:Gb4 ]",
|
||||||
|
"[ 2/1 → 3/1 | note:A4 ]",
|
||||||
|
"[ 3/1 → 4/1 | note:F3 ]",
|
||||||
|
"[ 3/1 → 4/1 | note:C4 ]",
|
||||||
|
"[ 3/1 → 4/1 | note:F4 ]",
|
||||||
|
"[ 3/1 → 4/1 | note:A4 ]",
|
||||||
|
"[ 3/1 → 4/1 | note:C5 ]",
|
||||||
|
]
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`runs examples > example "off" example index 0 1`] = `
|
exports[`runs examples > example "off" example index 0 1`] = `
|
||||||
[
|
[
|
||||||
"[ -5/24 ⇜ (0/1 → 1/8) | note:62 ]",
|
"[ -5/24 ⇜ (0/1 → 1/8) | note:62 ]",
|
||||||
@@ -6847,6 +6961,15 @@ exports[`runs examples > example "off" example index 0 1`] = `
|
|||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`runs examples > example "offset" example index 0 1`] = `
|
||||||
|
[
|
||||||
|
"[ 0/1 → 1/1 | chord:Am offset:0 ]",
|
||||||
|
"[ 1/1 → 2/1 | chord:C offset:1 ]",
|
||||||
|
"[ 2/1 → 3/1 | chord:D offset:2 ]",
|
||||||
|
"[ 3/1 → 4/1 | chord:F offset:3 ]",
|
||||||
|
]
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`runs examples > example "often" example index 0 1`] = `
|
exports[`runs examples > example "often" example index 0 1`] = `
|
||||||
[
|
[
|
||||||
"[ 0/1 → 1/8 | s:hh speed:0.5 ]",
|
"[ 0/1 → 1/8 | s:hh speed:0.5 ]",
|
||||||
@@ -9214,6 +9337,43 @@ exports[`runs examples > example "scale" example index 4 1`] = `
|
|||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`runs examples > example "scale" example index 5 1`] = `
|
||||||
|
[
|
||||||
|
"[ 0/1 → 1/8 | note:C3 ]",
|
||||||
|
"[ 1/8 → 1/4 | note:C3 ]",
|
||||||
|
"[ 1/4 → 3/8 | note:D3 ]",
|
||||||
|
"[ 3/8 → 1/2 | note:Eb3 ]",
|
||||||
|
"[ 1/2 → 5/8 | note:E3 ]",
|
||||||
|
"[ 5/8 → 3/4 | note:G3 ]",
|
||||||
|
"[ 3/4 → 7/8 | note:A3 ]",
|
||||||
|
"[ 7/8 → 1/1 | note:C4 ]",
|
||||||
|
"[ 1/1 → 9/8 | note:C3 ]",
|
||||||
|
"[ 9/8 → 5/4 | note:C3 ]",
|
||||||
|
"[ 5/4 → 11/8 | note:D3 ]",
|
||||||
|
"[ 11/8 → 3/2 | note:Eb3 ]",
|
||||||
|
"[ 3/2 → 13/8 | note:E3 ]",
|
||||||
|
"[ 13/8 → 7/4 | note:G3 ]",
|
||||||
|
"[ 7/4 → 15/8 | note:A3 ]",
|
||||||
|
"[ 15/8 → 2/1 | note:C4 ]",
|
||||||
|
"[ 2/1 → 17/8 | note:C3 ]",
|
||||||
|
"[ 17/8 → 9/4 | note:C3 ]",
|
||||||
|
"[ 9/4 → 19/8 | note:D3 ]",
|
||||||
|
"[ 19/8 → 5/2 | note:Eb3 ]",
|
||||||
|
"[ 5/2 → 21/8 | note:E3 ]",
|
||||||
|
"[ 21/8 → 11/4 | note:G3 ]",
|
||||||
|
"[ 11/4 → 23/8 | note:A3 ]",
|
||||||
|
"[ 23/8 → 3/1 | note:C4 ]",
|
||||||
|
"[ 3/1 → 25/8 | note:C3 ]",
|
||||||
|
"[ 25/8 → 13/4 | note:C3 ]",
|
||||||
|
"[ 13/4 → 27/8 | note:D3 ]",
|
||||||
|
"[ 27/8 → 7/2 | note:Eb3 ]",
|
||||||
|
"[ 7/2 → 29/8 | note:E3 ]",
|
||||||
|
"[ 29/8 → 15/4 | note:G3 ]",
|
||||||
|
"[ 15/4 → 31/8 | note:A3 ]",
|
||||||
|
"[ 31/8 → 4/1 | note:C4 ]",
|
||||||
|
]
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`runs examples > example "scaleTranspose" example index 0 1`] = `
|
exports[`runs examples > example "scaleTranspose" example index 0 1`] = `
|
||||||
[
|
[
|
||||||
"[ 0/1 → 1/2 | note:C3 ]",
|
"[ 0/1 → 1/2 | note:C3 ]",
|
||||||
|
|||||||
+6336
-6336
File diff suppressed because it is too large
Load Diff
+15
-1
@@ -4,11 +4,25 @@ import { describe, it } from 'vitest';
|
|||||||
|
|
||||||
const tuneKeys = Object.keys(tunes);
|
const tuneKeys = Object.keys(tunes);
|
||||||
|
|
||||||
|
// Node 24 tightened Number→string rounding; clamp decimals so snapshots stay stable across engines.
|
||||||
|
const roundFloatStrings = (input, precision = 12) => {
|
||||||
|
// if matches a decimal number ex: 12.34, -0.5, 0.123, 99.0, 1.932093850293
|
||||||
|
const regex = /-?\d+\.\d+/g;
|
||||||
|
return input.replace(regex, (match) => {
|
||||||
|
// converts the literal to a number, performs round to nearest (ties to even)
|
||||||
|
// at the requested precision, and returns the rounded decimal string
|
||||||
|
const rounded = Number(match).toFixed(precision);
|
||||||
|
// trims trailing zeros (and a dangling dot) after rounding, so the displayed string looks tidy
|
||||||
|
return rounded.replace(/\.?0+$/, '').replace(/\.$/, '');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
describe('renders tunes', () => {
|
describe('renders tunes', () => {
|
||||||
tuneKeys.forEach((key) => {
|
tuneKeys.forEach((key) => {
|
||||||
it(`tune: ${key}`, async ({ expect }) => {
|
it(`tune: ${key}`, async ({ expect }) => {
|
||||||
const haps = await queryCode(tunes[key], testCycles[key] || 1);
|
const haps = await queryCode(tunes[key], testCycles[key] || 1);
|
||||||
expect(haps).toMatchSnapshot();
|
const normalized = haps.map((hap) => roundFloatStrings(hap));
|
||||||
|
expect(normalized).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"csv": "^6.3.11"
|
"csv": "^6.3.11"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,5 +75,8 @@
|
|||||||
"sharp": "^0.33.5",
|
"sharp": "^0.33.5",
|
||||||
"workbox-window": "^7.3.0",
|
"workbox-window": "^7.3.0",
|
||||||
"vite-plugin-bundle-audioworklet": "workspace:*"
|
"vite-plugin-bundle-audioworklet": "workspace:*"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ You can also create custom aliases for existing sounds using the `soundAlias` fu
|
|||||||
|
|
||||||
<MiniRepl
|
<MiniRepl
|
||||||
client:idle
|
client:idle
|
||||||
tune={`soundAlias("RolandTR808_bd", "kick")
|
tune={`soundAlias('RolandTR808_bd', 'kick')
|
||||||
s("kick")`}
|
s("kick")`}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ There are 3 quick ways to embed strudel in your website:
|
|||||||
|
|
||||||
### Inside an iframe
|
### Inside an iframe
|
||||||
|
|
||||||
Using an iframe is the most easy way to embed a studel tune.
|
Using an iframe is the most easy way to embed a strudel tune.
|
||||||
You can embed any pattern of your choice via an iframe and the URL of the pattern of your choice:
|
You can embed any pattern of your choice via an iframe and the URL of the pattern of your choice:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
@@ -133,7 +133,7 @@ If you'd rather use your own UI, you can use the `@strudel/web` package:
|
|||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
For more info on this package, see the [@strudel/web README]https://codeberg.org/uzu/strudel/src/branch/main/packages/web#strudel-web).
|
For more info on this package, see the [@strudel/web README](https://codeberg.org/uzu/strudel/src/branch/main/packages/web#strudel-web).
|
||||||
|
|
||||||
## Via npm
|
## Via npm
|
||||||
|
|
||||||
|
|||||||
@@ -79,13 +79,11 @@ const updateCodeWindow = (context, patternData, reset = false) => {
|
|||||||
context.handleUpdate(patternData, reset);
|
context.handleUpdate(patternData, reset);
|
||||||
};
|
};
|
||||||
|
|
||||||
const autoResetPatternOnChange = !isUdels();
|
|
||||||
|
|
||||||
function UserPatterns({ context }) {
|
function UserPatterns({ context }) {
|
||||||
const activePattern = useActivePattern();
|
const activePattern = useActivePattern();
|
||||||
const viewingPatternStore = useViewingPatternData();
|
const viewingPatternStore = useViewingPatternData();
|
||||||
const viewingPatternData = parseJSON(viewingPatternStore);
|
const viewingPatternData = parseJSON(viewingPatternStore);
|
||||||
const { userPatterns, patternFilter } = useSettings();
|
const { userPatterns, patternFilter, patternAutoStart } = useSettings();
|
||||||
const viewingPatternID = viewingPatternData?.id;
|
const viewingPatternID = viewingPatternData?.id;
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-2 flex-grow overflow-hidden h-full pb-2 ">
|
<div className="flex flex-col gap-2 flex-grow overflow-hidden h-full pb-2 ">
|
||||||
@@ -135,13 +133,13 @@ function UserPatterns({ context }) {
|
|||||||
<div className="overflow-auto h-full bg-background p-2 rounded-md">
|
<div className="overflow-auto h-full bg-background p-2 rounded-md">
|
||||||
{/* {patternFilter === patternFilterName.user && ( */}
|
{/* {patternFilter === patternFilterName.user && ( */}
|
||||||
<PatternButtons
|
<PatternButtons
|
||||||
onClick={(id) =>
|
onClick={(id) => {
|
||||||
updateCodeWindow(
|
updateCodeWindow(context, { ...userPatterns[id], collection: userPattern.collection }, patternAutoStart);
|
||||||
context,
|
|
||||||
{ ...userPatterns[id], collection: userPattern.collection },
|
if (context.started && activePattern === id) {
|
||||||
autoResetPatternOnChange,
|
context.handleEvaluate();
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
}}
|
||||||
patterns={userPatterns}
|
patterns={userPatterns}
|
||||||
started={context.started}
|
started={context.started}
|
||||||
activePattern={activePattern}
|
activePattern={activePattern}
|
||||||
@@ -188,17 +186,14 @@ function FeaturedPatterns({ context }) {
|
|||||||
const examplePatterns = useExamplePatterns();
|
const examplePatterns = useExamplePatterns();
|
||||||
const collections = examplePatterns.collections;
|
const collections = examplePatterns.collections;
|
||||||
const patterns = collections.get(patternFilterName.featured);
|
const patterns = collections.get(patternFilterName.featured);
|
||||||
|
const { patternAutoStart } = useSettings();
|
||||||
return (
|
return (
|
||||||
<PatternPageWithPagination
|
<PatternPageWithPagination
|
||||||
patterns={patterns}
|
patterns={patterns}
|
||||||
context={context}
|
context={context}
|
||||||
initialPage={featuredPageNum}
|
initialPage={featuredPageNum}
|
||||||
patternOnClick={(id) => {
|
patternOnClick={(id) => {
|
||||||
updateCodeWindow(
|
updateCodeWindow(context, { ...patterns[id], collection: patternFilterName.featured }, patternAutoStart);
|
||||||
context,
|
|
||||||
{ ...patterns[id], collection: patternFilterName.featured },
|
|
||||||
autoResetPatternOnChange,
|
|
||||||
);
|
|
||||||
}}
|
}}
|
||||||
paginationOnChange={async (pageNum) => {
|
paginationOnChange={async (pageNum) => {
|
||||||
await loadAndSetFeaturedPatterns(pageNum - 1);
|
await loadAndSetFeaturedPatterns(pageNum - 1);
|
||||||
@@ -213,13 +208,14 @@ function LatestPatterns({ context }) {
|
|||||||
const examplePatterns = useExamplePatterns();
|
const examplePatterns = useExamplePatterns();
|
||||||
const collections = examplePatterns.collections;
|
const collections = examplePatterns.collections;
|
||||||
const patterns = collections.get(patternFilterName.public);
|
const patterns = collections.get(patternFilterName.public);
|
||||||
|
const { patternAutoStart } = useSettings();
|
||||||
return (
|
return (
|
||||||
<PatternPageWithPagination
|
<PatternPageWithPagination
|
||||||
patterns={patterns}
|
patterns={patterns}
|
||||||
context={context}
|
context={context}
|
||||||
initialPage={latestPageNum}
|
initialPage={latestPageNum}
|
||||||
patternOnClick={(id) => {
|
patternOnClick={(id) => {
|
||||||
updateCodeWindow(context, { ...patterns[id], collection: patternFilterName.public }, autoResetPatternOnChange);
|
updateCodeWindow(context, { ...patterns[id], collection: patternFilterName.public }, patternAutoStart);
|
||||||
}}
|
}}
|
||||||
paginationOnChange={async (pageNum) => {
|
paginationOnChange={async (pageNum) => {
|
||||||
await loadAndSetPublicPatterns(pageNum - 1);
|
await loadAndSetPublicPatterns(pageNum - 1);
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ export function SettingsTab({ started }) {
|
|||||||
multiChannelOrbits,
|
multiChannelOrbits,
|
||||||
isTabIndentationEnabled,
|
isTabIndentationEnabled,
|
||||||
isMultiCursorEnabled,
|
isMultiCursorEnabled,
|
||||||
|
patternAutoStart,
|
||||||
} = useSettings();
|
} = useSettings();
|
||||||
const shouldAlwaysSync = isUdels();
|
const shouldAlwaysSync = isUdels();
|
||||||
const canChangeAudioDevice = AudioContext.prototype.setSinkId != null;
|
const canChangeAudioDevice = AudioContext.prototype.setSinkId != null;
|
||||||
@@ -304,6 +305,11 @@ export function SettingsTab({ started }) {
|
|||||||
onChange={(cbEvent) => settingsMap.setKey('isCSSAnimationDisabled', cbEvent.target.checked)}
|
onChange={(cbEvent) => settingsMap.setKey('isCSSAnimationDisabled', cbEvent.target.checked)}
|
||||||
value={isCSSAnimationDisabled}
|
value={isCSSAnimationDisabled}
|
||||||
/>
|
/>
|
||||||
|
<Checkbox
|
||||||
|
label="Auto-start pattern on pattern change"
|
||||||
|
onChange={(cbEvent) => settingsMap.setKey('patternAutoStart', cbEvent.target.checked)}
|
||||||
|
value={patternAutoStart}
|
||||||
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem label="Zen Mode">Try clicking the logo in the top left!</FormItem>
|
<FormItem label="Zen Mode">Try clicking the logo in the top left!</FormItem>
|
||||||
<FormItem label="Reset Settings">
|
<FormItem label="Reset Settings">
|
||||||
|
|||||||
@@ -62,11 +62,9 @@ export function SoundsTab() {
|
|||||||
|
|
||||||
// stop current sound on mouseup
|
// stop current sound on mouseup
|
||||||
useEvent('mouseup', () => {
|
useEvent('mouseup', () => {
|
||||||
const t = trigRef.current;
|
const ref = trigRef.current;
|
||||||
trigRef.current = undefined;
|
trigRef.current = undefined;
|
||||||
t?.then((ref) => {
|
ref?.stop?.(getAudioContext().currentTime + 0.01);
|
||||||
ref?.stop(getAudioContext().currentTime + 0.01);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
return (
|
return (
|
||||||
<div id="sounds-tab" className="px-4 flex gap-2 flex-col w-full h-full text-foreground">
|
<div id="sounds-tab" className="px-4 flex gap-2 flex-col w-full h-full text-foreground">
|
||||||
@@ -124,12 +122,19 @@ export function SoundsTab() {
|
|||||||
duration: 0.5,
|
duration: 0.5,
|
||||||
};
|
};
|
||||||
soundPreviewIdx++;
|
soundPreviewIdx++;
|
||||||
const time = ctx.currentTime + 0.05;
|
|
||||||
const onended = () => trigRef.current?.node?.disconnect();
|
const onended = () => trigRef.current?.node?.disconnect();
|
||||||
trigRef.current = Promise.resolve(onTrigger(time, params, onended));
|
try {
|
||||||
trigRef.current.then((ref) => {
|
// Pre-load the sample by calling onTrigger with a future time
|
||||||
connectToDestination(ref?.node);
|
// This triggers the loading but schedules playback for later
|
||||||
});
|
const time = ctx.currentTime + 0.5; // Give 500ms for loading
|
||||||
|
const ref = await onTrigger(time, params, onended);
|
||||||
|
trigRef.current = ref;
|
||||||
|
if (ref?.node) {
|
||||||
|
connectToDestination(ref.node);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.warn('Failed to trigger sound:', err);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{' '}
|
{' '}
|
||||||
|
|||||||
@@ -96,6 +96,11 @@ export function useSettings() {
|
|||||||
isPanelOpen: parseBoolean(state.isPanelOpen),
|
isPanelOpen: parseBoolean(state.isPanelOpen),
|
||||||
userPatterns: userPatterns,
|
userPatterns: userPatterns,
|
||||||
multiChannelOrbits: parseBoolean(state.multiChannelOrbits),
|
multiChannelOrbits: parseBoolean(state.multiChannelOrbits),
|
||||||
|
patternAutoStart: isUdels()
|
||||||
|
? false
|
||||||
|
: state.patternAutoStart === undefined
|
||||||
|
? true
|
||||||
|
: parseBoolean(state.patternAutoStart),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user