Remove preloading code and instead await superdough
This commit is contained in:
parent
28df4259b8
commit
e7578be6c5
1 changed files with 5 additions and 37 deletions
|
|
@ -57,48 +57,16 @@ export async function renderPatternAudio(pattern, cps, begin, end, sampleRate, d
|
||||||
setMaxPolyphony(1024);
|
setMaxPolyphony(1024);
|
||||||
setMultiChannelOrbits(true);
|
setMultiChannelOrbits(true);
|
||||||
await initAudio();
|
await initAudio();
|
||||||
logger('[webaudio] start rendering');
|
logger('[webaudio] preloading');
|
||||||
|
|
||||||
let haps = pattern.queryArc(begin, end, { _cps: cps });
|
let haps = pattern.queryArc(begin, end, { _cps: cps });
|
||||||
await Promise.all([
|
|
||||||
loadModules(),
|
|
||||||
prebake(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
haps.forEach(async (h) => {
|
await Promise.all(haps.map(async (hap) => {
|
||||||
let s;
|
|
||||||
if (h.value.s) {
|
|
||||||
if (h.value.bank) {
|
|
||||||
s = `${h.value.bank}_${h.value.s}`;
|
|
||||||
} else {
|
|
||||||
s = h.value.s;
|
|
||||||
}
|
|
||||||
// let bank = getSound(s).data.samples;
|
|
||||||
let sample = getSound(s);
|
|
||||||
if (sample.data.type == "soundfont") {
|
|
||||||
for (let index = 0; index < sample.data.fonts.length; index++) {
|
|
||||||
const font = array[index];
|
|
||||||
await getFontBufferSource(font, h.value, audioContext)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (sample.data.type == "sample") {
|
|
||||||
for (let index = 0; index < sample.data.samples.length; index++) {
|
|
||||||
const sample = array[index];
|
|
||||||
await getSampleBuffer(h.value, bank, sample)
|
|
||||||
}
|
|
||||||
} // TODO: waveform
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
for (let index = 0; index < haps.length; index++) {
|
|
||||||
const hap = haps[index];
|
|
||||||
if (hap.hasOnset()) {
|
if (hap.hasOnset()) {
|
||||||
await hap.ensureObjectValue();
|
await superdough(hap2value(hap), hap.whole.begin.valueOf() / cps, hap.duration, cps, hap.whole?.begin.valueOf());
|
||||||
console.log("dough")
|
|
||||||
await superdough(hap.value, hap.whole.begin.valueOf() / cps, hap.duration, cps, hap.whole?.begin.valueOf());
|
|
||||||
}
|
}
|
||||||
}
|
}));
|
||||||
console.log("starting rendering")
|
logger('[webaudio] start rendering');
|
||||||
|
|
||||||
return audioContext
|
return audioContext
|
||||||
.startRendering()
|
.startRendering()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue