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