Game asset processing4 min read

Scheduled SFX Never Starts? Check the Web Audio Clock

Converting Date.now to seconds does not make it an audio-context timestamp. Separate a delay, a scheduled start and an offset inside the file.

Scheduled SFX Never Starts? Check the Web Audio Clock
Concept art of headphones, a game audio icon and glowing waves
AI-generated concept artwork, not a product interface, engine test or measurement.

A button should trigger a sound half a second later. No exception appears, but the sound never seems to arrive. Keep one unchanged file and trace where the scheduled start value came from before generating another asset.

Seconds can belong to different clocks

The MDN start reference defines when in seconds on the same coordinate system as AudioContext.currentTime. It is a scheduled time, not a relative delay from the call.

Dividing Date.now by a thousand changes its unit, not its clock origin. Consult the currentTime reference for the audio context's own time. Verify both the source of a timestamp and its unit.

Use a small arithmetic check

Suppose the context reads 12 seconds and the design asks for a 0.5-second delay. The corresponding scheduling value is 12.5 seconds, not 0.5. These are fictional values illustrating the contract, not a latency measurement from a device.

An offset inside the audio file is a separate requirement. Do not put a file offset into the scheduled start or delay the trigger to compensate for leading silence without first identifying which behavior needs to change.

Capture one controlled scheduling attempt

  1. Record the real playback API, context state and whether decoding has completed.
  2. At scheduling time, capture currentTime, intended delay, resulting when and the unit of each.
  3. Check source-instance lifecycle and output routing, retaining an immediate-play control.
  4. Observe a controlled attempt and distinguish an inactive context, a wrong timestamp and an output-path failure.

This is a diagnostic checklist, not a complete player implementation. If immediate playback is also silent, investigate context and playback permission first. A correct calculation does not by itself establish an audible output path.

A timer callback is not a synchronization measurement

Creating a source after a JavaScript timer fires and scheduling an already prepared source on the audio timeline are different implementations. Keep main-thread load, page state and player lifecycle in the test record. No fixed device latency or cross-browser timing precision is promised here.

If animation events drive sound, define what should happen to a late event. Immediate playback, dropping it and rescheduling it are design choices. Silently accumulating expired notifications can make a later test misleading.

Keep the source asset stable during acceptance

Choose one version in the SFX tool, preserve its export name and use that same file for immediate, delayed and repeated-trigger comparisons. A successful tool audition does not validate the receiving project's scheduling clock.

Record the requested delay, actual scheduling values, context state and audible result. Without measurement equipment, do not invent millisecond latency statistics. Return to asset generation only when the evidence identifies an asset problem.

Recommended tools

Ready to try "Scheduled SFX Never Starts? Check the Web Audio Clock"?

Use our online tools to apply this tutorial to your indie game project right away.