Reapply realtimeOptions after export

This commit is contained in:
Nikita
2025-10-24 14:07:57 +03:00
parent 9cbeaef88d
commit ff370cf86f
4 changed files with 16 additions and 13 deletions
+1 -1
View File
@@ -287,7 +287,7 @@ export async function onTriggerSample(t, value, onended, bank, resolveUrl) {
const { bufferSource, sliceDuration, offset } = await getSampleBufferSource(value, bank, resolveUrl);
// 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');
// console.warn('sample still loading:', s, n);
return;
+4 -4
View File
@@ -20,13 +20,13 @@ import { resetSeenKeys } from './wavetable.mjs';
export const DEFAULT_MAX_POLYPHONY = 128;
const DEFAULT_AUDIO_DEVICE_NAME = 'System Standard';
let maxPolyphony = DEFAULT_MAX_POLYPHONY;
export let maxPolyphony = DEFAULT_MAX_POLYPHONY;
export function setMaxPolyphony(polyphony) {
maxPolyphony = parseInt(polyphony) ?? DEFAULT_MAX_POLYPHONY;
}
let multiChannelOrbits = false;
export let multiChannelOrbits = false;
export function setMultiChannelOrbits(bool) {
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..
value.duration = hapDuration;
// calculate absolute time
if (t < ac.currentTime && !(ac instanceof OfflineAudioContext)) {
if (t < ac.currentTime) {
console.warn(
`[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;
}
if (ac.currentTime > t && !(ac instanceof OfflineAudioContext)) {
if (ac.currentTime > t) {
logger('[webaudio] skip hap: still loading', ac.currentTime - t);
return;
}
+11 -4
View File
@@ -18,6 +18,8 @@ import {
setMultiChannelOrbits,
resetGlobalEffects,
errorLogger,
maxPolyphony as superdoughMaxPolyphony,
multiChannelOrbits as superdoughMultiChannelOrbits
} from 'superdough';
import './supradough.mjs';
import { workletUrl } from 'supradough';
@@ -49,14 +51,19 @@ export async function renderPatternAudio(
multiChannelOrbits,
downloadName = undefined,
) {
let realtimeOptions = {
maxPolyphony: superdoughMaxPolyphony,
multiChannelOrbits: superdoughMultiChannelOrbits
}
let audioContext = getAudioContext();
await audioContext.close();
audioContext = new OfflineAudioContext(2, ((end - begin) / cps) * sampleRate, sampleRate);
setAudioContext(audioContext);
setSuperdoughAudioController(new SuperdoughAudioController(audioContext));
await initAudio();
setMaxPolyphony(maxPolyphony);
setMultiChannelOrbits(multiChannelOrbits);
await initAudio({
maxPolyphony,
multiChannelOrbits
});
logger('[webaudio] preloading');
let haps = pattern.queryArc(begin, end, { _cps: cps });
@@ -99,7 +106,7 @@ export async function renderPatternAudio(
setAudioContext(null);
setSuperdoughAudioController(null);
resetGlobalEffects();
await initAudio();
await initAudio(realtimeOptions);
});
}
@@ -4,8 +4,6 @@ import NumberInput from './NumberInput';
import { useEffect, useState } from 'react';
import { Textbox } from './textbox/Textbox';
import {
setMultiChannelOrbits as setStrudelMultiChannelOrbits,
setMaxPolyphony as setStrudelMaxPolyphony,
getAudioContext,
} from '@strudel/webaudio';
import XMarkIcon from '@heroicons/react/24/outline/XMarkIcon';
@@ -201,8 +199,6 @@ export default function ExportModal(Props) {
disabled={exporting}
onClick={async () => {
setExporting(true);
setStrudelMaxPolyphony(maxPolyphony);
setStrudelMultiChannelOrbits(multiChannelOrbits);
setTimeout(refreshProgress, 1000);
await handleExport(startCycle, endCycle, sampleRate, maxPolyphony, multiChannelOrbits, downloadName)
.then(() => {