Tone.js/Tone/core/context/BaseContext.ts

118 lines
3.6 KiB
TypeScript
Raw Normal View History

import { Seconds } from "../type/Units";
import { Emitter } from "../util/Emitter";
import { AnyAudioContext } from "./AudioContext";
type Draw = import("../util/Draw").Draw;
type Destination = import("./Destination").Destination;
type Transport = import("../clock/Transport").Transport;
type Listener = import("./Listener").Listener;
// these are either not used in Tone.js or deprecated and not implemented.
export type ExcludedFromBaseAudioContext = "onstatechange" | "addEventListener" | "removeEventListener" | "listener" | "dispatchEvent" | "audioWorklet" | "destination" | "createScriptProcessor";
// the subset of the BaseAudioContext which Tone.Context implements.
export type BaseAudioContextSubset = Omit<BaseAudioContext, ExcludedFromBaseAudioContext>;
export type ContextLatencyHint = AudioContextLatencyCategory;
2019-11-13 19:16:20 +00:00
export abstract class BaseContext extends Emitter<"statechange" | "tick"> implements BaseAudioContextSubset {
//---------------------------
// BASE AUDIO CONTEXT METHODS
//---------------------------
abstract createAnalyser(): AnalyserNode
abstract createOscillator(): OscillatorNode
abstract createBufferSource(): AudioBufferSourceNode
abstract createBiquadFilter(): BiquadFilterNode
abstract createBuffer(_numberOfChannels: number, _length: number, _sampleRate: number): AudioBuffer
abstract createChannelMerger(_numberOfInputs?: number | undefined): ChannelMergerNode
abstract createChannelSplitter(_numberOfOutputs?: number | undefined): ChannelSplitterNode
abstract createConstantSource(): ConstantSourceNode
abstract createConvolver(): ConvolverNode
abstract createDelay(_maxDelayTime?: number | undefined): DelayNode
abstract createDynamicsCompressor(): DynamicsCompressorNode
abstract createGain(): GainNode
abstract createIIRFilter(_feedForward: number[] | Float32Array, _feedback: number[] | Float32Array): IIRFilterNode
abstract createPanner(): PannerNode
abstract createPeriodicWave(
_real: number[] | Float32Array,
_imag: number[] | Float32Array,
_constraints?: PeriodicWaveConstraints | undefined,
): PeriodicWave
abstract createStereoPanner(): StereoPannerNode
abstract createWaveShaper(): WaveShaperNode
abstract createMediaStreamSource(_stream: MediaStream): MediaStreamAudioSourceNode
abstract createMediaElementSource(_element: HTMLMediaElement): MediaElementAudioSourceNode
2020-04-15 01:06:21 +00:00
abstract createMediaStreamDestination(): MediaStreamAudioDestinationNode
abstract decodeAudioData(_audioData: ArrayBuffer): Promise<AudioBuffer>
//---------------------------
// TONE AUDIO CONTEXT METHODS
//---------------------------
abstract createAudioWorkletNode(
2020-04-15 01:06:21 +00:00
_name: string,
_options?: Partial<AudioWorkletNodeOptions>
): AudioWorkletNode
abstract get rawContext(): AnyAudioContext
abstract async addAudioWorkletModule(_url: string, _name: string): Promise<void>
abstract lookAhead: number;
2019-11-13 19:16:20 +00:00
abstract latencyHint: ContextLatencyHint | Seconds;
abstract resume(): Promise<void>
abstract setTimeout(_fn: (...args: any[]) => void, _timeout: Seconds): number
abstract clearTimeout(_id: number): this
abstract setInterval(_fn: (...args: any[]) => void, _interval: Seconds): number
abstract clearInterval(_id: number): this
abstract getConstant(_val: number): AudioBufferSourceNode
abstract get currentTime(): Seconds
abstract get state(): AudioContextState
abstract get sampleRate(): number
abstract get listener(): Listener
abstract get transport(): Transport
abstract get draw(): Draw
abstract get destination(): Destination
abstract now(): Seconds
abstract immediate(): Seconds
readonly isOffline: boolean = false;
}