Typos on envelope values

This commit is contained in:
Aria 2025-10-14 11:37:41 -05:00
parent c13a726129
commit ac7e9c6978
3 changed files with 16 additions and 16 deletions

View file

@ -796,7 +796,7 @@ describe('Pattern', () => {
}); });
}); });
describe('apply', () => { describe('apply', () => {
(it('Can apply a function', () => { it('Can apply a function', () => {
expect(sequence('a', 'b').apply(fast(2)).firstCycle()).toStrictEqual(sequence('a', 'b').fast(2).firstCycle()); expect(sequence('a', 'b').apply(fast(2)).firstCycle()).toStrictEqual(sequence('a', 'b').fast(2).firstCycle());
}), }),
it('Can apply a pattern of functions', () => { it('Can apply a pattern of functions', () => {
@ -804,7 +804,7 @@ describe('Pattern', () => {
expect(sequence('a', 'b').apply(fast(2), fast(3)).firstCycle()).toStrictEqual( expect(sequence('a', 'b').apply(fast(2), fast(3)).firstCycle()).toStrictEqual(
sequence('a', 'b').fast(2, 3).firstCycle(), sequence('a', 'b').fast(2, 3).firstCycle(),
); );
})); });
}); });
describe('layer', () => { describe('layer', () => {
it('Can layer up multiple functions', () => { it('Can layer up multiple functions', () => {

View file

@ -195,8 +195,8 @@ export function applyParameterModulators(audioContext, param, start, end, envelo
export function createFilter(context, start, end, params, cps) { export function createFilter(context, start, end, params, cps) {
let { let {
frequency, frequency,
fanchor, anchor,
fenv, env,
type, type,
model, model,
q = 1, q = 1,
@ -208,7 +208,7 @@ export function createFilter(context, start, end, params, cps) {
rate, rate,
sync, sync,
} = params; } = params;
let frequencyParam; let frequencyParam, filter;
if (model === 'ladder') { if (model === 'ladder') {
filter = getWorklet(context, 'ladder-processor', { frequency, q, drive }); filter = getWorklet(context, 'ladder-processor', { frequency, q, drive });
frequencyParam = filter.parameters.get('frequency'); frequencyParam = filter.parameters.get('frequency');
@ -222,17 +222,17 @@ export function createFilter(context, start, end, params, cps) {
const envelopeValues = [params.attack, params.decay, params.sustain, params.release]; const envelopeValues = [params.attack, params.decay, params.sustain, params.release];
const [attack, decay, sustain, release] = getADSRValues(envelopeValues, 'exponential', [0.005, 0.14, 0, 0.1]); const [attack, decay, sustain, release] = getADSRValues(envelopeValues, 'exponential', [0.005, 0.14, 0, 0.1]);
// envelope is active when any of these values is set // envelope is active when any of these values is set
const hasEnvelope = att ?? dec ?? sus ?? rel ?? fenv; const hasEnvelope = [...envelopeValues, env].some((v) => v !== undefined);
// Apply ADSR to filter frequency // Apply ADSR to filter frequency
if (hasEnvelope !== undefined) { if (hasEnvelope) {
fenv = nanFallback(fenv, 1, true); env = nanFallback(env, 1, true);
fanchor = nanFallback(fanchor, 0, true); anchor = nanFallback(anchor, 0, true);
const fenvAbs = Math.abs(fenv); const envAbs = Math.abs(env);
const offset = fenvAbs * fanchor; const offset = envAbs * anchor;
let min = clamp(2 ** -offset * frequency, 0, 20000); let min = clamp(2 ** -offset * frequency, 0, 20000);
let max = clamp(2 ** (fenvAbs - offset) * frequency, 0, 20000); let max = clamp(2 ** (envAbs - offset) * frequency, 0, 20000);
if (fenv < 0) [min, max] = [max, min]; if (env < 0) [min, max] = [max, min];
getParamADSR(frequencyParam, attack, decay, sustain, release, min, max, start, end, curve); getParamADSR(frequencyParam, attack, decay, sustain, release, min, max, start, end, 'exponential');
} }
if (sync != null) { if (sync != null) {

View file

@ -18,8 +18,8 @@
--docsearch-modal-background: var(--background); --docsearch-modal-background: var(--background);
--docsearch-muted-color: color-mix(in srgb, var(--foreground), #fff 30%); --docsearch-muted-color: color-mix(in srgb, var(--foreground), #fff 30%);
--docsearch-key-gradient: var(--foreground); --docsearch-key-gradient: var(--foreground);
--docsearch-key-shadow: --docsearch-key-shadow: inset 0 -2px 0 0 var(--gutterForeground), inset 0 0 1px 1px var(--foreground),
inset 0 -2px 0 0 var(--gutterForeground), inset 0 0 1px 1px var(--foreground), 0 1px 2px 1px var(--gutterBackground); 0 1px 2px 1px var(--gutterBackground);
} }
.dark { .dark {
--docsearch-muted-color: color-mix(in srgb, var(--foreground), #000 30%); --docsearch-muted-color: color-mix(in srgb, var(--foreground), #000 30%);