Ready for testing
This commit is contained in:
parent
f8796d039f
commit
0dbca05de0
1 changed files with 31 additions and 19 deletions
|
|
@ -423,13 +423,13 @@ const targetToParamGuess = {
|
||||||
pan: 'pan',
|
pan: 'pan',
|
||||||
phaser: 'rate',
|
phaser: 'rate',
|
||||||
post: 'gain',
|
post: 'gain',
|
||||||
delay: 'time',
|
delay: 'delayTime',
|
||||||
room: 'size',
|
room: 'size',
|
||||||
djf: 'value',
|
djf: 'value',
|
||||||
lfo: 'frequency',
|
lfo: 'frequency',
|
||||||
env: 'depth',
|
env: 'depth',
|
||||||
send: 'depth',
|
send: 'depth',
|
||||||
}
|
};
|
||||||
|
|
||||||
function _getTargetParams(nodes, target) {
|
function _getTargetParams(nodes, target) {
|
||||||
let param;
|
let param;
|
||||||
|
|
@ -438,15 +438,14 @@ function _getTargetParams(nodes, target) {
|
||||||
target = split[0];
|
target = split[0];
|
||||||
param = split[1];
|
param = split[1];
|
||||||
} else {
|
} else {
|
||||||
param = targetToParamGuess[target];
|
const targetWithoutIndex = target.replace(/(\d+)$/, '');
|
||||||
|
param = targetToParamGuess[targetWithoutIndex];
|
||||||
}
|
}
|
||||||
const targetNodes = nodes[target];
|
const targetNodes = nodes[target];
|
||||||
if (!targetNodes) {
|
if (!targetNodes) {
|
||||||
const keys = Object.keys(nodes);
|
const keys = Object.keys(nodes);
|
||||||
errorLogger(
|
errorLogger(
|
||||||
new Error(
|
new Error(`Could not connect to target '${target}' — it does not exist. Available targets: ${keys.join(', ')}`),
|
||||||
`Could not connect to target '${target}' — it does not exist. Available targets: ${keys.join(', ')}`,
|
|
||||||
),
|
|
||||||
'superdough',
|
'superdough',
|
||||||
);
|
);
|
||||||
return [];
|
return [];
|
||||||
|
|
@ -470,13 +469,7 @@ function _getTargetParams(nodes, target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function connectLFO(idx, params, nodeTracker) {
|
function connectLFO(idx, params, nodeTracker) {
|
||||||
const {
|
const { rate = 1, sync, cps, target, ...filteredParams } = params;
|
||||||
rate = 1,
|
|
||||||
sync,
|
|
||||||
cps,
|
|
||||||
target,
|
|
||||||
...filteredParams
|
|
||||||
} = params;
|
|
||||||
filteredParams['frequency'] = sync !== undefined ? sync / cps : rate;
|
filteredParams['frequency'] = sync !== undefined ? sync / cps : rate;
|
||||||
const ac = getAudioContext();
|
const ac = getAudioContext();
|
||||||
lfoNode = getLfo(ac, filteredParams);
|
lfoNode = getLfo(ac, filteredParams);
|
||||||
|
|
@ -506,7 +499,7 @@ function connectSendModulator(params, signal, nodeTracker, pendingConnections) {
|
||||||
webAudioTimeout(
|
webAudioTimeout(
|
||||||
ac,
|
ac,
|
||||||
() => {
|
() => {
|
||||||
_getTargetParams(nodeTracker, params.target).forEach(signal.connect);;
|
_getTargetParams(nodeTracker, params.target).forEach(signal.connect);
|
||||||
},
|
},
|
||||||
0,
|
0,
|
||||||
params.begin,
|
params.begin,
|
||||||
|
|
@ -994,13 +987,32 @@ export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5)
|
||||||
} else {
|
} else {
|
||||||
connectSendModulator(params, post);
|
connectSendModulator(params, post);
|
||||||
pendingConnections[p.id] ??= {};
|
pendingConnections[p.id] ??= {};
|
||||||
pendingConnections[p.id][chainID] = [modulator, p.target, p.param, endWithRelease];
|
pendingConnections[p.id][chainID] = new WeakRef([modulator, p.target, endWithRelease]);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
if (value.id in pendingConnections) {
|
||||||
|
for (const data of Object.values(pendingConnections[id])) {
|
||||||
|
const [modulator, target, end] = data.deref();
|
||||||
|
const targets = _getTargetParams(nodes, target);
|
||||||
|
webAudioTimeout(
|
||||||
|
ac,
|
||||||
|
() => {
|
||||||
|
targets.forEach((target) => modulator.connect(target));
|
||||||
|
},
|
||||||
|
0,
|
||||||
|
t,
|
||||||
|
);
|
||||||
|
webAudioTimeout(
|
||||||
|
ac,
|
||||||
|
() => {
|
||||||
|
modulator.disconnect();
|
||||||
|
},
|
||||||
|
0,
|
||||||
|
end,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (applySends) {
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const superdoughTrigger = (t, hap, ct, cps) => {
|
export const superdoughTrigger = (t, hap, ct, cps) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue