Allow lfos to modulate other lfos without clamping
This commit is contained in:
parent
bae5571df0
commit
29f7f5c1f8
2 changed files with 18 additions and 7 deletions
|
|
@ -401,10 +401,11 @@ function _getControlData(control) {
|
||||||
return controlTargets[_stripIndex(control)];
|
return controlTargets[_stripIndex(control)];
|
||||||
}
|
}
|
||||||
|
|
||||||
function _getRangeForParam(paramName, targetParams, currentValue) {
|
function _getRangeForParam(paramName, currentValue, control) {
|
||||||
if (paramName === 'frequency') {
|
// For our normal oscillators / filters we want to clamp the frequency to a reasonable range
|
||||||
const liveValue = targetParams?.[0]?.value ?? currentValue ?? 0;
|
// For LFOs we allow it to be modulated freely
|
||||||
return { min: 20 - liveValue, max: 24000 - liveValue };
|
if (paramName === 'frequency' || control?.startsWith?.('lfo')) {
|
||||||
|
return { min: 20 - currentValue, max: 24000 - currentValue };
|
||||||
}
|
}
|
||||||
return { min: undefined, max: undefined };
|
return { min: undefined, max: undefined };
|
||||||
}
|
}
|
||||||
|
|
@ -447,7 +448,7 @@ function connectLFO(idx, params, nodeTracker) {
|
||||||
const { rate = 1, sync, cps, cycle, control = 'lfo', subControl, depth = 1, depthabs, ...filteredParams } = params;
|
const { rate = 1, sync, cps, cycle, control = 'lfo', subControl, depth = 1, depthabs, ...filteredParams } = params;
|
||||||
const { targetParams, paramName } = _getTargetParamsForControl(control, nodeTracker, subControl);
|
const { targetParams, paramName } = _getTargetParamsForControl(control, nodeTracker, subControl);
|
||||||
const currentValue = targetParams[0].value;
|
const currentValue = targetParams[0].value;
|
||||||
const { min, max } = _getRangeForParam(paramName, targetParams, currentValue);
|
const { min, max } = _getRangeForParam(paramName, currentValue, control);
|
||||||
const depthValue = depthabs != null ? depthabs : depth * currentValue;
|
const depthValue = depthabs != null ? depthabs : depth * currentValue;
|
||||||
const modParams = {
|
const modParams = {
|
||||||
...filteredParams,
|
...filteredParams,
|
||||||
|
|
@ -467,7 +468,7 @@ function connectEnvelope(idx, params, nodeTracker) {
|
||||||
const { control, subControl, acurve, dcurve, rcurve, depth = 1, depthabs, ...filteredParams } = params;
|
const { control, subControl, acurve, dcurve, rcurve, depth = 1, depthabs, ...filteredParams } = params;
|
||||||
const { targetParams, paramName } = _getTargetParamsForControl(control, nodeTracker, subControl);
|
const { targetParams, paramName } = _getTargetParamsForControl(control, nodeTracker, subControl);
|
||||||
const currentValue = targetParams[0].value;
|
const currentValue = targetParams[0].value;
|
||||||
const { min, max } = _getRangeForParam(paramName, targetParams, currentValue);
|
const { min, max } = _getRangeForParam(paramName, currentValue, control);
|
||||||
const depthValue = depthabs != null ? depthabs : depth * currentValue;
|
const depthValue = depthabs != null ? depthabs : depth * currentValue;
|
||||||
const envNode = getEnvelope(getAudioContext(), {
|
const envNode = getEnvelope(getAudioContext(), {
|
||||||
...filteredParams,
|
...filteredParams,
|
||||||
|
|
@ -493,7 +494,7 @@ function connectBusModulator(params, nodeTracker) {
|
||||||
signal.connect(shifted);
|
signal.connect(shifted);
|
||||||
const { targetParams, paramName } = _getTargetParamsForControl(control, nodeTracker, subControl);
|
const { targetParams, paramName } = _getTargetParamsForControl(control, nodeTracker, subControl);
|
||||||
const currentValue = targetParams[0].value;
|
const currentValue = targetParams[0].value;
|
||||||
const { min, max } = _getRangeForParam(paramName, targetParams, currentValue);
|
const { min, max } = _getRangeForParam(paramName, currentValue, control);
|
||||||
const depthValue = depthabs != null ? depthabs : depth * currentValue;
|
const depthValue = depthabs != null ? depthabs : depth * currentValue;
|
||||||
const maxAbsDepth = Math.min(Math.abs(min), Math.abs(max));
|
const maxAbsDepth = Math.min(Math.abs(min), Math.abs(max));
|
||||||
const boundedDepth = Math.min(Math.abs(depthValue), maxAbsDepth) || Math.abs(depthValue);
|
const boundedDepth = Math.min(Math.abs(depthValue), maxAbsDepth) || Math.abs(depthValue);
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,18 @@ const CONTROL_TARGETS = {
|
||||||
|
|
||||||
// MODULATORS
|
// MODULATORS
|
||||||
lfo: { node: 'lfo', param: 'frequency' },
|
lfo: { node: 'lfo', param: 'frequency' },
|
||||||
|
lfo_rate: { node: 'lfo', param: 'frequency' },
|
||||||
|
lfo_sync: { node: 'lfo', param: 'frequency' },
|
||||||
|
lfo_depth: { node: 'lfo', param: 'depth' },
|
||||||
|
lfo_depthabs: { node: 'lfo', param: 'depth' },
|
||||||
env: { node: 'env', param: 'depth' },
|
env: { node: 'env', param: 'depth' },
|
||||||
|
env_attack: { node: 'env', param: 'attack' },
|
||||||
|
env_decay: { node: 'env', param: 'decay' },
|
||||||
|
env_sustain: { node: 'env', param: 'sustain' },
|
||||||
|
env_release: { node: 'env', param: 'release' },
|
||||||
bmod: { node: 'bmod', param: 'depth' },
|
bmod: { node: 'bmod', param: 'depth' },
|
||||||
|
bmod_depth: { node: 'bmod', param: 'depth' },
|
||||||
|
bmod_depthabs: { node: 'bmod', param: 'depth' },
|
||||||
|
|
||||||
// LPF
|
// LPF
|
||||||
cutoff: { node: 'lpf', param: 'frequency' },
|
cutoff: { node: 'lpf', param: 'frequency' },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue