Skip to main content

Module audio

Module audio 

Source
Expand description

Sound effect playback for gamification feedback.

Provides audio cues for learning events like correct answers, XP gains, combo achievements, and streak status. Uses JavaScript interop on WASM targets; no-op on native targets for testing.

§Usage

use logicaffeine_web::audio::{SoundEffect, play_sound};

// Play a sound when the user answers correctly
play_sound(SoundEffect::Correct);

// Play combo sound for streak multipliers
play_sound(SoundEffect::ComboUp);

§JavaScript Integration

On WASM targets, this module expects a global window.playSound(name) function to be defined in the host page. The function receives the sound effect name as a string (e.g., “correct”, “combo_up”).

Enums§

SoundEffect
Audio cues for gamification events.

Functions§

play_sound
Plays a sound effect (no-op on non-WASM targets).