interface EventTarget { void addEventListener(DOMString type, EventListener? callback, optional boolean capture = false); void removeEventListener(DOMString type, EventListener? callback, optional boolean capture = false); boolean dispatchEvent(Event event); }; /* callback interface EventListener { void handleEvent(Event event); }; */ // Callback interfaces are not supported yet, but that's ok interface EventListener {};
callback DecodeSuccessCallback = void (AudioBuffer decodedData); callback DecodeErrorCallback = void (); [Constructor] interface AudioContext : EventTarget { readonly attribute AudioDestinationNode destination; readonly attribute float sampleRate; readonly attribute double currentTime; readonly attribute AudioListener listener; AudioBuffer createBuffer(unsigned long numberOfChannels, unsigned long length, float sampleRate); void decodeAudioData(ArrayBuffer audioData, DecodeSuccessCallback successCallback, optional DecodeErrorCallback errorCallback); // AudioNode creation AudioBufferSourceNode createBufferSource(); MediaElementAudioSourceNode createMediaElementSource(HTMLMediaElement mediaElement); MediaStreamAudioSourceNode createMediaStreamSource(MediaStream mediaStream); MediaStreamAudioDestinationNode createMediaStreamDestination(); ScriptProcessorNode createScriptProcessor(optional unsigned long bufferSize = 0, optional unsigned long numberOfInputChannels = 2, optional unsigned long numberOfOutputChannels = 2); AnalyserNode createAnalyser(); GainNode createGain(); DelayNode createDelay(optional double maxDelayTime = 1.0); BiquadFilterNode createBiquadFilter(); WaveShaperNode createWaveShaper(); PannerNode createPanner(); ConvolverNode createConvolver(); ChannelSplitterNode createChannelSplitter(optional unsigned long numberOfOutputs = 6); ChannelMergerNode createChannelMerger(optional unsigned long numberOfInputs = 6); DynamicsCompressorNode createDynamicsCompressor(); OscillatorNode createOscillator(); PeriodicWave createPeriodicWave(Float32Array real, Float32Array imag); };
interface AudioBuffer { readonly attribute float sampleRate; readonly attribute long length; // in seconds readonly attribute double duration; readonly attribute long numberOfChannels; Float32Array getChannelData(unsigned long channel); };