perf: stream propagation working sets

This commit is contained in:
2026-08-29 10:56:51 +09:00
parent de0053eae3
commit 044be3cf92
13 changed files with 1532 additions and 267 deletions
+25
View File
@@ -15,6 +15,31 @@ function sampleAsset(signal, assetBuffers, time) {
return channel[left] + (rightValue - channel[left]) * fraction;
}
/**
* Return the interval in which an entry can emit non-zero samples according to
* its declared duration and, for a non-looping asset, the decoded channel
* duration. Sample contents themselves are intentionally not inspected.
*/
export function effectiveSignalDurationSeconds(
entry,
scene,
assetBuffers = new Map(),
) {
const declaredDuration = entry.duration ?? scene.duration;
const signal = entry.signal;
if (signal?.type !== "asset" || signal.loop) return declaredDuration;
const asset = assetBuffers.get(signal.assetId);
const channel = asset?.channels?.[signal.channel ?? 0];
if (
!channel ||
!(asset.sampleRate > 0) ||
!Number.isFinite(asset.sampleRate)
) {
return declaredDuration;
}
return Math.min(declaredDuration, channel.length / asset.sampleRate);
}
/**
* Render one signal entry into the scene-sized output buffer.
*