mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-22 02:58:32 +00:00
still working on popping issue with firefox
This commit is contained in:
parent
deb973afa5
commit
fb81f6f268
@ -1,7 +1,7 @@
|
|||||||
import { getAudioContext } from './superdough.mjs';
|
import { getAudioContext } from './superdough.mjs';
|
||||||
import { clamp } from './util.mjs';
|
import { clamp } from './util.mjs';
|
||||||
|
|
||||||
const setRelease = (param, startTime, endTime, endValue, curve = 'linear') => {
|
const setRelease = (param, phase, sustain, startTime, endTime, endValue, curve = 'linear') => {
|
||||||
const ctx = getAudioContext();
|
const ctx = getAudioContext();
|
||||||
const ramp = curve === 'exponential' ? 'exponentialRampToValueAtTime' : 'linearRampToValueAtTime';
|
const ramp = curve === 'exponential' ? 'exponentialRampToValueAtTime' : 'linearRampToValueAtTime';
|
||||||
if (param.cancelAndHoldAtTime == null) {
|
if (param.cancelAndHoldAtTime == null) {
|
||||||
@ -15,9 +15,10 @@ const setRelease = (param, startTime, endTime, endValue, curve = 'linear') => {
|
|||||||
param[ramp](endValue, endTime);
|
param[ramp](endValue, endTime);
|
||||||
}, (startTime - ctx.currentTime) * 1000);
|
}, (startTime - ctx.currentTime) * 1000);
|
||||||
} else {
|
} else {
|
||||||
|
if (phase < startTime) {
|
||||||
|
param.setValueAtTime(sustain, startTime);
|
||||||
|
}
|
||||||
param.cancelAndHoldAtTime(startTime);
|
param.cancelAndHoldAtTime(startTime);
|
||||||
param.setValueAtTime(param.value, startTime);
|
|
||||||
//release
|
|
||||||
param[ramp](endValue, endTime);
|
param[ramp](endValue, endTime);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -43,7 +44,7 @@ export const getEnvelope = (attack, decay, sustain, release, velocity, begin) =>
|
|||||||
node: gainNode,
|
node: gainNode,
|
||||||
stop: (t) => {
|
stop: (t) => {
|
||||||
const endTime = t + release;
|
const endTime = t + release;
|
||||||
setRelease(gainNode.gain, t, endTime, 0);
|
setRelease(gainNode.gain, phase, sustain, t, endTime, 0);
|
||||||
// helps prevent pops from overlapping sounds
|
// helps prevent pops from overlapping sounds
|
||||||
return endTime;
|
return endTime;
|
||||||
},
|
},
|
||||||
@ -113,10 +114,11 @@ export const getParamADSR = (
|
|||||||
param[ramp](peak, phase);
|
param[ramp](peak, phase);
|
||||||
phase += decay;
|
phase += decay;
|
||||||
const sustainLevel = min + sustain * range;
|
const sustainLevel = min + sustain * range;
|
||||||
|
|
||||||
//decay
|
//decay
|
||||||
param[ramp](sustainLevel, phase);
|
param[ramp](sustainLevel, phase);
|
||||||
|
|
||||||
setRelease(param, end, end + release, min, curve);
|
setRelease(param, phase, sustain, end, end + release, min, curve);
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getCompressor(ac, threshold, ratio, knee, attack, release) {
|
export function getCompressor(ac, threshold, ratio, knee, attack, release) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user