{"id":14384605,"url":"https://github.com/chrisguttandin/standardized-audio-context","last_synced_at":"2025-05-14T01:07:08.038Z","repository":{"id":44443393,"uuid":"47925308","full_name":"chrisguttandin/standardized-audio-context","owner":"chrisguttandin","description":"A cross-browser wrapper for the Web Audio API which aims to closely follow the standard.","archived":false,"fork":false,"pushed_at":"2025-04-01T21:52:58.000Z","size":27444,"stargazers_count":710,"open_issues_count":13,"forks_count":33,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-10T02:59:15.443Z","etag":null,"topics":["audio","audio-worklet","browser","polyfill","web-audio"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chrisguttandin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-12-13T15:44:24.000Z","updated_at":"2025-04-09T15:56:05.000Z","dependencies_parsed_at":"2023-02-17T08:31:21.472Z","dependency_job_id":"f387aacf-1313-42a9-a62a-8aa385a55897","html_url":"https://github.com/chrisguttandin/standardized-audio-context","commit_stats":{"total_commits":5687,"total_committers":5,"mean_commits":1137.4,"dds":0.03762968173026204,"last_synced_commit":"5cc380ed68fe9eb28339be9a5de391707eb71c99"},"previous_names":[],"tags_count":465,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisguttandin%2Fstandardized-audio-context","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisguttandin%2Fstandardized-audio-context/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisguttandin%2Fstandardized-audio-context/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisguttandin%2Fstandardized-audio-context/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrisguttandin","download_url":"https://codeload.github.com/chrisguttandin/standardized-audio-context/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248252679,"owners_count":21072699,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio","audio-worklet","browser","polyfill","web-audio"],"created_at":"2024-08-28T18:01:30.544Z","updated_at":"2025-05-14T01:07:08.020Z","avatar_url":"https://github.com/chrisguttandin.png","language":"JavaScript","funding_links":["https://tidelift.com/security"],"categories":["Libraries Audio","JavaScript"],"sub_categories":[],"readme":"![logo](https://repository-images.githubusercontent.com/47925308/9fbb5e00-e6b0-11e9-9a9f-ba142abbeb7b)\n\n# standardized-audio-context\n\n**A cross-browser wrapper for the Web Audio API which aims to closely follow the standard.**\n\n[![version](https://img.shields.io/npm/v/standardized-audio-context.svg?style=flat-square)](https://www.npmjs.com/package/standardized-audio-context)\n\nThis package provides a subset (although it's almost complete) of the [Web Audio API](https://webaudio.github.io/web-audio-api) which works in a reliable and consistent way in every supported browser. In contrast to other popular polyfills `standardized-audio-context` does not patch or modify anything on the global scope. In other words, it does not cause any side effects. It can therefore be used safely inside of libraries. It's what's known as a [ponyfill](https://github.com/sindresorhus/ponyfill).\n\nOne of the goals of `standardized-audio-context` is to only implement missing functionality and to\navoid rewriting built-in features whenever possible. Please take a look at the paragraph about the\n[browser support](#browser-support) below for more information.\n\nThere are some things which cannot be faked in a way that makes them as performant as they could be when implemented natively. The most prominent amongst those things is the [`AudioWorklet`](https://webaudio.github.io/web-audio-api/#audioworklet). Please have a look at the [list of all supported methods](https://github.com/chrisguttandin/standardized-audio-context#api) below for more detailed information.\n\n## Usage\n\nThe `standardized-audio-context` is available on\n[npm](https://www.npmjs.com/package/standardized-audio-context) and can be installed as usual.\n\n```shell\nnpm install standardized-audio-context\n```\n\nYou can then import the `AudioContext` and `OfflineAudioContext` like this:\n\n```js\nimport { AudioContext, OfflineAudioContext } from 'standardized-audio-context';\n```\n\nIt is also possible to load `standardized-audio-context` with a service like [jspm](https://jspm.org). The import statement from above would then need to be changed to point to a URL.\n\n```js\nimport { AudioContext, OfflineAudioContext } from 'https://jspm.dev/standardized-audio-context';\n```\n\nOnce the `AudioContext` and/or `OfflineAudioContext` are imported they can be used in the same way as their native counterparts. The following snippet will for example produce a nice and clean (as well as annoying) sine wave.\n\n```js\nimport { AudioContext } from 'standardized-audio-context';\n\nconst audioContext = new AudioContext();\nconst oscillatorNode = audioContext.createOscillator();\n\noscillatorNode.connect(audioContext.destination);\n\noscillatorNode.start();\n```\n\nAn alternative approach would be to use the AudioNode constructors (the OscillatorNode constructor in this case) instead of the factory methods.\n\n```js\nimport { AudioContext, OscillatorNode } from 'standardized-audio-context';\n\nconst audioContext = new AudioContext();\nconst oscillatorNode = new OscillatorNode(audioContext);\n\noscillatorNode.connect(audioContext.destination);\n\noscillatorNode.start();\n```\n\n## API\n\n### AudioContext\n\nThis is an almost complete implementation of the [`AudioContext`](https://webaudio.github.io/web-audio-api/#audiocontext) interface. It only misses the `createScriptProcessor()` method which is deprecated anyway.\n\nThe AudioContext implements the following TypeScript interface.\n\n```typescript\ninterface IAudioContext extends EventTarget {\n    readonly audioWorklet?: IAudioWorklet;\n    readonly baseLatency: number;\n    readonly currentTime: number;\n    readonly destination: IAudioDestinationNode\u003cIAudioContext\u003e;\n    readonly listener: IAudioListener;\n    onstatechange: null | TEventHandler\u003cIAudioContext\u003e;\n    readonly sampleRate: number;\n    readonly state: TAudioContextState;\n    close(): Promise\u003cvoid\u003e;\n    createAnalyser(): IAnalyserNode\u003cIAudioContext\u003e;\n    createBiquadFilter(): IBiquadFilterNode\u003cIAudioContext\u003e;\n    createBuffer(numberOfChannels: number, length: number, sampleRate: number): IAudioBuffer;\n    createBufferSource(): IAudioBufferSourceNode\u003cIAudioContext\u003e;\n    createChannelMerger(numberOfInputs?: number): IAudioNode\u003cIAudioContext\u003e;\n    createChannelSplitter(numberOfOutputs?: number): IAudioNode\u003cIAudioContext\u003e;\n    createConstantSource(): IConstantSourceNode\u003cIAudioContext\u003e;\n    createConvolver(): IConvolverNode\u003cIAudioContext\u003e;\n    createDelay(maxDelayTime?: number): IDelayNode\u003cIAudioContext\u003e;\n    createDynamicsCompressor(): IDynamicsCompressorNode\u003cIAudioContext\u003e;\n    createGain(): IGainNode\u003cIAudioContext\u003e;\n    createIIRFilter(feedforward: number[], feedback: number[]): IIIRFilterNode\u003cIAudioContext\u003e;\n    createMediaElementSource(mediaElement: HTMLMediaElement): IMediaElementAudioSourceNode\u003cIAudioContext\u003e;\n    createMediaStreamDestination(): IMediaElementAudioDestinationNode\u003cIAudioContext\u003e;\n    createMediaStreamSource(mediaStream: MediaStream): IMediaStreamAudioSourceNode\u003cIAudioContext\u003e;\n    createMediaStreamTrackSource(mediaStreamTrack: MediaStreamTrack): IMediaStreamTrackAudioSourceNode\u003cIAudioContext\u003e;\n    createOscillator(): IOscillatorNode\u003cIAudioContext\u003e;\n    createPanner(): IPannerNode\u003cIAudioContext\u003e;\n    createPeriodicWave(real: number[], imag: number[], constraints?: Partial\u003cIPeriodicWaveConstraints\u003e): IPeriodicWave;\n    createStereoPanner(): IStereoPannerNode\u003cIAudioContext\u003e;\n    createWaveShaper(): IWaveShaperNode\u003cIAudioContext\u003e;\n    decodeAudioData(\n        audioData: ArrayBuffer,\n        successCallback?: TDecodeSuccessCallback,\n        errorCallback?: TDecodeErrorCallback\n    ): Promise\u003cIAudioBuffer\u003e;\n    resume(): Promise\u003cvoid\u003e;\n    suspend(): Promise\u003cvoid\u003e;\n}\n```\n\nThe properties and methods are described in greater detail below.\n\n### OfflineAudioContext\n\nThis is an almost complete implementation of the [`OfflineAudioContext`](https://webaudio.github.io/web-audio-api/#offlineaudiocontext) interface. It only misses the `createScriptProcessor()` method which is deprecated anyway.\n\nIt implements the following TypeScript interface.\n\n```typescript\ninterface IOfflineAudioContext extends EventTarget {\n    readonly audioWorklet?: IAudioWorklet;\n    readonly baseLatency: number;\n    readonly currentTime: number;\n    readonly destination: IAudioDestinationNode\u003cIOfflineAudioContext\u003e;\n    readonly length: number;\n    readonly listener: IAudioListener;\n    onstatechange: null | TEventHandler\u003cIOfflineAudioContext\u003e;\n    readonly sampleRate: number;\n    readonly state: TAudioContextState;\n    createAnalyser(): IAnalyserNode\u003cIOfflineAudioContext\u003e;\n    createBiquadFilter(): IBiquadFilterNode\u003cIOfflineAudioContext\u003e;\n    createBuffer(numberOfChannels: number, length: number, sampleRate: number): IAudioBuffer;\n    createBufferSource(): IAudioBufferSourceNode\u003cIOfflineAudioContext\u003e;\n    createChannelMerger(numberOfInputs?: number): IAudioNode\u003cIOfflineAudioContext\u003e;\n    createChannelSplitter(numberOfOutputs?: number): IAudioNode\u003cIOfflineAudioContext\u003e;\n    createConstantSource(): IConstantSourceNode\u003cIOfflineAudioContext\u003e;\n    createConvolver(): IConvolverNode\u003cIOfflineAudioContext\u003e;\n    createDelay(maxDelayTime?: number): IDelayNode\u003cIOfflineAudioContext\u003e;\n    createDynamicsCompressor(): IDynamicsCompressorNode\u003cIOfflineAudioContext\u003e;\n    createGain(): IGainNode\u003cIOfflineAudioContext\u003e;\n    createIIRFilter(feedforward: number[], feedback: number[]): IIIRFilterNode\u003cIOfflineAudioContext\u003e;\n    createOscillator(): IOscillatorNode\u003cIOfflineAudioContext\u003e;\n    createPanner(): IPannerNode\u003cIOfflineAudioContext\u003e;\n    createPeriodicWave(real: number[], imag: number[], constraints?: Partial\u003cIPeriodicWaveConstraints\u003e): IPeriodicWave;\n    createStereoPanner(): IStereoPannerNode\u003cIOfflineAudioContext\u003e;\n    createWaveShaper(): IWaveShaperNode\u003cIOfflineAudioContext\u003e;\n    decodeAudioData(\n        audioData: ArrayBuffer,\n        successCallback?: TDecodeSuccessCallback,\n        errorCallback?: TDecodeErrorCallback\n    ): Promise\u003cIAudioBuffer\u003e;\n    startRendering(): Promise\u003cIAudioBuffer\u003e;\n}\n```\n\nThe properties and methods are described in greater detail below.\n\n#### audioWorklet\n\nThe [`audioworklet`](https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-audioworklet) property is only available in a [`SecureContext`](https://webidl.spec.whatwg.org/#SecureContext).\n\n#### listener\n\n⚠️ \u003c!-- Bug #117 --\u003e Firefox and Safari up to version 14.0.1 do not support modifying the listener via AudioParams. Therefore calling any of the scheduling functions on the AudioParams of a listener of an OfflineAudioContext throws a `NotSupportedError`.\n\n#### createAnalyser() / AnalyserNode\n\nThis is an implementation of the [`createAnalyser()`](https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createanalyser) factory method. The [`AnalyserNode`](https://webaudio.github.io/web-audio-api/#analysernode) constructor may be used as an alternative.\n\n#### createBiquadFilter() / BiquadFilterNode\n\nThis is an implementation of the [`createBiquadFilter()`](https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createbiquadfilter) factory method. The [`BiquadFilterNode`](https://webaudio.github.io/web-audio-api/#biquadfilternode) constructor may be used as an alternative.\n\n#### createBuffer() / AudioBuffer\n\nThis is an implementation of the [`createBuffer()`](https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createbuffer) factory method. The [`AudioBuffer`](https://webaudio.github.io/web-audio-api/#audiobuffer) constructor may be used as an alternative.\n\n#### createBufferSource() / AudioBufferSourceNode\n\nThis is an implementation of the [`createBufferSource()`](https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createbuffersource) factory method. The [`AudioBufferSourceNode`](https://webaudio.github.io/web-audio-api/#AudioBufferSourceNode) constructor may be used as an alternative.\n\n#### createChannelMerger() / ChannelMergerNode\n\nThis is an implementation of the [`createChannelMerger()`](https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createchannelmerger) factory method. The [`ChannelMergerNode`](https://webaudio.github.io/web-audio-api/#channelmergernode) constructor may be used as an alternative.\n\n#### createChannelSplitter() / ChannelSplitterNode\n\nThis is an implementation of the [`createChannelSplitter()`](https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createchannelsplitter) factory method. The [`ChannelSplitterNode`](https://webaudio.github.io/web-audio-api/#channelsplitternode) constructor may be used as an alternative.\n\n#### createConstantSource() / ConstantSourceNode\n\nThis is an implementation of the [`createConstantSource()`](https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createconstantsource) factory method. The [`ConstantSourceNode`](https://webaudio.github.io/web-audio-api/#ConstantSourceNode) constructor may be used as an alternative.\n\n#### createConvolver() / ConvolverNode\n\nThis is an implementation of the [`createConvolver()`](https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createconvolver) factory method. The [`ConvolverNode`](https://webaudio.github.io/web-audio-api/#ConvolverNode) constructor may be used as an alternative.\n\n#### createDelay() / DelayNode\n\nThis is an implementation of the [`createDelay()`](https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createdelay) factory method. The [`DelayNode`](https://webaudio.github.io/web-audio-api/#DelayNode) constructor may be used as an alternative.\n\n⚠️ \u003c!-- Bug #163 --\u003e The [delayTime AudioParam](https://webaudio.github.io/web-audio-api/#dom-delaynode-delaytime) can't be set to very small values in any browser except Firefox.\n\n#### createDynamicsCompressor() / DynamicsCompressorNode\n\nThis is an implementation of the [`createDynamicsCompressor()`](https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createdynamicscompressor) factory method. The [`DynamicsCompressorNode`](https://webaudio.github.io/web-audio-api/#dynamicscompressornode) constructor may be used as an alternative.\n\n#### createGain() / GainNode\n\nThis is an implementation of the [`createGain()`](https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-creategain) factory method. The [`GainNode`](https://webaudio.github.io/web-audio-api/#gainnode) constructor may be used as an alternative.\n\n#### createIIRFilter() / IIRFilterNode\n\nThis is an implementation of the [`createIIRFilter()`](https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createiirfilter) factory method. The [`IIRFilterNode`](https://webaudio.github.io/web-audio-api/#iirfilternode) constructor may be used as an alternative.\n\n#### createMediaElementSource() / MediaElementAudioSourceNode\n\nThis is an implementation of the [`createMediaElementSource()`](https://webaudio.github.io/web-audio-api/#dom-audiocontext-createmediaelementsource) factory method. The [`MediaElementAudioSourceNode`](https://webaudio.github.io/web-audio-api/#mediaelementaudiosourcenode) constructor may be used as an alternative.\n\nIt does only work with an AudioContext but not with an OfflineAudioContext.\n\n#### createMediaStreamDestination() / MediaStreamAudioDestinationNode\n\nThis is an implementation of the [`createMediaStreamDestination()`](https://webaudio.github.io/web-audio-api/#dom-audiocontext-createmediastreamdestination) factory method. The [`MediaStreamAudioDestinationNode`](https://webaudio.github.io/web-audio-api/#mediastreamaudiodestinationnode) constructor may be used as an alternative.\n\nIt does only work with an AudioContext but not with an OfflineAudioContext.\n\n#### createMediaStreamSource() / MediaStreamAudioSourceNode\n\nThis is an implementation of the [`createMediaStreamSource()`](https://webaudio.github.io/web-audio-api/#dom-audiocontext-createmediastreamsource) factory method. The [`MediaStreamAudioSourceNode`](https://webaudio.github.io/web-audio-api/#mediastreamaudiosourcenode) constructor may be used as an alternative.\n\nIt does only work with an AudioContext but not with an OfflineAudioContext.\n\n#### createMediaStreamTrackSource() / MediaStreamTrackAudioSourceNode\n\nThis is an implementation of the [`createMediaStreamTrackSource()`](https://webaudio.github.io/web-audio-api/#dom-audiocontext-createmediastreamtracksource) factory method. The [`MediaStreamTrackAudioSourceNode`](https://webaudio.github.io/web-audio-api/#mediastreamtrackaudiosourcenode) constructor may be used as an alternative.\n\nIt does only work with an AudioContext but not with an OfflineAudioContext.\n\n#### createOscillator() / OscillatorNode\n\nThis is an implementation of the [`createOscillator()`](https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createoscillator) factory method. The [`OscillatorNode`](https://webaudio.github.io/web-audio-api/#oscillatornode) constructor may be used as an alternative.\n\n#### createPanner() / PannerNode\n\nThis is an implementation of the [`createPanner()`](https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createpanner) factory method. The [`PannerNode`](https://webaudio.github.io/web-audio-api/#pannernode) constructor may be used as an alternative.\n\n#### createPeriodicWave() / PeriodicWave\n\nThis is an implementation of the [`createPeriodicWave()`](https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createperiodicwave) factory method. The [`PeriodicWave`](https://webaudio.github.io/web-audio-api/#periodicwave) constructor may be used as an alternative.\n\n#### createStereoPanner() / StereoPannerNode\n\nThis is an implementation of the [`createStereoPanner()`](https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createstereopanner) factory method. The [`StereoPannerNode`](https://webaudio.github.io/web-audio-api/#stereopannernode) constructor may be used as an alternative.\n\nThe channelCountMode can only be `'explicit'` unless Safari comes up with a native implementation.\n\n#### createWaveShaper() / WaveShaperNode\n\nThis is an implementation of the [`createWaveShaper()`](https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createwaveshaper) factory method. The [`WaveShaperNode`](https://webaudio.github.io/web-audio-api/#waveshapernode) constructor may be used as an alternative.\n\n#### decodeAudioData()\n\nThis is an implementation of the\n[`decodeAudioData()`](https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-decodeaudiodata) method. There is also a standalone method with a similar interface described below.\n\n### decodeAudioData()\n\nThis is a standalone wrapper which can be used in a similar way as the instance method with the same name. The most notable difference is that it expects an (Offline)AudioContext created with this library as the first parameter. But it can also handle a native (Offline)AudioContext. Another difference is that it only returns a promise. It will not call any callbacks.\n\n```js\nimport { decodeAudioData } from 'standardized-audio-context';\n\nconst nativeAudioContext = new AudioContext();\n\nconst response = await fetch('/a-super-cool-audio-file');\nconst arrayBuffer = await response.arrayBuffer();\n\nconst audioBuffer = await decodeAudioData(nativeAudioContext, arrayBuffer);\n```\n\n### isAnyAudioContext()\n\nThis is a utility function which determines if the given value is an AudioContext or not. It does not differentiate between an AudioContext created by `standardized-audio-context` or a native one. But it will return false for an OfflineAudioContext.\n\n```js\nimport { AudioContext, isAnyAudioContext } from 'standardized-audio-context';\n\n// This will create an AudioContext from standardized-audio-context.\nconst audioContext = new AudioContext();\n\nisAnyAudioContext(audioContext); // true\n\n// This will create a native AudioContext.\nconst nativeAudioContext = new window.AudioContext();\n\nisAnyAudioContext(nativeAudioContext); // true\n```\n\n### isAnyAudioNode()\n\nThis is a helper function which allows to identify an AudioNode without any custom instanceof or property checks. It returns true if the given value is an AudioNode or false if not. It doesn't matter if the given value is an AudioNode which has been created with `standardized-audio-context` or not.\n\n```js\nimport { OfflineAudioContext, isAnyAudioNode } from 'standardized-audio-context';\n\n// This will create a native AudioContext.\nconst nativeAudioContext = new AudioContext();\n\nisAnyAudioNode(nativeAudioContext.createGain()); // true\n\n// This will create an OfflineAudioContext from standardized-audio-context.\nconst offlineAudioContext = new OfflineAudioContext({ length: 10, sampleRate: 44100 });\n\nisAnyAudioNode(offlineAudioContext.createGain()); // true\n```\n\n### isAnyAudioParam()\n\nThis is a helper function similiar to `isAnyAudioNode()` but for AudioParams. It returns true if the given value is an AudioParam or false in case it isn't. It doesn't matter if the given value is an AudioParam which has been created with `standardized-audio-context` or not.\n\n```js\nimport { OfflineAudioContext, isAnyAudioParam } from 'standardized-audio-context';\n\n// This will create a native AudioContext.\nconst nativeAudioContext = new AudioContext();\n\nisAnyAudioParam(nativeAudioContext.createGain().gain); // true\n\n// This will create an OfflineAudioContext from standardized-audio-context.\nconst offlineAudioContext = new OfflineAudioContext({ length: 10, sampleRate: 44100 });\n\nisAnyAudioParam(offlineAudioContext.createGain().gain); // true\n```\n\n### isAnyOfflineAudioContext()\n\nThis is a utility function which determines if the given value is an OfflineAudioContext or not. It does not differentiate between an OfflineAudioContext created by `standardized-audio-context` or a native one.\n\n```js\nimport { OfflineAudioContext, isAnyOfflineAudioContext } from 'standardized-audio-context';\n\n// This will create an OfflineAudioContext from standardized-audio-context.\nconst offlineAudioContext = new OfflineAudioContext({ length: 10, sampleRate: 44100 });\n\nisAnyOfflineAudioContext(offlineAudioContext); // true\n\n// This will create a native OfflineAudioContext.\nconst nativeOfflineAudioContext = new window.OfflineAudioContext(1, 10, 44100);\n\nisAnyOfflineAudioContext(nativeOfflineAudioContext); // true\n```\n\n### isSupported()\n\n`standardized-audio-context` is also exporting a promise which can be accessed by calling `isSupported()`. This promise resolves to a boolean which indicates if the functionality is supported within the currently used browser. This is not part of the specification.\n\n```js\nimport { isSupported } from 'standardized-audio-context';\n\nisSupported().then((isSupported) =\u003e {\n    if (isSupported) {\n        // yeah everything should work\n    } else {\n        // oh no this browser seems to be outdated\n    }\n});\n```\n\n## Browser Support\n\nThe goal of this package is to provide a consistent API. But at the same time this package should\nnot grow indefinitely until everything works in IE 6. Whenever a feature is implemented in every\nsupported browser which required a polyfill before to work correctly that polyfill gets removed\nfrom this package. And hopefully at some point in the future this package boils down to a file\nwhich only re-exports built-in objects.\n\nBut until then great care is taken to avoid any unnecessary bloat. This means whenever a workaround\nfor a certain browser is added to this library it will be accompanied by a test which checks that\nthis particular workaround is still needed. I call those tests expectation tests because they test\nif a browser behaves as expected. An expectation test is designed to fail when the browser\neventually ships a fix. Once that happens the workaround and the backing expectation test get\nremoved. The expectation test however gets recycled and will now be used as part of the browser\ncheck performed when calling `isSupported()`.\n\nThe list of currently supported browsers includes Chrome v105+, Firefox v113+ and Safari v17.3+. Please note that the tests only run in the current and upcoming version of each browser.\n\nSupporting a browser only means that it is supported on the feature level. It is absolutely\npossible that a transpiler like [Babel](https://babeljs.io) is necessary to use this package in\nevery supported browser without encountering any syntax errors.\n\nThis package doesn't work with Node.js.\n\n## TypeScript\n\nThis package is written in [TypeScript](https://www.typescriptlang.org/) which means it can be used seamlessly in any TypeScript project. But that is entirely optional.\n\nIn contrast to the Web Audio API types that TypeScript provides out of the box the types exported\nby `standardized-audio-context` do actually match the concrete implementation. TypeScript\ngenerates its types from the [Web IDL](https://heycam.github.io/webidl) definition of the Web Audio\nAPI which does not always match the actually available implementations.\n\n## Tests\n\nAll implemented methods are covered by a large number of tests which run in all the browsers mentioned above. Many thanks to [BrowserStack](https://www.browserstack.com) and [Sauce Labs](https://saucelabs.com) for allowing this module to be tested with their services.\n\n## Security contact information\n\nTo report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisguttandin%2Fstandardized-audio-context","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrisguttandin%2Fstandardized-audio-context","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisguttandin%2Fstandardized-audio-context/lists"}