UNPKG

@azgaar/tone

Version:

A fork of Web Audio framework for making interactive music in the browser.

75 lines (74 loc) 2.37 kB
import { ToneMediaElement } from "../../core/context/ToneMediaElement"; import { GainFactor, Positive, Seconds, Time } from "../../core/type/Units"; import { OneShotSource, OneShotSourceOptions } from "../OneShotSource"; export interface ToneMediaElementSourceOptions extends OneShotSourceOptions { element: ToneMediaElement; playbackRate: Positive; fadeIn: Time; fadeOut: Time; loopStart: Time; loopEnd: Time; loop: boolean; onload: () => void; onerror: (error: Error) => void; } /** * Wrapper around the native MediaElementAudioSourceNode. * @category Source */ export declare class ToneMediaElementSource extends OneShotSource<ToneMediaElementSourceOptions> { readonly name: string; /** * The oscillator */ private _source; /** * The frequency of the oscillator */ readonly playbackRate: Positive; /** * Playback speed */ readonly duration: Positive; /** * indicators if the source has started/stopped */ private _sourceStarted; private _sourceStopped; /** * loop params */ loop: boolean; loopStart: Positive; loopEnd: Positive; /** * @param url The url to load * @param onload The callback to invoke when the source is done playing. */ constructor(mediaElement?: ToneMediaElement, onload?: () => void); constructor(options?: Partial<ToneMediaElementSourceOptions>); static getDefaults(): ToneMediaElementSourceOptions; /** * The fadeIn time of the amplitude envelope. */ get fadeIn(): Time; set fadeIn(t: Time); /** * The fadeOut time of the amplitude envelope. */ get fadeOut(): Time; set fadeOut(t: Time); /** * Start the source * @param time When the player should start. * @param offset The offset from the beginning of the sample to start at. * @param duration How long the sample should play. If no duration is given, it will default to the full length of the sample (minus any offset) * @param gain The gain to play the source back at. */ start(time?: Time, offset?: Time, duration?: Time, gain?: GainFactor): this; protected _stopSource(time?: Seconds): void; /** * Clean up. */ dispose(): this; }