Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some tunes #247

Merged
merged 11 commits into from
Nov 6, 2022
4 changes: 4 additions & 0 deletions packages/webaudio/sampler.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
138 changes: 138 additions & 0 deletions repl/src/test/__snapshots__/tunes.test.mjs.snap
Original file line number Diff line number Diff line change
@@ -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}",
Expand Down Expand Up @@ -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\\"}",
Expand Down Expand Up @@ -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}",
Expand Down Expand Up @@ -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\\"}",
Expand Down Expand Up @@ -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}",
Expand Down Expand Up @@ -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\\"}",
Expand Down
127 changes: 127 additions & 0 deletions repl/src/tunes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -854,3 +854,130 @@ export const orbit = `stack(
.delayfeedback(.7)
.orbit(2)
).sometimes(x=>x.speed("-1"))`;

export const belldub = `samples({ bell: {b4:'https://cdn.freesound.org/previews/339/339809_5121236-lq.mp3'}})
// "Hand Bells, B, Single.wav" by InspectorJ (www.jshaw.co.uk) of Freesound.org
stack(
// bass
note("[0 ~] [2 [0 2]] [4 4*2] [[4 ~] [2 ~] 0@2]".scale('g1 dorian').superimpose(x=>x.add(.02)))
.s('sawtooth').cutoff(200).resonance(20).gain(.15).shape(.6).release(.05),
// perc
s("[~ hh]*4").room("0 0.5".fast(2)).end(perlin.range(0.02,1)),
s("mt lt ht").struct("x(3,8)").fast(2).gain(.5).room(.5).sometimes(x=>x.speed(".5")),
s("misc:2").speed(1).delay(.5).delaytime(1/3).gain(.4),
// chords
note("[~ Gm7] ~ [~ Dm7] ~".voicings().superimpose(x=>x.add(.1)))
.s('sawtooth').gain(.5)
.cutoff(perlin.range(400,3000).slow(8))
.decay(perlin.range(0.05,.2)).sustain(0)
.delay(.9).room(1),
// blips
note(
"0 5 4 2".iter(4)
.off(1/3, add(7))
.scale('g4 dorian')
).s('square').cutoff(2000).decay(.03).sustain(0)
.degradeBy(.2)
.orbit(2).delay(.2).delaytime(".33 | .6 | .166 | .25")
.room(1).gain(.5).mask("<0 1>/8"),
// bell
note(rand.range(0,12).struct("x(5,8)").scale('g2 minor pentatonic')).s('bell').begin(.05)
.delay(.2).degradeBy(.4).gain(.4)
.mask("<1 0>/8")
).slow(5)`;

export const dinofunk = `samples({bass:'https://cdn.freesound.org/previews/614/614637_2434927-hq.mp3',
dino:{b4:'https://cdn.freesound.org/previews/316/316403_5123851-hq.mp3'}})

stack(
s('bass').loopAt(8,1).clip(1),
s("bd*2, ~ sd,hh*4"),
note("Abm7".voicings(['c3','a4']).struct("x(3,8,1)".slow(2))),
"0 1 2 3".scale('ab4 minor pentatonic')
.superimpose(x=>x.add(.1))
.sometimes(x=>x.add(12))
.note().s('sawtooth')
.cutoff(sine.range(400,2000).slow(16)).gain(.8)
.decay(perlin.range(.05,.2)).sustain(0)
.delay(sine.range(0,.5).slow(32))
.degradeBy(.4).room(1),
note("<b4 eb4>").s('dino').delay(.8).slow(8).room(.5)
)`;

export const sampleDemo = `stack(
// percussion
s("[woodblock:1 woodblock:2*2] snare_rim:0,gong/8,brakedrum:1(3,8),~@3 cowbell:3")
.sometimes(x=>x.speed(2)),
// melody
note("<0 4 1 3 2>".off(".25 | .125",add(2)).scale('D3 hirajoshi'))
.s("clavisynth").gain(.2).delay(.25).jux(rev)
.degradeBy(sine.range(0,.5).slow(32)),
// bass
note("<0@3 <2(3,8) 3(3,8)>>".scale('D1 hirajoshi'))
.s('psaltery_pluck').gain(.6).clip(1)
.release(.1).room(.5)
)`;

export const holyflute = `"c3 eb3(3,8) c4/2 g3*2"
.superimpose(
x=>x.slow(2).add(12),
x=>x.slow(4).sub(5)
).add("<0 1>/16")
.note().s('ocarina_vib').clip(1)
.release(.1).room(1).gain(.2)
.color("salmon | orange | darkseagreen")
.pianoroll({fold:0,autorange:0,vertical:0,cycles:12,smear:0,minMidi:40})
`;

export const flatrave = `stack(
s("bd*2,~ [cp,sd]").bank('RolandTR909'),

s("hh:1*4").sometimes(fast("2"))
.rarely(x=>x.speed(".5").delay(.5))
.end(perlin.range(0.02,.05).slow(8))
.bank('RolandTR909').room(.5)
.gain("0.4,0.4(5,8)"),

note("<0 2 5 3>".scale('G1 minor')).struct("x(5,8)")
.s('sawtooth').decay(.1).sustain(0),

note("<G4 A4 Bb4 A4>,Bb3,D3").struct("~ x*2").s('square').clip(1)
.cutoff(sine.range(500,4000).slow(16)).resonance(10)
.decay(sine.slow(15).range(.05,.2)).sustain(0)
.room(.5).gain(.3).delay(.2).mask("<0 1@3>/8"),

"0 5 3 2".sometimes(slow(2)).off(1/8,add(5)).scale('G4 minor').note()
.decay(.05).sustain(0).delay(.2).degradeBy(.5).mask("<0 1>/16")
)`;

export const amensister = `samples('github:tidalcycles/Dirt-Samples/master')

stack(
// amen
n("0 1 2 3 4 5 6 7")
.sometimes(x=>x.ply(2))
.rarely(x=>x.speed("2 | -2"))
.sometimesBy(.4, x=>x.delay(".5"))
.s("amencutup")
.slow(2)
.room(.5)
,
// bass
sine.add(saw.slow(4)).range(0,7).segment(8)
.superimpose(x=>x.add(.1))
.scale('G0 minor').note()
.s("sawtooth").decay(.1).sustain(0)
.gain(.4).cutoff(perlin.range(300,3000).slow(8)).resonance(10)
.degradeBy("0 0.1 .5 .1")
.rarely(add(note("12")))
,
// chord
note("Bb3,D4".superimpose(x=>x.add(.2)))
.s('sawtooth').cutoff(1000).struct("<~@3 [~ x]>")
.decay(.05).sustain(.0).delay(.8).delaytime(.125).room(.8)
,
// alien
s("breath").room(1).shape(.6).chop(16).rev().mask("<x ~@7>")
,
n("0 1").s("east").delay(.5).degradeBy(.8).speed(rand.range(.5,1.5))
).reset("<x@7 x(5,8)>")`;