fix test error

- add mock 'midin' and 'sysex'
- typo in sysex example
This commit is contained in:
nkymut 2025-01-25 01:12:38 +08:00
parent d06a75a2cd
commit 393d17a41b
3 changed files with 81 additions and 2 deletions

View File

@ -1669,7 +1669,7 @@ export const { miditouch } = registerControl('miditouch');
* @param {number | Pattern} id Sysex ID * @param {number | Pattern} id Sysex ID
* @param {number | Pattern} data Sysex data * @param {number | Pattern} data Sysex data
* @example * @example
* note("c4").sysex("0x77, "0x01:0x02:0x03:0x04").midichan(1).midi() * note("c4").sysex(["0x77", "0x01:0x02:0x03:0x04"]).midichan(1).midi()
*/ */
export const sysex = register('sysex', (args, pat) => { export const sysex = register('sysex', (args, pat) => {
if (!Array.isArray(args)) { if (!Array.isArray(args)) {

View File

@ -4669,6 +4669,45 @@ exports[`runs examples > example "mask" example index 0 1`] = `
] ]
`; `;
exports[`runs examples > example "midi" example index 0 1`] = `
[
"[ 0/1 → 1/1 | note:c4 midichan:1 ]",
"[ 1/1 → 2/1 | note:c4 midichan:1 ]",
"[ 2/1 → 3/1 | note:c4 midichan:1 ]",
"[ 3/1 → 4/1 | note:c4 midichan:1 ]",
]
`;
exports[`runs examples > example "midichan" example index 0 1`] = `
[
"[ 0/1 → 1/1 | note:c4 midichan:1 ]",
"[ 1/1 → 2/1 | note:c4 midichan:1 ]",
"[ 2/1 → 3/1 | note:c4 midichan:1 ]",
"[ 3/1 → 4/1 | note:c4 midichan:1 ]",
]
`;
exports[`runs examples > example "midin" example index 0 1`] = `
[
"[ 0/1 → 1/4 | note:c cutoff:0 resonance:0 s:sawtooth ]",
"[ 1/4 → 1/2 | note:a cutoff:0 resonance:0 s:sawtooth ]",
"[ 1/2 → 3/4 | note:f cutoff:0 resonance:0 s:sawtooth ]",
"[ 3/4 → 1/1 | note:e cutoff:0 resonance:0 s:sawtooth ]",
"[ 1/1 → 5/4 | note:c cutoff:0 resonance:0 s:sawtooth ]",
"[ 5/4 → 3/2 | note:a cutoff:0 resonance:0 s:sawtooth ]",
"[ 3/2 → 7/4 | note:f cutoff:0 resonance:0 s:sawtooth ]",
"[ 7/4 → 2/1 | note:e cutoff:0 resonance:0 s:sawtooth ]",
"[ 2/1 → 9/4 | note:c cutoff:0 resonance:0 s:sawtooth ]",
"[ 9/4 → 5/2 | note:a cutoff:0 resonance:0 s:sawtooth ]",
"[ 5/2 → 11/4 | note:f cutoff:0 resonance:0 s:sawtooth ]",
"[ 11/4 → 3/1 | note:e cutoff:0 resonance:0 s:sawtooth ]",
"[ 3/1 → 13/4 | note:c cutoff:0 resonance:0 s:sawtooth ]",
"[ 13/4 → 7/2 | note:a cutoff:0 resonance:0 s:sawtooth ]",
"[ 7/2 → 15/4 | note:f cutoff:0 resonance:0 s:sawtooth ]",
"[ 15/4 → 4/1 | note:e cutoff:0 resonance:0 s:sawtooth ]",
]
`;
exports[`runs examples > example "mousex" example index 0 1`] = ` exports[`runs examples > example "mousex" example index 0 1`] = `
[ [
"[ 0/1 → 1/4 | note:C3 ]", "[ 0/1 → 1/4 | note:C3 ]",
@ -8285,6 +8324,33 @@ exports[`runs examples > example "swingBy" example index 0 1`] = `
] ]
`; `;
exports[`runs examples > example "sysex" example index 0 1`] = `
[
"[ 0/1 → 1/1 | note:c4 sysexid:119 sysexdata:[1 2 3 4] midichan:1 ]",
"[ 1/1 → 2/1 | note:c4 sysexid:119 sysexdata:[1 2 3 4] midichan:1 ]",
"[ 2/1 → 3/1 | note:c4 sysexid:119 sysexdata:[1 2 3 4] midichan:1 ]",
"[ 3/1 → 4/1 | note:c4 sysexid:119 sysexdata:[1 2 3 4] midichan:1 ]",
]
`;
exports[`runs examples > example "sysexdata" example index 0 1`] = `
[
"[ 0/1 → 1/1 | note:c4 sysexid:119 sysexdata:[1 2 3 4] midichan:1 ]",
"[ 1/1 → 2/1 | note:c4 sysexid:119 sysexdata:[1 2 3 4] midichan:1 ]",
"[ 2/1 → 3/1 | note:c4 sysexid:119 sysexdata:[1 2 3 4] midichan:1 ]",
"[ 3/1 → 4/1 | note:c4 sysexid:119 sysexdata:[1 2 3 4] midichan:1 ]",
]
`;
exports[`runs examples > example "sysexid" example index 0 1`] = `
[
"[ 0/1 → 1/1 | note:c4 sysexid:119 sysexdata:[1 2 3 4] midichan:1 ]",
"[ 1/1 → 2/1 | note:c4 sysexid:119 sysexdata:[1 2 3 4] midichan:1 ]",
"[ 2/1 → 3/1 | note:c4 sysexid:119 sysexdata:[1 2 3 4] midichan:1 ]",
"[ 3/1 → 4/1 | note:c4 sysexid:119 sysexdata:[1 2 3 4] midichan:1 ]",
]
`;
exports[`runs examples > example "transpose" example index 0 1`] = ` exports[`runs examples > example "transpose" example index 0 1`] = `
[ [
"[ 0/1 → 1/4 | note:C2 ]", "[ 0/1 → 1/4 | note:C2 ]",

View File

@ -11,7 +11,7 @@ import * as webaudio from '@strudel/webaudio';
import { mini, m } from '@strudel/mini/mini.mjs'; import { mini, m } from '@strudel/mini/mini.mjs';
// import * as voicingHelpers from '@strudel/tonal/voicings.mjs'; // import * as voicingHelpers from '@strudel/tonal/voicings.mjs';
// import euclid from '@strudel/core/euclid.mjs'; // import euclid from '@strudel/core/euclid.mjs';
// import '@strudel/midi/midi.mjs'; //import '@strudel/midi/midi.mjs';
import * as tonalHelpers from '@strudel/tonal'; import * as tonalHelpers from '@strudel/tonal';
import '@strudel/xen/xen.mjs'; import '@strudel/xen/xen.mjs';
// import '@strudel/xen/tune.mjs'; // import '@strudel/xen/tune.mjs';
@ -122,6 +122,10 @@ strudel.Pattern.prototype.midi = function () {
return this; return this;
}; };
strudel.Pattern.prototype.midin = function () {
return this;
};
strudel.Pattern.prototype._scope = function () { strudel.Pattern.prototype._scope = function () {
return this; return this;
}; };
@ -164,6 +168,12 @@ const loadCsound = () => {};
const loadCSound = () => {}; const loadCSound = () => {};
const loadcsound = () => {}; const loadcsound = () => {};
const midin = () => {
return (ccNum) => strudel.ref(() => 0); // returns ref with default value 0
};
const sysex = ([id, data]) => {};
// TODO: refactor to evalScope // TODO: refactor to evalScope
evalScope( evalScope(
// Tone, // Tone,
@ -172,6 +182,7 @@ evalScope(
uiHelpersMocked, uiHelpersMocked,
webaudio, webaudio,
tonalHelpers, tonalHelpers,
/* /*
toneHelpers, toneHelpers,
voicingHelpers, voicingHelpers,
@ -179,6 +190,8 @@ evalScope(
uiHelpers, uiHelpers,
*/ */
{ {
midin,
sysex,
// gist, // gist,
// euclid, // euclid,
csound: id, csound: id,