Hiyve Components - v1.0.0
    Preparing search index...

    Interface UseGameSoundsResult

    What useGameSounds returns.

    interface UseGameSoundsResult {
        playBoing: () => void;
        playClick: (sound?: ClickSound, atMs?: number) => number | null;
        playFanfare: () => void;
        playNote: (midi: number, durationMs?: number, gain?: number) => () => void;
        playPop: () => void;
        playRattle: () => void;
        playRight: () => void;
        playSplash: () => void;
        playThud: () => void;
        playWhoosh: () => void;
        playWrong: () => void;
        ready: () => Promise<boolean>;
        supported: boolean;
    }
    Index

    Properties

    playBoing: () => void

    A boing: a vine climbed

    playClick: (sound?: ClickSound, atMs?: number) => number | null

    A click now — or at atMs on the page's clock (performance.now()) when that is still to come, scheduled on the audio clock so a row of clicks keeps perfect time. Returns when it will be heard on the same clock, the device's output delay included — or null when nothing can sound. Call ready first for clicks that must keep time

    playFanfare: () => void

    A little fanfare: freed from a trap, the finish

    playNote: (midi: number, durationMs?: number, gain?: number) => () => void

    Sound a note, held for durationMs (default: under a second), at a loudness from 0 to 1 (default: 0.5); returns a function that stops it early

    playPop: () => void

    A tiny pop: a catch, a hop, a card turned

    playRattle: () => void

    Dice rattling in a cup

    playRight: () => void

    A short rising tone

    playSplash: () => void

    A splash: a wrong pad, a miss, a whirlpool

    playThud: () => void

    A low thud: a fox hole, a trap

    playWhoosh: () => void

    A rush of water or air: a whirlpool, a slide

    playWrong: () => void

    A short falling tone

    ready: () => Promise<boolean>

    Start the sound from a tap and wait until it runs: true once clicks can be scheduled on time, false when sound is off or the browser holds it back

    supported: boolean

    Whether the browser can make sound