fixed panic function
This commit is contained in:
parent
64c2e7c1e8
commit
886b16d6fd
1 changed files with 10 additions and 11 deletions
|
|
@ -36,15 +36,6 @@ export const getAudioContext = () => {
|
||||||
}
|
}
|
||||||
return audioContext;
|
return audioContext;
|
||||||
};
|
};
|
||||||
// outputs: Map<int, GainNode>
|
|
||||||
const outputs = new Map();
|
|
||||||
|
|
||||||
export const panic = () => {
|
|
||||||
outputs.forEach((output) => {
|
|
||||||
return output.gain.linearRampToValueAtTime(0, getAudioContext().currentTime + 0.01);
|
|
||||||
});
|
|
||||||
outputs.clear();
|
|
||||||
};
|
|
||||||
|
|
||||||
let workletsLoading;
|
let workletsLoading;
|
||||||
|
|
||||||
|
|
@ -92,13 +83,16 @@ export async function initAudioOnFirstClick(options) {
|
||||||
let delays = {};
|
let delays = {};
|
||||||
const maxfeedback = 0.98;
|
const maxfeedback = 0.98;
|
||||||
|
|
||||||
let channelMerger;
|
let channelMerger, destinationGain;
|
||||||
|
|
||||||
// input: AudioNode, channels: ?Array<int>
|
// input: AudioNode, channels: ?Array<int>
|
||||||
export const connectToDestination = (input, channels = [0, 1]) => {
|
export const connectToDestination = (input, channels = [0, 1]) => {
|
||||||
const ctx = getAudioContext();
|
const ctx = getAudioContext();
|
||||||
if (channelMerger == null) {
|
if (channelMerger == null) {
|
||||||
channelMerger = new ChannelMergerNode(ctx, { numberOfInputs: ctx.destination.channelCount });
|
channelMerger = new ChannelMergerNode(ctx, { numberOfInputs: ctx.destination.channelCount });
|
||||||
channelMerger.connect(ctx.destination);
|
destinationGain = new GainNode(ctx);
|
||||||
|
channelMerger.connect(destinationGain);
|
||||||
|
destinationGain.connect(ctx.destination);
|
||||||
}
|
}
|
||||||
//This upmix can be removed if correct channel counts are set throughout the app,
|
//This upmix can be removed if correct channel counts are set throughout the app,
|
||||||
// and then strudel could theoretically support surround sound audio files
|
// and then strudel could theoretically support surround sound audio files
|
||||||
|
|
@ -114,6 +108,11 @@ export const connectToDestination = (input, channels = [0, 1]) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const panic = () => {
|
||||||
|
destinationGain.gain.linearRampToValueAtTime(0, getAudioContext().currentTime + 0.01);
|
||||||
|
destinationGain = null;
|
||||||
|
};
|
||||||
|
|
||||||
function getDelay(orbit, delaytime, delayfeedback, t) {
|
function getDelay(orbit, delaytime, delayfeedback, t) {
|
||||||
if (delayfeedback > maxfeedback) {
|
if (delayfeedback > maxfeedback) {
|
||||||
//logger(`delayfeedback was clamped to ${maxfeedback} to save your ears`);
|
//logger(`delayfeedback was clamped to ${maxfeedback} to save your ears`);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue