More bug fixes

This commit is contained in:
Nikita
2025-10-24 19:21:34 +03:00
parent 03d2f363f1
commit fc74dcdb1a
2 changed files with 25 additions and 28 deletions
+16 -27
View File
@@ -14,12 +14,8 @@ import {
setAudioContext,
initAudio,
setSuperdoughAudioController,
setMaxPolyphony,
setMultiChannelOrbits,
resetGlobalEffects,
errorLogger,
maxPolyphony as superdoughMaxPolyphony,
multiChannelOrbits as superdoughMultiChannelOrbits
errorLogger
} from 'superdough';
import './supradough.mjs';
import { workletUrl } from 'supradough';
@@ -51,10 +47,6 @@ export async function renderPatternAudio(
multiChannelOrbits,
downloadName = undefined,
) {
let realtimeOptions = {
maxPolyphony: superdoughMaxPolyphony,
multiChannelOrbits: superdoughMultiChannelOrbits
}
let audioContext = getAudioContext();
await audioContext.close();
audioContext = new OfflineAudioContext(2, ((end - begin) / cps) * sampleRate, sampleRate);
@@ -63,28 +55,26 @@ export async function renderPatternAudio(
await initAudio({
maxPolyphony,
multiChannelOrbits
});
})
logger('[webaudio] preloading');
let haps = pattern.queryArc(begin, end, { _cps: cps });
await Promise.all(
haps.map(async (hap) => {
if (hap.hasOnset()) {
try {
await superdough(
hap2value(hap),
hap.whole.begin.valueOf() / cps,
hap.duration / cps,
cps,
hap.whole?.begin.valueOf(),
);
} catch (err) {
errorLogger(err, 'webaudio');
}
for (const hap of haps) {
if (hap.hasOnset()) {
try {
await superdough(
hap2value(hap),
(hap.whole.begin.valueOf() - begin) / cps,
hap.duration / cps,
cps,
(hap.whole?.begin.valueOf() - begin) / cps,
);
} catch (err) {
errorLogger(err, 'webaudio');
}
}),
);
}
}
logger('[webaudio] start rendering');
return audioContext
@@ -106,7 +96,6 @@ export async function renderPatternAudio(
setAudioContext(null);
setSuperdoughAudioController(null);
resetGlobalEffects();
await initAudio(realtimeOptions);
});
}
+9 -1
View File
@@ -15,6 +15,7 @@ import {
resetLoadedSounds,
initAudioOnFirstClick,
resetDefaults,
initAudio,
} from '@strudel/webaudio';
import { setVersionDefaultsFrom } from './util.mjs';
import { StrudelMirror, defaultSettings } from '@strudel/codemirror';
@@ -217,7 +218,14 @@ export function useReplContext() {
maxPolyphony,
multiChannelOrbits,
downloadName,
).finally(() => {
).finally(async () => {
const { latestCode, maxPolyphony, audioDeviceName, multiChannelOrbits } = settingsMap.get()
await initAudio({
latestCode,
maxPolyphony,
audioDeviceName,
multiChannelOrbits
})
editorRef.current.repl.scheduler.stop();
});
};