MAIDR Documentation - v3.46.2
    Preparing search index...

    Class AudioService

    Service responsible for audio sonification of plot data. Implements the Observer pattern to receive state updates from plot models and converts data values to audio frequencies with spatial panning.

    Features:

    • Frequency mapping based on data value ranges
    • HRTF spatial audio panning based on position in plot
    • Distinct timbres for multiclass/multiline plots via AudioPaletteService
    • ADSR envelope shaping for natural tone attack/decay
    • Simultaneous tone playback for intersection points
    • Warning and notification tones for boundaries and completion

    Implements

    Index

    Constructors

    Methods

    • Disposes of all audio resources and cleans up the service. Stops all active audio, disposes the audio palette, disconnects the compressor, and closes the AudioContext.

      Returns void

    • Observer callback invoked when plot state changes. Plays appropriate audio based on the current data point, including:

      • Empty/warning tones for out-of-bounds navigation
      • Simultaneous tones for multiline intersection points
      • Single tones with frequency mapped to data value
      • Continuous smooth tones for violin/density plots

      Parameters

      • state: PlotState

        The updated plot state containing audio parameters

      Returns void

    • Plays a warning tone to indicate navigation boundary or invalid state. Consists of two descending beeps (half-step down) to clearly signal a warning.

      Returns void

    • Plays a warning tone only if audio mode is enabled. Use this for conditional warnings that should respect user's audio preferences.

      Returns void

    • Plays a repeating waiting tone to indicate an ongoing async operation. The tone repeats every second until stopped.

      Returns Timeout

      AudioId that can be passed to stop() to cancel the waiting tone

    • Plays a completion tone to indicate an async operation has finished. Uses a higher frequency than the waiting tone for clear distinction.

      Returns Timeout

      AudioId for the played tone

    • Toggles the audio mode between off, separate, and combined states. Cycles through modes and notifies the user of the current state.

      • OFF: No audio playback
      • SEPARATE: Sequential playback for multi-point data
      • COMBINED: Simultaneous playback for multi-point data

      Returns void

    • Stops one or more active audio tones by their IDs. Disconnects oscillators and clears associated timeouts/intervals.

      Parameters

      • audioId: Timeout | Timeout[]

        Single AudioId or array of AudioIds to stop

      Returns void