webaudio.idl (20870B)
1 // GENERATED CONTENT - DO NOT EDIT 2 // Content was automatically extracted by Reffy into webref 3 // (https://github.com/w3c/webref) 4 // Source: Web Audio API 1.1 (https://webaudio.github.io/web-audio-api/) 5 6 enum AudioContextState { 7 "suspended", 8 "running", 9 "closed", 10 "interrupted" 11 }; 12 13 enum AudioContextRenderSizeCategory { 14 "default", 15 "hardware" 16 }; 17 18 callback DecodeErrorCallback = undefined (DOMException error); 19 20 callback DecodeSuccessCallback = undefined (AudioBuffer decodedData); 21 22 [Exposed=Window] 23 interface BaseAudioContext : EventTarget { 24 readonly attribute AudioDestinationNode destination; 25 readonly attribute float sampleRate; 26 readonly attribute double currentTime; 27 readonly attribute AudioListener listener; 28 readonly attribute AudioContextState state; 29 readonly attribute unsigned long renderQuantumSize; 30 [SameObject, SecureContext] 31 readonly attribute AudioWorklet audioWorklet; 32 attribute EventHandler onstatechange; 33 34 AnalyserNode createAnalyser (); 35 BiquadFilterNode createBiquadFilter (); 36 AudioBuffer createBuffer (unsigned long numberOfChannels, 37 unsigned long length, 38 float sampleRate); 39 AudioBufferSourceNode createBufferSource (); 40 ChannelMergerNode createChannelMerger (optional unsigned long numberOfInputs = 6); 41 ChannelSplitterNode createChannelSplitter ( 42 optional unsigned long numberOfOutputs = 6); 43 ConstantSourceNode createConstantSource (); 44 ConvolverNode createConvolver (); 45 DelayNode createDelay (optional double maxDelayTime = 1.0); 46 DynamicsCompressorNode createDynamicsCompressor (); 47 GainNode createGain (); 48 IIRFilterNode createIIRFilter (sequence<double> feedforward, 49 sequence<double> feedback); 50 OscillatorNode createOscillator (); 51 PannerNode createPanner (); 52 PeriodicWave createPeriodicWave (sequence<float> real, 53 sequence<float> imag, 54 optional PeriodicWaveConstraints constraints = {}); 55 ScriptProcessorNode createScriptProcessor( 56 optional unsigned long bufferSize = 0, 57 optional unsigned long numberOfInputChannels = 2, 58 optional unsigned long numberOfOutputChannels = 2); 59 StereoPannerNode createStereoPanner (); 60 WaveShaperNode createWaveShaper (); 61 62 Promise<AudioBuffer> decodeAudioData ( 63 ArrayBuffer audioData, 64 optional DecodeSuccessCallback? successCallback, 65 optional DecodeErrorCallback? errorCallback); 66 }; 67 68 enum AudioContextLatencyCategory { 69 "balanced", 70 "interactive", 71 "playback" 72 }; 73 74 enum AudioSinkType { 75 "none" 76 }; 77 78 [Exposed=Window] 79 interface AudioContext : BaseAudioContext { 80 constructor (optional AudioContextOptions contextOptions = {}); 81 readonly attribute double baseLatency; 82 readonly attribute double outputLatency; 83 [SecureContext] readonly attribute (DOMString or AudioSinkInfo) sinkId; 84 attribute EventHandler onsinkchange; 85 attribute EventHandler onerror; 86 AudioTimestamp getOutputTimestamp (); 87 Promise<undefined> resume (); 88 Promise<undefined> suspend (); 89 Promise<undefined> close (); 90 [SecureContext] Promise<undefined> setSinkId ((DOMString or AudioSinkOptions) sinkId); 91 MediaElementAudioSourceNode createMediaElementSource (HTMLMediaElement mediaElement); 92 MediaStreamAudioSourceNode createMediaStreamSource (MediaStream mediaStream); 93 MediaStreamTrackAudioSourceNode createMediaStreamTrackSource ( 94 MediaStreamTrack mediaStreamTrack); 95 MediaStreamAudioDestinationNode createMediaStreamDestination (); 96 }; 97 98 dictionary AudioContextOptions { 99 (AudioContextLatencyCategory or double) latencyHint = "interactive"; 100 float sampleRate; 101 (DOMString or AudioSinkOptions) sinkId; 102 (AudioContextRenderSizeCategory or unsigned long) renderSizeHint = "default"; 103 }; 104 105 dictionary AudioSinkOptions { 106 required AudioSinkType type; 107 }; 108 109 [Exposed=Window] 110 interface AudioSinkInfo { 111 readonly attribute AudioSinkType type; 112 }; 113 114 dictionary AudioTimestamp { 115 double contextTime; 116 DOMHighResTimeStamp performanceTime; 117 }; 118 119 [Exposed=Window] 120 interface OfflineAudioContext : BaseAudioContext { 121 constructor(OfflineAudioContextOptions contextOptions); 122 constructor(unsigned long numberOfChannels, unsigned long length, float sampleRate); 123 Promise<AudioBuffer> startRendering(); 124 Promise<undefined> resume(); 125 Promise<undefined> suspend(double suspendTime); 126 readonly attribute unsigned long length; 127 attribute EventHandler oncomplete; 128 }; 129 130 dictionary OfflineAudioContextOptions { 131 unsigned long numberOfChannels = 1; 132 required unsigned long length; 133 required float sampleRate; 134 (AudioContextRenderSizeCategory or unsigned long) renderSizeHint = "default"; 135 }; 136 137 [Exposed=Window] 138 interface OfflineAudioCompletionEvent : Event { 139 constructor (DOMString type, OfflineAudioCompletionEventInit eventInitDict); 140 readonly attribute AudioBuffer renderedBuffer; 141 }; 142 143 dictionary OfflineAudioCompletionEventInit : EventInit { 144 required AudioBuffer renderedBuffer; 145 }; 146 147 [Exposed=Window] 148 interface AudioBuffer { 149 constructor (AudioBufferOptions options); 150 readonly attribute float sampleRate; 151 readonly attribute unsigned long length; 152 readonly attribute double duration; 153 readonly attribute unsigned long numberOfChannels; 154 Float32Array getChannelData (unsigned long channel); 155 undefined copyFromChannel (Float32Array destination, 156 unsigned long channelNumber, 157 optional unsigned long bufferOffset = 0); 158 undefined copyToChannel (Float32Array source, 159 unsigned long channelNumber, 160 optional unsigned long bufferOffset = 0); 161 }; 162 163 dictionary AudioBufferOptions { 164 unsigned long numberOfChannels = 1; 165 required unsigned long length; 166 required float sampleRate; 167 }; 168 169 [Exposed=Window] 170 interface AudioNode : EventTarget { 171 AudioNode connect (AudioNode destinationNode, 172 optional unsigned long output = 0, 173 optional unsigned long input = 0); 174 undefined connect (AudioParam destinationParam, optional unsigned long output = 0); 175 undefined disconnect (); 176 undefined disconnect (unsigned long output); 177 undefined disconnect (AudioNode destinationNode); 178 undefined disconnect (AudioNode destinationNode, unsigned long output); 179 undefined disconnect (AudioNode destinationNode, 180 unsigned long output, 181 unsigned long input); 182 undefined disconnect (AudioParam destinationParam); 183 undefined disconnect (AudioParam destinationParam, unsigned long output); 184 readonly attribute BaseAudioContext context; 185 readonly attribute unsigned long numberOfInputs; 186 readonly attribute unsigned long numberOfOutputs; 187 attribute unsigned long channelCount; 188 attribute ChannelCountMode channelCountMode; 189 attribute ChannelInterpretation channelInterpretation; 190 }; 191 192 enum ChannelCountMode { 193 "max", 194 "clamped-max", 195 "explicit" 196 }; 197 198 enum ChannelInterpretation { 199 "speakers", 200 "discrete" 201 }; 202 203 dictionary AudioNodeOptions { 204 unsigned long channelCount; 205 ChannelCountMode channelCountMode; 206 ChannelInterpretation channelInterpretation; 207 }; 208 209 enum AutomationRate { 210 "a-rate", 211 "k-rate" 212 }; 213 214 [Exposed=Window] 215 interface AudioParam { 216 attribute float value; 217 attribute AutomationRate automationRate; 218 readonly attribute float defaultValue; 219 readonly attribute float minValue; 220 readonly attribute float maxValue; 221 AudioParam setValueAtTime (float value, double startTime); 222 AudioParam linearRampToValueAtTime (float value, double endTime); 223 AudioParam exponentialRampToValueAtTime (float value, double endTime); 224 AudioParam setTargetAtTime (float target, double startTime, float timeConstant); 225 AudioParam setValueCurveAtTime (sequence<float> values, 226 double startTime, 227 double duration); 228 AudioParam cancelScheduledValues (double cancelTime); 229 AudioParam cancelAndHoldAtTime (double cancelTime); 230 }; 231 232 [Exposed=Window] 233 interface AudioScheduledSourceNode : AudioNode { 234 attribute EventHandler onended; 235 undefined start(optional double when = 0); 236 undefined stop(optional double when = 0); 237 }; 238 239 [Exposed=Window] 240 interface AnalyserNode : AudioNode { 241 constructor (BaseAudioContext context, optional AnalyserOptions options = {}); 242 undefined getFloatFrequencyData (Float32Array array); 243 undefined getByteFrequencyData (Uint8Array array); 244 undefined getFloatTimeDomainData (Float32Array array); 245 undefined getByteTimeDomainData (Uint8Array array); 246 attribute unsigned long fftSize; 247 readonly attribute unsigned long frequencyBinCount; 248 attribute double minDecibels; 249 attribute double maxDecibels; 250 attribute double smoothingTimeConstant; 251 }; 252 253 dictionary AnalyserOptions : AudioNodeOptions { 254 unsigned long fftSize = 2048; 255 double maxDecibels = -30; 256 double minDecibels = -100; 257 double smoothingTimeConstant = 0.8; 258 }; 259 260 [Exposed=Window] 261 interface AudioBufferSourceNode : AudioScheduledSourceNode { 262 constructor (BaseAudioContext context, 263 optional AudioBufferSourceOptions options = {}); 264 attribute AudioBuffer? buffer; 265 readonly attribute AudioParam playbackRate; 266 readonly attribute AudioParam detune; 267 attribute boolean loop; 268 attribute double loopStart; 269 attribute double loopEnd; 270 undefined start (optional double when = 0, 271 optional double offset, 272 optional double duration); 273 }; 274 275 dictionary AudioBufferSourceOptions { 276 AudioBuffer? buffer; 277 float detune = 0; 278 boolean loop = false; 279 double loopEnd = 0; 280 double loopStart = 0; 281 float playbackRate = 1; 282 }; 283 284 [Exposed=Window] 285 interface AudioDestinationNode : AudioNode { 286 readonly attribute unsigned long maxChannelCount; 287 }; 288 289 [Exposed=Window] 290 interface AudioListener { 291 readonly attribute AudioParam positionX; 292 readonly attribute AudioParam positionY; 293 readonly attribute AudioParam positionZ; 294 readonly attribute AudioParam forwardX; 295 readonly attribute AudioParam forwardY; 296 readonly attribute AudioParam forwardZ; 297 readonly attribute AudioParam upX; 298 readonly attribute AudioParam upY; 299 readonly attribute AudioParam upZ; 300 undefined setPosition (float x, float y, float z); 301 undefined setOrientation (float x, float y, float z, float xUp, float yUp, float zUp); 302 }; 303 304 [Exposed=Window] 305 interface AudioProcessingEvent : Event { 306 constructor (DOMString type, AudioProcessingEventInit eventInitDict); 307 readonly attribute double playbackTime; 308 readonly attribute AudioBuffer inputBuffer; 309 readonly attribute AudioBuffer outputBuffer; 310 }; 311 312 dictionary AudioProcessingEventInit : EventInit { 313 required double playbackTime; 314 required AudioBuffer inputBuffer; 315 required AudioBuffer outputBuffer; 316 }; 317 318 enum BiquadFilterType { 319 "lowpass", 320 "highpass", 321 "bandpass", 322 "lowshelf", 323 "highshelf", 324 "peaking", 325 "notch", 326 "allpass" 327 }; 328 329 [Exposed=Window] 330 interface BiquadFilterNode : AudioNode { 331 constructor (BaseAudioContext context, optional BiquadFilterOptions options = {}); 332 attribute BiquadFilterType type; 333 readonly attribute AudioParam frequency; 334 readonly attribute AudioParam detune; 335 readonly attribute AudioParam Q; 336 readonly attribute AudioParam gain; 337 undefined getFrequencyResponse (Float32Array frequencyHz, 338 Float32Array magResponse, 339 Float32Array phaseResponse); 340 }; 341 342 dictionary BiquadFilterOptions : AudioNodeOptions { 343 BiquadFilterType type = "lowpass"; 344 float Q = 1; 345 float detune = 0; 346 float frequency = 350; 347 float gain = 0; 348 }; 349 350 [Exposed=Window] 351 interface ChannelMergerNode : AudioNode { 352 constructor (BaseAudioContext context, optional ChannelMergerOptions options = {}); 353 }; 354 355 dictionary ChannelMergerOptions : AudioNodeOptions { 356 unsigned long numberOfInputs = 6; 357 }; 358 359 [Exposed=Window] 360 interface ChannelSplitterNode : AudioNode { 361 constructor (BaseAudioContext context, optional ChannelSplitterOptions options = {}); 362 }; 363 364 dictionary ChannelSplitterOptions : AudioNodeOptions { 365 unsigned long numberOfOutputs = 6; 366 }; 367 368 [Exposed=Window] 369 interface ConstantSourceNode : AudioScheduledSourceNode { 370 constructor (BaseAudioContext context, optional ConstantSourceOptions options = {}); 371 readonly attribute AudioParam offset; 372 }; 373 374 dictionary ConstantSourceOptions { 375 float offset = 1; 376 }; 377 378 [Exposed=Window] 379 interface ConvolverNode : AudioNode { 380 constructor (BaseAudioContext context, optional ConvolverOptions options = {}); 381 attribute AudioBuffer? buffer; 382 attribute boolean normalize; 383 }; 384 385 dictionary ConvolverOptions : AudioNodeOptions { 386 AudioBuffer? buffer; 387 boolean disableNormalization = false; 388 }; 389 390 [Exposed=Window] 391 interface DelayNode : AudioNode { 392 constructor (BaseAudioContext context, optional DelayOptions options = {}); 393 readonly attribute AudioParam delayTime; 394 }; 395 396 dictionary DelayOptions : AudioNodeOptions { 397 double maxDelayTime = 1; 398 double delayTime = 0; 399 }; 400 401 [Exposed=Window] 402 interface DynamicsCompressorNode : AudioNode { 403 constructor (BaseAudioContext context, 404 optional DynamicsCompressorOptions options = {}); 405 readonly attribute AudioParam threshold; 406 readonly attribute AudioParam knee; 407 readonly attribute AudioParam ratio; 408 readonly attribute float reduction; 409 readonly attribute AudioParam attack; 410 readonly attribute AudioParam release; 411 }; 412 413 dictionary DynamicsCompressorOptions : AudioNodeOptions { 414 float attack = 0.003; 415 float knee = 30; 416 float ratio = 12; 417 float release = 0.25; 418 float threshold = -24; 419 }; 420 421 [Exposed=Window] 422 interface GainNode : AudioNode { 423 constructor (BaseAudioContext context, optional GainOptions options = {}); 424 readonly attribute AudioParam gain; 425 }; 426 427 dictionary GainOptions : AudioNodeOptions { 428 float gain = 1.0; 429 }; 430 431 [Exposed=Window] 432 interface IIRFilterNode : AudioNode { 433 constructor (BaseAudioContext context, IIRFilterOptions options); 434 undefined getFrequencyResponse (Float32Array frequencyHz, 435 Float32Array magResponse, 436 Float32Array phaseResponse); 437 }; 438 439 dictionary IIRFilterOptions : AudioNodeOptions { 440 required sequence<double> feedforward; 441 required sequence<double> feedback; 442 }; 443 444 [Exposed=Window] 445 interface MediaElementAudioSourceNode : AudioNode { 446 constructor (AudioContext context, MediaElementAudioSourceOptions options); 447 [SameObject] readonly attribute HTMLMediaElement mediaElement; 448 }; 449 450 dictionary MediaElementAudioSourceOptions { 451 required HTMLMediaElement mediaElement; 452 }; 453 454 [Exposed=Window] 455 interface MediaStreamAudioDestinationNode : AudioNode { 456 constructor (AudioContext context, optional AudioNodeOptions options = {}); 457 readonly attribute MediaStream stream; 458 }; 459 460 [Exposed=Window] 461 interface MediaStreamAudioSourceNode : AudioNode { 462 constructor (AudioContext context, MediaStreamAudioSourceOptions options); 463 [SameObject] readonly attribute MediaStream mediaStream; 464 }; 465 466 dictionary MediaStreamAudioSourceOptions { 467 required MediaStream mediaStream; 468 }; 469 470 [Exposed=Window] 471 interface MediaStreamTrackAudioSourceNode : AudioNode { 472 constructor (AudioContext context, MediaStreamTrackAudioSourceOptions options); 473 }; 474 475 dictionary MediaStreamTrackAudioSourceOptions { 476 required MediaStreamTrack mediaStreamTrack; 477 }; 478 479 enum OscillatorType { 480 "sine", 481 "square", 482 "sawtooth", 483 "triangle", 484 "custom" 485 }; 486 487 [Exposed=Window] 488 interface OscillatorNode : AudioScheduledSourceNode { 489 constructor (BaseAudioContext context, optional OscillatorOptions options = {}); 490 attribute OscillatorType type; 491 readonly attribute AudioParam frequency; 492 readonly attribute AudioParam detune; 493 undefined setPeriodicWave (PeriodicWave periodicWave); 494 }; 495 496 dictionary OscillatorOptions : AudioNodeOptions { 497 OscillatorType type = "sine"; 498 float frequency = 440; 499 float detune = 0; 500 PeriodicWave periodicWave; 501 }; 502 503 enum PanningModelType { 504 "equalpower", 505 "HRTF" 506 }; 507 508 enum DistanceModelType { 509 "linear", 510 "inverse", 511 "exponential" 512 }; 513 514 [Exposed=Window] 515 interface PannerNode : AudioNode { 516 constructor (BaseAudioContext context, optional PannerOptions options = {}); 517 attribute PanningModelType panningModel; 518 readonly attribute AudioParam positionX; 519 readonly attribute AudioParam positionY; 520 readonly attribute AudioParam positionZ; 521 readonly attribute AudioParam orientationX; 522 readonly attribute AudioParam orientationY; 523 readonly attribute AudioParam orientationZ; 524 attribute DistanceModelType distanceModel; 525 attribute double refDistance; 526 attribute double maxDistance; 527 attribute double rolloffFactor; 528 attribute double coneInnerAngle; 529 attribute double coneOuterAngle; 530 attribute double coneOuterGain; 531 undefined setPosition (float x, float y, float z); 532 undefined setOrientation (float x, float y, float z); 533 }; 534 535 dictionary PannerOptions : AudioNodeOptions { 536 PanningModelType panningModel = "equalpower"; 537 DistanceModelType distanceModel = "inverse"; 538 float positionX = 0; 539 float positionY = 0; 540 float positionZ = 0; 541 float orientationX = 1; 542 float orientationY = 0; 543 float orientationZ = 0; 544 double refDistance = 1; 545 double maxDistance = 10000; 546 double rolloffFactor = 1; 547 double coneInnerAngle = 360; 548 double coneOuterAngle = 360; 549 double coneOuterGain = 0; 550 }; 551 552 [Exposed=Window] 553 interface PeriodicWave { 554 constructor (BaseAudioContext context, optional PeriodicWaveOptions options = {}); 555 }; 556 557 dictionary PeriodicWaveConstraints { 558 boolean disableNormalization = false; 559 }; 560 561 dictionary PeriodicWaveOptions : PeriodicWaveConstraints { 562 sequence<float> real; 563 sequence<float> imag; 564 }; 565 566 [Exposed=Window] 567 interface ScriptProcessorNode : AudioNode { 568 attribute EventHandler onaudioprocess; 569 readonly attribute long bufferSize; 570 }; 571 572 [Exposed=Window] 573 interface StereoPannerNode : AudioNode { 574 constructor (BaseAudioContext context, optional StereoPannerOptions options = {}); 575 readonly attribute AudioParam pan; 576 }; 577 578 dictionary StereoPannerOptions : AudioNodeOptions { 579 float pan = 0; 580 }; 581 582 enum OverSampleType { 583 "none", 584 "2x", 585 "4x" 586 }; 587 588 [Exposed=Window] 589 interface WaveShaperNode : AudioNode { 590 constructor (BaseAudioContext context, optional WaveShaperOptions options = {}); 591 attribute Float32Array? curve; 592 attribute OverSampleType oversample; 593 }; 594 595 dictionary WaveShaperOptions : AudioNodeOptions { 596 sequence<float> curve; 597 OverSampleType oversample = "none"; 598 }; 599 600 [Exposed=Window, SecureContext] 601 interface AudioWorklet : Worklet { 602 readonly attribute MessagePort port; 603 }; 604 605 callback AudioWorkletProcessorConstructor = AudioWorkletProcessor (object options); 606 607 [Global=(Worklet, AudioWorklet), Exposed=AudioWorklet] 608 interface AudioWorkletGlobalScope : WorkletGlobalScope { 609 undefined registerProcessor (DOMString name, 610 AudioWorkletProcessorConstructor processorCtor); 611 readonly attribute unsigned long long currentFrame; 612 readonly attribute double currentTime; 613 readonly attribute float sampleRate; 614 readonly attribute unsigned long renderQuantumSize; 615 readonly attribute MessagePort port; 616 }; 617 618 [Exposed=Window] 619 interface AudioParamMap { 620 readonly maplike<DOMString, AudioParam>; 621 }; 622 623 [Exposed=Window, SecureContext] 624 interface AudioWorkletNode : AudioNode { 625 constructor (BaseAudioContext context, DOMString name, 626 optional AudioWorkletNodeOptions options = {}); 627 readonly attribute AudioParamMap parameters; 628 readonly attribute MessagePort port; 629 attribute EventHandler onprocessorerror; 630 }; 631 632 dictionary AudioWorkletNodeOptions : AudioNodeOptions { 633 unsigned long numberOfInputs = 1; 634 unsigned long numberOfOutputs = 1; 635 sequence<unsigned long> outputChannelCount; 636 record<DOMString, double> parameterData; 637 object processorOptions; 638 }; 639 640 [Exposed=AudioWorklet] 641 interface AudioWorkletProcessor { 642 constructor (); 643 readonly attribute MessagePort port; 644 }; 645 646 callback AudioWorkletProcessCallback = 647 boolean (FrozenArray<FrozenArray<Float32Array>> inputs, 648 FrozenArray<FrozenArray<Float32Array>> outputs, 649 object parameters); 650 651 dictionary AudioParamDescriptor { 652 required DOMString name; 653 float defaultValue = 0; 654 float minValue = -3.4028235e38; 655 float maxValue = 3.4028235e38; 656 AutomationRate automationRate = "a-rate"; 657 };