fix: calling doughsamples multiple times
This commit is contained in:
parent
e99adffc56
commit
3963b807eb
1 changed files with 1 additions and 6 deletions
|
|
@ -90,18 +90,12 @@ async function loadSampleChannels(key, url) {
|
||||||
return [key, channels, buffer.sampleRate];
|
return [key, channels, buffer.sampleRate];
|
||||||
}
|
}
|
||||||
|
|
||||||
let loaded = false;
|
|
||||||
export async function doughsamples(sampleMap, baseUrl) {
|
export async function doughsamples(sampleMap, baseUrl) {
|
||||||
if (typeof sampleMap === 'string') {
|
if (typeof sampleMap === 'string') {
|
||||||
const [json, base] = await fetchSampleMap(sampleMap);
|
const [json, base] = await fetchSampleMap(sampleMap);
|
||||||
// console.log('json', json, 'base', base);
|
// console.log('json', json, 'base', base);
|
||||||
return doughsamples(json, base);
|
return doughsamples(json, base);
|
||||||
}
|
}
|
||||||
!doughWorklet && initDoughWorklet();
|
|
||||||
if (loaded) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
loaded = true;
|
|
||||||
const json = (
|
const json = (
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
Object.entries(sampleMap).map(async ([key, url]) => {
|
Object.entries(sampleMap).map(async ([key, url]) => {
|
||||||
|
|
@ -113,5 +107,6 @@ export async function doughsamples(sampleMap, baseUrl) {
|
||||||
)
|
)
|
||||||
).filter(Boolean);
|
).filter(Boolean);
|
||||||
// console.log('sampleMap', json);
|
// console.log('sampleMap', json);
|
||||||
|
!doughWorklet && initDoughWorklet();
|
||||||
doughWorklet.port.postMessage({ samples: json });
|
doughWorklet.port.postMessage({ samples: json });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue