diff --git a/packages/superdough/sampler.mjs b/packages/superdough/sampler.mjs index 188732656..e0c6fef44 100644 --- a/packages/superdough/sampler.mjs +++ b/packages/superdough/sampler.mjs @@ -10,11 +10,17 @@ import { releaseAudioNode, } from './helpers.mjs'; import { logger } from './logger.mjs'; -import { note2midi } from 'node_modules/@strudel/tonal/tonleiter.mjs'; const bufferCache = {}; // string: Promise const loadCache = {}; // string: Promise +/** + * + * @typedef {Object} SampleMetaData + * @property {string} url + * @property {midi} number + */ + export const getCachedBuffer = (url) => bufferCache[url]; function humanFileSize(bytes, si) { @@ -158,6 +164,11 @@ export const processSampleMap = (sampleMap, fn, baseUrl = sampleMap._base || '') if (baseUrl.startsWith('github:')) { baseUrl = githubPath(baseUrl, ''); } + /** + * + * @param {string} v + * @returns {SampleMetaData} + */ const fullUrl = (v) => ({ url: baseUrl + v, midi: extractMidiNoteFromString(v) }); if (Array.isArray(value)) { //return [key, value.map(replaceUrl)]; diff --git a/packages/superdough/util.mjs b/packages/superdough/util.mjs index 8fc6752ce..022c328c0 100644 --- a/packages/superdough/util.mjs +++ b/packages/superdough/util.mjs @@ -2,12 +2,7 @@ import { logger } from './logger.mjs'; // currently duplicate with core util.mjs to skip dependency // TODO: add separate util module? -/** - * - * @typedef {Object} SampleMetaData - * @property {string} url - * @property {baseFrequency} number - */ + export const tokenizeNote = (note) => { if (typeof note !== 'string') { return []; diff --git a/website/src/repl/idbutils.mjs b/website/src/repl/idbutils.mjs index 4022da883..bcd721832 100644 --- a/website/src/repl/idbutils.mjs +++ b/website/src/repl/idbutils.mjs @@ -61,7 +61,9 @@ export function registerSamplesFromDB(config = userSamplesDBConfig, onComplete = return blobToDataUrl(blob).then((path) => { const sampleInfoMap = sounds.get(parentDirectory) ?? new Map(); const midi = extractMidiNoteFromString(title); - sampleInfoMap.set(title, { url: path, midi }); + /** @type {import('@strudel/webaudio').SampleMetaData} */ + const samplemetadata = { url: path, midi }; + sampleInfoMap.set(title, samplemetadata); sounds.set(parentDirectory, sampleInfoMap); return;