diff --git a/packages/superdough/sampler.mjs b/packages/superdough/sampler.mjs index a7e9c3a3..d0733b14 100644 --- a/packages/superdough/sampler.mjs +++ b/packages/superdough/sampler.mjs @@ -147,7 +147,12 @@ function getSamplesPrefixHandler(url) { * sd: '808sd/SD0010.WAV' * }, 'https://raw.githubusercontent.com/tidalcycles/Dirt-Samples/master/'); * s("[bd ~]*2, [~ hh]*2, ~ sd") - * + * @example + * samples('shabda:noise,chimp:2') + * s("noise ") + * @example + * samples('shabda/speech/fr-FR/f:chocolat') + * s("chocolat*4") */ export const samples = async (sampleMap, baseUrl = sampleMap._base || '', options = {}) => { @@ -162,6 +167,21 @@ export const samples = async (sampleMap, baseUrl = sampleMap._base || '', option path = path.endsWith('/') ? path.slice(0, -1) : path; sampleMap = `https://raw.githubusercontent.com/${path}/strudel.json`; } + if (sampleMap.startsWith('shabda:')) { + let [_, path] = sampleMap.split('shabda:'); + sampleMap = `https://shabda.ndre.gr/${path}.json?strudel=1`; + } + if (sampleMap.startsWith('shabda/speech')) { + let [_, path] = sampleMap.split('shabda/speech'); + path = path.startsWith('/') ? path.substring(1) : path; + let [params, words] = path.split(':'); + let gender = 'f'; + let language = 'en-GB'; + if (params) { + [language, gender] = params.split('/'); + } + sampleMap = `https://shabda.ndre.gr/speech/${words}.json?gender=${gender}&language=${language}&strudel=1'`; + } if (typeof fetch !== 'function') { // not a browser return; diff --git a/test/__snapshots__/examples.test.mjs.snap b/test/__snapshots__/examples.test.mjs.snap index ed0249f3..62c2f0d8 100644 --- a/test/__snapshots__/examples.test.mjs.snap +++ b/test/__snapshots__/examples.test.mjs.snap @@ -3981,6 +3981,42 @@ exports[`runs examples > example "samples" example index 1 1`] = ` ] `; +exports[`runs examples > example "samples" example index 2 1`] = ` +[ + "[ 0/1 → 1/2 | s:noise ]", + "[ 1/2 → 3/4 | s:chimp n:0 ]", + "[ 3/4 → 1/1 | s:chimp n:0 ]", + "[ 1/1 → 3/2 | s:noise ]", + "[ 3/2 → 2/1 | s:chimp n:1 ]", + "[ 2/1 → 5/2 | s:noise ]", + "[ 5/2 → 11/4 | s:chimp n:0 ]", + "[ 11/4 → 3/1 | s:chimp n:0 ]", + "[ 3/1 → 7/2 | s:noise ]", + "[ 7/2 → 4/1 | s:chimp n:1 ]", +] +`; + +exports[`runs examples > example "samples" example index 3 1`] = ` +[ + "[ 0/1 → 1/4 | s:chocolat ]", + "[ 1/4 → 1/2 | s:chocolat ]", + "[ 1/2 → 3/4 | s:chocolat ]", + "[ 3/4 → 1/1 | s:chocolat ]", + "[ 1/1 → 5/4 | s:chocolat ]", + "[ 5/4 → 3/2 | s:chocolat ]", + "[ 3/2 → 7/4 | s:chocolat ]", + "[ 7/4 → 2/1 | s:chocolat ]", + "[ 2/1 → 9/4 | s:chocolat ]", + "[ 9/4 → 5/2 | s:chocolat ]", + "[ 5/2 → 11/4 | s:chocolat ]", + "[ 11/4 → 3/1 | s:chocolat ]", + "[ 3/1 → 13/4 | s:chocolat ]", + "[ 13/4 → 7/2 | s:chocolat ]", + "[ 7/2 → 15/4 | s:chocolat ]", + "[ 15/4 → 4/1 | s:chocolat ]", +] +`; + exports[`runs examples > example "saw" example index 0 1`] = ` [ "[ 0/1 → 1/4 | note:c3 clip:0.03125 ]", diff --git a/website/src/pages/learn/samples.mdx b/website/src/pages/learn/samples.mdx index 10d8c730..658caec7 100644 --- a/website/src/pages/learn/samples.mdx +++ b/website/src/pages/learn/samples.mdx @@ -283,7 +283,7 @@ With it, you can enter any sample name(s) to query from [freesound.org](https:// +You can also generate artificial voice samples with any text, in multiple languages. +Note that the language code and the gender parameters are optional and default to `en-GB` and `f` + + + # Sampler Effects Sampler effects are functions that can be used to change the behaviour of sample playback.