Re-init audio before and after export
This commit is contained in:
parent
0fbde61b2d
commit
920776fdfe
2 changed files with 19 additions and 4 deletions
|
|
@ -250,8 +250,9 @@ export async function initAudio(options = {}) {
|
||||||
logger('[superdough] failed to set audio interface', 'warning');
|
logger('[superdough] failed to set audio interface', 'warning');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!audioCtx instanceof OfflineAudioContext) {
|
||||||
await audioCtx.resume();
|
await audioCtx.resume();
|
||||||
|
}
|
||||||
if (disableWorklets) {
|
if (disableWorklets) {
|
||||||
logger('[superdough]: AudioWorklets disabled with disableWorklets');
|
logger('[superdough]: AudioWorklets disabled with disableWorklets');
|
||||||
return;
|
return;
|
||||||
|
|
@ -285,6 +286,12 @@ function getSuperdoughAudioController() {
|
||||||
}
|
}
|
||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setSuperdoughAudioController(newController) {
|
||||||
|
controller = newController
|
||||||
|
return controller;
|
||||||
|
}
|
||||||
|
|
||||||
export function connectToDestination(input, channels) {
|
export function connectToDestination(input, channels) {
|
||||||
const controller = getSuperdoughAudioController();
|
const controller = getSuperdoughAudioController();
|
||||||
controller.output.connectToDestination(input, channels);
|
controller.output.connectToDestination(input, channels);
|
||||||
|
|
@ -367,7 +374,7 @@ function mapChannelNumbers(channels) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5) => {
|
export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5) => {
|
||||||
controller = null;
|
// controller = null;
|
||||||
// new: t is always expected to be the absolute target onset time
|
// new: t is always expected to be the absolute target onset time
|
||||||
const ac = getAudioContext();
|
const ac = getAudioContext();
|
||||||
const audioController = getSuperdoughAudioController();
|
const audioController = getSuperdoughAudioController();
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ This program is free software: you can redistribute it and/or modify it under th
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as strudel from '@strudel/core';
|
import * as strudel from '@strudel/core';
|
||||||
import { superdough, getAudioContext, setLogger, doughTrigger, registerWorklet, setAudioContext, getSampleBufferSource, loadBuffer, getSampleInfo, getSound } from 'superdough';
|
import { superdough, getAudioContext, setLogger, doughTrigger, registerWorklet, setAudioContext, getSampleBufferSource, loadBuffer, getSampleInfo, getSound, initAudio, setSuperdoughAudioController } from 'superdough';
|
||||||
import './supradough.mjs';
|
import './supradough.mjs';
|
||||||
import { workletUrl } from 'supradough';
|
import { workletUrl } from 'supradough';
|
||||||
|
|
||||||
|
|
@ -29,6 +29,12 @@ export const webaudioOutput = (hap, _deadline, hapDuration, cps, t) => {
|
||||||
export async function renderPatternAudio(pattern, cps, begin, end) {
|
export async function renderPatternAudio(pattern, cps, begin, end) {
|
||||||
let audioContext = new OfflineAudioContext(2, (end - begin) / cps * 48000, 48000);
|
let audioContext = new OfflineAudioContext(2, (end - begin) / cps * 48000, 48000);
|
||||||
setAudioContext(audioContext)
|
setAudioContext(audioContext)
|
||||||
|
setSuperdoughAudioController(null)
|
||||||
|
await initAudio({
|
||||||
|
maxPolyphony: 1024,
|
||||||
|
multiChannelOrbits: true
|
||||||
|
|
||||||
|
})
|
||||||
logger('[webaudio] start rendering');
|
logger('[webaudio] start rendering');
|
||||||
console.log(audioContext)
|
console.log(audioContext)
|
||||||
|
|
||||||
|
|
@ -77,6 +83,8 @@ export async function renderPatternAudio(pattern, cps, begin, end) {
|
||||||
document.body.removeChild(a);
|
document.body.removeChild(a);
|
||||||
URL.revokeObjectURL(url);
|
URL.revokeObjectURL(url);
|
||||||
setAudioContext(null)
|
setAudioContext(null)
|
||||||
|
setSuperdoughAudioController(null)
|
||||||
|
initAudio()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue