Remove webaudioapi. It is included in lib.d.ts.

This commit is contained in:
Andy Hanson
2017-01-05 14:12:58 -08:00
parent ebcd2ff158
commit c201695d68
4 changed files with 0 additions and 579 deletions
-208
View File
@@ -1,208 +0,0 @@
// Type definitions for Web Audio API
// Project: http://www.w3.org/TR/webaudio/
// Definitions by: Baruch Berger <https://github.com/bbss>, Kon <http://phyzkit.net/>, kubosho <https://github.com/kubosho>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// This file refers to the latest published working draft (currently from 10 october 2013) http://www.w3.org/TR/2013/WD-webaudio-20131010/, not to be confused with the latest editor's draft http://webaudio.github.io/web-audio-api/
// DEPRECATED: use TypeScript 1.5.3
declare var webkitAudioContext: {
new (): AudioContext;
}
declare var webkitOfflineAudioContext: {
new (numberOfChannels: number, length: number, sampleRate: number): OfflineAudioContext;
}
declare enum ChannelCountMode {
'max',
'clamped-max',
'explicit'
}
declare enum ChannelInterpretation {
speakers,
discrete
}
declare enum PanningModelType {
/**
* A simple and efficient spatialization algorithm using equal-power panning.
*/
equalpower,
/**
* A higher quality spatialization algorithm using a convolution with measured impulse responses from human subjects. This panning method renders stereo output.
*/
HRTF
}
declare enum DistanceModelType {
/**
* A linear distance model which calculates distanceGain according to:
* 1 - rolloffFactor * (distance - refDistance) / (maxDistance - refDistance)
*/
linear,
/**
* An inverse distance model which calculates distanceGain according to:
* refDistance / (refDistance + rolloffFactor * (distance - refDistance))
*/
inverse,
/**
* An exponential distance model which calculates distanceGain according to:
* pow(distance / refDistance, -rolloffFactor)
*/
exponential
}
declare enum BiquadFilterType {
/**
* A lowpass filter allows frequencies below the cutoff frequency to pass through and attenuates frequencies above the cutoff. It implements a standard second-order resonant lowpass filter with 12dB/octave rolloff.
*
* ## frequency
* The cutoff frequency
* ## Q
* Controls how peaked the response will be at the cutoff frequency. A large value makes the response more peaked. Please note that for this filter type, this value is not a traditional Q, but is a resonance value in decibels.
* ## gain
* Not used in this filter type
*/
lowpass,
/**
* A highpass filter is the opposite of a lowpass filter. Frequencies above the cutoff frequency are passed through, but frequencies below the cutoff are attenuated. It implements a standard second-order resonant highpass filter with 12dB/octave rolloff.
*
* ## frequency
* The cutoff frequency below which the frequencies are attenuated
* ## Q
* Controls how peaked the response will be at the cutoff frequency. A large value makes the response more peaked. Please note that for this filter type, this value is not a traditional Q, but is a resonance value in decibels.
* ## gain
* Not used in this filter type
*/
highpass,
/**
* A bandpass filter allows a range of frequencies to pass through and attenuates the frequencies below and above this frequency range. It implements a second-order bandpass filter.
*
* ## frequency
* The center of the frequency band
* ## Q
* Controls the width of the band. The width becomes narrower as the Q value increases.
* ## gain
* Not used in this filter type
*/
bandpass,
/**
* The lowshelf filter allows all frequencies through, but adds a boost (or attenuation) to the lower frequencies. It implements a second-order lowshelf filter.
*
* ## frequency
* The upper limit of the frequences where the boost (or attenuation) is applied.
* ## Q
* Not used in this filter type.
* ## gain
* The boost, in dB, to be applied. If the value is negative, the frequencies are attenuated.
*/
lowshelf,
/**
* The highshelf filter is the opposite of the lowshelf filter and allows all frequencies through, but adds a boost to the higher frequencies. It implements a second-order highshelf filter
*
* ## frequency
* The lower limit of the frequences where the boost (or attenuation) is applied.
* ## Q
* Not used in this filter type.
* ## gain
* The boost, in dB, to be applied. If the value is negative, the frequencies are attenuated.
*/
highshelf,
/**
* The peaking filter allows all frequencies through, but adds a boost (or attenuation) to a range of frequencies.
*
* ## frequency
* The center frequency of where the boost is applied.
* ## Q
* Controls the width of the band of frequencies that are boosted. A large value implies a narrow width.
* ## gain
* The boost, in dB, to be applied. If the value is negative, the frequencies are attenuated.
*/
peaking,
/**
* The notch filter (also known as a band-stop or band-rejection filter) is the opposite of a bandpass filter. It allows all frequencies through, except for a set of frequencies.
*
* ## frequency
* The center frequency of where the notch is applied.
* ## Q
* Controls the width of the band of frequencies that are attenuated. A large value implies a narrow width.
* ## gain
* Not used in this filter type.
*/
notch,
/**
* An allpass filter allows all frequencies through, but changes the phase relationship between the various frequencies. It implements a second-order allpass filter
*
* ## frequency
* The frequency where the center of the phase transition occurs. Viewed another way, this is the frequency with maximal group delay.
* ## Q
* Controls how sharp the phase transition is at the center frequency. A larger value implies a sharper transition and a larger group delay.
* ## gain
* Not used in this filter type.
*/
allpass
}
declare enum OverSampleType {
'none',
'2x',
'4x'
}
declare enum OscillatorType {
sine,
square,
sawtooth,
triangle,
custom
}
interface AudioContextConstructor {
new(): AudioContext;
}
interface Window {
AudioContext: AudioContextConstructor;
}
interface AudioContext {
createMediaStreamSource(stream: MediaStream): MediaStreamAudioSourceNode;
}
interface MediaStreamAudioSourceNode extends AudioNode {
}
interface MediaStreamAudioDestinationNode extends AudioNode {
stream: MediaStream;
}
interface AudioBuffer {
copyFromChannel(destination: Float32Array, channelNumber: number, startInChannel?: number): void;
copyToChannel(source: Float32Array, channelNumber: number, startInChannel?: number): void;
}
interface AudioNode {
disconnect(destination: AudioNode): void;
}
interface AudioContext {
suspend(): Promise<void>;
resume(): Promise<void>;
close(): Promise<void>;
createMediaStreamDestination(): MediaStreamAudioDestinationNode;
}
-18
View File
@@ -1,18 +0,0 @@
# Web Audio API Definition Notes
## The Web Audio API
The Web Audio API is currently still under development. However WebKit browsers have started an implementation of the proposed specifications which can be found at: [w3.org](http://www.w3.org/TR/webaudio/).
The WebKit nightly builds try to keep up with the editors draft version of the specifications [w3.org](https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html)
### Adding the reference to your project
or
-20
View File
@@ -1,20 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"waa-tests.ts"
]
}
-333
View File
@@ -1,333 +0,0 @@
// http://www.w3.org/TR/2012/WD-webaudio-20121213/
declare var dogBarkingBuffer: any;
()=>{
var context = new AudioContext();
function playSound() {
var source = context.createBufferSource();
source.buffer = dogBarkingBuffer;
source.connect(context.destination);
source.start(0);
}
};
declare var manTalkingBuffer: any;
declare var footstepsBuffer: any;
()=>{
var context = new AudioContext();
// Create the effects nodes.
var lowpassFilter = context.createBiquadFilter();
var waveShaper = context.createWaveShaper();
var panner = context.createPanner();
var compressor = context.createDynamicsCompressor();
var reverb = context.createConvolver();
// Create master wet and dry.
var masterDry = context.createGain();
var masterWet = context.createGain();
// Connect final compressor to final destination.
compressor.connect(context.destination);
// Connect master dry and wet to compressor.
masterDry.connect(compressor);
masterWet.connect(compressor);
// Connect reverb to master wet.
reverb.connect(masterWet);
// Create a few sources.
var source1 = context.createBufferSource();
var source2 = context.createBufferSource();
var source3 = context.createOscillator();
source1.buffer = manTalkingBuffer;
source2.buffer = footstepsBuffer;
source3.frequency.value = 440;
// Connect source1
var dry1 = context.createGain();
var wet1 = context.createGain();
source1.connect(lowpassFilter);
lowpassFilter.connect(dry1);
lowpassFilter.connect(wet1);
dry1.connect(masterDry);
wet1.connect(reverb);
source1.loop = true;
source1.loopStart = 0;
source1.loopEnd = 300;
// Connect source2
var dry2 = context.createGain();
var wet2 = context.createGain();
source2.connect(waveShaper);
waveShaper.connect(dry2);
waveShaper.connect(wet2);
dry2.connect(masterDry);
wet2.connect(reverb);
// Connect source3
var dry3 = context.createGain();
var wet3 = context.createGain();
source3.connect(panner);
panner.connect(dry3);
panner.connect(wet3);
dry3.connect(masterDry);
wet3.connect(reverb);
// Start the sources now.
source1.start(0);
// MEMO: should be when parameter is 0
// http://www.w3.org/TR/webaudio/#AudioBufferSourceNode
source2.start();
source3.start(0);
// Stop the sources are 2 seconds later.
source1.stop(2);
// MEMO: should be when parameter is 0
// http://www.w3.org/TR/webaudio/#AudioBufferSourceNode
source2.stop();
source3.stop(2);
};
()=>{
var context: AudioContext;
var compressor: DynamicsCompressorNode;
var gainNode1: GainNode;
var streamingAudioSource: MediaElementAudioSourceNode;
// Initial setup of the "long-lived" part of the routing graph
function setupAudioContext() {
context = new AudioContext();
compressor = context.createDynamicsCompressor();
gainNode1 = context.createGain();
// Create a streaming audio source.
var audioElement = <HTMLAudioElement> document.getElementById('audioTagID');
streamingAudioSource = context.createMediaElementSource(audioElement);
streamingAudioSource.connect(gainNode1);
gainNode1.connect(compressor);
compressor.connect(context.destination);
}
// Later in response to some user action (typically mouse or key event)
// a one-shot sound can be played.
function playSound() {
var oneShotSound = context.createBufferSource();
oneShotSound.buffer = dogBarkingBuffer;
// Create a filter, panner, and gain node.
var lowpass = context.createBiquadFilter();
var panner = context.createPanner();
var gainNode2 = context.createGain();
// Make connections
oneShotSound.connect(lowpass);
lowpass.connect(panner);
panner.connect(gainNode2);
gainNode2.connect(compressor);
// Play 0.75 seconds from now (to play immediately pass in 0)
oneShotSound.start(context.currentTime + 0.75);
}
};
()=>{
var param:AudioParam;
var t0 = 0;
var t1 = 0.1;
var t2 = 0.2;
var t3 = 0.3;
var t4 = 0.4;
var t5 = 0.6;
var t6 = 0.7;
var t7 = 1.0;
var curveLength = 44100;
var curve = new Float32Array(curveLength);
for (var i = 0; i < curveLength; ++i)
curve[i] = Math.sin(Math.PI * i / curveLength);
param.setValueAtTime(0.2, t0);
param.setValueAtTime(0.3, t1);
param.setValueAtTime(0.4, t2);
param.linearRampToValueAtTime(1, t3);
param.linearRampToValueAtTime(0.15, t4);
param.exponentialRampToValueAtTime(0.75, t5);
param.exponentialRampToValueAtTime(0.05, t6);
param.setValueCurveAtTime(curve, t6, t7 - t6);
};
()=>{
var param: AudioParam;
var t0 = 0;
var t1 = 0.1;
var t2 = 0.2;
var t3 = 0.3;
var t4 = 0.4;
var t5 = 0.6;
var t6 = 0.7;
var t7 = 1.0;
var curveLength = 44100;
var curve = new Float32Array(curveLength);
for (var i = 0; i < curveLength; ++i)
curve[i] = Math.sin(Math.PI * i / curveLength);
param.setValueAtTime(0.2, t0);
param.setValueAtTime(0.3, t1);
param.setValueAtTime(0.4, t2);
param.linearRampToValueAtTime(1, t3);
param.linearRampToValueAtTime(0.15, t4);
param.exponentialRampToValueAtTime(0.75, t5);
param.exponentialRampToValueAtTime(0.05, t6);
param.setValueCurveAtTime(curve, t6, t7 - t6);
};
()=>{
var context: AudioContext;
var filterNode: AudioNode;
var mediaElement = <HTMLMediaElement> document.getElementById('mediaElementID');
var sourceNode = context.createMediaElementSource(mediaElement);
sourceNode.connect(filterNode);
};
()=>{
// Setup routing graph
function setupRoutingGraph() {
var context = new AudioContext();
var compressor = context.createDynamicsCompressor();
// Send1 effect
var reverb = context.createConvolver();
// Convolver impulse response may be set here or later
// Send2 effect
var delay = context.createDelay();
// Connect final compressor to final destination
compressor.connect(context.destination);
// Connect sends 1 & 2 through effects to main mixer
var s1 = context.createGain();
reverb.connect(s1);
s1.connect(compressor);
var s2 = context.createGain();
delay.connect(s2);
s2.connect(compressor);
// Create a couple of sources
var source1 = context.createBufferSource();
var source2 = context.createBufferSource();
source1.buffer = manTalkingBuffer;
source2.buffer = footstepsBuffer;
// Connect source1
var g1_1 = context.createGain();
var g2_1 = context.createGain();
var g3_1 = context.createGain();
source1.connect(g1_1);
source1.connect(g2_1);
source1.connect(g3_1);
g1_1.connect(compressor);
g2_1.connect(reverb);
g3_1.connect(delay);
// Connect source2
var g1_2 = context.createGain();
var g2_2 = context.createGain();
var g3_2 = context.createGain();
source2.connect(g1_2);
source2.connect(g2_2);
source2.connect(g3_2);
g1_2.connect(compressor);
g2_2.connect(reverb);
g3_2.connect(delay);
// We now have explicit control over all the volumes g1_1, g2_1, ..., s1, s2
g2_1.gain.value = 0.2; // For example, set source1 reverb gain
// Because g2_1.gain is an "AudioParam",
// an automation curve could also be attached to it.
// A "mixing board" UI could be created in canvas or WebGL controlling these gains.
}
};
()=>{
var context: AudioContext;
var compressor: DynamicsCompressorNode;
var gainNode1: GainNode;
var streamingAudioSource: MediaElementAudioSourceNode;
// Initial setup of the "long-lived" part of the routing graph
function setupAudioContext() {
context = new AudioContext();
compressor = context.createDynamicsCompressor();
gainNode1 = context.createGain();
// Create a streaming audio source.
var audioElement = <HTMLAudioElement> document.getElementById('audioTagID');
streamingAudioSource = context.createMediaElementSource(audioElement);
streamingAudioSource.connect(gainNode1);
gainNode1.connect(compressor);
compressor.connect(context.destination);
}
// Later in response to some user action (typically mouse or key event)
// a one-shot sound can be played.
function playSound() {
var oneShotSound = context.createBufferSource();
oneShotSound.buffer = dogBarkingBuffer;
// Create a filter, panner, and gain node.
var lowpass = context.createBiquadFilter();
var panner = context.createPanner();
var gainNode2 = context.createGain();
// Make connections
oneShotSound.connect(lowpass);
lowpass.connect(panner);
panner.connect(gainNode2);
gainNode2.connect(compressor);
// Play 0.75 seconds from now (to play immediately pass in 0)
oneShotSound.start(context.currentTime + 0.75);
}
};
()=>{
var context = new webkitOfflineAudioContext(1, 2, 44100.5);
context.oncomplete = function(e) {
context.createBufferSource().buffer;
}
context.startRendering();
}
// Test automatic type inference of the audio processing event handler
() => {
var context = new AudioContext();
var recorder = context.createScriptProcessor(2048, 1, 1);
recorder.onaudioprocess = function (e) {
e.inputBuffer;
};
}