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