Merge branch 'glossing/basic-node-pool' into glossing/full-node-pool

This commit is contained in:
Aria
2025-12-04 22:52:57 -06:00
2 changed files with 9 additions and 8 deletions
+8 -7
View File
@@ -147,11 +147,10 @@ export function getCompressor(ac, threshold, ratio, knee, attack, release) {
attack: attack ?? 0.005,
release: release ?? 0.05,
};
node.threshold.value = options.threshold;
node.ratio.value = options.ratio;
node.knee.value = options.knee;
node.attack.value = options.attack;
node.release.value = options.release;
const now = ac.currentTime;
Object.entries(options).forEach(([key, value]) => {
node[key].setValueAtTime(value, now);
});
return node;
}
@@ -234,8 +233,10 @@ export function createFilter(context, start, end, params, cps, cycle) {
const factory = () => context.createBiquadFilter();
filter = getNodeFromPool('filter', factory);
filter.type = type;
filter.Q.value = q;
filter.frequency.value = frequency;
const now = context.currentTime;
Object.entries({ Q: q, frequency }).forEach(([key, value]) => {
filter[key].setValueAtTime(value, now);
});
frequencyParam = filter.frequency;
}
const envelopeValues = [params.attack, params.decay, params.sustain, params.release];
+1 -1
View File
@@ -47,7 +47,6 @@ export const getNodeFromPool = (key, factory, params = {}) => {
node = factory();
}
node[POOL_KEY] = key;
const now = node.context?.currentTime ?? 0;
const paramMap = new Map();
if (node instanceof AudioWorkletNode) {
for (const [name, param] of node.parameters.entries()) {
@@ -61,6 +60,7 @@ export const getNodeFromPool = (key, factory, params = {}) => {
}
}
}
const now = node.context?.currentTime ?? 0;
paramMap.forEach((param, name) => {
param.cancelScheduledValues(now);
// Set values from `params` or restore defaults