mickeyf.docs
    Preparing search index...

    Audio processing/analysis engine.

    Ownership:

    • Owns the AudioContext and nodes it creates.
    • Owns the per-frame analysis loop (driven by requestAnimationFrame).

    Thread model: this code runs on the main JS thread; Web Audio processing occurs on the browser's internal audio thread and is sampled into JS on each analysis tick.

    Index

    Constructors

    Properties

    state: AudioState = ...

    Methods

    • Maps a volume reading in dB to a UI-friendly percentage.

      The mapping assumes a typical display range of [-40, 20] dB.

      Parameters

      • volume: number

        Volume in dB.

      Returns number

      Percentage in [0, 100].

    • Wires a file input to processAudio().

      Parameters

      • fileInput: HTMLInputElement

        File input element that provides audio files.

      Returns () => void

      Cleanup function that removes the event listener.

    • Loads an audio file, constructs the Web Audio graph, and begins playback/analysis.

      If an existing track is loaded, it is torn down first.

      • Analyzer configuration: uses an AnalyserNode with fftSize = 2048.

      Parameters

      • file: File

        Audio file selected by the user.

      Returns Promise<void>

    • Stops playback and resets the playback position to the beginning.

      This clears transient analysis state but keeps the AudioContext alive so that subsequent play() calls can resume without rebuilding the entire graph.

      Returns void