FlapSoundManager class

Procedural, density-aware sound engine for the Split-Flap display.

Architecture

Uses a polyphonic player pool for overlapping click sounds and a single looping player for the ambient "rain" texture. All audio parameters are computed from one value: global density (ratio of active flipping characters to total board capacity).

Web Audio Policy

Browsers block audio until a user gesture triggers playback. This engine does NOT use a manual "unlock" step. Instead, every play() call is wrapped in a silent catchError. Before the first gesture, plays fail silently (the board animates without sound). The instant the user taps anywhere, the browser's AudioContext auto-resumes and all subsequent plays succeed — no overlay, no extra button.

Hard-Stop Contract

When the last row reports activeChars = 0, the engine immediately mutes the rain loop (volume → 0) and pauses it after a 400 ms grace period. This guarantees dead silence when the board is idle.

Integration

// Row widget (every animation cycle):
FlapSoundManager.instance.updateRowActivity(rowHashCode, activeCount);
FlapSoundManager.instance.playClick();

// Host screen:
FlapSoundManager.instance.init();      // initState (preload only)
FlapSoundManager.instance.dispose();   // dispose

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() → void
Releases all player resources.
init() Future<void>
Preloads all audio assets. Does NOT play anything. Safe to call multiple times (idempotent).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
playClick() → void
Fires a click sound (throttled by the pulse timer).
playHaptic() → void
Triggers haptic feedback. Throttled to preserve UI thread budget.
toString() String
A string representation of this object.
inherited
updateRowActivity(int rowId, int activeChars) → void
Reports current activity for a specific row.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

instance FlapSoundManager
final

Constants

maxBoardCapacity → const int
Max characters that could flip simultaneously on a full board.