1 | import { AudioContext as stdAudioContext, AudioWorkletNode as stdAudioWorkletNode, OfflineAudioContext as stdOfflineAudioContext, } from "standardized-audio-context";
|
2 | import { assert } from "../util/Debug.js";
|
3 | import { isDefined } from "../util/TypeCheck.js";
|
4 |
|
5 |
|
6 |
|
7 | export function createAudioContext(options) {
|
8 | return new stdAudioContext(options);
|
9 | }
|
10 |
|
11 |
|
12 |
|
13 | export function createOfflineAudioContext(channels, length, sampleRate) {
|
14 | return new stdOfflineAudioContext(channels, length, sampleRate);
|
15 | }
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | export const theWindow = typeof self === "object" ? self : null;
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | export const hasAudioContext = theWindow &&
|
26 | (theWindow.hasOwnProperty("AudioContext") ||
|
27 | theWindow.hasOwnProperty("webkitAudioContext"));
|
28 | export function createAudioWorkletNode(context, name, options) {
|
29 | assert(isDefined(stdAudioWorkletNode), "AudioWorkletNode only works in a secure context (https or localhost)");
|
30 | return new (context instanceof (theWindow === null || theWindow === void 0 ? void 0 : theWindow.BaseAudioContext)
|
31 | ? theWindow === null || theWindow === void 0 ? void 0 : theWindow.AudioWorkletNode
|
32 | : stdAudioWorkletNode)(context, name, options);
|
33 | }
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | export { isSupported as supported } from "standardized-audio-context";
|
40 |
|
\ | No newline at end of file |