Playlist Mode Silence Detection And Playlist Switching

Scope

This document describes the player logic in playlist mode for deciding whether the live radio stream contains sound or silence, and therefore whether programmed music playlist content should be used as the audible output.

The core method can be described as:

  1. maintain a background decoded live-radio stream while playlist mode is active;
  2. split decoded audio into fixed-size PCM analysis frames;
  3. classify each frame by comparing sample amplitudes with an audio-presence threshold;
  4. confirm silence only after a continuous hold duration or a no-frame watchdog window;
  5. select live radio output when sound is present;
  6. select programmed music playlist output when silence or stream unavailability is confirmed;

Runtime Roles

Role Responsibility
Background live radio stream Keeps the real radio stream loaded even when playlist audio is currently audible.
Audio frame extractor Converts decoded radio samples into fixed-size PCM analysis frames.
Presence detector Classifies every frame as sound-present or silent by scanning sample amplitude.
Delay manager Confirms silence only after a continuous hold window or a no-frame watchdog condition.
Playlist controller Provides the music playlist that can replace live radio while radio is silent.
Output selector Enables live radio output or playlist output based on confirmed detector state.

Current Parameters

Parameter Current value Meaning
AudioWorklet frame 1152 samples PCM frame aggregation size used for analysis.
Silence threshold 0.008 absolute amplitude A frame has sound if any sample in either channel reaches this value.
Silence hold 4000 ms Low-energy frames must continue this long before radio is considered silent.
No-frame watchdog interval 2000 ms Period used to detect that no analysis frames are arriving.
No-frame silence trigger 2 missed ticks About 4 seconds without frames marks the radio as silent/unavailable.
Sound recovery Immediate Any above-threshold frame resets silence accumulation and marks radio as sound-present.

High-Level Decision Schema

[Diagram]

Detection State Machine

[Diagram]

Delay Management

The detector uses asymmetric delays:

Transition Delay behavior Reason
Sound to silence Delayed by 4000 ms of continuous low-energy frames. Avoid switching to playlist during short pauses, quiet speech gaps, or stream encoding artifacts.
Silence to sound Immediate on the first above-threshold frame. Return to live radio as soon as real radio audio is back.
Frames missing to silence Delayed by two watchdog ticks, about 4000 ms. Treat a stalled stream or stalled analysis pipeline as unavailable radio.
Frame arrival after watchdog misses Immediate reset of missed-tick counter. Prevent a temporary analyzer gap from forcing playlist mode after frames resume.

The effective silence confirmation is therefore not based on a single audio frame. It requires either sustained low-energy audio over time, or sustained absence of analyzable frames.

Playlist Read / Do-Not-Read Decision

In this schema, "read the music playlist" means allowing the programmed playlist to become the active audible content while the real radio stream is silent.

Detector result Radio state Playlist decision Output decision
Above-threshold frame Sound present Do not use playlist as substitution output. Prefer live radio output.
Below-threshold frames for less than hold window Pending silence Keep current output until silence is confirmed. Avoid unstable switching.
Below-threshold frames for at least 4000 ms Silence confirmed Read/play programmed music playlist. Mute live radio output and use playlist output.
No frames for about 4000 ms Radio unavailable or analyzer stalled Read/play programmed music playlist. Use playlist output while the live path is not reliable.
Sound returns while playlist is active Sound present Stop using playlist as substitution output. Pause playlist and restore live radio output.