perf: stream propagation working sets
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user