fix: samples function did not work in tests

This commit is contained in:
Felix Roos 2022-11-06 00:44:23 +01:00
parent da8e00eb4e
commit 866277510e
2 changed files with 142 additions and 0 deletions

View File

@ -108,6 +108,10 @@ export const samples = async (sampleMap, baseUrl = sampleMap._base || '') => {
const [_, path] = sampleMap.split('github:');
sampleMap = `https://raw.githubusercontent.com/${path}/strudel.json`;
}
if (typeof fetch !== 'function') {
// not a browser
return;
}
const base = sampleMap.split('/').slice(0, -1).join('/');
return fetch(sampleMap)
.then((res) => res.json())

View File

@ -1,5 +1,44 @@
// Vitest Snapshot v1
exports[`renders tunes > tune: amensister 1`] = `
[
"0/1 -> 1/4: {\\"n\\":0,\\"s\\":\\"amencutup\\",\\"room\\":0.5}",
"1/2 -> 3/4: {\\"n\\":2,\\"s\\":\\"amencutup\\",\\"room\\":0.5}",
"3/8 -> 1/2: {\\"n\\":1,\\"s\\":\\"amencutup\\",\\"room\\":0.5}",
"3/4 -> 7/8: {\\"n\\":3,\\"s\\":\\"amencutup\\",\\"room\\":0.5}",
"7/8 -> 1/1: {\\"n\\":3,\\"s\\":\\"amencutup\\",\\"room\\":0.5}",
"1/4 -> 3/8: {\\"n\\":1,\\"speed\\":-2,\\"delay\\":0.5,\\"s\\":\\"amencutup\\",\\"room\\":0.5}",
"0/1 -> 1/8: {\\"note\\":\\"Eb1\\",\\"s\\":\\"sawtooth\\",\\"decay\\":0.1,\\"sustain\\":0,\\"gain\\":0.4,\\"cutoff\\":300.0066107586751,\\"resonance\\":10}",
"0/1 -> 1/8: {\\"note\\":\\"F1\\",\\"s\\":\\"sawtooth\\",\\"decay\\":0.1,\\"sustain\\":0,\\"gain\\":0.4,\\"cutoff\\":300.0066107586751,\\"resonance\\":10}",
"1/4 -> 3/8: {\\"note\\":\\"A1\\",\\"s\\":\\"sawtooth\\",\\"decay\\":0.1,\\"sustain\\":0,\\"gain\\":0.4,\\"cutoff\\":300.7878869297153,\\"resonance\\":10}",
"3/8 -> 1/2: {\\"note\\":\\"F1\\",\\"s\\":\\"sawtooth\\",\\"decay\\":0.1,\\"sustain\\":0,\\"gain\\":0.4,\\"cutoff\\":302.11020572391345,\\"resonance\\":10}",
"1/4 -> 3/8: {\\"note\\":\\"A1\\",\\"s\\":\\"sawtooth\\",\\"decay\\":0.1,\\"sustain\\":0,\\"gain\\":0.4,\\"cutoff\\":300.7878869297153,\\"resonance\\":10}",
"3/8 -> 1/2: {\\"note\\":\\"F1\\",\\"s\\":\\"sawtooth\\",\\"decay\\":0.1,\\"sustain\\":0,\\"gain\\":0.4,\\"cutoff\\":302.11020572391345,\\"resonance\\":10}",
"3/4 -> 7/8: {\\"note\\":\\"Bb0\\",\\"s\\":\\"sawtooth\\",\\"decay\\":0.1,\\"sustain\\":0,\\"gain\\":0.4,\\"cutoff\\":312.54769231985796,\\"resonance\\":10}",
"7/8 -> 1/1: {\\"note\\":\\"D1\\",\\"s\\":\\"sawtooth\\",\\"decay\\":0.1,\\"sustain\\":0,\\"gain\\":0.4,\\"cutoff\\":318.7927796831686,\\"resonance\\":10}",
"3/4 -> 7/8: {\\"note\\":\\"Bb0\\",\\"s\\":\\"sawtooth\\",\\"decay\\":0.1,\\"sustain\\":0,\\"gain\\":0.4,\\"cutoff\\":312.54769231985796,\\"resonance\\":10}",
"7/8 -> 1/1: {\\"note\\":\\"D1\\",\\"s\\":\\"sawtooth\\",\\"decay\\":0.1,\\"sustain\\":0,\\"gain\\":0.4,\\"cutoff\\":318.7927796831686,\\"resonance\\":10}",
"1/8 -> 1/4: {\\"note\\":45,\\"s\\":\\"sawtooth\\",\\"decay\\":0.1,\\"sustain\\":0,\\"gain\\":0.4,\\"cutoff\\":300.174310575404,\\"resonance\\":10}",
"1/8 -> 1/4: {\\"note\\":45,\\"s\\":\\"sawtooth\\",\\"decay\\":0.1,\\"sustain\\":0,\\"gain\\":0.4,\\"cutoff\\":300.174310575404,\\"resonance\\":10}",
"15/16 -> 1/1: {\\"s\\":\\"breath\\",\\"room\\":1,\\"shape\\":0.6,\\"begin\\":0,\\"end\\":0.0625}",
"7/8 -> 15/16: {\\"s\\":\\"breath\\",\\"room\\":1,\\"shape\\":0.6,\\"begin\\":0.0625,\\"end\\":0.125}",
"13/16 -> 7/8: {\\"s\\":\\"breath\\",\\"room\\":1,\\"shape\\":0.6,\\"begin\\":0.125,\\"end\\":0.1875}",
"3/4 -> 13/16: {\\"s\\":\\"breath\\",\\"room\\":1,\\"shape\\":0.6,\\"begin\\":0.1875,\\"end\\":0.25}",
"11/16 -> 3/4: {\\"s\\":\\"breath\\",\\"room\\":1,\\"shape\\":0.6,\\"begin\\":0.25,\\"end\\":0.3125}",
"5/8 -> 11/16: {\\"s\\":\\"breath\\",\\"room\\":1,\\"shape\\":0.6,\\"begin\\":0.3125,\\"end\\":0.375}",
"9/16 -> 5/8: {\\"s\\":\\"breath\\",\\"room\\":1,\\"shape\\":0.6,\\"begin\\":0.375,\\"end\\":0.4375}",
"1/2 -> 9/16: {\\"s\\":\\"breath\\",\\"room\\":1,\\"shape\\":0.6,\\"begin\\":0.4375,\\"end\\":0.5}",
"7/16 -> 1/2: {\\"s\\":\\"breath\\",\\"room\\":1,\\"shape\\":0.6,\\"begin\\":0.5,\\"end\\":0.5625}",
"3/8 -> 7/16: {\\"s\\":\\"breath\\",\\"room\\":1,\\"shape\\":0.6,\\"begin\\":0.5625,\\"end\\":0.625}",
"5/16 -> 3/8: {\\"s\\":\\"breath\\",\\"room\\":1,\\"shape\\":0.6,\\"begin\\":0.625,\\"end\\":0.6875}",
"1/4 -> 5/16: {\\"s\\":\\"breath\\",\\"room\\":1,\\"shape\\":0.6,\\"begin\\":0.6875,\\"end\\":0.75}",
"3/16 -> 1/4: {\\"s\\":\\"breath\\",\\"room\\":1,\\"shape\\":0.6,\\"begin\\":0.75,\\"end\\":0.8125}",
"1/8 -> 3/16: {\\"s\\":\\"breath\\",\\"room\\":1,\\"shape\\":0.6,\\"begin\\":0.8125,\\"end\\":0.875}",
"1/16 -> 1/8: {\\"s\\":\\"breath\\",\\"room\\":1,\\"shape\\":0.6,\\"begin\\":0.875,\\"end\\":0.9375}",
"0/1 -> 1/16: {\\"s\\":\\"breath\\",\\"room\\":1,\\"shape\\":0.6,\\"begin\\":0.9375,\\"end\\":1}",
]
`;
exports[`renders tunes > tune: barryHarris 1`] = `
[
"0/1 -> 2/1: {\\"note\\":\\"C3\\",\\"clip\\":1,\\"s\\":\\"piano\\",\\"release\\":0.1,\\"pan\\":0.4722222222222222}",
@ -240,6 +279,25 @@ exports[`renders tunes > tune: bassFuge 1`] = `
]
`;
exports[`renders tunes > tune: belldub 1`] = `
[
"0/1 -> 5/8: {\\"note\\":\\"G1\\",\\"s\\":\\"sawtooth\\",\\"cutoff\\":200,\\"resonance\\":20,\\"gain\\":0.15,\\"shape\\":0.6,\\"release\\":0.05}",
"0/1 -> 5/8: {\\"note\\":31.02,\\"s\\":\\"sawtooth\\",\\"cutoff\\":200,\\"resonance\\":20,\\"gain\\":0.15,\\"shape\\":0.6,\\"release\\":0.05}",
"5/8 -> 5/4: {\\"s\\":\\"hh\\",\\"room\\":0,\\"end\\":0.04483079938329212}",
"0/1 -> 5/16: {\\"s\\":\\"mt\\",\\"gain\\":0.5,\\"room\\":0.5}",
"15/16 -> 5/4: {\\"s\\":\\"lt\\",\\"gain\\":0.5,\\"room\\":0.5}",
"0/1 -> 5/1: {\\"s\\":\\"misc:2\\",\\"speed\\":1,\\"delay\\":0.5,\\"delaytime\\":0.3333333333333333,\\"gain\\":0.4}",
"5/8 -> 5/4: {\\"note\\":\\"Bb3\\",\\"s\\":\\"sawtooth\\",\\"gain\\":0.5,\\"cutoff\\":400.16785462816676,\\"decay\\":0.05380063255866716,\\"sustain\\":0,\\"delay\\":0.9,\\"room\\":1}",
"5/8 -> 5/4: {\\"note\\":\\"D4\\",\\"s\\":\\"sawtooth\\",\\"gain\\":0.5,\\"cutoff\\":400.16785462816676,\\"decay\\":0.05380063255866716,\\"sustain\\":0,\\"delay\\":0.9,\\"room\\":1}",
"5/8 -> 5/4: {\\"note\\":\\"F4\\",\\"s\\":\\"sawtooth\\",\\"gain\\":0.5,\\"cutoff\\":400.16785462816676,\\"decay\\":0.05380063255866716,\\"sustain\\":0,\\"delay\\":0.9,\\"room\\":1}",
"5/8 -> 5/4: {\\"note\\":\\"A4\\",\\"s\\":\\"sawtooth\\",\\"gain\\":0.5,\\"cutoff\\":400.16785462816676,\\"decay\\":0.05380063255866716,\\"sustain\\":0,\\"delay\\":0.9,\\"room\\":1}",
"5/8 -> 5/4: {\\"note\\":58.1,\\"s\\":\\"sawtooth\\",\\"gain\\":0.5,\\"cutoff\\":400.16785462816676,\\"decay\\":0.05380063255866716,\\"sustain\\":0,\\"delay\\":0.9,\\"room\\":1}",
"5/8 -> 5/4: {\\"note\\":62.1,\\"s\\":\\"sawtooth\\",\\"gain\\":0.5,\\"cutoff\\":400.16785462816676,\\"decay\\":0.05380063255866716,\\"sustain\\":0,\\"delay\\":0.9,\\"room\\":1}",
"5/8 -> 5/4: {\\"note\\":65.1,\\"s\\":\\"sawtooth\\",\\"gain\\":0.5,\\"cutoff\\":400.16785462816676,\\"decay\\":0.05380063255866716,\\"sustain\\":0,\\"delay\\":0.9,\\"room\\":1}",
"5/8 -> 5/4: {\\"note\\":69.1,\\"s\\":\\"sawtooth\\",\\"gain\\":0.5,\\"cutoff\\":400.16785462816676,\\"decay\\":0.05380063255866716,\\"sustain\\":0,\\"delay\\":0.9,\\"room\\":1}",
]
`;
exports[`renders tunes > tune: blippyRhodes 1`] = `
[
"0/1 -> 1/3: {\\"s\\":\\"bd\\"}",
@ -1358,6 +1416,28 @@ exports[`renders tunes > tune: delay 1`] = `
]
`;
exports[`renders tunes > tune: dinofunk 1`] = `
[
"0/1 -> 8/1: {\\"s\\":\\"bass\\",\\"speed\\":0.125,\\"unit\\":\\"c\\",\\"clip\\":1}",
"0/1 -> 1/2: {\\"s\\":\\"bd\\"}",
"1/2 -> 1/1: {\\"s\\":\\"bd\\"}",
"1/2 -> 1/1: {\\"s\\":\\"sd\\"}",
"0/1 -> 1/4: {\\"s\\":\\"hh\\"}",
"1/4 -> 1/2: {\\"s\\":\\"hh\\"}",
"1/2 -> 3/4: {\\"s\\":\\"hh\\"}",
"3/4 -> 1/1: {\\"s\\":\\"hh\\"}",
"1/4 -> 1/2: {\\"note\\":\\"Gb3\\"}",
"1/4 -> 1/2: {\\"note\\":\\"Bb3\\"}",
"1/4 -> 1/2: {\\"note\\":\\"Cb4\\"}",
"1/4 -> 1/2: {\\"note\\":\\"Eb4\\"}",
"0/1 -> 1/4: {\\"note\\":\\"Ab4\\",\\"s\\":\\"sawtooth\\",\\"cutoff\\":1239.2541394619345,\\"gain\\":0.8,\\"decay\\":0.05125097280354112,\\"sustain\\":0,\\"delay\\":0.2561353071307281,\\"room\\":1}",
"0/1 -> 1/4: {\\"note\\":68.1,\\"s\\":\\"sawtooth\\",\\"cutoff\\":1239.2541394619345,\\"gain\\":0.8,\\"decay\\":0.05125097280354112,\\"sustain\\":0,\\"delay\\":0.2561353071307281,\\"room\\":1}",
"1/4 -> 1/2: {\\"note\\":83,\\"s\\":\\"sawtooth\\",\\"cutoff\\":1317.3843795642892,\\"gain\\":0.8,\\"decay\\":0.07144728658238364,\\"sustain\\":0,\\"delay\\":0.26839114089991684,\\"room\\":1}",
"1/4 -> 1/2: {\\"note\\":83.1,\\"s\\":\\"sawtooth\\",\\"cutoff\\":1317.3843795642892,\\"gain\\":0.8,\\"decay\\":0.07144728658238364,\\"sustain\\":0,\\"delay\\":0.26839114089991684,\\"room\\":1}",
"0/1 -> 8/1: {\\"note\\":\\"b4\\",\\"s\\":\\"dino\\",\\"delay\\":0.8,\\"room\\":0.5}",
]
`;
exports[`renders tunes > tune: echoPiano 1`] = `
[
"0/1 -> 1/2: {\\"note\\":\\"D3\\",\\"clip\\":1,\\"s\\":\\"piano\\",\\"release\\":0.1,\\"pan\\":0.4814814814814815}",
@ -6892,6 +6972,30 @@ exports[`renders tunes > tune: festivalOfFingers3 1`] = `
]
`;
exports[`renders tunes > tune: flatrave 1`] = `
[
"0/1 -> 1/2: {\\"s\\":\\"bd\\",\\"bank\\":\\"RolandTR909\\"}",
"1/2 -> 1/1: {\\"s\\":\\"bd\\",\\"bank\\":\\"RolandTR909\\"}",
"1/2 -> 1/1: {\\"s\\":\\"cp\\",\\"bank\\":\\"RolandTR909\\"}",
"1/2 -> 1/1: {\\"s\\":\\"sd\\",\\"bank\\":\\"RolandTR909\\"}",
"0/1 -> 1/4: {\\"s\\":\\"hh:1\\",\\"end\\":0.02000058072071123,\\"bank\\":\\"RolandTR909\\",\\"room\\":0.5,\\"gain\\":0.4}",
"0/1 -> 1/4: {\\"s\\":\\"hh:1\\",\\"end\\":0.02000058072071123,\\"bank\\":\\"RolandTR909\\",\\"room\\":0.5,\\"gain\\":0.4}",
"1/4 -> 3/8: {\\"s\\":\\"hh:1\\",\\"end\\":0.02000875429921906,\\"bank\\":\\"RolandTR909\\",\\"room\\":0.5,\\"gain\\":0.4}",
"1/4 -> 3/8: {\\"s\\":\\"hh:1\\",\\"end\\":0.02000875429921906,\\"bank\\":\\"RolandTR909\\",\\"room\\":0.5,\\"gain\\":0.4}",
"3/8 -> 1/2: {\\"s\\":\\"hh:1\\",\\"end\\":0.020023446730265706,\\"bank\\":\\"RolandTR909\\",\\"room\\":0.5,\\"gain\\":0.4}",
"5/8 -> 3/4: {\\"s\\":\\"hh:1\\",\\"end\\":0.020086608138500644,\\"bank\\":\\"RolandTR909\\",\\"room\\":0.5,\\"gain\\":0.4}",
"5/8 -> 3/4: {\\"s\\":\\"hh:1\\",\\"end\\":0.020086608138500644,\\"bank\\":\\"RolandTR909\\",\\"room\\":0.5,\\"gain\\":0.4}",
"3/4 -> 7/8: {\\"s\\":\\"hh:1\\",\\"end\\":0.02013941880355398,\\"bank\\":\\"RolandTR909\\",\\"room\\":0.5,\\"gain\\":0.4}",
"1/8 -> 1/4: {\\"s\\":\\"hh:1\\",\\"speed\\":0.5,\\"delay\\":0.5,\\"end\\":0.020001936784171157,\\"bank\\":\\"RolandTR909\\",\\"room\\":0.5,\\"gain\\":0.4}",
"1/8 -> 1/4: {\\"s\\":\\"hh:1\\",\\"speed\\":0.5,\\"delay\\":0.5,\\"end\\":0.020001936784171157,\\"bank\\":\\"RolandTR909\\",\\"room\\":0.5,\\"gain\\":0.4}",
"1/8 -> 1/4: {\\"note\\":\\"G1\\",\\"s\\":\\"sawtooth\\",\\"decay\\":0.1,\\"sustain\\":0}",
"1/4 -> 3/8: {\\"note\\":\\"G1\\",\\"s\\":\\"sawtooth\\",\\"decay\\":0.1,\\"sustain\\":0}",
"1/2 -> 5/8: {\\"note\\":\\"G1\\",\\"s\\":\\"sawtooth\\",\\"decay\\":0.1,\\"sustain\\":0}",
"5/8 -> 3/4: {\\"note\\":\\"G1\\",\\"s\\":\\"sawtooth\\",\\"decay\\":0.1,\\"sustain\\":0}",
"7/8 -> 1/1: {\\"note\\":\\"G1\\",\\"s\\":\\"sawtooth\\",\\"decay\\":0.1,\\"sustain\\":0}",
]
`;
exports[`renders tunes > tune: giantSteps 1`] = `
[
"0/1 -> 5/8: {\\"note\\":\\"F#5\\"}",
@ -7547,6 +7651,23 @@ exports[`renders tunes > tune: goodTimes 1`] = `
]
`;
exports[`renders tunes > tune: holyflute 1`] = `
[
"0/1 -> 1/4: {\\"note\\":48,\\"s\\":\\"ocarina_vib\\",\\"clip\\":1,\\"release\\":0.1,\\"room\\":1,\\"gain\\":0.2}",
"1/4 -> 9/32: {\\"note\\":51,\\"s\\":\\"ocarina_vib\\",\\"clip\\":1,\\"release\\":0.1,\\"room\\":1,\\"gain\\":0.2}",
"11/32 -> 3/8: {\\"note\\":51,\\"s\\":\\"ocarina_vib\\",\\"clip\\":1,\\"release\\":0.1,\\"room\\":1,\\"gain\\":0.2}",
"7/16 -> 15/32: {\\"note\\":51,\\"s\\":\\"ocarina_vib\\",\\"clip\\":1,\\"release\\":0.1,\\"room\\":1,\\"gain\\":0.2}",
"1/2 -> 1/1: {\\"note\\":60,\\"s\\":\\"ocarina_vib\\",\\"clip\\":1,\\"release\\":0.1,\\"room\\":1,\\"gain\\":0.2}",
"3/4 -> 7/8: {\\"note\\":55,\\"s\\":\\"ocarina_vib\\",\\"clip\\":1,\\"release\\":0.1,\\"room\\":1,\\"gain\\":0.2}",
"7/8 -> 1/1: {\\"note\\":55,\\"s\\":\\"ocarina_vib\\",\\"clip\\":1,\\"release\\":0.1,\\"room\\":1,\\"gain\\":0.2}",
"0/1 -> 1/2: {\\"note\\":60,\\"s\\":\\"ocarina_vib\\",\\"clip\\":1,\\"release\\":0.1,\\"room\\":1,\\"gain\\":0.2}",
"1/2 -> 9/16: {\\"note\\":63,\\"s\\":\\"ocarina_vib\\",\\"clip\\":1,\\"release\\":0.1,\\"room\\":1,\\"gain\\":0.2}",
"11/16 -> 3/4: {\\"note\\":63,\\"s\\":\\"ocarina_vib\\",\\"clip\\":1,\\"release\\":0.1,\\"room\\":1,\\"gain\\":0.2}",
"7/8 -> 15/16: {\\"note\\":63,\\"s\\":\\"ocarina_vib\\",\\"clip\\":1,\\"release\\":0.1,\\"room\\":1,\\"gain\\":0.2}",
"0/1 -> 1/1: {\\"note\\":43,\\"s\\":\\"ocarina_vib\\",\\"clip\\":1,\\"release\\":0.1,\\"room\\":1,\\"gain\\":0.2}",
]
`;
exports[`renders tunes > tune: hyperpop 1`] = `
[
"1/8 -> 1/4: {\\"n\\":\\"D1\\",\\"s\\":\\"sawtooth\\",\\"gain\\":0.3,\\"attack\\":0.01,\\"decay\\":0.1,\\"sustain\\":0.5,\\"cutoff\\":1699.6897509708342}",
@ -8451,6 +8572,23 @@ exports[`renders tunes > tune: randomBells 1`] = `
]
`;
exports[`renders tunes > tune: sampleDemo 1`] = `
[
"0/1 -> 1/4: {\\"s\\":\\"woodblock:1\\"}",
"1/4 -> 3/8: {\\"s\\":\\"woodblock:2\\"}",
"0/1 -> 1/8: {\\"s\\":\\"brakedrum:1\\"}",
"3/4 -> 7/8: {\\"s\\":\\"brakedrum:1\\"}",
"3/8 -> 1/2: {\\"s\\":\\"woodblock:2\\",\\"speed\\":2}",
"1/2 -> 1/1: {\\"s\\":\\"snare_rim:0\\",\\"speed\\":2}",
"0/1 -> 8/1: {\\"s\\":\\"gong\\",\\"speed\\":2}",
"3/8 -> 1/2: {\\"s\\":\\"brakedrum:1\\",\\"speed\\":2}",
"3/4 -> 1/1: {\\"s\\":\\"cowbell:3\\",\\"speed\\":2}",
"-7/8 -> 1/8: {\\"note\\":\\"Bb3\\",\\"s\\":\\"clavisynth\\",\\"gain\\":0.2,\\"delay\\":0.25,\\"pan\\":0}",
"-1/8 -> 7/8: {\\"note\\":\\"F3\\",\\"s\\":\\"clavisynth\\",\\"gain\\":0.2,\\"delay\\":0.25,\\"pan\\":1}",
"0/1 -> 3/1: {\\"note\\":\\"D1\\",\\"s\\":\\"psaltery_pluck\\",\\"gain\\":0.6,\\"clip\\":1,\\"release\\":0.1,\\"room\\":0.5}",
]
`;
exports[`renders tunes > tune: sampleDrums 1`] = `
[
"0/1 -> 1/1: {\\"s\\":\\"bd\\"}",