Add ability for LFOs to target.. other lfos :devil emoji:
This commit is contained in:
parent
945b325336
commit
23aa8ef509
1 changed files with 8 additions and 4 deletions
|
|
@ -636,7 +636,7 @@ function _setWorkletParamsAtTime(audioParams, params, time) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let lfos = {};
|
let lfos = {};
|
||||||
function _connectLFO(params) {
|
function _connectLFO(params, nodeTracker) {
|
||||||
const {
|
const {
|
||||||
frequency = 1,
|
frequency = 1,
|
||||||
synced = 0,
|
synced = 0,
|
||||||
|
|
@ -653,10 +653,12 @@ function _connectLFO(params) {
|
||||||
const ac = getAudioContext();
|
const ac = getAudioContext();
|
||||||
lfoNode = getLfo(ac, filteredParams);
|
lfoNode = getLfo(ac, filteredParams);
|
||||||
lfos[num] = lfoNode;
|
lfos[num] = lfoNode;
|
||||||
|
nodeTracker[`lfo${num}`] = [lfoNode];
|
||||||
}
|
}
|
||||||
const targets = _getTargetParams(target, param);
|
const targets = _getTargetParams(target, param);
|
||||||
targets.forEach((target) => lfoNode.connect(target));
|
targets.forEach((target) => lfoNode.connect(target));
|
||||||
_setWorkletParamsAtTime(lfoNode.parameters, Object.entries(filteredParams), begin);
|
_setWorkletParamsAtTime(lfoNode.parameters, Object.entries(filteredParams), begin);
|
||||||
|
return lfoNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _connectEnvelope(params) {
|
function _connectEnvelope(params) {
|
||||||
|
|
@ -671,15 +673,16 @@ function _connectEnvelope(params) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function connectModulators(params, modulatorType) {
|
function connectModulators(params, modulatorType, nodeTracker) {
|
||||||
// We break down params specifying multiple modulators into a set of parameters for
|
// We break down params specifying multiple modulators into a set of parameters for
|
||||||
// a single one
|
// a single one
|
||||||
const individualParams = _splitParams(params);
|
const individualParams = _splitParams(params);
|
||||||
if (modulatorType === 'lfo') {
|
if (modulatorType === 'lfo') {
|
||||||
individualParams.forEach(_connectLFO);
|
individualParams.map((p) => _connectLFO(p, nodeTracker));
|
||||||
} else if (modulatorType === 'envelope') {
|
} else if (modulatorType === 'envelope') {
|
||||||
individualParams.forEach(_connectEnvelope);
|
individualParams.forEach(_connectEnvelope);
|
||||||
}
|
}
|
||||||
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
let activeSoundSources = new Map();
|
let activeSoundSources = new Map();
|
||||||
|
|
@ -1118,7 +1121,7 @@ export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5)
|
||||||
if (lfoTarget !== undefined && lfoParam !== undefined) {
|
if (lfoTarget !== undefined && lfoParam !== undefined) {
|
||||||
connectModulators(
|
connectModulators(
|
||||||
{
|
{
|
||||||
num: lfoNum,
|
num: lfoNum ?? 1,
|
||||||
target: lfoTarget,
|
target: lfoTarget,
|
||||||
param: lfoParam,
|
param: lfoParam,
|
||||||
frequency: lfoRate,
|
frequency: lfoRate,
|
||||||
|
|
@ -1133,6 +1136,7 @@ export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5)
|
||||||
cps: cps,
|
cps: cps,
|
||||||
},
|
},
|
||||||
'lfo',
|
'lfo',
|
||||||
|
nodes,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (envTarget !== undefined && envParam !== undefined) {
|
if (envTarget !== undefined && envParam !== undefined) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue