summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/blink/renderer/modules/webaudio/base_audio_context.idl
blob: ffd2965c0150089cc246910b9c0a9d5436681921 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// See https://webaudio.github.io/web-audio-api/#BaseAudioContext

enum AudioContextState {
    "suspended",
    "running",
    "closed"
};

callback DecodeErrorCallback = void (DOMException error);
callback DecodeSuccessCallback = void (AudioBuffer decodedData);

[
    Exposed=Window,
    ActiveScriptWrappable
] interface BaseAudioContext : EventTarget {
    // All rendered audio ultimately connects to destination, which represents the audio hardware.
    readonly attribute AudioDestinationNode destination;

    // All scheduled times are relative to this time in seconds.
    readonly attribute double currentTime;

    // All AudioNodes in the context run at this sample-rate (sample-frames per second).
    [HighEntropy=Direct, Measure] readonly attribute float sampleRate;

    // All panning is relative to this listener.
    readonly attribute AudioListener listener;

    // Current state of the AudioContext
    readonly attribute AudioContextState state;

    [RaisesException] AudioBuffer createBuffer(unsigned long numberOfChannels, unsigned long numberOfFrames, float sampleRate);

    // Asynchronous audio file data decoding.
    // TODO(crbug.com/841185): |successCallback| and |errorCallback| are not
    // nullable in the spec.
    [RaisesException, MeasureAs=AudioContextDecodeAudioData, CallWith=ScriptState] Promise<AudioBuffer> decodeAudioData(ArrayBuffer audioData, optional DecodeSuccessCallback? successCallback, optional DecodeErrorCallback? errorCallback);

    // Sources
    [RaisesException, MeasureAs=AudioContextCreateBufferSource] AudioBufferSourceNode createBufferSource();
    [RaisesException, MeasureAs=AudioContextCreateConstantSource] ConstantSourceNode createConstantSource();

    // Processing nodes
    [RaisesException, MeasureAs=AudioContextCreateGain] GainNode createGain();
    [RaisesException, MeasureAs=AudioContextCreateDelay] DelayNode createDelay(optional double maxDelayTime);
    [RaisesException, MeasureAs=AudioContextCreateBiquadFilter] BiquadFilterNode createBiquadFilter();
    [RaisesException, MeasureAs=AudioContextCreateIIRFilter] IIRFilterNode createIIRFilter(sequence<double> feedForward, sequence<double> feedBack);
    [RaisesException, MeasureAs=AudioContextCreateWaveShaper] WaveShaperNode createWaveShaper();
    [RaisesException, MeasureAs=AudioContextCreatePannerAutomated] PannerNode createPanner();
    [RaisesException, MeasureAs=AudioContextCreateConvolver] ConvolverNode createConvolver();
    [RaisesException, MeasureAs=AudioContextCreateDynamicsCompressor] DynamicsCompressorNode createDynamicsCompressor();
    [RaisesException, MeasureAs=AudioContextCreateAnalyser] AnalyserNode createAnalyser();
    [RaisesException, MeasureAs=AudioContextCreateScriptProcessor] ScriptProcessorNode createScriptProcessor(optional unsigned long bufferSize, optional unsigned long numberOfInputChannels, optional unsigned long numberOfOutputChannels);
    [RaisesException, MeasureAs=AudioContextCreateStereoPanner] StereoPannerNode createStereoPanner();
    [RaisesException, MeasureAs=AudioContextCreateOscillator] OscillatorNode createOscillator();
    [RaisesException, MeasureAs=AudioContextCreatePeriodicWave] PeriodicWave createPeriodicWave(sequence<float> real, sequence<float> imag, optional PeriodicWaveConstraints constraints = {});

    // Channel splitting and merging
    [RaisesException, MeasureAs=AudioContextCreateChannelSplitter] ChannelSplitterNode createChannelSplitter(optional unsigned long numberOfOutputs);
    [RaisesException, MeasureAs=AudioContextCreateChannelMerger] ChannelMergerNode createChannelMerger(optional unsigned long numberOfInputs);

    [SecureContext] readonly attribute AudioWorklet audioWorklet;

    attribute EventHandler onstatechange;
};