Fix wavetables breaking after playback

This commit is contained in:
Nikita
2025-10-22 20:00:36 +03:00
parent e7578be6c5
commit 95700e1196
4 changed files with 24 additions and 9 deletions
+3 -3
View File
@@ -42,9 +42,9 @@ const extensions = {
isMultiCursorEnabled: (on) =>
on
? [
EditorState.allowMultipleSelections.of(true),
EditorView.clickAddsSelectionRange.of((ev) => ev.metaKey || ev.ctrlKey),
]
EditorState.allowMultipleSelections.of(true),
EditorView.clickAddsSelectionRange.of((ev) => ev.metaKey || ev.ctrlKey),
]
: [],
};
const compartments = Object.fromEntries(Object.keys(extensions).map((key) => [key, new Compartment()]));
+2
View File
@@ -15,6 +15,7 @@ import { logger } from './logger.mjs';
import { loadBuffer } from './sampler.mjs';
import { getAudioContext, setAudioContext } from './audioContext.mjs';
import { SuperdoughAudioController } from './superdoughoutput.mjs';
import { resetSeenKeys } from './wavetable.mjs';
export const DEFAULT_MAX_POLYPHONY = 128;
const DEFAULT_AUDIO_DEVICE_NAME = 'System Standard';
@@ -231,6 +232,7 @@ export async function initAudio(options = {}) {
setMaxPolyphony(maxPolyphony);
setMultiChannelOrbits(multiChannelOrbits);
resetSeenKeys();
if (typeof window === 'undefined') {
return;
}
+5
View File
@@ -40,6 +40,11 @@ export const Warpmode = Object.freeze({
});
const seenKeys = new Set();
export function resetSeenKeys() {
seenKeys.clear();
}
async function getPayload(url, label, frameLen = 2048) {
const key = `${url},${frameLen}`;
if (!seenKeys.has(key)) {
+14 -6
View File
@@ -61,17 +61,25 @@ export async function renderPatternAudio(pattern, cps, begin, end, sampleRate, d
let haps = pattern.queryArc(begin, end, { _cps: cps });
await Promise.all(haps.map(async (hap) => {
if (hap.hasOnset()) {
await superdough(hap2value(hap), hap.whole.begin.valueOf() / cps, hap.duration, cps, hap.whole?.begin.valueOf());
}
}));
await Promise.all(
haps.map(async (hap) => {
if (hap.hasOnset()) {
await superdough(
hap2value(hap),
hap.whole.begin.valueOf() / cps,
hap.duration,
cps,
hap.whole?.begin.valueOf(),
);
}
}),
);
logger('[webaudio] start rendering');
return audioContext
.startRendering()
.then((renderedBuffer) => {
console.log('downloading')
console.log('downloading');
const wavBuffer = audioBufferToWav(renderedBuffer);
const blob = new Blob([wavBuffer], { type: 'audio/wav' });
const url = URL.createObjectURL(blob);