Fix maxPolyphony and multiChannelOrbits not applying to export
This commit is contained in:
parent
85f6454340
commit
6baca67cd3
3 changed files with 8 additions and 6 deletions
|
|
@ -39,15 +39,15 @@ export const webaudioOutput = (hap, _deadline, hapDuration, cps, t) => {
|
||||||
return superdough(hap2value(hap), t, hapDuration, cps, hap.whole?.begin.valueOf());
|
return superdough(hap2value(hap), t, hapDuration, cps, hap.whole?.begin.valueOf());
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function renderPatternAudio(pattern, cps, begin, end, sampleRate, downloadName = undefined) {
|
export async function renderPatternAudio(pattern, cps, begin, end, sampleRate, maxPolyphony, multiChannelOrbits, downloadName = undefined) {
|
||||||
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);
|
||||||
setAudioContext(audioContext);
|
setAudioContext(audioContext);
|
||||||
setSuperdoughAudioController(new SuperdoughAudioController(audioContext));
|
setSuperdoughAudioController(new SuperdoughAudioController(audioContext));
|
||||||
setMaxPolyphony(1024);
|
|
||||||
setMultiChannelOrbits(true);
|
|
||||||
await initAudio();
|
await initAudio();
|
||||||
|
setMaxPolyphony(maxPolyphony);
|
||||||
|
setMultiChannelOrbits(multiChannelOrbits);
|
||||||
logger('[webaudio] preloading');
|
logger('[webaudio] preloading');
|
||||||
|
|
||||||
let haps = pattern.queryArc(begin, end, { _cps: cps });
|
let haps = pattern.queryArc(begin, end, { _cps: cps });
|
||||||
|
|
@ -64,7 +64,7 @@ export async function renderPatternAudio(pattern, cps, begin, end, sampleRate, d
|
||||||
hap.whole?.begin.valueOf(),
|
hap.whole?.begin.valueOf(),
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
errorLogger(err, 'webaudio')
|
errorLogger(err, 'webaudio');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -204,7 +204,7 @@ export default function ExportModal(Props) {
|
||||||
setStrudelMaxPolyphony(maxPolyphony);
|
setStrudelMaxPolyphony(maxPolyphony);
|
||||||
setStrudelMultiChannelOrbits(multiChannelOrbits);
|
setStrudelMultiChannelOrbits(multiChannelOrbits);
|
||||||
setTimeout(refreshProgress, 1000);
|
setTimeout(refreshProgress, 1000);
|
||||||
await handleExport(startCycle, endCycle, sampleRate, downloadName).finally(() => {
|
await handleExport(startCycle, endCycle, sampleRate, maxPolyphony, multiChannelOrbits, downloadName).finally(() => {
|
||||||
setExporting(false);
|
setExporting(false);
|
||||||
const modal = document.getElementById('exportModal');
|
const modal = document.getElementById('exportModal');
|
||||||
setProgress(0);
|
setProgress(0);
|
||||||
|
|
|
||||||
|
|
@ -205,7 +205,7 @@ export function useReplContext() {
|
||||||
editorRef.current.evaluate();
|
editorRef.current.evaluate();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleExport = async (begin, end, sampleRate, downloadName = undefined) => {
|
const handleExport = async (begin, end, sampleRate, maxPolyphony, multiChannelOrbits, downloadName = undefined) => {
|
||||||
await editorRef.current.evaluate(false);
|
await editorRef.current.evaluate(false);
|
||||||
editorRef.current.repl.scheduler.stop();
|
editorRef.current.repl.scheduler.stop();
|
||||||
await renderPatternAudio(
|
await renderPatternAudio(
|
||||||
|
|
@ -214,6 +214,8 @@ export function useReplContext() {
|
||||||
begin,
|
begin,
|
||||||
end,
|
end,
|
||||||
sampleRate,
|
sampleRate,
|
||||||
|
maxPolyphony,
|
||||||
|
multiChannelOrbits,
|
||||||
downloadName,
|
downloadName,
|
||||||
).finally(() => {
|
).finally(() => {
|
||||||
editorRef.current.repl.scheduler.stop();
|
editorRef.current.repl.scheduler.stop();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue