mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-27 21:48:27 +00:00
fix last crack?
This commit is contained in:
parent
606dcc8cc3
commit
48753b2539
@ -68,10 +68,12 @@ export const getADSR = (attack, decay, sustain, release, velocity, begin, end) =
|
|||||||
|
|
||||||
export const getParamADSR = (param, attack, decay, sustain, release, min, max, begin, end) => {
|
export const getParamADSR = (param, attack, decay, sustain, release, min, max, begin, end) => {
|
||||||
const range = max - min;
|
const range = max - min;
|
||||||
|
const peak = min + range;
|
||||||
|
const sustainLevel = min + sustain * range;
|
||||||
param.setValueAtTime(min, begin);
|
param.setValueAtTime(min, begin);
|
||||||
param.linearRampToValueAtTime(min + range, begin + attack);
|
param.linearRampToValueAtTime(peak, begin + attack);
|
||||||
param.linearRampToValueAtTime(min + sustain * range, begin + attack + decay);
|
param.linearRampToValueAtTime(sustainLevel, begin + attack + decay);
|
||||||
param.setValueAtTime(min + sustain * range, end);
|
param.setValueAtTime(sustainLevel, end);
|
||||||
param.linearRampToValueAtTime(min, end + release);
|
param.linearRampToValueAtTime(min, end + release);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -79,23 +81,15 @@ export function createFilter(context, type, frequency, Q, attack, decay, sustain
|
|||||||
const filter = context.createBiquadFilter();
|
const filter = context.createBiquadFilter();
|
||||||
filter.type = type;
|
filter.type = type;
|
||||||
filter.Q.value = Q;
|
filter.Q.value = Q;
|
||||||
|
frequency = Math.max(frequency, 20);
|
||||||
|
filter.frequency.value = frequency;
|
||||||
|
|
||||||
// Apply ADSR to filter frequency
|
// Apply ADSR to filter frequency
|
||||||
if (fenv > 0) {
|
if (fenv > 0) {
|
||||||
const envelope = getParamADSR(
|
const min = frequency;
|
||||||
filter.frequency,
|
const max = Math.min(frequency + 200 * 2 ** fenv, 20000);
|
||||||
attack,
|
getParamADSR(filter.frequency, attack, decay, sustain, release, min, max, start, end);
|
||||||
decay,
|
|
||||||
sustain,
|
|
||||||
release,
|
|
||||||
frequency,
|
|
||||||
Math.min(frequency + 200 * 2 ** fenv, 20000),
|
|
||||||
start,
|
|
||||||
end + release,
|
|
||||||
);
|
|
||||||
return filter;
|
return filter;
|
||||||
} else {
|
|
||||||
filter.frequency.value = frequency;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return filter;
|
return filter;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user