node-web-audio-api
Version:
Web Audio API implementation for Node.js
226 lines (187 loc) • 5.38 kB
JavaScript
import { kEnumerableProperty } from './lib/utils.js';
export class OfflineAudioCompletionEvent extends Event {
constructor(type, eventInitDict) {
super(type);
if (
typeof eventInitDict !== 'object'
|| eventInitDict === null
|| !('renderedBuffer' in eventInitDict)
) {
throw TypeError(`Failed to construct 'OfflineAudioCompletionEvent': Invalid 'OfflineAudioCompletionEventInit' dict given`);
}
this.
}
get renderedBuffer() {
return this.
}
}
Object.defineProperties(OfflineAudioCompletionEvent.prototype, {
[]: {
__proto__: null,
writable: false,
enumerable: false,
configurable: true,
value: 'OfflineAudioCompletionEvent',
},
renderedBuffer: kEnumerableProperty,
});
export class AudioProcessingEvent extends Event {
constructor(type, eventInitDict) {
if (
typeof eventInitDict !== 'object'
|| eventInitDict === null
|| !('playbackTime' in eventInitDict)
|| !('inputBuffer' in eventInitDict)
|| !('outputBuffer' in eventInitDict)
) {
throw TypeError(`Failed to construct 'AudioProcessingEvent': Invalid 'AudioProcessingEventInit' dict given`);
}
super(type);
this.
this.
this.
}
get playbackTime() {
return this.
}
get inputBuffer() {
return this.
}
get outputBuffer() {
return this.
}
}
Object.defineProperties(AudioProcessingEvent.prototype, {
[]: {
__proto__: null,
writable: false,
enumerable: false,
configurable: true,
value: 'AudioProcessingEvent',
},
playbackTime: kEnumerableProperty,
inputBuffer: kEnumerableProperty,
outputBuffer: kEnumerableProperty,
});
export class AudioRenderCapacityEvent extends Event {
constructor(type, eventInitDict) {
if (
typeof eventInitDict !== 'object'
|| eventInitDict === null
|| !('timestamp' in eventInitDict)
|| !('averageLoad' in eventInitDict)
|| !('peakLoad' in eventInitDict)
|| !('underrunRatio' in eventInitDict)
) {
throw TypeError(`Failed to construct 'AudioRenderCapacityEvent': Invalid 'AudioRenderCapacityEventInit' dict given`);
}
super(type);
this.
this.
this.
this.
}
get timestamp() {
return this.
}
get averageLoad() {
return this.
}
get peakLoad() {
return this.
}
get underrunRatio() {
return this.
}
}
Object.defineProperties(AudioRenderCapacityEvent.prototype, {
[]: {
__proto__: null,
writable: false,
enumerable: false,
configurable: true,
value: 'AudioRenderCapacityEvent',
},
timestamp: kEnumerableProperty,
averageLoad: kEnumerableProperty,
peakLoad: kEnumerableProperty,
underrunRatio: kEnumerableProperty,
});
// https://html.spec.whatwg.org/multipage/webappapis.html#errorevent
// interface ErrorEvent : Event {
// constructor(DOMString type, optional ErrorEventInit eventInitDict = {});
// readonly attribute DOMString message;
// readonly attribute USVString filename;
// readonly attribute unsigned long lineno;
// readonly attribute unsigned long colno;
// readonly attribute any error;
// };
// dictionary ErrorEventInit : EventInit {
// DOMString message = "";
// USVString filename = "";
// unsigned long lineno = 0;
// unsigned long colno = 0;
// any error;
// };
export class ErrorEvent extends Event {
constructor(type, eventInitDict = {}) {
super(type);
if (eventInitDict && typeof eventInitDict.message === 'string') {
this.
}
if (eventInitDict && typeof eventInitDict.filename === 'string') {
this.
}
if (eventInitDict && Number.isFinite(eventInitDict.lineno)) {
this.
}
if (eventInitDict && Number.isFinite(eventInitDict.colno)) {
this.
}
if (eventInitDict && eventInitDict.error instanceof Error) {
this.
}
}
get message() {
return this.
}
get filename() {
return this.
}
get lineno() {
return this.
}
get colno() {
return this.
}
get error() {
return this.
}
}
Object.defineProperties(ErrorEvent.prototype, {
[]: {
__proto__: null,
writable: false,
enumerable: false,
configurable: true,
value: 'ErrorEvent',
},
message: kEnumerableProperty,
filename: kEnumerableProperty,
lineno: kEnumerableProperty,
colno: kEnumerableProperty,
error: kEnumerableProperty,
});