Audio · class

ProbeScheduler

When a source is allowed to ask the world whether something is in the way.

Explained in Your first game.

class ProbeScheduler
import { ProbeScheduler } from '@driftengine/audio';

In depth

A segment test per source per frame is the most expensive thing occlusion can do, and it is paid by the consumer's own collision code — which is exactly why the throttling lives here rather than being left for them to discover. Each source is probed once per period, and the phase is spread across its index, so twenty sources are twenty single tests rather than one spike.

Cost: a wall that appears between a source and the listener takes up to one period to be heard, and the smoothing above adds its own approach on top of that. At the default that is well under the time a player takes to walk through a doorway. What would make this wrong is a source moving faster than the period — a projectile — which should be probed every frame and say so.

Constructor

new

constructor(periodSec?: number)
ParameterTypeDescription
periodSec?number

Methods

due

due(index: number, count: number, nowSec: number): boolean
ParameterTypeDescription
indexnumber
countnumber
nowSecnumber

forget

forget(index: number): void
ParameterTypeDescription
indexnumber