Reapply realtimeOptions after export
This commit is contained in:
parent
9cbeaef88d
commit
ff370cf86f
4 changed files with 16 additions and 13 deletions
|
|
@ -287,7 +287,7 @@ export async function onTriggerSample(t, value, onended, bank, resolveUrl) {
|
||||||
const { bufferSource, sliceDuration, offset } = await getSampleBufferSource(value, bank, resolveUrl);
|
const { bufferSource, sliceDuration, offset } = await getSampleBufferSource(value, bank, resolveUrl);
|
||||||
|
|
||||||
// asny stuff above took too long?
|
// asny stuff above took too long?
|
||||||
if (ac.currentTime > t && !(ac instanceof OfflineAudioContext)) {
|
if (ac.currentTime > t) {
|
||||||
logger(`[sampler] still loading sound "${s}:${n}"`, 'highlight');
|
logger(`[sampler] still loading sound "${s}:${n}"`, 'highlight');
|
||||||
// console.warn('sample still loading:', s, n);
|
// console.warn('sample still loading:', s, n);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -20,13 +20,13 @@ 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';
|
||||||
|
|
||||||
let maxPolyphony = DEFAULT_MAX_POLYPHONY;
|
export let maxPolyphony = DEFAULT_MAX_POLYPHONY;
|
||||||
|
|
||||||
export function setMaxPolyphony(polyphony) {
|
export function setMaxPolyphony(polyphony) {
|
||||||
maxPolyphony = parseInt(polyphony) ?? DEFAULT_MAX_POLYPHONY;
|
maxPolyphony = parseInt(polyphony) ?? DEFAULT_MAX_POLYPHONY;
|
||||||
}
|
}
|
||||||
|
|
||||||
let multiChannelOrbits = false;
|
export let multiChannelOrbits = false;
|
||||||
export function setMultiChannelOrbits(bool) {
|
export function setMultiChannelOrbits(bool) {
|
||||||
multiChannelOrbits = bool == true;
|
multiChannelOrbits = bool == true;
|
||||||
}
|
}
|
||||||
|
|
@ -398,7 +398,7 @@ export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5)
|
||||||
// duration is passed as value too..
|
// duration is passed as value too..
|
||||||
value.duration = hapDuration;
|
value.duration = hapDuration;
|
||||||
// calculate absolute time
|
// calculate absolute time
|
||||||
if (t < ac.currentTime && !(ac instanceof OfflineAudioContext)) {
|
if (t < ac.currentTime) {
|
||||||
console.warn(
|
console.warn(
|
||||||
`[superdough]: cannot schedule sounds in the past (target: ${t.toFixed(2)}, now: ${ac.currentTime.toFixed(2)})`,
|
`[superdough]: cannot schedule sounds in the past (target: ${t.toFixed(2)}, now: ${ac.currentTime.toFixed(2)})`,
|
||||||
);
|
);
|
||||||
|
|
@ -564,7 +564,7 @@ export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ac.currentTime > t && !(ac instanceof OfflineAudioContext)) {
|
if (ac.currentTime > t) {
|
||||||
logger('[webaudio] skip hap: still loading', ac.currentTime - t);
|
logger('[webaudio] skip hap: still loading', ac.currentTime - t);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ import {
|
||||||
setMultiChannelOrbits,
|
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';
|
||||||
|
|
@ -49,14 +51,19 @@ 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);
|
||||||
setAudioContext(audioContext);
|
setAudioContext(audioContext);
|
||||||
setSuperdoughAudioController(new SuperdoughAudioController(audioContext));
|
setSuperdoughAudioController(new SuperdoughAudioController(audioContext));
|
||||||
await initAudio();
|
await initAudio({
|
||||||
setMaxPolyphony(maxPolyphony);
|
maxPolyphony,
|
||||||
setMultiChannelOrbits(multiChannelOrbits);
|
multiChannelOrbits
|
||||||
|
});
|
||||||
logger('[webaudio] preloading');
|
logger('[webaudio] preloading');
|
||||||
|
|
||||||
let haps = pattern.queryArc(begin, end, { _cps: cps });
|
let haps = pattern.queryArc(begin, end, { _cps: cps });
|
||||||
|
|
@ -99,7 +106,7 @@ export async function renderPatternAudio(
|
||||||
setAudioContext(null);
|
setAudioContext(null);
|
||||||
setSuperdoughAudioController(null);
|
setSuperdoughAudioController(null);
|
||||||
resetGlobalEffects();
|
resetGlobalEffects();
|
||||||
await initAudio();
|
await initAudio(realtimeOptions);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@ import NumberInput from './NumberInput';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { Textbox } from './textbox/Textbox';
|
import { Textbox } from './textbox/Textbox';
|
||||||
import {
|
import {
|
||||||
setMultiChannelOrbits as setStrudelMultiChannelOrbits,
|
|
||||||
setMaxPolyphony as setStrudelMaxPolyphony,
|
|
||||||
getAudioContext,
|
getAudioContext,
|
||||||
} from '@strudel/webaudio';
|
} from '@strudel/webaudio';
|
||||||
import XMarkIcon from '@heroicons/react/24/outline/XMarkIcon';
|
import XMarkIcon from '@heroicons/react/24/outline/XMarkIcon';
|
||||||
|
|
@ -201,8 +199,6 @@ export default function ExportModal(Props) {
|
||||||
disabled={exporting}
|
disabled={exporting}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
setExporting(true);
|
setExporting(true);
|
||||||
setStrudelMaxPolyphony(maxPolyphony);
|
|
||||||
setStrudelMultiChannelOrbits(multiChannelOrbits);
|
|
||||||
setTimeout(refreshProgress, 1000);
|
setTimeout(refreshProgress, 1000);
|
||||||
await handleExport(startCycle, endCycle, sampleRate, maxPolyphony, multiChannelOrbits, downloadName)
|
await handleExport(startCycle, endCycle, sampleRate, maxPolyphony, multiChannelOrbits, downloadName)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue