wip
This commit is contained in:
parent
2518b2aed2
commit
30e672a027
2 changed files with 23 additions and 6 deletions
|
|
@ -191,8 +191,10 @@ export function applyParameterModulators(audioContext, param, start, end, envelo
|
||||||
const lfo = getParamLfo(audioContext, param, start, end, lfoValues);
|
const lfo = getParamLfo(audioContext, param, start, end, lfoValues);
|
||||||
return { lfo, disconnect: () => lfo?.disconnect() };
|
return { lfo, disconnect: () => lfo?.disconnect() };
|
||||||
}
|
}
|
||||||
|
function biloparExponential(x, k) {
|
||||||
export function createFilter(context, start, end, params, cps) {
|
return Math.sign(x) * 2 ** (Math.abs(x) * k);
|
||||||
|
}
|
||||||
|
export function createFilter(context, start, end, params, cps, cycle) {
|
||||||
let {
|
let {
|
||||||
frequency,
|
frequency,
|
||||||
anchor,
|
anchor,
|
||||||
|
|
@ -231,6 +233,7 @@ export function createFilter(context, start, end, params, cps) {
|
||||||
const offset = envAbs * anchor;
|
const offset = envAbs * anchor;
|
||||||
let min = clamp(2 ** -offset * frequency, 0, 20000);
|
let min = clamp(2 ** -offset * frequency, 0, 20000);
|
||||||
let max = clamp(2 ** (envAbs - offset) * frequency, 0, 20000);
|
let max = clamp(2 ** (envAbs - offset) * frequency, 0, 20000);
|
||||||
|
|
||||||
if (env < 0) [min, max] = [max, min];
|
if (env < 0) [min, max] = [max, min];
|
||||||
getParamADSR(frequencyParam, attack, decay, sustain, release, min, max, start, end, 'exponential');
|
getParamADSR(frequencyParam, attack, decay, sustain, release, min, max, start, end, 'exponential');
|
||||||
}
|
}
|
||||||
|
|
@ -238,8 +241,22 @@ export function createFilter(context, start, end, params, cps) {
|
||||||
if (sync != null) {
|
if (sync != null) {
|
||||||
rate = cps * sync;
|
rate = cps * sync;
|
||||||
}
|
}
|
||||||
const lfoValues = { depth, dcoffset, skew, shape, frequency: rate, min: 10, max: 20000 };
|
const hasLFO = [depth, skew, shape, rate].some((v) => v !== undefined);
|
||||||
getParamLfo(context, frequencyParam, start, end, lfoValues);
|
if (hasLFO) {
|
||||||
|
depth = depth ?? 1
|
||||||
|
|
||||||
|
const mag = Math.abs(depth);
|
||||||
|
const sign = Math.sign(depth);
|
||||||
|
|
||||||
|
const shaped = 2 ** (mag * (1 - dcoffset));
|
||||||
|
const dp = clamp((sign * shaped * frequency) - frequency, -20000, 20000);
|
||||||
|
console.info(dp)
|
||||||
|
const time = cycle / cps;
|
||||||
|
// let d = 2 ** -dcoffset
|
||||||
|
const lfoValues = { depth: dp, dcoffset, skew, shape, frequency: rate, min: 10, max: 20000, time };
|
||||||
|
getParamLfo(context, frequencyParam, start, end, lfoValues);
|
||||||
|
}
|
||||||
|
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -386,7 +403,7 @@ export function applyFM(param, value, begin) {
|
||||||
duration,
|
duration,
|
||||||
} = value;
|
} = value;
|
||||||
let modulator;
|
let modulator;
|
||||||
let stop = () => {};
|
let stop = () => { };
|
||||||
|
|
||||||
if (fmModulationIndex) {
|
if (fmModulationIndex) {
|
||||||
const ac = getAudioContext();
|
const ac = getAudioContext();
|
||||||
|
|
|
||||||
|
|
@ -559,7 +559,7 @@ export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5)
|
||||||
};
|
};
|
||||||
const lpParams = pickAndRename(value, lpMap);
|
const lpParams = pickAndRename(value, lpMap);
|
||||||
lpParams.type = 'lowpass';
|
lpParams.type = 'lowpass';
|
||||||
let lp = () => createFilter(ac, t, end, lpParams, cps);
|
let lp = () => createFilter(ac, t, end, lpParams, cps, cycle);
|
||||||
chain.push(lp());
|
chain.push(lp());
|
||||||
if (ftype === '24db') {
|
if (ftype === '24db') {
|
||||||
chain.push(lp());
|
chain.push(lp());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue