melonJS
    Preparing search index...

    Interface ToneOptions

    Options for tone.

    interface ToneOptions {
        attack?: number;
        duration: number;
        freq: number | number[];
        gain?: number;
        pan?: number;
        pitchSlide?: number;
        wave?: OscillatorType;
    }
    Index

    Properties

    attack?: number

    Attack time in seconds — linear ramp from 0 up to gain. Clamped to [0.001, duration / 2]. For very short durations (< 2 ms) the upper bound wins so the envelope still fits inside the playback window. Defaults to 0.005.

    duration: number

    Total sound length in seconds (envelope decays over this window).

    freq: number | number[]

    Carrier frequency in Hz. Pass an array to layer multiple partials (chord, bell ring, fundamental + harmonic) — they share the gain envelope, pan, and pitch slide.

    gain?: number

    Peak gain at attack end, 0..1. Defaults to 0.1.

    pan?: number

    Stereo pan, -1 (full left) to 1 (full right). Defaults to 0.

    pitchSlide?: number

    Frequency multiplier applied over duration as an exponential ramp. 1 = no slide (default); 0.5 = slide an octave down; 2 = slide an octave up. Useful for percussive impacts (small value < 1) or rising stings (value > 1).

    wave?: OscillatorType

    Oscillator waveform. Defaults to "sine".