Function XSound

Properties

Analyser: typeof Analyser
Autopanner: typeof Autopanner
BitCrusher: typeof BitCrusher
Chorus: typeof Chorus
Compressor: typeof Compressor
DOT: "."
Delay: typeof Delay
EQUAL_TEMPERAMENT: 12
Effector: typeof Effector
Equalizer: typeof Equalizer
FREQUENCY_RATIO: 1.0594630943592953
Filter: typeof Filter
Flanger: typeof Flanger
Fuzz: typeof Fuzz
HALF_DOWN: "-"
HALF_UP: "+"
Listener: typeof Listener
MIN_A: 27.5
NoiseGate: typeof NoiseGate
NoiseSuppressor: typeof NoiseSuppressor
OverDrive: typeof OverDrive
Panner: typeof Panner
Phaser: typeof Phaser
PitchShifter: typeof PitchShifter
Preamp: typeof Preamp
QUARTER_NOT: 4
Recorder: typeof Recorder
Reverb: typeof Reverb
Ringmodulator: typeof Ringmodulator
SAMPLE_RATE: number

Class (Static) properties

Stereo: typeof Stereo
Tremolo: typeof Tremolo
VocalCanceler: typeof VocalCanceler
Wah: typeof Wah
ajax: ((params) => void)

Type declaration

    • (params): void
    • This class (static) method retrieves resource on web by Ajax.

      Parameters

      • params: {
            timeout?: number;
            type?: XMLHttpRequestResponseType;
            url: string;
            errorCallback?(event, textStatus): void;
            progressCallback?(event): void;
            successCallback?(event, respsonse): void;
        }
        • Optional timeout?: number
        • Optional type?: XMLHttpRequestResponseType
        • url: string
        • errorCallback?:function
          • Parameters

            • event: ProgressEvent<EventTarget>
            • textStatus: "error" | "timeout"

            Returns void

        • progressCallback?:function
          • Parameters

            • event: ProgressEvent<EventTarget>

            Returns void

        • successCallback?:function
          • Parameters

            • event: ProgressEvent<EventTarget>
            • respsonse: string | ArrayBuffer | Blob | Document

            Returns void

      Returns void

computeFrequency: ((index) => number)

Type declaration

    • (index): number
    • This class (static) method computes frequency from index that corresponds to 12 equal temperament.

      Parameters

      • index: number

        This argument is index that corresponds to 12 equal temperament. For example, this value is between 0 and 88 in case of piano.

      Returns number

      Return value is frequency.

computeHz: ((frequency, detune) => number)

Type declaration

computeIndex: ((octave, pitchChar) => number)

Type declaration

    • (octave, pitchChar): number
    • This class (static) method computes index by octave and PitchChar string.

      Parameters

      • octave: number

        This argument is octave.

      • pitchChar: PitchChar

        This argument is PitchChar string.

      Returns number

      Return value is index that is computed by octave and pitch character.

computePlaybackRate: ((playbackRate, detune) => number)

Type declaration

    • (playbackRate, detune): number
    • This class (static) method computes playback rate from playbackRate property and detune property (@see https://www.w3.org/TR/webaudio/#computedplaybackrate).

      Parameters

      • playbackRate: number

        This argument is playbackRate property as instance of AudioParam.

      • detune: number

        This argument is detune property as instance of AudioParam.

      Returns number

      Return value is computed playback rate.

convertTime: ((time) => ConvertedTime)

Type declaration

    • (time): ConvertedTime
    • This class (static) method calculates minutes, seconds and milliseconds from designated time (seconds).

      Parameters

      • time: number

        This argument is time (seconds).

      Returns ConvertedTime

      Return value is converted time as associative array

decode: ((context, arraybuffer, successCallback?, errorCallback?) => Promise<AudioBuffer>)

Type declaration

    • (context, arraybuffer, successCallback?, errorCallback?): Promise<AudioBuffer>
    • This class (static) method decodes instance of ArrayBuffer to instance of AudioBuffer.

      Parameters

      • context: AudioContext

        This argument is instance of AudioContext for decodeAudioData method.

      • arraybuffer: ArrayBuffer

        This argument is decoded to instance of AudioBuffer.

      • Optional successCallback: ((buffer) => void)

        This argument is invoked on success.

          • (buffer): void
          • Parameters

            • buffer: AudioBuffer

            Returns void

      • Optional errorCallback: ((error) => void)

        This argument is invoked on failure.

          • (error): void
          • Parameters

            • error: Error

            Returns void

      Returns Promise<AudioBuffer>

      Return value is instance of Promise that has instance of AudioBuffer.

drop: ((params) => string | File | null)

Type declaration

    • (params): string | File | null
    • This class (static) method gets instance of File from DataTransfer.

      Parameters

      • params: {
            event: DragEvent;
            type: "objectURL" | FileReaderType;
            errorCallback?(event, textStatus): void;
            progressCallback?(event): void;
            successCallback?(event, result): void;
        }
        • event: DragEvent
        • type: "objectURL" | FileReaderType
        • errorCallback?:function
        • progressCallback?:function
          • Parameters

            • event: ProgressEvent<EventTarget>

            Returns void

        • successCallback?:function
          • Parameters

            • event: ProgressEvent<EventTarget>
            • result: any

            Returns void

      Returns string | File | null

      Return value is Object URL or instance of File on success. Otherwise, it is null.

exitFullscreen: (() => Promise<void>)

Type declaration

    • (): Promise<void>
    • This class (static) method shows Document in original size from full screen.

      Returns Promise<void>

      Return value is instance of Promise.

fft: ((reals, imags, size) => void)

Type declaration

    • (reals, imags, size): void
    • This class (static) method executes FFT.

      Parameters

      • reals: Float32Array

        This argument is instance of Float32Array for real number.

      • imags: Float32Array

        This argument is instance of Float32Array for imaginary number.

      • size: number

        This argument is FFT size (power of two).

      Returns void

file: ((params) => string | File | null)

Type declaration

    • (params): string | File | null
    • This class (static) method gets instance of File.

      Parameters

      • params: {
            event: FileEvent;
            type: "objectURL" | FileReaderType;
            errorCallback?(event, textStatus): void;
            progressCallback?(event): void;
            successCallback?(event, result): void;
        }
        • event: FileEvent
        • type: "objectURL" | FileReaderType
        • errorCallback?:function
        • progressCallback?:function
          • Parameters

            • event: ProgressEvent<EventTarget>

            Returns void

        • successCallback?:function
          • Parameters

            • event: ProgressEvent<EventTarget>
            • result: any

            Returns void

      Returns string | File | null

      Return value is Object URL or instance of File on success. Otherwise, it is null.

ifft: ((reals, imags, size) => void)

Type declaration

    • (reals, imags, size): void
    • This class (static) method executes IFFT.

      Parameters

      • reals: Float32Array

        This argument is instance of Float32Array for real number.

      • imags: Float32Array

        This argument is instance of Float32Array for imaginary number.

      • size: number

        This argument is IFFT size (power of two).

      Returns void

isPitchChar: ((pitchChar) => pitchChar is PitchChar)

Type declaration

    • (pitchChar): pitchChar is PitchChar
    • This predicate method determine whether is PitchChar type.

      Parameters

      • pitchChar: string

        This argument is any string.

      Returns pitchChar is PitchChar

read: ((params) => void)

Type declaration

    • (params): void
    • This class (static) method reads file.

      Parameters

      • params: {
            file: File;
            type: FileReaderType;
            errorCallback?(event, textStatus): void;
            progressCallback?(event): void;
            successCallback?(event, result): void;
        }
        • file: File
        • type: FileReaderType
        • errorCallback?:function
        • progressCallback?:function
          • Parameters

            • event: ProgressEvent<EventTarget>

            Returns void

        • successCallback?:function
          • Parameters

            • event: ProgressEvent<EventTarget>
            • result: any

            Returns void

      Returns void

requestFullscreen: ((element) => Promise<void>)

Type declaration

    • (element): Promise<void>
    • This class (static) method shows designated Element in full screen.

      Parameters

      • element: Element

        This argument is instance of Element that is target of full screen.

      Returns Promise<void>

      Return value is instance of Promise.

toFrequencies: ((indexes) => number[])

Type declaration

    • (indexes): number[]
    • This class (static) method calculates frequency from index that corresponds to 12 equal temperament.

      Parameters

      • indexes: number[]

        This argument is array that contains index that corresponds to 12 equal temperament. For example, this value is between 0 and 88 in case of piano.

      Returns number[]

      Return value is array that contains frequency.

toTextFile: ((text, asObjectURL) => string)

Type declaration

    • (text, asObjectURL): string
    • This class (static) method creates text file.

      Parameters

      • text: string

        This argument is string.

      • asObjectURL: boolean

        This argument is true in case of getting text file as Object URL.

      Returns string

      Return value is text file as Data URL or Object URL.

Methods

  • This class (static) method releases memory of unused instances.

    Parameters

    • unusedSources: Source[]

      This argument is array that contains unused instance of Source.

    Returns void

  • This class (static) method gets instance of AudioContext.

    Returns AudioContext

  • This class (static) method gets elapsed time from creating instance of AudioContext.

    Returns number

  • This method deletes XSound function as global object.

    Parameters

    • deep: boolean

      This argument selects whether deleting both of global objects. If this value is true, both of global objects are deleted.

    Returns typeof XSound

  • This class (static) method returns Promise that waits instantiating AudioWorkletProcessors.

    Returns Promise<Error | {
        [sourceName: string]: Source | null;
    }>

    Return value is Promise.

  • This class (static) method changes AudioContextState to 'running'. Initial state is 'suspended' by Autoplay Policy. Therefore, this method must be invoked by user gestures.

    Returns Promise<void>

    Return value is Promise.