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;