fixed
This commit is contained in:
parent
30e672a027
commit
7bbb653963
2 changed files with 20 additions and 15 deletions
|
|
@ -1294,6 +1294,8 @@ export const { fanchor } = registerControl('fanchor');
|
||||||
*
|
*
|
||||||
* @name lprate
|
* @name lprate
|
||||||
* @param {number | Pattern} rate rate in hertz
|
* @param {number | Pattern} rate rate in hertz
|
||||||
|
* @example
|
||||||
|
* note("<c c c# c c c4>*16").s("sawtooth").lpf(600).lprate("<4 8 2 1>")
|
||||||
*/
|
*/
|
||||||
export const { lprate } = registerControl('lprate');
|
export const { lprate } = registerControl('lprate');
|
||||||
|
|
||||||
|
|
@ -1302,6 +1304,8 @@ export const { lprate } = registerControl('lprate');
|
||||||
*
|
*
|
||||||
* @name lpsync
|
* @name lpsync
|
||||||
* @param {number | Pattern} rate rate in cycles
|
* @param {number | Pattern} rate rate in cycles
|
||||||
|
* @example
|
||||||
|
* note("<c c c# c c c4>*16").s("sawtooth").lpf(600).lpsync("<4 8 2 1>")
|
||||||
*/
|
*/
|
||||||
export const { lpsync } = registerControl('lpsync');
|
export const { lpsync } = registerControl('lpsync');
|
||||||
|
|
||||||
|
|
@ -1310,7 +1314,10 @@ export const { lpsync } = registerControl('lpsync');
|
||||||
*
|
*
|
||||||
* @name lpdepth
|
* @name lpdepth
|
||||||
* @param {number | Pattern} depth depth of modulation
|
* @param {number | Pattern} depth depth of modulation
|
||||||
|
* @example
|
||||||
|
* note("<c c c# c c c4>*16").s("sawtooth").lpf(600).lpdepth("<1 .5 1.8 0>")
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const { lpdepth } = registerControl('lpdepth');
|
export const { lpdepth } = registerControl('lpdepth');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -191,9 +191,6 @@ 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) {
|
|
||||||
return Math.sign(x) * 2 ** (Math.abs(x) * k);
|
|
||||||
}
|
|
||||||
export function createFilter(context, start, end, params, cps, cycle) {
|
export function createFilter(context, start, end, params, cps, cycle) {
|
||||||
let {
|
let {
|
||||||
frequency,
|
frequency,
|
||||||
|
|
@ -233,7 +230,6 @@ export function createFilter(context, start, end, params, cps, cycle) {
|
||||||
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');
|
||||||
}
|
}
|
||||||
|
|
@ -243,17 +239,19 @@ export function createFilter(context, start, end, params, cps, cycle) {
|
||||||
}
|
}
|
||||||
const hasLFO = [depth, skew, shape, rate].some((v) => v !== undefined);
|
const hasLFO = [depth, skew, shape, rate].some((v) => v !== undefined);
|
||||||
if (hasLFO) {
|
if (hasLFO) {
|
||||||
depth = depth ?? 1
|
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;
|
const time = cycle / cps;
|
||||||
// let d = 2 ** -dcoffset
|
const lfoValues = {
|
||||||
const lfoValues = { depth: dp, dcoffset, skew, shape, frequency: rate, min: 10, max: 20000, time };
|
depth: (depth ?? 1) * frequency,
|
||||||
|
dcoffset,
|
||||||
|
skew,
|
||||||
|
shape,
|
||||||
|
frequency: rate ?? cps,
|
||||||
|
min: -frequency + 30,
|
||||||
|
max: 20000 - frequency,
|
||||||
|
time,
|
||||||
|
curve: 1,
|
||||||
|
};
|
||||||
getParamLfo(context, frequencyParam, start, end, lfoValues);
|
getParamLfo(context, frequencyParam, start, end, lfoValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -403,7 +401,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();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue