├── .github └── workflows │ └── test.yml ├── .gitignore ├── .husky ├── commit-msg └── pre-commit ├── LICENSE ├── README.md ├── config ├── babel │ ├── build.json │ └── test.json ├── eslint │ ├── config.json │ ├── src.json │ └── test.json ├── karma │ ├── config-expectation-chrome-canary.js │ ├── config-expectation-chrome-penultimate.js │ ├── config-expectation-chrome-previous.js │ ├── config-expectation-chrome.js │ ├── config-expectation-firefox-developer.js │ ├── config-expectation-firefox-penultimate.js │ ├── config-expectation-firefox-previous.js │ ├── config-expectation-firefox.js │ ├── config-expectation-safari-penultimate.js │ ├── config-expectation-safari-previous.js │ ├── config-expectation-safari.js │ ├── config-integration.js │ └── config-unit.js ├── lint-staged │ └── config.json ├── mocha │ ├── config-integration.js │ └── config-memory.js ├── prettier │ └── config.json ├── rollup │ └── bundle.mjs └── tslint │ └── src.json ├── package-lock.json ├── package.json ├── src ├── big-int64-array.d.ts ├── big-uint64-array.d.ts ├── constants.ts ├── factories │ ├── abort-error.ts │ ├── add-active-input-connection-to-audio-node.ts │ ├── add-audio-node-connections.ts │ ├── add-audio-param-connections.ts │ ├── add-audio-worklet-module.ts │ ├── add-connection-to-audio-node.ts │ ├── add-passive-input-connection-to-audio-node.ts │ ├── add-silent-connection.ts │ ├── add-unrendered-audio-worklet-node.ts │ ├── analyser-node-constructor.ts │ ├── analyser-node-renderer-factory.ts │ ├── audio-buffer-constructor.ts │ ├── audio-buffer-source-node-constructor.ts │ ├── audio-buffer-source-node-renderer-factory.ts │ ├── audio-context-constructor.ts │ ├── audio-destination-node-constructor.ts │ ├── audio-destination-node-renderer-factory.ts │ ├── audio-listener-factory.ts │ ├── audio-node-constructor.ts │ ├── audio-param-factory.ts │ ├── audio-worklet-node-constructor.ts │ ├── audio-worklet-node-renderer-factory.ts │ ├── base-audio-context-constructor.ts │ ├── biquad-filter-node-constructor.ts │ ├── biquad-filter-node-renderer-factory.ts │ ├── cache-test-result.ts │ ├── channel-merger-node-constructor.ts │ ├── channel-merger-node-renderer-factory.ts │ ├── channel-splitter-node-constructor.ts │ ├── channel-splitter-node-renderer-factory.ts │ ├── connect-audio-param.ts │ ├── connected-native-audio-buffer-source-node-factory.ts │ ├── constant-source-node-constructor.ts │ ├── constant-source-node-renderer-factory.ts │ ├── convolver-node-constructor.ts │ ├── convolver-node-renderer-factory.ts │ ├── create-native-offline-audio-context.ts │ ├── data-clone-error.ts │ ├── decode-audio-data.ts │ ├── decrement-cycle-counter.ts │ ├── delay-node-constructor.ts │ ├── delay-node-renderer-factory.ts │ ├── delete-active-input-connection-to-audio-node.ts │ ├── delete-unrendered-audio-worklet-node.ts │ ├── detect-cycles.ts │ ├── dynamics-compressor-node-constructor.ts │ ├── dynamics-compressor-node-renderer-factory.ts │ ├── event-target-constructor.ts │ ├── fetch-source.ts │ ├── gain-node-constructor.ts │ ├── gain-node-renderer-factory.ts │ ├── get-audio-node-renderer.ts │ ├── get-audio-node-tail-time.ts │ ├── get-backup-offline-audio-context.ts │ ├── get-native-context.ts │ ├── get-or-create-backup-offline-audio-context.ts │ ├── get-unrendered-audio-worklet-nodes.ts │ ├── iir-filter-node-constructor.ts │ ├── iir-filter-node-renderer-factory.ts │ ├── increment-cycle-counter-factory.ts │ ├── index-size-error.ts │ ├── invalid-access-error.ts │ ├── invalid-state-error.ts │ ├── is-any-audio-context.ts │ ├── is-any-audio-node.ts │ ├── is-any-audio-param.ts │ ├── is-any-offline-audio-context.ts │ ├── is-native-audio-context.ts │ ├── is-native-audio-node.ts │ ├── is-native-audio-param.ts │ ├── is-native-context.ts │ ├── is-native-offline-audio-context.ts │ ├── is-secure-context.ts │ ├── is-supported-promise.ts │ ├── media-element-audio-source-node-constructor.ts │ ├── media-stream-audio-destination-node-constructor.ts │ ├── media-stream-audio-source-node-constructor.ts │ ├── media-stream-track-audio-source-node-constructor.ts │ ├── minimal-audio-context-constructor.ts │ ├── minimal-base-audio-context-constructor.ts │ ├── minimal-offline-audio-context-constructor.ts │ ├── monitor-connections.ts │ ├── native-analyser-node-factory.ts │ ├── native-audio-buffer-constructor.ts │ ├── native-audio-buffer-source-node-factory.ts │ ├── native-audio-context-constructor.ts │ ├── native-audio-destination-node.ts │ ├── native-audio-worklet-node-constructor.ts │ ├── native-audio-worklet-node-factory.ts │ ├── native-biquad-filter-node.ts │ ├── native-channel-merger-node.ts │ ├── native-channel-splitter-node.ts │ ├── native-constant-source-node-factory.ts │ ├── native-convolver-node.ts │ ├── native-delay-node.ts │ ├── native-dynamics-compressor-node.ts │ ├── native-gain-node.ts │ ├── native-iir-filter-node.ts │ ├── native-media-element-audio-source-node.ts │ ├── native-media-stream-audio-destination-node.ts │ ├── native-media-stream-audio-source-node.ts │ ├── native-media-stream-track-audio-source-node-factory.ts │ ├── native-offline-audio-context-constructor.ts │ ├── native-oscillator-node-factory.ts │ ├── native-panner-node.ts │ ├── native-periodic-wave-constructor.ts │ ├── native-periodic-wave.ts │ ├── native-script-processor-node.ts │ ├── native-stereo-panner-node.ts │ ├── native-wave-shaper-node-factory.ts │ ├── not-supported-error.ts │ ├── offline-audio-context-constructor.ts │ ├── oscillator-node-constructor.ts │ ├── oscillator-node-renderer-factory.ts │ ├── panner-node-constructor.ts │ ├── panner-node-renderer-factory.ts │ ├── periodic-wave-constructor.ts │ ├── render-inputs-of-audio-node.ts │ ├── render-inputs-of-audio-param.ts │ ├── set-active-audio-worklet-node-inputs.ts │ ├── set-audio-node-tail-time.ts │ ├── start-rendering.ts │ ├── stereo-panner-node-constructor.ts │ ├── stereo-panner-node-renderer-factory.ts │ ├── test-audio-buffer-constructor-support.ts │ ├── test-audio-buffer-copy-channel-methods-out-of-bounds-support.ts │ ├── test-audio-buffer-copy-channel-methods-subarray-support.ts │ ├── test-audio-buffer-factory-method-support.ts │ ├── test-audio-buffer-source-node-buffer-reassignment-support.ts │ ├── test-audio-context-close-method-support.ts │ ├── test-audio-context-decode-audio-data-method-type-error-support.ts │ ├── test-audio-context-get-output-timestamp-support.ts │ ├── test-audio-context-options-support.ts │ ├── test-audio-context-resume-support.ts │ ├── test-audio-node-connect-method-chainability-support.ts │ ├── test-audio-node-connect-method-verification-support.ts │ ├── test-audio-param-value-setter-support.ts │ ├── test-audio-worklet-add-module-method-support.ts │ ├── test-audio-worklet-node-constructor-support.ts │ ├── test-audio-worklet-processor-no-inputs-support.ts │ ├── test-audio-worklet-processor-no-outputs-support.ts │ ├── test-audio-worklet-processor-post-message-support.ts │ ├── test-biquad-filter-node-get-frequency-response-method-support.ts │ ├── test-channel-merger-node-channel-count-support.ts │ ├── test-constant-source-node-accurate-scheduling-support.ts │ ├── test-convolver-node-buffer-reassignability-support.ts │ ├── test-convolver-node-channel-count-support.ts │ ├── test-is-secure-context-support.ts │ ├── test-media-stream-audio-source-node-media-stream-without-audio-track-support.ts │ ├── test-periodic-wave-constructor-support.ts │ ├── test-stereo-panner-node-default-value-support.ts │ ├── wave-shaper-node-constructor.ts │ ├── wave-shaper-node-renderer-factory.ts │ └── window.ts ├── globals.ts ├── guards │ ├── audio-buffer-source-node.ts │ ├── audio-node-output-connection.ts │ ├── audio-node.ts │ ├── audio-worklet-node.ts │ ├── biquad-filter-node.ts │ ├── constant-source-node.ts │ ├── delay-node.ts │ ├── gain-node.ts │ ├── native-audio-node.ts │ ├── oscillator-node.ts │ └── stereo-panner-node.ts ├── helpers │ ├── add-active-input-connection-to-audio-param.ts │ ├── add-passive-input-connection-to-audio-param.ts │ ├── assign-native-audio-node-audio-param-value.ts │ ├── assign-native-audio-node-option.ts │ ├── assign-native-audio-node-options.ts │ ├── connect-native-audio-node-to-native-audio-node.ts │ ├── deactivate-active-audio-node-input-connections.ts │ ├── deactivate-audio-graph.ts │ ├── delete-active-input-connection-to-audio-param.ts │ ├── delete-active-input-connection.ts │ ├── delete-event-listeners-of-audio-node.ts │ ├── delete-passive-input-connection-to-audio-node.ts │ ├── delete-passive-input-connection-to-audio-param.ts │ ├── detach-array-buffer.ts │ ├── disconnect-native-audio-node-from-native-audio-node.ts │ ├── get-audio-node-connections.ts │ ├── get-audio-param-connections.ts │ ├── get-event-listeners-of-audio-node.ts │ ├── get-first-sample.ts │ ├── get-native-audio-node.ts │ ├── get-native-audio-param.ts │ ├── get-value-for-key.ts │ ├── insert-element-in-set.ts │ ├── is-active-audio-node.ts │ ├── is-dc-curve.ts │ ├── is-part-of-a-cycle.ts │ ├── is-passive-audio-node.ts │ ├── is-valid-latency-hint.ts │ ├── overwrite-accessors.ts │ ├── pick-element-from-set.ts │ ├── sanitize-channel-splitter-options.ts │ ├── sanitize-periodic-wave-options.ts │ ├── set-internal-state-to-active.ts │ ├── set-internal-state-to-passive-when-necessary.ts │ ├── set-internal-state-to-passive.ts │ ├── split-import-statements.ts │ ├── test-audio-scheduled-source-node-stop-method-negative-parameters-support.ts │ ├── test-audio-worklet-node-options-clonability.ts │ ├── test-dom-exception-constructor-support.ts │ ├── test-error-event-error-property-support.ts │ ├── test-transferables-support.ts │ ├── visit-each-audio-node-once.ts │ ├── wrap-audio-scheduled-source-node-stop-method-negative-parameters.ts │ ├── wrap-event-listener.ts │ └── wrap-iir-filter-node-get-frequency-response-method.ts ├── interfaces │ ├── analyser-node.ts │ ├── analyser-options.ts │ ├── audio-buffer-options.ts │ ├── audio-buffer-source-node.ts │ ├── audio-buffer-source-options.ts │ ├── audio-buffer.ts │ ├── audio-context-options.ts │ ├── audio-context.ts │ ├── audio-destination-node.ts │ ├── audio-listener.ts │ ├── audio-node-options.ts │ ├── audio-node-renderer.ts │ ├── audio-node.ts │ ├── audio-param.ts │ ├── audio-scheduled-source-node-event-map.ts │ ├── audio-scheduled-source-node.ts │ ├── audio-timestamp.ts │ ├── audio-worklet-node-event-map.ts │ ├── audio-worklet-node-options.ts │ ├── audio-worklet-node.ts │ ├── audio-worklet.ts │ ├── automation.ts │ ├── base-audio-context.ts │ ├── biquad-filter-node.ts │ ├── biquad-filter-options.ts │ ├── channel-merger-options.ts │ ├── channel-splitter-options.ts │ ├── common-audio-context.ts │ ├── common-offline-audio-context.ts │ ├── constant-source-node.ts │ ├── constant-source-options.ts │ ├── convolver-node.ts │ ├── convolver-options.ts │ ├── delay-node.ts │ ├── delay-options.ts │ ├── dynamics-compressor-node.ts │ ├── dynamics-compressor-options.ts │ ├── event-target.ts │ ├── gain-node.ts │ ├── gain-options.ts │ ├── iir-filter-node.ts │ ├── iir-filter-options.ts │ ├── index.ts │ ├── media-element-audio-source-node.ts │ ├── media-element-audio-source-options.ts │ ├── media-stream-audio-destination-node.ts │ ├── media-stream-audio-source-node.ts │ ├── media-stream-audio-source-options.ts │ ├── media-stream-track-audio-source-node.ts │ ├── media-stream-track-audio-source-options.ts │ ├── minimal-audio-context.ts │ ├── minimal-base-audio-context-event-map.ts │ ├── minimal-base-audio-context.ts │ ├── minimal-offline-audio-context.ts │ ├── offline-audio-completion-event.ts │ ├── offline-audio-context-constructor.ts │ ├── offline-audio-context-options.ts │ ├── offline-audio-context.ts │ ├── oscillator-node.ts │ ├── oscillator-options.ts │ ├── panner-node.ts │ ├── panner-options.ts │ ├── periodic-wave-constraints.ts │ ├── periodic-wave-options.ts │ ├── periodic-wave.ts │ ├── read-only-map.ts │ ├── stereo-panner-node.ts │ ├── stereo-panner-options.ts │ ├── wave-shaper-node.ts │ ├── wave-shaper-options.ts │ └── worklet-options.ts ├── message-port.d.ts ├── module.ts ├── read-only-map.ts ├── tsconfig.json └── types │ ├── abort-error-factory.ts │ ├── active-audio-worklet-node-inputs-store.ts │ ├── active-input-connection.ts │ ├── add-active-input-connection-to-audio-node-factory.ts │ ├── add-active-input-connection-to-audio-node-function.ts │ ├── add-audio-node-connections-factory.ts │ ├── add-audio-node-connections-function.ts │ ├── add-audio-param-connections-factory.ts │ ├── add-audio-param-connections-function.ts │ ├── add-audio-worklet-module-factory.ts │ ├── add-audio-worklet-module-function.ts │ ├── add-connection-to-audio-node-factory.ts │ ├── add-connection-to-audio-node-function.ts │ ├── add-passive-input-connection-to-audio-node-factory.ts │ ├── add-passive-input-connection-to-audio-node-function.ts │ ├── add-silent-connection-factory.ts │ ├── add-silent-connection-function.ts │ ├── add-unrendered-audio-worklet-node-factory.ts │ ├── add-unrendered-audio-worklet-node-function.ts │ ├── analyser-node-constructor-factory.ts │ ├── analyser-node-constructor.ts │ ├── any-audio-buffer.ts │ ├── any-context.ts │ ├── audio-buffer-constructor-factory.ts │ ├── audio-buffer-constructor.ts │ ├── audio-buffer-source-node-constructor-factory.ts │ ├── audio-buffer-source-node-constructor.ts │ ├── audio-buffer-store.ts │ ├── audio-context-constructor-factory.ts │ ├── audio-context-constructor.ts │ ├── audio-context-latency-category.ts │ ├── audio-context-state.ts │ ├── audio-destination-node-constructor-factory.ts │ ├── audio-destination-node-constructor.ts │ ├── audio-listener-factory-factory.ts │ ├── audio-listener-factory.ts │ ├── audio-node-connections-store.ts │ ├── audio-node-connections.ts │ ├── audio-node-constructor-factory.ts │ ├── audio-node-constructor.ts │ ├── audio-node-output-connection.ts │ ├── audio-node-renderer.ts │ ├── audio-node-store.ts │ ├── audio-node-tail-time-store.ts │ ├── audio-param-audio-node-store.ts │ ├── audio-param-connections-store.ts │ ├── audio-param-connections.ts │ ├── audio-param-factory-factory.ts │ ├── audio-param-factory.ts │ ├── audio-param-map.ts │ ├── audio-param-output-connection.ts │ ├── audio-param-store.ts │ ├── audio-worklet-node-constructor-factory.ts │ ├── audio-worklet-node-constructor.ts │ ├── backup-offline-audio-context-store.ts │ ├── base-audio-context-constructor-factory.ts │ ├── base-audio-context-constructor.ts │ ├── biquad-filter-node-constructor-factory.ts │ ├── biquad-filter-node-constructor.ts │ ├── biquad-filter-type.ts │ ├── cache-test-result-factory.ts │ ├── cache-test-result-function.ts │ ├── channel-count-mode.ts │ ├── channel-interpretation.ts │ ├── channel-merger-node-constructor-factory.ts │ ├── channel-merger-node-constructor.ts │ ├── channel-splitter-node-constructor-factory.ts │ ├── channel-splitter-node-constructor.ts │ ├── connect-audio-param-factory.ts │ ├── connect-audio-param-function.ts │ ├── connect-native-audio-node-to-native-audio-node-function.ts │ ├── connected-native-audio-buffer-source-node-factory-factory.ts │ ├── connected-native-audio-buffer-source-node-factory.ts │ ├── constant-source-node-constructor-factory.ts │ ├── constant-source-node-constructor.ts │ ├── constructor.ts │ ├── context-store.ts │ ├── context.ts │ ├── convolver-node-constructor-factory.ts │ ├── convolver-node-constructor.ts │ ├── create-native-offline-audio-context-factory.ts │ ├── create-native-offline-audio-context-function.ts │ ├── cycle-counters.ts │ ├── data-clone-error-factory.ts │ ├── decode-audio-data-factory.ts │ ├── decode-audio-data-function.ts │ ├── decode-error-callback.ts │ ├── decode-success-callback.ts │ ├── decrement-cycle-counter-factory.ts │ ├── decrement-cycle-counter-function.ts │ ├── delay-node-constructor-factory.ts │ ├── delay-node-constructor.ts │ ├── delete-active-input-connection-to-audio-node-factory.ts │ ├── delete-active-input-connection-to-audio-node-function.ts │ ├── delete-unrendered-audio-worklet-node-factory.ts │ ├── delete-unrendered-audio-worklet-node-function.ts │ ├── detect-cycles-factory.ts │ ├── detect-cycles-function.ts │ ├── disconnect-native-audio-node-from-native-audio-node-function.ts │ ├── distance-model-type.ts │ ├── dynamics-compressor-node-constructor-factory.ts │ ├── dynamics-compressor-node-constructor.ts │ ├── error-event-handler.ts │ ├── event-handler.ts │ ├── event-target-constructor-factory.ts │ ├── event-target-constructor.ts │ ├── fetch-source-factory.ts │ ├── fetch-source-function.ts │ ├── gain-node-constructor-factory.ts │ ├── gain-node-constructor.ts │ ├── get-audio-node-connections-function.ts │ ├── get-audio-node-renderer-factory.ts │ ├── get-audio-node-renderer-function.ts │ ├── get-audio-node-tail-time-factory.ts │ ├── get-audio-node-tail-time-function.ts │ ├── get-audio-param-connections-function.ts │ ├── get-backup-offline-audio-context-factory.ts │ ├── get-backup-offline-audio-context-function.ts │ ├── get-event-listeners-of-audio-node-function.ts │ ├── get-first-sample-function.ts │ ├── get-native-audio-node-function.ts │ ├── get-native-audio-param-function.ts │ ├── get-native-context-factory.ts │ ├── get-native-context-function.ts │ ├── get-or-create-backup-offline-audio-context-factory.ts │ ├── get-or-create-backup-offline-audio-context-function.ts │ ├── get-unrendered-audio-worklet-nodes-factory.ts │ ├── get-unrendered-audio-worklet-nodes-function.ts │ ├── get-value-for-key-function.ts │ ├── iir-filter-node-constructor-factory.ts │ ├── iir-filter-node-constructor.ts │ ├── increment-cycle-counter-factory-factory.ts │ ├── increment-cycle-counter-factory.ts │ ├── increment-cycle-counter-function.ts │ ├── index-size-error-factory.ts │ ├── index.ts │ ├── insert-element-in-set-function.ts │ ├── internal-state-event-listener.ts │ ├── invalid-access-error-factory.ts │ ├── invalid-state-error-factory.ts │ ├── is-active-audio-node-function.ts │ ├── is-any-audio-context-factory.ts │ ├── is-any-audio-context-function.ts │ ├── is-any-audio-node-factory.ts │ ├── is-any-audio-node-function.ts │ ├── is-any-audio-param-factory.ts │ ├── is-any-audio-param-function.ts │ ├── is-any-offline-audio-context-factory.ts │ ├── is-any-offline-audio-context-function.ts │ ├── is-dc-curve-function.ts │ ├── is-native-audio-context-factory.ts │ ├── is-native-audio-context-function.ts │ ├── is-native-audio-node-factory.ts │ ├── is-native-audio-node-function.ts │ ├── is-native-audio-param-factory.ts │ ├── is-native-audio-param-function.ts │ ├── is-native-context-factory.ts │ ├── is-native-context-function.ts │ ├── is-native-offline-audio-context-factory.ts │ ├── is-native-offline-audio-context-function.ts │ ├── is-part-of-a-cycle-function.ts │ ├── is-passive-audio-node-function.ts │ ├── is-secure-context-factory.ts │ ├── media-element-audio-source-node-constructor-factory.ts │ ├── media-element-audio-source-node-constructor.ts │ ├── media-stream-audio-destination-node-constructor-factory.ts │ ├── media-stream-audio-destination-node-constructor.ts │ ├── media-stream-audio-source-node-constructor-factory.ts │ ├── media-stream-audio-source-node-constructor.ts │ ├── media-stream-track-audio-source-node-constructor-factory.ts │ ├── media-stream-track-audio-source-node-constructor.ts │ ├── minimal-audio-context-constructor-factory.ts │ ├── minimal-audio-context-constructor.ts │ ├── minimal-base-audio-context-constructor-factory.ts │ ├── minimal-base-audio-context-constructor.ts │ ├── minimal-offline-audio-context-constructor-factory.ts │ ├── minimal-offline-audio-context-constructor.ts │ ├── monitor-connections-factory.ts │ ├── monitor-connections-function.ts │ ├── native-analyser-node-factory-factory.ts │ ├── native-analyser-node-factory.ts │ ├── native-analyser-node.ts │ ├── native-audio-buffer-constructor-factory.ts │ ├── native-audio-buffer-constructor.ts │ ├── native-audio-buffer-source-node-factory-factory.ts │ ├── native-audio-buffer-source-node-factory.ts │ ├── native-audio-buffer-source-node.ts │ ├── native-audio-buffer.ts │ ├── native-audio-context-constructor-factory.ts │ ├── native-audio-context-constructor.ts │ ├── native-audio-context.ts │ ├── native-audio-destination-node-factory-factory.ts │ ├── native-audio-destination-node-factory.ts │ ├── native-audio-destination-node.ts │ ├── native-audio-listener.ts │ ├── native-audio-node.ts │ ├── native-audio-param-map.ts │ ├── native-audio-param.ts │ ├── native-audio-timestamp.ts │ ├── native-audio-worklet-node-constructor-factory.ts │ ├── native-audio-worklet-node-constructor.ts │ ├── native-audio-worklet-node-factory-factory.ts │ ├── native-audio-worklet-node-factory.ts │ ├── native-audio-worklet-node-options.ts │ ├── native-audio-worklet-node.ts │ ├── native-audio-worklet.ts │ ├── native-biquad-filter-node-factory.ts │ ├── native-biquad-filter-node.ts │ ├── native-channel-merger-node-factory.ts │ ├── native-channel-merger-node.ts │ ├── native-channel-splitter-node-factory.ts │ ├── native-channel-splitter-node.ts │ ├── native-constant-source-node-factory-factory.ts │ ├── native-constant-source-node-factory.ts │ ├── native-constant-source-node.ts │ ├── native-context.ts │ ├── native-convolver-node-factory.ts │ ├── native-convolver-node.ts │ ├── native-delay-node-factory.ts │ ├── native-delay-node.ts │ ├── native-dynamics-compressor-node-factory.ts │ ├── native-dynamics-compressor-node.ts │ ├── native-event-target.ts │ ├── native-gain-node-factory.ts │ ├── native-gain-node.ts │ ├── native-iir-filter-node-factory.ts │ ├── native-iir-filter-node.ts │ ├── native-media-element-audio-source-node-factory.ts │ ├── native-media-element-audio-source-node.ts │ ├── native-media-stream-audio-destination-node-factory.ts │ ├── native-media-stream-audio-destination-node.ts │ ├── native-media-stream-audio-source-node-factory.ts │ ├── native-media-stream-audio-source-node.ts │ ├── native-media-stream-track-audio-source-node-factory-factory.ts │ ├── native-media-stream-track-audio-source-node-factory.ts │ ├── native-media-stream-track-audio-source-node.ts │ ├── native-offline-audio-context-constructor-factory.ts │ ├── native-offline-audio-context-constructor.ts │ ├── native-offline-audio-context.ts │ ├── native-oscillator-node-factory-factory.ts │ ├── native-oscillator-node-factory.ts │ ├── native-oscillator-node.ts │ ├── native-panner-node-factory.ts │ ├── native-panner-node.ts │ ├── native-periodic-wave-factory.ts │ ├── native-periodic-wave.ts │ ├── native-script-processor-node-factory.ts │ ├── native-script-processor-node.ts │ ├── native-stereo-panner-node-factory.ts │ ├── native-stereo-panner-node.ts │ ├── native-wave-shaper-node-factory-factory.ts │ ├── native-wave-shaper-node-factory.ts │ ├── native-wave-shaper-node.ts │ ├── not-supported-error-factory.ts │ ├── offline-audio-context-constructor-factory.ts │ ├── oscillator-node-constructor-factory.ts │ ├── oscillator-node-constructor.ts │ ├── oscillator-type.ts │ ├── output-connection.ts │ ├── over-sample-type.ts │ ├── overwrite-accessors-function.ts │ ├── panner-node-constructor-factory.ts │ ├── panner-node-constructor.ts │ ├── panning-model-type.ts │ ├── passive-audio-node-input-connection.ts │ ├── passive-audio-param-input-connection.ts │ ├── periodic-wave-constructor-factory.ts │ ├── periodic-wave-constructor.ts │ ├── pick-element-from-set-function.ts │ ├── render-inputs-of-audio-node-factory.ts │ ├── render-inputs-of-audio-node-function.ts │ ├── render-inputs-of-audio-param-factory.ts │ ├── render-inputs-of-audio-param-function.ts │ ├── sanitize-channel-splitter-options-function.ts │ ├── sanitize-periodic-wave-options-function.ts │ ├── set-active-audio-worklet-node-inputs-factory.ts │ ├── set-active-audio-worklet-node-inputs-function.ts │ ├── set-audio-node-tail-time-factory.ts │ ├── set-audio-node-tail-time-function.ts │ ├── start-rendering-factory.ts │ ├── start-rendering-function.ts │ ├── stereo-panner-node-constructor-factory.ts │ ├── stereo-panner-node-constructor.ts │ ├── test-audio-buffer-constructor-support-factory.ts │ ├── test-audio-buffer-copy-channel-methods-subarray-support-factory.ts │ ├── test-audio-context-close-method-support-factory.ts │ ├── test-audio-context-decode-audio-data-method-type-error-support-factory.ts │ ├── test-audio-context-options-support-factory.ts │ ├── test-audio-worklet-node-options-clonability-function.ts │ ├── test-audio-worklet-processor-no-outputs-support-factory.ts │ ├── test-audio-worklet-processor-post-message-support-factory.ts │ ├── test-channel-merger-node-channel-count-support-factory.ts │ ├── test-constant-source-node-accurate-scheduling-support-factory.ts │ ├── test-convolver-node-buffer-reassignability-support-factory.ts │ ├── test-convolver-node-channel-count-support-factory.ts │ ├── test-is-secure-context-support-factory.ts │ ├── test-media-stream-audio-source-node-media-stream-without-audio-track-support.ts │ ├── test-stereo-panner-node-default-value-support-factory.ts │ ├── unrendered-audio-worklet-node-store.ts │ ├── unrendered-audio-worklet-nodes.ts │ ├── wave-shaper-node-constructor-factory.ts │ ├── wave-shaper-node-constructor.ts │ ├── window-factory.ts │ ├── window.ts │ ├── with-additional-property.ts │ └── wrap-event-listener-function.ts └── test ├── expectation ├── chrome │ ├── canary │ │ ├── audio-buffer-source-node.js │ │ ├── audio-context-constructor.js │ │ ├── audio-worklet-node.js │ │ ├── dynamics-compressor-node.js │ │ ├── media-stream-audio-source-node.js │ │ └── offline-audio-context-constructor.js │ ├── current │ │ ├── audio-buffer-source-node.js │ │ ├── audio-context-constructor.js │ │ ├── audio-worklet-node.js │ │ ├── dynamics-compressor-node.js │ │ ├── media-stream-audio-source-node.js │ │ └── offline-audio-context-constructor.js │ ├── penultimate │ │ ├── audio-buffer-source-node.js │ │ ├── audio-context-constructor.js │ │ ├── audio-worklet-node.js │ │ ├── dynamics-compressor-node.js │ │ ├── media-stream-audio-source-node.js │ │ └── offline-audio-context-constructor.js │ └── previous │ │ ├── audio-buffer-source-node.js │ │ ├── audio-context-constructor.js │ │ ├── audio-worklet-node.js │ │ ├── dynamics-compressor-node.js │ │ ├── media-stream-audio-source-node.js │ │ └── offline-audio-context-constructor.js ├── firefox │ ├── current │ │ ├── audio-buffer-source-node.js │ │ ├── audio-context-constructor.js │ │ ├── audio-element.js │ │ ├── audio-worklet-node.js │ │ ├── dynamics-compressor-node.js │ │ ├── media-stream-track-generator.js │ │ └── offline-audio-context-constructor.js │ ├── developer │ │ ├── audio-buffer-source-node.js │ │ ├── audio-context-constructor.js │ │ ├── audio-element.js │ │ ├── audio-worklet-node.js │ │ ├── dynamics-compressor-node.js │ │ ├── media-stream-track-generator.js │ │ └── offline-audio-context-constructor.js │ ├── penultimate │ │ ├── audio-buffer-source-node.js │ │ ├── audio-context-constructor.js │ │ ├── audio-element.js │ │ ├── audio-worklet-node.js │ │ ├── dynamics-compressor-node.js │ │ ├── media-stream-track-generator.js │ │ └── offline-audio-context-constructor.js │ └── previous │ │ ├── audio-buffer-source-node.js │ │ ├── audio-context-constructor.js │ │ ├── audio-element.js │ │ ├── audio-worklet-node.js │ │ ├── dynamics-compressor-node.js │ │ ├── media-stream-track-generator.js │ │ └── offline-audio-context-constructor.js └── safari │ ├── current │ ├── audio-context-constructor.js │ ├── audio-element.js │ ├── audio-worklet-node.js │ ├── dynamics-compressor-node.js │ ├── media-stream-audio-source-node.js │ ├── media-stream-track-generator.js │ └── offline-audio-context-constructor.js │ ├── penultimate │ ├── audio-context-constructor.js │ ├── audio-element.js │ ├── audio-worklet-node.js │ ├── dynamics-compressor-node.js │ ├── media-stream-audio-source-node.js │ ├── media-stream-track-generator.js │ └── offline-audio-context-constructor.js │ └── previous │ ├── audio-context-constructor.js │ ├── audio-element.js │ ├── audio-worklet-node.js │ ├── dynamics-compressor-node.js │ ├── media-stream-audio-source-node.js │ ├── media-stream-track-generator.js │ └── offline-audio-context-constructor.js ├── fixtures ├── 1000-frames-of-noise-mono.wav ├── 1000-frames-of-noise-stereo.wav ├── 1000-hertz-for-ten-seconds.wav ├── constant.js ├── delayed-frames-detector-processor.js ├── dependent-processor.js ├── duplicate-gain-processor.js ├── empty-string-processor.js ├── failing-processor.js ├── gain-processor-with-comment.xs ├── gain-processor.js ├── gibberish-processor.js ├── inspector-processor.js ├── invalid-parameter-descriptors-property-processor.js ├── library.js ├── one-pixel-of-transparency.png ├── processless-processor.js ├── prototypeless-processor.js ├── render-processor.js ├── transferring-processor.js ├── unconstructible-processor.js └── unparsable-processor.xs ├── helper ├── create-audio-context.js ├── create-audio-worklet-node-and-start-frame.js ├── create-minimal-audio-context.js ├── create-minimal-offline-audio-context.js ├── create-native-audio-context.js ├── create-native-offline-audio-context.js ├── create-offline-audio-context.js ├── create-renderer.js ├── is-safari.js ├── load-fixture.js └── round-to-samples.js ├── integration ├── add-audio-worklet-module.js ├── audio-buffer.js ├── audio-contexts │ ├── audio-context.js │ ├── minimal-audio-context.js │ ├── minimal-offline-audio-context.js │ └── offline-audio-context.js ├── audio-listener.js ├── audio-nodes │ ├── analyser-node.js │ ├── audio-buffer-source-node.js │ ├── audio-destination-node.js │ ├── audio-worklet-node.js │ ├── biquad-filter-node.js │ ├── channel-merger-node.js │ ├── channel-splitter-node.js │ ├── constant-source-node.js │ ├── convolver-node.js │ ├── delay-node.js │ ├── dynamics-compressor-node.js │ ├── gain-node.js │ ├── iir-filter-node.js │ ├── media-element-audio-source-node.js │ ├── media-stream-audio-destination-node.js │ ├── media-stream-audio-source-node.js │ ├── media-stream-track-audio-source-node.js │ ├── oscillator-node.js │ ├── panner-node.js │ ├── stereo-panner-node.js │ └── wave-shaper-node.js ├── audio-worklet-global-scope.js ├── decode-audio-data.js ├── is-supported.js ├── module.js └── periodic-wave.js ├── memory └── module.js └── unit ├── factories ├── cache-test-result.js ├── detect-cycles.js ├── is-any-audio-context.js ├── is-any-audio-node.js ├── is-any-audio-param.js ├── is-any-offline-audio-context.js ├── is-native-audio-context.js ├── is-native-audio-node.js ├── is-native-audio-param.js ├── is-native-offline-audio-context.js ├── is-supported-promise.js ├── native-audio-context-constructor.js ├── native-offline-audio-context-constructor.js └── window.js └── helpers ├── sanitize-channel-splitter-options.js ├── sanitize-periodic-wave-options.js └── split-import-statements.js /.gitignore: -------------------------------------------------------------------------------- 1 | *.DS_Store 2 | node_modules/ 3 | /build/ 4 | /config/environment/* 5 | -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | commitlint --edit --extends @commitlint/config-angular 2 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | lint-staged --config config/lint-staged/config.json && npm run lint 2 | -------------------------------------------------------------------------------- /config/babel/build.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@babel/preset-env", 5 | { 6 | "targets": { 7 | "node": "20.9" 8 | } 9 | } 10 | ] 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /config/babel/test.json: -------------------------------------------------------------------------------- 1 | { 2 | "only": ["./test"], 3 | "presets": [ 4 | [ 5 | "@babel/preset-env", 6 | { 7 | "targets": { 8 | "node": "20.9" 9 | } 10 | } 11 | ] 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /config/eslint/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "node": true 4 | }, 5 | "extends": "eslint-config-holy-grail", 6 | "rules": { 7 | "no-sync": "off", 8 | "node/no-missing-require": "off" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /config/eslint/src.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true 4 | }, 5 | "extends": "eslint-config-holy-grail" 6 | } 7 | -------------------------------------------------------------------------------- /config/eslint/test.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "mocha": true 5 | }, 6 | "extends": "eslint-config-holy-grail", 7 | "globals": { 8 | "expect": "readonly" 9 | }, 10 | "rules": { 11 | "no-unused-expressions": "off", 12 | "node/file-extension-in-import": "off", 13 | "node/no-missing-require": "off" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /config/lint-staged/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "*": "prettier --config config/prettier/config.json --ignore-unknown --write" 3 | } 4 | -------------------------------------------------------------------------------- /config/mocha/config-memory.js: -------------------------------------------------------------------------------- 1 | const { expect } = require('chai'); 2 | 3 | global.expect = expect; 4 | -------------------------------------------------------------------------------- /config/prettier/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "arrowParens": "always", 3 | "printWidth": 140, 4 | "quoteProps": "consistent", 5 | "singleQuote": true, 6 | "tabWidth": 4, 7 | "trailingComma": "none" 8 | } 9 | -------------------------------------------------------------------------------- /config/tslint/src.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint-config-holy-grail" 3 | } 4 | -------------------------------------------------------------------------------- /src/big-int64-array.d.ts: -------------------------------------------------------------------------------- 1 | // tslint:disable-next-line:interface-name no-empty-interface 2 | interface BigInt64Array {} 3 | -------------------------------------------------------------------------------- /src/big-uint64-array.d.ts: -------------------------------------------------------------------------------- 1 | // tslint:disable-next-line:interface-name no-empty-interface 2 | interface BigUint64Array {} 3 | -------------------------------------------------------------------------------- /src/constants.ts: -------------------------------------------------------------------------------- 1 | export const MOST_NEGATIVE_SINGLE_FLOAT = -3.4028234663852886e38; 2 | 3 | export const MOST_POSITIVE_SINGLE_FLOAT = -MOST_NEGATIVE_SINGLE_FLOAT; 4 | -------------------------------------------------------------------------------- /src/factories/abort-error.ts: -------------------------------------------------------------------------------- 1 | import { TAbortErrorFactory } from '../types'; 2 | 3 | export const createAbortError: TAbortErrorFactory = () => new DOMException('', 'AbortError'); 4 | -------------------------------------------------------------------------------- /src/factories/add-audio-param-connections.ts: -------------------------------------------------------------------------------- 1 | import { IAudioParam } from '../interfaces'; 2 | import { TAddAudioParamConnectionsFactory } from '../types'; 3 | 4 | export const createAddAudioParamConnections: TAddAudioParamConnectionsFactory = (audioParamConnectionsStore) => { 5 | return (audioParam: IAudioParam) => { 6 | audioParamConnectionsStore.set(audioParam, { activeInputs: new Set(), passiveInputs: new WeakMap() }); 7 | }; 8 | }; 9 | -------------------------------------------------------------------------------- /src/factories/add-unrendered-audio-worklet-node.ts: -------------------------------------------------------------------------------- 1 | import { TAddUnrenderedAudioWorkletNodeFactory } from '../types'; 2 | 3 | export const createAddUnrenderedAudioWorkletNode: TAddUnrenderedAudioWorkletNodeFactory = (getUnrenderedAudioWorkletNodes) => { 4 | return (nativeContext, audioWorkletNode) => { 5 | getUnrenderedAudioWorkletNodes(nativeContext).add(audioWorkletNode); 6 | }; 7 | }; 8 | -------------------------------------------------------------------------------- /src/factories/connect-audio-param.ts: -------------------------------------------------------------------------------- 1 | import { TConnectAudioParamFactory } from '../types'; 2 | 3 | export const createConnectAudioParam: TConnectAudioParamFactory = (renderInputsOfAudioParam) => { 4 | return (nativeOfflineAudioContext, audioParam, nativeAudioParam) => { 5 | return renderInputsOfAudioParam(audioParam, nativeOfflineAudioContext, nativeAudioParam); 6 | }; 7 | }; 8 | -------------------------------------------------------------------------------- /src/factories/create-native-offline-audio-context.ts: -------------------------------------------------------------------------------- 1 | import { TCreateNativeOfflineAudioContextFactory } from '../types'; 2 | 3 | export const createCreateNativeOfflineAudioContext: TCreateNativeOfflineAudioContextFactory = (nativeOfflineAudioContextConstructor) => { 4 | return (numberOfChannels, length, sampleRate) => { 5 | if (nativeOfflineAudioContextConstructor === null) { 6 | throw new Error('Missing the native OfflineAudioContext constructor.'); 7 | } 8 | 9 | return new nativeOfflineAudioContextConstructor(numberOfChannels, length, sampleRate); 10 | }; 11 | }; 12 | -------------------------------------------------------------------------------- /src/factories/data-clone-error.ts: -------------------------------------------------------------------------------- 1 | import { TDataCloneErrorFactory } from '../types'; 2 | 3 | export const createDataCloneError: TDataCloneErrorFactory = () => new DOMException('', 'DataCloneError'); 4 | -------------------------------------------------------------------------------- /src/factories/delete-active-input-connection-to-audio-node.ts: -------------------------------------------------------------------------------- 1 | import { TDeleteActiveInputConnectionToAudioNodeFactory } from '../types'; 2 | 3 | export const createDeleteActiveInputConnectionToAudioNode: TDeleteActiveInputConnectionToAudioNodeFactory = (pickElementFromSet) => { 4 | return (activeInputs, source, output, input) => { 5 | return pickElementFromSet( 6 | activeInputs[input], 7 | (activeInputConnection) => activeInputConnection[0] === source && activeInputConnection[1] === output 8 | ); 9 | }; 10 | }; 11 | -------------------------------------------------------------------------------- /src/factories/delete-unrendered-audio-worklet-node.ts: -------------------------------------------------------------------------------- 1 | import { TDeleteUnrenderedAudioWorkletNodeFactory } from '../types'; 2 | 3 | export const createDeleteUnrenderedAudioWorkletNode: TDeleteUnrenderedAudioWorkletNodeFactory = (getUnrenderedAudioWorkletNodes) => { 4 | return (nativeContext, audioWorkletNode) => { 5 | getUnrenderedAudioWorkletNodes(nativeContext).delete(audioWorkletNode); 6 | }; 7 | }; 8 | -------------------------------------------------------------------------------- /src/factories/fetch-source.ts: -------------------------------------------------------------------------------- 1 | import { TFetchSourceFactory } from '../types'; 2 | 3 | export const createFetchSource: TFetchSourceFactory = (createAbortError) => { 4 | return async (url) => { 5 | try { 6 | const response = await fetch(url); 7 | 8 | if (response.ok) { 9 | return [await response.text(), response.url]; 10 | } 11 | } catch { 12 | // Ignore errors. 13 | } // tslint:disable-line:no-empty 14 | 15 | throw createAbortError(); 16 | }; 17 | }; 18 | -------------------------------------------------------------------------------- /src/factories/get-audio-node-tail-time.ts: -------------------------------------------------------------------------------- 1 | import { TGetAudioNodeTailTimeFactory } from '../types'; 2 | 3 | export const createGetAudioNodeTailTime: TGetAudioNodeTailTimeFactory = (audioNodeTailTimeStore) => { 4 | return (audioNode) => audioNodeTailTimeStore.get(audioNode) ?? 0; 5 | }; 6 | -------------------------------------------------------------------------------- /src/factories/get-backup-offline-audio-context.ts: -------------------------------------------------------------------------------- 1 | import { TGetBackupOfflineAudioContextFactory } from '../types'; 2 | 3 | export const createGetBackupOfflineAudioContext: TGetBackupOfflineAudioContextFactory = (backupOfflineAudioContextStore) => { 4 | return (nativeContext) => { 5 | return backupOfflineAudioContextStore.get(nativeContext); 6 | }; 7 | }; 8 | -------------------------------------------------------------------------------- /src/factories/get-unrendered-audio-worklet-nodes.ts: -------------------------------------------------------------------------------- 1 | import { TGetUnrenderedAudioWorkletNodesFactory } from '../types'; 2 | 3 | export const createGetUnrenderedAudioWorkletNodes: TGetUnrenderedAudioWorkletNodesFactory = (unrenderedAudioWorkletNodeStore) => { 4 | return (nativeContext) => { 5 | const unrenderedAudioWorkletNodes = unrenderedAudioWorkletNodeStore.get(nativeContext); 6 | 7 | if (unrenderedAudioWorkletNodes === undefined) { 8 | throw new Error('The context has no set of AudioWorkletNodes.'); 9 | } 10 | 11 | return unrenderedAudioWorkletNodes; 12 | }; 13 | }; 14 | -------------------------------------------------------------------------------- /src/factories/index-size-error.ts: -------------------------------------------------------------------------------- 1 | import { TIndexSizeErrorFactory } from '../types'; 2 | 3 | export const createIndexSizeError: TIndexSizeErrorFactory = () => new DOMException('', 'IndexSizeError'); 4 | -------------------------------------------------------------------------------- /src/factories/invalid-access-error.ts: -------------------------------------------------------------------------------- 1 | import { TInvalidAccessErrorFactory } from '../types'; 2 | 3 | export const createInvalidAccessError: TInvalidAccessErrorFactory = () => new DOMException('', 'InvalidAccessError'); 4 | -------------------------------------------------------------------------------- /src/factories/invalid-state-error.ts: -------------------------------------------------------------------------------- 1 | import { TInvalidStateErrorFactory } from '../types'; 2 | 3 | export const createInvalidStateError: TInvalidStateErrorFactory = () => new DOMException('', 'InvalidStateError'); 4 | -------------------------------------------------------------------------------- /src/factories/is-any-audio-context.ts: -------------------------------------------------------------------------------- 1 | import { IAudioContext, IMinimalAudioContext } from '../interfaces'; 2 | import { TIsAnyAudioContextFactory, TNativeAudioContext } from '../types'; 3 | 4 | export const createIsAnyAudioContext: TIsAnyAudioContextFactory = (contextStore, isNativeAudioContext) => { 5 | return (anything): anything is IAudioContext | IMinimalAudioContext | TNativeAudioContext => { 6 | const nativeContext = contextStore.get(anything); 7 | 8 | return isNativeAudioContext(nativeContext) || isNativeAudioContext(anything); 9 | }; 10 | }; 11 | -------------------------------------------------------------------------------- /src/factories/is-any-audio-node.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TIsAnyAudioNodeFactory, TNativeAudioNode } from '../types'; 3 | 4 | export const createIsAnyAudioNode: TIsAnyAudioNodeFactory = (audioNodeStore, isNativeAudioNode) => { 5 | return (anything): anything is IAudioNode | TNativeAudioNode => audioNodeStore.has(anything) || isNativeAudioNode(anything); 6 | }; 7 | -------------------------------------------------------------------------------- /src/factories/is-any-audio-param.ts: -------------------------------------------------------------------------------- 1 | import { IAudioParam } from '../interfaces'; 2 | import { TIsAnyAudioParamFactory, TNativeAudioParam } from '../types'; 3 | 4 | export const createIsAnyAudioParam: TIsAnyAudioParamFactory = (audioParamStore, isNativeAudioParam) => { 5 | return (anything): anything is IAudioParam | TNativeAudioParam => audioParamStore.has(anything) || isNativeAudioParam(anything); 6 | }; 7 | -------------------------------------------------------------------------------- /src/factories/is-any-offline-audio-context.ts: -------------------------------------------------------------------------------- 1 | import { IMinimalOfflineAudioContext, IOfflineAudioContext } from '../interfaces'; 2 | import { TIsAnyOfflineAudioContextFactory, TNativeOfflineAudioContext } from '../types'; 3 | 4 | export const createIsAnyOfflineAudioContext: TIsAnyOfflineAudioContextFactory = (contextStore, isNativeOfflineAudioContext) => { 5 | return (anything): anything is IMinimalOfflineAudioContext | IOfflineAudioContext | TNativeOfflineAudioContext => { 6 | const nativeContext = contextStore.get(anything); 7 | 8 | return isNativeOfflineAudioContext(nativeContext) || isNativeOfflineAudioContext(anything); 9 | }; 10 | }; 11 | -------------------------------------------------------------------------------- /src/factories/is-native-audio-context.ts: -------------------------------------------------------------------------------- 1 | import { TIsNativeAudioContextFactory, TNativeAudioContext } from '../types'; 2 | 3 | export const createIsNativeAudioContext: TIsNativeAudioContextFactory = (nativeAudioContextConstructor) => { 4 | return (anything): anything is TNativeAudioContext => { 5 | return nativeAudioContextConstructor !== null && anything instanceof nativeAudioContextConstructor; 6 | }; 7 | }; 8 | -------------------------------------------------------------------------------- /src/factories/is-native-audio-node.ts: -------------------------------------------------------------------------------- 1 | import { TIsNativeAudioNodeFactory, TNativeAudioNode } from '../types'; 2 | 3 | export const createIsNativeAudioNode: TIsNativeAudioNodeFactory = (window) => { 4 | return (anything): anything is TNativeAudioNode => { 5 | return window !== null && typeof window.AudioNode === 'function' && anything instanceof window.AudioNode; 6 | }; 7 | }; 8 | -------------------------------------------------------------------------------- /src/factories/is-native-audio-param.ts: -------------------------------------------------------------------------------- 1 | import { TIsNativeAudioParamFactory, TNativeAudioParam } from '../types'; 2 | 3 | export const createIsNativeAudioParam: TIsNativeAudioParamFactory = (window) => { 4 | return (anything): anything is TNativeAudioParam => { 5 | return window !== null && typeof window.AudioParam === 'function' && anything instanceof window.AudioParam; 6 | }; 7 | }; 8 | -------------------------------------------------------------------------------- /src/factories/is-native-context.ts: -------------------------------------------------------------------------------- 1 | import { TIsNativeContextFactory, TNativeAudioContext } from '../types'; 2 | 3 | export const createIsNativeContext: TIsNativeContextFactory = (isNativeAudioContext, isNativeOfflineAudioContext) => { 4 | return (anything): anything is TNativeAudioContext => { 5 | return isNativeAudioContext(anything) || isNativeOfflineAudioContext(anything); 6 | }; 7 | }; 8 | -------------------------------------------------------------------------------- /src/factories/is-native-offline-audio-context.ts: -------------------------------------------------------------------------------- 1 | import { TIsNativeOfflineAudioContextFactory, TNativeOfflineAudioContext } from '../types'; 2 | 3 | export const createIsNativeOfflineAudioContext: TIsNativeOfflineAudioContextFactory = (nativeOfflineAudioContextConstructor) => { 4 | return (anything): anything is TNativeOfflineAudioContext => { 5 | return nativeOfflineAudioContextConstructor !== null && anything instanceof nativeOfflineAudioContextConstructor; 6 | }; 7 | }; 8 | -------------------------------------------------------------------------------- /src/factories/is-secure-context.ts: -------------------------------------------------------------------------------- 1 | import { TIsSecureContextFactory } from '../types'; 2 | 3 | export const createIsSecureContext: TIsSecureContextFactory = (window) => window !== null && window.isSecureContext; 4 | -------------------------------------------------------------------------------- /src/factories/native-audio-buffer-constructor.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioBufferConstructorFactory } from '../types'; 2 | 3 | export const createNativeAudioBufferConstructor: TNativeAudioBufferConstructorFactory = (window) => { 4 | if (window === null) { 5 | return null; 6 | } 7 | 8 | if (window.hasOwnProperty('AudioBuffer')) { 9 | return window.AudioBuffer; 10 | } 11 | 12 | return null; 13 | }; 14 | -------------------------------------------------------------------------------- /src/factories/native-audio-context-constructor.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioContextConstructorFactory } from '../types'; 2 | 3 | export const createNativeAudioContextConstructor: TNativeAudioContextConstructorFactory = (window) => { 4 | if (window !== null && 'AudioContext' in window) { 5 | return window.AudioContext; 6 | } 7 | 8 | return null; 9 | }; 10 | -------------------------------------------------------------------------------- /src/factories/native-audio-worklet-node-constructor.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioWorkletNodeConstructorFactory } from '../types'; 2 | 3 | export const createNativeAudioWorkletNodeConstructor: TNativeAudioWorkletNodeConstructorFactory = (window) => { 4 | if (window === null) { 5 | return null; 6 | } 7 | 8 | return window.hasOwnProperty('AudioWorkletNode') ? window.AudioWorkletNode : null; 9 | }; 10 | -------------------------------------------------------------------------------- /src/factories/native-channel-merger-node.ts: -------------------------------------------------------------------------------- 1 | import { assignNativeAudioNodeOptions } from '../helpers/assign-native-audio-node-options'; 2 | import { TNativeChannelMergerNodeFactory } from '../types'; 3 | 4 | export const createNativeChannelMergerNode: TNativeChannelMergerNodeFactory = (nativeContext, options) => { 5 | const nativeChannelMergerNode = nativeContext.createChannelMerger(options.numberOfInputs); 6 | 7 | assignNativeAudioNodeOptions(nativeChannelMergerNode, options); 8 | 9 | return nativeChannelMergerNode; 10 | }; 11 | -------------------------------------------------------------------------------- /src/factories/native-channel-splitter-node.ts: -------------------------------------------------------------------------------- 1 | import { assignNativeAudioNodeOptions } from '../helpers/assign-native-audio-node-options'; 2 | import { TNativeChannelSplitterNodeFactory } from '../types'; 3 | 4 | export const createNativeChannelSplitterNode: TNativeChannelSplitterNodeFactory = (nativeContext, options) => { 5 | const nativeChannelSplitterNode = nativeContext.createChannelSplitter(options.numberOfOutputs); 6 | 7 | assignNativeAudioNodeOptions(nativeChannelSplitterNode, options); 8 | 9 | return nativeChannelSplitterNode; 10 | }; 11 | -------------------------------------------------------------------------------- /src/factories/native-delay-node.ts: -------------------------------------------------------------------------------- 1 | import { assignNativeAudioNodeAudioParamValue } from '../helpers/assign-native-audio-node-audio-param-value'; 2 | import { assignNativeAudioNodeOptions } from '../helpers/assign-native-audio-node-options'; 3 | import { TNativeDelayNodeFactory } from '../types'; 4 | 5 | export const createNativeDelayNode: TNativeDelayNodeFactory = (nativeContext, options) => { 6 | const nativeDelayNode = nativeContext.createDelay(options.maxDelayTime); 7 | 8 | assignNativeAudioNodeOptions(nativeDelayNode, options); 9 | 10 | assignNativeAudioNodeAudioParamValue(nativeDelayNode, options, 'delayTime'); 11 | 12 | return nativeDelayNode; 13 | }; 14 | -------------------------------------------------------------------------------- /src/factories/native-gain-node.ts: -------------------------------------------------------------------------------- 1 | import { assignNativeAudioNodeAudioParamValue } from '../helpers/assign-native-audio-node-audio-param-value'; 2 | import { assignNativeAudioNodeOptions } from '../helpers/assign-native-audio-node-options'; 3 | import { TNativeGainNodeFactory } from '../types'; 4 | 5 | export const createNativeGainNode: TNativeGainNodeFactory = (nativeContext, options) => { 6 | const nativeGainNode = nativeContext.createGain(); 7 | 8 | assignNativeAudioNodeOptions(nativeGainNode, options); 9 | 10 | assignNativeAudioNodeAudioParamValue(nativeGainNode, options, 'gain'); 11 | 12 | return nativeGainNode; 13 | }; 14 | -------------------------------------------------------------------------------- /src/factories/native-iir-filter-node.ts: -------------------------------------------------------------------------------- 1 | import { assignNativeAudioNodeOptions } from '../helpers/assign-native-audio-node-options'; 2 | import { TNativeIIRFilterNodeFactory } from '../types'; 3 | 4 | export const createNativeIIRFilterNode: TNativeIIRFilterNodeFactory = (nativeContext, options) => { 5 | // @todo TypeScript defines the parameters of createIIRFilter() as arrays of numbers. 6 | const nativeIIRFilterNode = nativeContext.createIIRFilter(options.feedforward, options.feedback); 7 | 8 | assignNativeAudioNodeOptions(nativeIIRFilterNode, options); 9 | 10 | return nativeIIRFilterNode; 11 | }; 12 | -------------------------------------------------------------------------------- /src/factories/native-media-element-audio-source-node.ts: -------------------------------------------------------------------------------- 1 | import { TNativeMediaElementAudioSourceNodeFactory } from '../types'; 2 | 3 | export const createNativeMediaElementAudioSourceNode: TNativeMediaElementAudioSourceNodeFactory = (nativeAudioContext, options) => { 4 | return nativeAudioContext.createMediaElementSource(options.mediaElement); 5 | }; 6 | -------------------------------------------------------------------------------- /src/factories/native-media-stream-audio-destination-node.ts: -------------------------------------------------------------------------------- 1 | import { assignNativeAudioNodeOptions } from '../helpers/assign-native-audio-node-options'; 2 | import { TNativeMediaStreamAudioDestinationNodeFactory } from '../types'; 3 | 4 | export const createNativeMediaStreamAudioDestinationNode: TNativeMediaStreamAudioDestinationNodeFactory = (nativeAudioContext, options) => { 5 | const nativeMediaStreamAudioDestinationNode = nativeAudioContext.createMediaStreamDestination(); 6 | 7 | assignNativeAudioNodeOptions(nativeMediaStreamAudioDestinationNode, options); 8 | 9 | return nativeMediaStreamAudioDestinationNode; 10 | }; 11 | -------------------------------------------------------------------------------- /src/factories/native-offline-audio-context-constructor.ts: -------------------------------------------------------------------------------- 1 | import { TNativeOfflineAudioContextConstructorFactory } from '../types'; 2 | 3 | export const createNativeOfflineAudioContextConstructor: TNativeOfflineAudioContextConstructorFactory = (window) => { 4 | if (window !== null && 'OfflineAudioContext' in window) { 5 | return window.OfflineAudioContext; 6 | } 7 | 8 | return null; 9 | }; 10 | -------------------------------------------------------------------------------- /src/factories/native-periodic-wave-constructor.ts: -------------------------------------------------------------------------------- 1 | import { TWindow } from '../types'; 2 | 3 | export const createNativePeriodicWaveConstructor = (window: null | TWindow) => { 4 | if (window !== null && 'PeriodicWave' in window) { 5 | return window.PeriodicWave; 6 | } 7 | 8 | return null; 9 | }; 10 | -------------------------------------------------------------------------------- /src/factories/native-periodic-wave.ts: -------------------------------------------------------------------------------- 1 | import { TNativePeriodicWaveFactory } from '../types'; 2 | 3 | export const createNativePeriodicWave: TNativePeriodicWaveFactory = (nativeContext, { disableNormalization, imag, real }) => 4 | nativeContext.createPeriodicWave(real, imag, { disableNormalization }); 5 | -------------------------------------------------------------------------------- /src/factories/native-script-processor-node.ts: -------------------------------------------------------------------------------- 1 | import { TNativeScriptProcessorNodeFactory } from '../types'; 2 | 3 | export const createNativeScriptProcessorNode: TNativeScriptProcessorNodeFactory = ( 4 | nativeContext, 5 | bufferSize, 6 | numberOfInputChannels, 7 | numberOfOutputChannels 8 | ) => { 9 | return nativeContext.createScriptProcessor(bufferSize, numberOfInputChannels, numberOfOutputChannels); // tslint:disable-line deprecation 10 | }; 11 | -------------------------------------------------------------------------------- /src/factories/not-supported-error.ts: -------------------------------------------------------------------------------- 1 | import { TNotSupportedErrorFactory } from '../types'; 2 | 3 | export const createNotSupportedError: TNotSupportedErrorFactory = () => new DOMException('', 'NotSupportedError'); 4 | -------------------------------------------------------------------------------- /src/factories/set-active-audio-worklet-node-inputs.ts: -------------------------------------------------------------------------------- 1 | import { TSetActiveAudioWorkletNodeInputsFactory } from '../types'; 2 | 3 | export const createSetActiveAudioWorkletNodeInputs: TSetActiveAudioWorkletNodeInputsFactory = (activeAudioWorkletNodeInputsStore) => { 4 | return (nativeAudioWorkletNode, activeInputs) => { 5 | activeAudioWorkletNodeInputsStore.set(nativeAudioWorkletNode, activeInputs); 6 | }; 7 | }; 8 | -------------------------------------------------------------------------------- /src/factories/set-audio-node-tail-time.ts: -------------------------------------------------------------------------------- 1 | import { TSetAudioNodeTailTimeFactory } from '../types'; 2 | 3 | export const createSetAudioNodeTailTime: TSetAudioNodeTailTimeFactory = (audioNodeTailTimeStore) => { 4 | return (audioNode, tailTime) => audioNodeTailTimeStore.set(audioNode, tailTime); 5 | }; 6 | -------------------------------------------------------------------------------- /src/factories/test-audio-context-options-support.ts: -------------------------------------------------------------------------------- 1 | import { TTestAudioContextOptionsSupportFactory } from '../types'; 2 | 3 | export const createTestAudioContextOptionsSupport: TTestAudioContextOptionsSupportFactory = (nativeAudioContextConstructor) => { 4 | return () => { 5 | if (nativeAudioContextConstructor === null) { 6 | return false; 7 | } 8 | 9 | let audioContext; 10 | 11 | try { 12 | audioContext = new nativeAudioContextConstructor({ latencyHint: 'balanced' }); 13 | } catch { 14 | return false; 15 | } 16 | 17 | audioContext.close(); 18 | 19 | return true; 20 | }; 21 | }; 22 | -------------------------------------------------------------------------------- /src/factories/test-is-secure-context-support.ts: -------------------------------------------------------------------------------- 1 | import { TTestIsSecureContextSupportFactory } from '../types'; 2 | 3 | export const createTestIsSecureContextSupport: TTestIsSecureContextSupportFactory = (window) => { 4 | return () => window !== null && window.hasOwnProperty('isSecureContext'); 5 | }; 6 | -------------------------------------------------------------------------------- /src/factories/window.ts: -------------------------------------------------------------------------------- 1 | import { TWindow, TWindowFactory } from '../types'; 2 | 3 | export const createWindow: TWindowFactory = () => (typeof window === 'undefined' ? null : window); 4 | -------------------------------------------------------------------------------- /src/guards/audio-buffer-source-node.ts: -------------------------------------------------------------------------------- 1 | import { IAudioBufferSourceNode, IAudioNode } from '../interfaces'; 2 | import { TContext } from '../types'; 3 | 4 | export const isAudioBufferSourceNode = (audioNode: IAudioNode): audioNode is IAudioBufferSourceNode => { 5 | return 'playbackRate' in audioNode; 6 | }; 7 | -------------------------------------------------------------------------------- /src/guards/audio-node-output-connection.ts: -------------------------------------------------------------------------------- 1 | import { TAudioNodeOutputConnection, TContext, TOutputConnection } from '../types'; 2 | import { isAudioNode } from './audio-node'; 3 | 4 | export const isAudioNodeOutputConnection = ( 5 | outputConnection: TOutputConnection 6 | ): outputConnection is TAudioNodeOutputConnection => { 7 | return isAudioNode(outputConnection[0]); 8 | }; 9 | -------------------------------------------------------------------------------- /src/guards/audio-node.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode, IAudioParam } from '../interfaces'; 2 | import { TContext } from '../types'; 3 | 4 | export const isAudioNode = ( 5 | audioNodeOrAudioParam: IAudioNode | IAudioParam 6 | ): audioNodeOrAudioParam is IAudioNode => { 7 | return 'context' in audioNodeOrAudioParam; 8 | }; 9 | -------------------------------------------------------------------------------- /src/guards/audio-worklet-node.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode, IAudioWorkletNode } from '../interfaces'; 2 | import { TContext } from '../types'; 3 | 4 | export const isAudioWorkletNode = (audioNode: IAudioNode): audioNode is IAudioWorkletNode => { 5 | return 'port' in audioNode; 6 | }; 7 | -------------------------------------------------------------------------------- /src/guards/biquad-filter-node.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode, IBiquadFilterNode } from '../interfaces'; 2 | import { TContext } from '../types'; 3 | 4 | export const isBiquadFilterNode = (audioNode: IAudioNode): audioNode is IBiquadFilterNode => { 5 | return 'frequency' in audioNode && 'gain' in audioNode; 6 | }; 7 | -------------------------------------------------------------------------------- /src/guards/constant-source-node.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode, IConstantSourceNode } from '../interfaces'; 2 | import { TContext } from '../types'; 3 | 4 | export const isConstantSourceNode = (audioNode: IAudioNode): audioNode is IConstantSourceNode => { 5 | return 'offset' in audioNode; 6 | }; 7 | -------------------------------------------------------------------------------- /src/guards/delay-node.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode, IDelayNode } from '../interfaces'; 2 | import { TContext } from '../types'; 3 | 4 | export const isDelayNode = (audioNode: IAudioNode): audioNode is IDelayNode => { 5 | return 'delayTime' in audioNode; 6 | }; 7 | -------------------------------------------------------------------------------- /src/guards/gain-node.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode, IGainNode } from '../interfaces'; 2 | import { TContext } from '../types'; 3 | 4 | export const isGainNode = (audioNode: IAudioNode): audioNode is IGainNode => { 5 | return !('frequency' in audioNode) && 'gain' in audioNode; 6 | }; 7 | -------------------------------------------------------------------------------- /src/guards/native-audio-node.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioNode, TNativeAudioParam } from '../types'; 2 | 3 | export const isNativeAudioNode = ( 4 | nativeAudioNodeOrAudioParam: TNativeAudioNode | TNativeAudioParam 5 | ): nativeAudioNodeOrAudioParam is TNativeAudioNode => { 6 | return 'context' in nativeAudioNodeOrAudioParam; 7 | }; 8 | -------------------------------------------------------------------------------- /src/guards/oscillator-node.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode, IOscillatorNode } from '../interfaces'; 2 | import { TContext } from '../types'; 3 | 4 | export const isOscillatorNode = (audioNode: IAudioNode): audioNode is IOscillatorNode => { 5 | return 'detune' in audioNode && 'frequency' in audioNode && !('gain' in audioNode); 6 | }; 7 | -------------------------------------------------------------------------------- /src/guards/stereo-panner-node.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode, IStereoPannerNode } from '../interfaces'; 2 | import { TContext } from '../types'; 3 | 4 | export const isStereoPannerNode = (audioNode: IAudioNode): audioNode is IStereoPannerNode => { 5 | return 'pan' in audioNode; 6 | }; 7 | -------------------------------------------------------------------------------- /src/helpers/assign-native-audio-node-audio-param-value.ts: -------------------------------------------------------------------------------- 1 | export const assignNativeAudioNodeAudioParamValue = ( 2 | nativeAudioNode: T, 3 | options: U, 4 | audioParam: keyof T & keyof U 5 | ) => { 6 | const value = options[audioParam]; 7 | 8 | if (value !== undefined && value !== nativeAudioNode[audioParam].value) { 9 | nativeAudioNode[audioParam].value = value; 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /src/helpers/assign-native-audio-node-option.ts: -------------------------------------------------------------------------------- 1 | export const assignNativeAudioNodeOption = ( 2 | nativeAudioNode: Record, 3 | options: Record, 4 | option: T 5 | ) => { 6 | const value = options[option]; 7 | 8 | if (value !== undefined && value !== nativeAudioNode[option]) { 9 | nativeAudioNode[option] = value; 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /src/helpers/assign-native-audio-node-options.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNodeOptions } from '../interfaces'; 2 | import { TNativeAudioNode } from '../types'; 3 | import { assignNativeAudioNodeOption } from './assign-native-audio-node-option'; 4 | 5 | export const assignNativeAudioNodeOptions = (nativeAudioNode: TNativeAudioNode, options: IAudioNodeOptions): void => { 6 | assignNativeAudioNodeOption(nativeAudioNode, options, 'channelCount'); 7 | assignNativeAudioNodeOption(nativeAudioNode, options, 'channelCountMode'); 8 | assignNativeAudioNodeOption(nativeAudioNode, options, 'channelInterpretation'); 9 | }; 10 | -------------------------------------------------------------------------------- /src/helpers/connect-native-audio-node-to-native-audio-node.ts: -------------------------------------------------------------------------------- 1 | import { TConnectNativeAudioNodeToNativeAudioNodeFunction, TNativeAudioNode } from '../types'; 2 | 3 | export const connectNativeAudioNodeToNativeAudioNode: TConnectNativeAudioNodeToNativeAudioNodeFunction = ( 4 | nativeSourceAudioNode: TNativeAudioNode, 5 | nativeDestinationAudioNode: TNativeAudioNode, 6 | output: number, 7 | input: number 8 | ): [TNativeAudioNode, number, number] => { 9 | nativeSourceAudioNode.connect(nativeDestinationAudioNode, output, input); 10 | 11 | return [nativeDestinationAudioNode, output, input]; 12 | }; 13 | -------------------------------------------------------------------------------- /src/helpers/deactivate-audio-graph.ts: -------------------------------------------------------------------------------- 1 | import { IAudioDestinationNode } from '../interfaces'; 2 | import { TContext } from '../types'; 3 | import { deactivateActiveAudioNodeInputConnections } from './deactivate-active-audio-node-input-connections'; 4 | 5 | export const deactivateAudioGraph = (context: T): void => { 6 | deactivateActiveAudioNodeInputConnections(>context.destination, []); 7 | }; 8 | -------------------------------------------------------------------------------- /src/helpers/delete-active-input-connection-to-audio-param.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TActiveInputConnection, TContext } from '../types'; 3 | import { pickElementFromSet } from './pick-element-from-set'; 4 | 5 | export const deleteActiveInputConnectionToAudioParam = ( 6 | activeInputs: Set>, 7 | source: IAudioNode, 8 | output: number 9 | ) => { 10 | return pickElementFromSet( 11 | activeInputs, 12 | (activeInputConnection) => activeInputConnection[0] === source && activeInputConnection[1] === output 13 | ); 14 | }; 15 | -------------------------------------------------------------------------------- /src/helpers/delete-event-listeners-of-audio-node.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TContext, TInternalStateEventListener } from '../types'; 3 | import { getEventListenersOfAudioNode } from './get-event-listeners-of-audio-node'; 4 | 5 | export const deleteEventListenerOfAudioNode = ( 6 | audioNode: IAudioNode, 7 | eventListener: TInternalStateEventListener 8 | ) => { 9 | const eventListeners = getEventListenersOfAudioNode(audioNode); 10 | 11 | if (!eventListeners.delete(eventListener)) { 12 | throw new Error('Missing the expected event listener.'); 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /src/helpers/disconnect-native-audio-node-from-native-audio-node.ts: -------------------------------------------------------------------------------- 1 | import { TDisconnectNativeAudioNodeFromNativeAudioNodeFunction } from '../types'; 2 | 3 | export const disconnectNativeAudioNodeFromNativeAudioNode: TDisconnectNativeAudioNodeFromNativeAudioNodeFunction = ( 4 | nativeSourceAudioNode, 5 | nativeDestinationAudioNode, 6 | output, 7 | input 8 | ) => { 9 | nativeSourceAudioNode.disconnect(nativeDestinationAudioNode, output, input); 10 | }; 11 | -------------------------------------------------------------------------------- /src/helpers/get-audio-node-connections.ts: -------------------------------------------------------------------------------- 1 | import { AUDIO_NODE_CONNECTIONS_STORE } from '../globals'; 2 | import { IAudioNode } from '../interfaces'; 3 | import { TAudioNodeConnections, TContext, TGetAudioNodeConnectionsFunction } from '../types'; 4 | import { getValueForKey } from './get-value-for-key'; 5 | 6 | export const getAudioNodeConnections: TGetAudioNodeConnectionsFunction = ( 7 | audioNode: IAudioNode 8 | ): TAudioNodeConnections => { 9 | return >getValueForKey(AUDIO_NODE_CONNECTIONS_STORE, audioNode); 10 | }; 11 | -------------------------------------------------------------------------------- /src/helpers/get-audio-param-connections.ts: -------------------------------------------------------------------------------- 1 | import { AUDIO_PARAM_CONNECTIONS_STORE } from '../globals'; 2 | import { IAudioParam } from '../interfaces'; 3 | import { TAudioParamConnections, TContext, TGetAudioParamConnectionsFunction } from '../types'; 4 | import { getValueForKey } from './get-value-for-key'; 5 | 6 | export const getAudioParamConnections: TGetAudioParamConnectionsFunction = ( 7 | audioParam: IAudioParam 8 | ): TAudioParamConnections => { 9 | return >getValueForKey(AUDIO_PARAM_CONNECTIONS_STORE, audioParam); 10 | }; 11 | -------------------------------------------------------------------------------- /src/helpers/get-event-listeners-of-audio-node.ts: -------------------------------------------------------------------------------- 1 | import { EVENT_LISTENERS } from '../globals'; 2 | import { TGetEventListenersOfAudioNodeFunction } from '../types'; 3 | import { getValueForKey } from './get-value-for-key'; 4 | 5 | export const getEventListenersOfAudioNode: TGetEventListenersOfAudioNodeFunction = (audioNode) => { 6 | return getValueForKey(EVENT_LISTENERS, audioNode); 7 | }; 8 | -------------------------------------------------------------------------------- /src/helpers/get-first-sample.ts: -------------------------------------------------------------------------------- 1 | import { TGetFirstSampleFunction } from '../types'; 2 | 3 | export const getFirstSample: TGetFirstSampleFunction = (audioBuffer, buffer, channelNumber) => { 4 | audioBuffer.copyFromChannel(buffer, channelNumber); 5 | 6 | return buffer[0]; 7 | }; 8 | -------------------------------------------------------------------------------- /src/helpers/get-native-audio-node.ts: -------------------------------------------------------------------------------- 1 | import { AUDIO_NODE_STORE } from '../globals'; 2 | import { IAudioNode } from '../interfaces'; 3 | import { TContext, TGetNativeAudioNodeFunction, TNativeAudioNode } from '../types'; 4 | import { getValueForKey } from './get-value-for-key'; 5 | 6 | export const getNativeAudioNode: TGetNativeAudioNodeFunction = ( 7 | audioNode: IAudioNode 8 | ): U => { 9 | return getValueForKey(AUDIO_NODE_STORE, audioNode); 10 | }; 11 | -------------------------------------------------------------------------------- /src/helpers/get-native-audio-param.ts: -------------------------------------------------------------------------------- 1 | import { AUDIO_PARAM_STORE } from '../globals'; 2 | import { IAudioParam } from '../interfaces'; 3 | import { TNativeAudioParam } from '../types'; 4 | import { getValueForKey } from './get-value-for-key'; 5 | 6 | export const getNativeAudioParam = (audioParam: IAudioParam): TNativeAudioParam => { 7 | return getValueForKey(AUDIO_PARAM_STORE, audioParam); 8 | }; 9 | -------------------------------------------------------------------------------- /src/helpers/get-value-for-key.ts: -------------------------------------------------------------------------------- 1 | import { TGetValueForKeyFunction } from '../types'; 2 | 3 | export const getValueForKey: TGetValueForKeyFunction = (map, key) => { 4 | const value = map.get(key); 5 | 6 | if (value === undefined) { 7 | throw new Error('A value with the given key could not be found.'); 8 | } 9 | 10 | return value; 11 | }; 12 | -------------------------------------------------------------------------------- /src/helpers/insert-element-in-set.ts: -------------------------------------------------------------------------------- 1 | import { TInsertElementInSetFunction } from '../types'; 2 | 3 | export const insertElementInSet: TInsertElementInSetFunction = (set, element, predicate, ignoreDuplicates) => { 4 | for (const lmnt of set) { 5 | if (predicate(lmnt)) { 6 | if (ignoreDuplicates) { 7 | return false; 8 | } 9 | 10 | throw Error('The set contains at least one similar element.'); 11 | } 12 | } 13 | 14 | set.add(element); 15 | 16 | return true; 17 | }; 18 | -------------------------------------------------------------------------------- /src/helpers/is-active-audio-node.ts: -------------------------------------------------------------------------------- 1 | import { ACTIVE_AUDIO_NODE_STORE } from '../globals'; 2 | import { TIsActiveAudioNodeFunction } from '../types'; 3 | 4 | export const isActiveAudioNode: TIsActiveAudioNodeFunction = (audioNode) => ACTIVE_AUDIO_NODE_STORE.has(audioNode); 5 | -------------------------------------------------------------------------------- /src/helpers/is-dc-curve.ts: -------------------------------------------------------------------------------- 1 | import { TIsDCCurveFunction } from '../types'; 2 | 3 | export const isDCCurve: TIsDCCurveFunction = (curve) => { 4 | if (curve === null) { 5 | return false; 6 | } 7 | 8 | const length = curve.length; 9 | 10 | if (length % 2 !== 0) { 11 | return curve[Math.floor(length / 2)] !== 0; 12 | } 13 | 14 | return curve[length / 2 - 1] + curve[length / 2] !== 0; 15 | }; 16 | -------------------------------------------------------------------------------- /src/helpers/is-part-of-a-cycle.ts: -------------------------------------------------------------------------------- 1 | import { CYCLE_COUNTERS } from '../globals'; 2 | import { TIsPartOfACycleFunction } from '../types'; 3 | 4 | export const isPartOfACycle: TIsPartOfACycleFunction = (audioNode) => { 5 | return CYCLE_COUNTERS.has(audioNode); 6 | }; 7 | -------------------------------------------------------------------------------- /src/helpers/is-passive-audio-node.ts: -------------------------------------------------------------------------------- 1 | import { ACTIVE_AUDIO_NODE_STORE } from '../globals'; 2 | import { TIsPassiveAudioNodeFunction } from '../types'; 3 | 4 | export const isPassiveAudioNode: TIsPassiveAudioNodeFunction = (audioNode) => { 5 | return !ACTIVE_AUDIO_NODE_STORE.has(audioNode); 6 | }; 7 | -------------------------------------------------------------------------------- /src/helpers/is-valid-latency-hint.ts: -------------------------------------------------------------------------------- 1 | import { IAudioContextOptions } from '../interfaces'; 2 | 3 | export const isValidLatencyHint = (latencyHint: IAudioContextOptions['latencyHint']) => { 4 | return ( 5 | latencyHint === undefined || 6 | typeof latencyHint === 'number' || 7 | (typeof latencyHint === 'string' && (latencyHint === 'balanced' || latencyHint === 'interactive' || latencyHint === 'playback')) 8 | ); 9 | }; 10 | -------------------------------------------------------------------------------- /src/helpers/overwrite-accessors.ts: -------------------------------------------------------------------------------- 1 | import { TOverwriteAccessorsFunction } from '../types'; 2 | 3 | export const overwriteAccessors: TOverwriteAccessorsFunction = (object, property, createGetter, createSetter) => { 4 | let prototype = object; 5 | 6 | while (!prototype.hasOwnProperty(property)) { 7 | prototype = Object.getPrototypeOf(prototype); 8 | } 9 | 10 | const { get, set } = >Object.getOwnPropertyDescriptor(prototype, property); 11 | 12 | Object.defineProperty(object, property, { get: createGetter(get), set: createSetter(set) }); 13 | }; 14 | -------------------------------------------------------------------------------- /src/helpers/pick-element-from-set.ts: -------------------------------------------------------------------------------- 1 | import { TPickElementFromSetFunction } from '../types'; 2 | 3 | export const pickElementFromSet: TPickElementFromSetFunction = (set, predicate) => { 4 | const matchingElements = Array.from(set).filter(predicate); 5 | 6 | if (matchingElements.length > 1) { 7 | throw Error('More than one element was found.'); 8 | } 9 | 10 | if (matchingElements.length === 0) { 11 | throw Error('No element was found.'); 12 | } 13 | 14 | const [matchingElement] = matchingElements; 15 | 16 | set.delete(matchingElement); 17 | 18 | return matchingElement; 19 | }; 20 | -------------------------------------------------------------------------------- /src/helpers/sanitize-channel-splitter-options.ts: -------------------------------------------------------------------------------- 1 | import { TSanitizeChannelSplitterOptionsFunction } from '../types'; 2 | 3 | export const sanitizeChannelSplitterOptions: TSanitizeChannelSplitterOptionsFunction = (options) => { 4 | return { ...options, channelCount: options.numberOfOutputs }; 5 | }; 6 | -------------------------------------------------------------------------------- /src/helpers/sanitize-periodic-wave-options.ts: -------------------------------------------------------------------------------- 1 | import { TSanitizePeriodicWaveOptionsFunction } from '../types'; 2 | 3 | export const sanitizePeriodicWaveOptions: TSanitizePeriodicWaveOptionsFunction = (options) => { 4 | const { imag, real } = options; 5 | 6 | if (imag === undefined) { 7 | if (real === undefined) { 8 | return { ...options, imag: [0, 0], real: [0, 0] }; 9 | } 10 | 11 | return { ...options, imag: Array.from(real, () => 0), real }; 12 | } 13 | 14 | if (real === undefined) { 15 | return { ...options, imag, real: Array.from(imag, () => 0) }; 16 | } 17 | 18 | return { ...options, imag, real }; 19 | }; 20 | -------------------------------------------------------------------------------- /src/helpers/set-internal-state-to-active.ts: -------------------------------------------------------------------------------- 1 | import { ACTIVE_AUDIO_NODE_STORE } from '../globals'; 2 | import { IAudioNode } from '../interfaces'; 3 | import { TContext } from '../types'; 4 | import { getEventListenersOfAudioNode } from './get-event-listeners-of-audio-node'; 5 | 6 | export const setInternalStateToActive = (audioNode: IAudioNode) => { 7 | if (ACTIVE_AUDIO_NODE_STORE.has(audioNode)) { 8 | throw new Error('The AudioNode is already stored.'); 9 | } 10 | 11 | ACTIVE_AUDIO_NODE_STORE.add(audioNode); 12 | 13 | getEventListenersOfAudioNode(audioNode).forEach((eventListener) => eventListener(true)); 14 | }; 15 | -------------------------------------------------------------------------------- /src/helpers/set-internal-state-to-passive.ts: -------------------------------------------------------------------------------- 1 | import { ACTIVE_AUDIO_NODE_STORE } from '../globals'; 2 | import { IAudioNode } from '../interfaces'; 3 | import { TContext } from '../types'; 4 | import { getEventListenersOfAudioNode } from './get-event-listeners-of-audio-node'; 5 | 6 | export const setInternalStateToPassive = (audioNode: IAudioNode) => { 7 | if (!ACTIVE_AUDIO_NODE_STORE.has(audioNode)) { 8 | throw new Error('The AudioNode is not stored.'); 9 | } 10 | 11 | ACTIVE_AUDIO_NODE_STORE.delete(audioNode); 12 | 13 | getEventListenersOfAudioNode(audioNode).forEach((eventListener) => eventListener(false)); 14 | }; 15 | -------------------------------------------------------------------------------- /src/helpers/test-audio-scheduled-source-node-stop-method-negative-parameters-support.ts: -------------------------------------------------------------------------------- 1 | import { TNativeContext } from '../types'; 2 | 3 | export const testAudioScheduledSourceNodeStopMethodNegativeParametersSupport = (nativeContext: TNativeContext) => { 4 | const nativeAudioBufferSourceNode = nativeContext.createOscillator(); 5 | 6 | try { 7 | nativeAudioBufferSourceNode.stop(-1); 8 | } catch (err) { 9 | return err instanceof RangeError; 10 | } 11 | 12 | return false; 13 | }; 14 | -------------------------------------------------------------------------------- /src/helpers/test-audio-worklet-node-options-clonability.ts: -------------------------------------------------------------------------------- 1 | import { TTestAudioWorkletNodeOptionsClonabilityFunction } from '../types'; 2 | 3 | export const testAudioWorkletNodeOptionsClonability: TTestAudioWorkletNodeOptionsClonabilityFunction = (audioWorkletNodeOptions) => { 4 | const { port1, port2 } = new MessageChannel(); 5 | 6 | try { 7 | // This will throw an error if the audioWorkletNodeOptions are not clonable. 8 | port1.postMessage(audioWorkletNodeOptions); 9 | } finally { 10 | port1.close(); 11 | port2.close(); 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /src/helpers/test-error-event-error-property-support.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Bug #193: Chrome up to version 104 and Safari up to version 15.6 initialized the error property of an ErrorEvent with null. 3 | */ 4 | export const testErrorEventErrorPropertySupport = () => { 5 | const errorEvent = new ErrorEvent('error'); 6 | 7 | return errorEvent.error === undefined; 8 | }; 9 | -------------------------------------------------------------------------------- /src/helpers/test-transferables-support.ts: -------------------------------------------------------------------------------- 1 | // Safari at version 11 did not support transferables. 2 | export const testTransferablesSupport = () => 3 | new Promise((resolve) => { 4 | const arrayBuffer = new ArrayBuffer(0); 5 | const { port1, port2 } = new MessageChannel(); 6 | 7 | port1.onmessage = ({ data }) => resolve(data !== null); 8 | port2.postMessage(arrayBuffer, [arrayBuffer]); 9 | }); 10 | -------------------------------------------------------------------------------- /src/helpers/visit-each-audio-node-once.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TContext } from '../types'; 3 | 4 | export const visitEachAudioNodeOnce = ( 5 | cycles: IAudioNode[][], 6 | visitor: (audioNode: IAudioNode, count: number) => void 7 | ): void => { 8 | const counts = new Map, number>(); 9 | 10 | for (const cycle of cycles) { 11 | for (const audioNode of cycle) { 12 | const count = counts.get(audioNode); 13 | 14 | counts.set(audioNode, count === undefined ? 1 : count + 1); 15 | } 16 | } 17 | 18 | counts.forEach((count, audioNode) => visitor(audioNode, count)); 19 | }; 20 | -------------------------------------------------------------------------------- /src/helpers/wrap-event-listener.ts: -------------------------------------------------------------------------------- 1 | import { TWrapEventListenerFunction } from '../types'; 2 | 3 | export const wrapEventListener: TWrapEventListenerFunction = (target, eventListener) => { 4 | return (event) => { 5 | const descriptor = { value: target }; 6 | 7 | Object.defineProperties(event, { 8 | currentTarget: descriptor, 9 | target: descriptor 10 | }); 11 | 12 | if (typeof eventListener === 'function') { 13 | return eventListener.call(target, event); 14 | } 15 | 16 | return eventListener.handleEvent.call(target, event); 17 | }; 18 | }; 19 | -------------------------------------------------------------------------------- /src/interfaces/analyser-node.ts: -------------------------------------------------------------------------------- 1 | import { TContext } from '../types'; 2 | import { IAudioNode } from './audio-node'; 3 | 4 | export interface IAnalyserNode extends IAudioNode { 5 | fftSize: number; 6 | 7 | readonly frequencyBinCount: number; 8 | 9 | maxDecibels: number; 10 | 11 | minDecibels: number; 12 | 13 | smoothingTimeConstant: number; 14 | 15 | getByteFrequencyData(array: Uint8Array): void; 16 | 17 | getByteTimeDomainData(array: Uint8Array): void; 18 | 19 | getFloatFrequencyData(array: Float32Array): void; 20 | 21 | getFloatTimeDomainData(array: Float32Array): void; 22 | } 23 | -------------------------------------------------------------------------------- /src/interfaces/analyser-options.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNodeOptions } from './audio-node-options'; 2 | 3 | export interface IAnalyserOptions extends IAudioNodeOptions { 4 | fftSize: number; 5 | 6 | maxDecibels: number; 7 | 8 | minDecibels: number; 9 | 10 | smoothingTimeConstant: number; 11 | } 12 | -------------------------------------------------------------------------------- /src/interfaces/audio-buffer-options.ts: -------------------------------------------------------------------------------- 1 | export interface IAudioBufferOptions { 2 | length: number; 3 | 4 | numberOfChannels?: number; 5 | 6 | sampleRate: number; 7 | } 8 | -------------------------------------------------------------------------------- /src/interfaces/audio-buffer-source-node.ts: -------------------------------------------------------------------------------- 1 | import { TAnyAudioBuffer, TContext } from '../types'; 2 | import { IAudioParam } from './audio-param'; 3 | import { IAudioScheduledSourceNode } from './audio-scheduled-source-node'; 4 | 5 | export interface IAudioBufferSourceNode extends IAudioScheduledSourceNode { 6 | buffer: null | TAnyAudioBuffer; 7 | 8 | readonly detune: IAudioParam; 9 | 10 | loop: boolean; 11 | 12 | loopEnd: number; 13 | 14 | loopStart: number; 15 | 16 | readonly playbackRate: IAudioParam; 17 | 18 | start(when?: number, offset?: number, duration?: number): void; 19 | } 20 | -------------------------------------------------------------------------------- /src/interfaces/audio-buffer-source-options.ts: -------------------------------------------------------------------------------- 1 | import { TAnyAudioBuffer } from '../types'; 2 | import { IAudioNodeOptions } from './audio-node-options'; 3 | 4 | export interface IAudioBufferSourceOptions extends IAudioNodeOptions { 5 | buffer: null | TAnyAudioBuffer; 6 | 7 | detune: number; 8 | 9 | loop: boolean; 10 | 11 | loopEnd: number; 12 | 13 | loopStart: number; 14 | 15 | playbackRate: number; 16 | } 17 | -------------------------------------------------------------------------------- /src/interfaces/audio-buffer.ts: -------------------------------------------------------------------------------- 1 | export interface IAudioBuffer { 2 | readonly duration: number; 3 | 4 | readonly length: number; 5 | 6 | readonly numberOfChannels: number; 7 | 8 | readonly sampleRate: number; 9 | 10 | copyFromChannel(destination: Float32Array, channelNumber: number, bufferOffset?: number): void; 11 | 12 | copyToChannel(source: Float32Array, channelNumber: number, bufferOffset?: number): void; 13 | 14 | getChannelData(channel: number): Float32Array; 15 | } 16 | -------------------------------------------------------------------------------- /src/interfaces/audio-context-options.ts: -------------------------------------------------------------------------------- 1 | import { TAudioContextLatencyCategory } from '../types'; 2 | 3 | export interface IAudioContextOptions { 4 | latencyHint?: number | TAudioContextLatencyCategory; 5 | 6 | sampleRate?: number; 7 | } 8 | -------------------------------------------------------------------------------- /src/interfaces/audio-destination-node.ts: -------------------------------------------------------------------------------- 1 | import { TContext } from '../types'; 2 | import { IAudioNode } from './audio-node'; 3 | 4 | export interface IAudioDestinationNode extends IAudioNode { 5 | readonly maxChannelCount: number; 6 | } 7 | -------------------------------------------------------------------------------- /src/interfaces/audio-listener.ts: -------------------------------------------------------------------------------- 1 | import { IAudioParam } from './audio-param'; 2 | 3 | export interface IAudioListener { 4 | readonly forwardX: IAudioParam; 5 | 6 | readonly forwardY: IAudioParam; 7 | 8 | readonly forwardZ: IAudioParam; 9 | 10 | readonly positionX: IAudioParam; 11 | 12 | readonly positionY: IAudioParam; 13 | 14 | readonly positionZ: IAudioParam; 15 | 16 | readonly upX: IAudioParam; 17 | 18 | readonly upY: IAudioParam; 19 | 20 | readonly upZ: IAudioParam; 21 | } 22 | -------------------------------------------------------------------------------- /src/interfaces/audio-node-options.ts: -------------------------------------------------------------------------------- 1 | import { TChannelCountMode, TChannelInterpretation } from '../types'; 2 | 3 | export interface IAudioNodeOptions { 4 | channelCount: number; 5 | 6 | channelCountMode: TChannelCountMode; 7 | 8 | channelInterpretation: TChannelInterpretation; 9 | } 10 | -------------------------------------------------------------------------------- /src/interfaces/audio-node-renderer.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioNode, TNativeOfflineAudioContext } from '../types'; 2 | import { IAudioNode } from './audio-node'; 3 | import { IMinimalOfflineAudioContext } from './minimal-offline-audio-context'; 4 | import { IOfflineAudioContext } from './offline-audio-context'; 5 | 6 | export interface IAudioNodeRenderer> { 7 | render(proxy: U, nativeOfflineAudioContext: TNativeOfflineAudioContext): Promise; 8 | } 9 | -------------------------------------------------------------------------------- /src/interfaces/audio-scheduled-source-node-event-map.ts: -------------------------------------------------------------------------------- 1 | export interface IAudioScheduledSourceNodeEventMap extends Record { 2 | ended: Event; 3 | } 4 | -------------------------------------------------------------------------------- /src/interfaces/audio-scheduled-source-node.ts: -------------------------------------------------------------------------------- 1 | import { TContext, TEventHandler } from '../types'; 2 | import { IAudioNode } from './audio-node'; 3 | import { IAudioScheduledSourceNodeEventMap } from './audio-scheduled-source-node-event-map'; 4 | 5 | export interface IAudioScheduledSourceNode extends IAudioNode { 6 | onended: null | TEventHandler; 7 | 8 | start(when?: number): void; 9 | 10 | stop(when?: number): void; 11 | } 12 | -------------------------------------------------------------------------------- /src/interfaces/audio-timestamp.ts: -------------------------------------------------------------------------------- 1 | export interface IAudioTimestamp { 2 | contextTime: number; 3 | 4 | performanceTime: number; 5 | } 6 | -------------------------------------------------------------------------------- /src/interfaces/audio-worklet-node-event-map.ts: -------------------------------------------------------------------------------- 1 | export interface IAudioWorkletNodeEventMap extends Record { 2 | processorerror: ErrorEvent; 3 | } 4 | -------------------------------------------------------------------------------- /src/interfaces/audio-worklet-node-options.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNodeOptions } from './audio-node-options'; 2 | 3 | export interface IAudioWorkletNodeOptions extends IAudioNodeOptions { 4 | numberOfInputs: number; 5 | 6 | numberOfOutputs: number; 7 | 8 | outputChannelCount: Iterable; 9 | 10 | parameterData: { [name: string]: number }; 11 | 12 | processorOptions: unknown; 13 | } 14 | -------------------------------------------------------------------------------- /src/interfaces/audio-worklet-node.ts: -------------------------------------------------------------------------------- 1 | import { TAudioParamMap, TContext, TErrorEventHandler } from '../types'; 2 | import { IAudioNode } from './audio-node'; 3 | import { IAudioWorkletNodeEventMap } from './audio-worklet-node-event-map'; 4 | 5 | export interface IAudioWorkletNode extends IAudioNode { 6 | onprocessorerror: null | TErrorEventHandler; 7 | 8 | readonly parameters: TAudioParamMap; 9 | 10 | readonly port: MessagePort; 11 | } 12 | -------------------------------------------------------------------------------- /src/interfaces/audio-worklet.ts: -------------------------------------------------------------------------------- 1 | import { IWorkletOptions } from './worklet-options'; 2 | 3 | export interface IAudioWorklet { 4 | addModule(moduleURL: string, options?: IWorkletOptions): Promise; 5 | } 6 | -------------------------------------------------------------------------------- /src/interfaces/automation.ts: -------------------------------------------------------------------------------- 1 | export interface IAutomation { 2 | type: string; 3 | } 4 | -------------------------------------------------------------------------------- /src/interfaces/biquad-filter-node.ts: -------------------------------------------------------------------------------- 1 | import { TBiquadFilterType, TContext } from '../types'; 2 | import { IAudioNode } from './audio-node'; 3 | import { IAudioParam } from './audio-param'; 4 | 5 | export interface IBiquadFilterNode extends IAudioNode { 6 | readonly detune: IAudioParam; 7 | 8 | readonly frequency: IAudioParam; 9 | 10 | readonly gain: IAudioParam; 11 | 12 | readonly Q: IAudioParam; 13 | 14 | type: TBiquadFilterType; 15 | 16 | getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; 17 | } 18 | -------------------------------------------------------------------------------- /src/interfaces/biquad-filter-options.ts: -------------------------------------------------------------------------------- 1 | import { TBiquadFilterType } from '../types'; 2 | import { IAudioNodeOptions } from './audio-node-options'; 3 | 4 | export interface IBiquadFilterOptions extends IAudioNodeOptions { 5 | detune: number; 6 | 7 | frequency: number; 8 | 9 | gain: number; 10 | 11 | Q: number; 12 | 13 | type: TBiquadFilterType; 14 | } 15 | -------------------------------------------------------------------------------- /src/interfaces/channel-merger-options.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNodeOptions } from './audio-node-options'; 2 | 3 | export interface IChannelMergerOptions extends IAudioNodeOptions { 4 | numberOfInputs: number; 5 | } 6 | -------------------------------------------------------------------------------- /src/interfaces/channel-splitter-options.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNodeOptions } from './audio-node-options'; 2 | 3 | export interface IChannelSplitterOptions extends IAudioNodeOptions { 4 | numberOfOutputs: number; 5 | } 6 | -------------------------------------------------------------------------------- /src/interfaces/common-audio-context.ts: -------------------------------------------------------------------------------- 1 | export interface ICommonAudioContext { 2 | readonly baseLatency: number; 3 | 4 | close(): Promise; 5 | 6 | // @todo This should be part of the IMinimalBaseAudioContext. 7 | resume(): Promise; 8 | 9 | suspend(): Promise; 10 | } 11 | -------------------------------------------------------------------------------- /src/interfaces/common-offline-audio-context.ts: -------------------------------------------------------------------------------- 1 | export interface ICommonOfflineAudioContext { 2 | readonly length: number; 3 | 4 | startRendering(): Promise; 5 | } 6 | -------------------------------------------------------------------------------- /src/interfaces/constant-source-node.ts: -------------------------------------------------------------------------------- 1 | import { TContext } from '../types'; 2 | import { IAudioParam } from './audio-param'; 3 | import { IAudioScheduledSourceNode } from './audio-scheduled-source-node'; 4 | 5 | export interface IConstantSourceNode extends IAudioScheduledSourceNode { 6 | readonly offset: IAudioParam; 7 | } 8 | -------------------------------------------------------------------------------- /src/interfaces/constant-source-options.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNodeOptions } from './audio-node-options'; 2 | 3 | export interface IConstantSourceOptions extends IAudioNodeOptions { 4 | offset: number; 5 | } 6 | -------------------------------------------------------------------------------- /src/interfaces/convolver-node.ts: -------------------------------------------------------------------------------- 1 | import { TAnyAudioBuffer, TContext } from '../types'; 2 | import { IAudioNode } from './audio-node'; 3 | 4 | export interface IConvolverNode extends IAudioNode { 5 | buffer: null | TAnyAudioBuffer; 6 | 7 | normalize: boolean; 8 | } 9 | -------------------------------------------------------------------------------- /src/interfaces/convolver-options.ts: -------------------------------------------------------------------------------- 1 | import { TAnyAudioBuffer } from '../types'; 2 | import { IAudioNodeOptions } from './audio-node-options'; 3 | 4 | export interface IConvolverOptions extends IAudioNodeOptions { 5 | buffer: null | TAnyAudioBuffer; 6 | 7 | disableNormalization: boolean; 8 | } 9 | -------------------------------------------------------------------------------- /src/interfaces/delay-node.ts: -------------------------------------------------------------------------------- 1 | import { TContext } from '../types'; 2 | import { IAudioNode } from './audio-node'; 3 | import { IAudioParam } from './audio-param'; 4 | 5 | export interface IDelayNode extends IAudioNode { 6 | readonly delayTime: IAudioParam; 7 | } 8 | -------------------------------------------------------------------------------- /src/interfaces/delay-options.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNodeOptions } from './audio-node-options'; 2 | 3 | export interface IDelayOptions extends IAudioNodeOptions { 4 | delayTime: number; 5 | 6 | maxDelayTime: number; 7 | } 8 | -------------------------------------------------------------------------------- /src/interfaces/dynamics-compressor-node.ts: -------------------------------------------------------------------------------- 1 | import { TContext } from '../types'; 2 | import { IAudioNode } from './audio-node'; 3 | import { IAudioParam } from './audio-param'; 4 | 5 | export interface IDynamicsCompressorNode extends IAudioNode { 6 | readonly attack: IAudioParam; 7 | 8 | readonly knee: IAudioParam; 9 | 10 | readonly ratio: IAudioParam; 11 | 12 | readonly reduction: number; 13 | 14 | readonly release: IAudioParam; 15 | 16 | readonly threshold: IAudioParam; 17 | } 18 | -------------------------------------------------------------------------------- /src/interfaces/dynamics-compressor-options.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNodeOptions } from './audio-node-options'; 2 | 3 | export interface IDynamicsCompressorOptions extends IAudioNodeOptions { 4 | attack: number; 5 | 6 | knee: number; 7 | 8 | ratio: number; 9 | 10 | release: number; 11 | 12 | threshold: number; 13 | } 14 | -------------------------------------------------------------------------------- /src/interfaces/gain-node.ts: -------------------------------------------------------------------------------- 1 | import { TContext } from '../types'; 2 | import { IAudioNode } from './audio-node'; 3 | import { IAudioParam } from './audio-param'; 4 | 5 | export interface IGainNode extends IAudioNode { 6 | readonly gain: IAudioParam; 7 | } 8 | -------------------------------------------------------------------------------- /src/interfaces/gain-options.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNodeOptions } from './audio-node-options'; 2 | 3 | export interface IGainOptions extends IAudioNodeOptions { 4 | gain: number; 5 | } 6 | -------------------------------------------------------------------------------- /src/interfaces/iir-filter-node.ts: -------------------------------------------------------------------------------- 1 | import { TContext } from '../types'; 2 | import { IAudioNode } from './audio-node'; 3 | 4 | export interface IIIRFilterNode extends IAudioNode { 5 | getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; 6 | } 7 | -------------------------------------------------------------------------------- /src/interfaces/iir-filter-options.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNodeOptions } from './audio-node-options'; 2 | 3 | export interface IIIRFilterOptions extends IAudioNodeOptions { 4 | feedback: Iterable; 5 | 6 | feedforward: Iterable; 7 | } 8 | -------------------------------------------------------------------------------- /src/interfaces/media-element-audio-source-node.ts: -------------------------------------------------------------------------------- 1 | import { IAudioContext } from './audio-context'; 2 | import { IAudioNode } from './audio-node'; 3 | import { IMinimalAudioContext } from './minimal-audio-context'; 4 | 5 | export interface IMediaElementAudioSourceNode extends IAudioNode { 6 | readonly mediaElement: HTMLMediaElement; 7 | } 8 | -------------------------------------------------------------------------------- /src/interfaces/media-element-audio-source-options.ts: -------------------------------------------------------------------------------- 1 | export interface IMediaElementAudioSourceOptions { 2 | mediaElement: HTMLMediaElement; 3 | } 4 | -------------------------------------------------------------------------------- /src/interfaces/media-stream-audio-destination-node.ts: -------------------------------------------------------------------------------- 1 | import { IAudioContext } from './audio-context'; 2 | import { IAudioNode } from './audio-node'; 3 | import { IMinimalAudioContext } from './minimal-audio-context'; 4 | 5 | export interface IMediaStreamAudioDestinationNode extends IAudioNode { 6 | readonly stream: MediaStream; 7 | } 8 | -------------------------------------------------------------------------------- /src/interfaces/media-stream-audio-source-node.ts: -------------------------------------------------------------------------------- 1 | import { IAudioContext } from './audio-context'; 2 | import { IAudioNode } from './audio-node'; 3 | import { IMinimalAudioContext } from './minimal-audio-context'; 4 | 5 | export interface IMediaStreamAudioSourceNode extends IAudioNode { 6 | readonly mediaStream: MediaStream; 7 | } 8 | -------------------------------------------------------------------------------- /src/interfaces/media-stream-audio-source-options.ts: -------------------------------------------------------------------------------- 1 | export interface IMediaStreamAudioSourceOptions { 2 | mediaStream: MediaStream; 3 | } 4 | -------------------------------------------------------------------------------- /src/interfaces/media-stream-track-audio-source-node.ts: -------------------------------------------------------------------------------- 1 | import { IAudioContext } from './audio-context'; 2 | import { IAudioNode } from './audio-node'; 3 | import { IMinimalAudioContext } from './minimal-audio-context'; 4 | 5 | export interface IMediaStreamTrackAudioSourceNode extends IAudioNode {} 6 | -------------------------------------------------------------------------------- /src/interfaces/media-stream-track-audio-source-options.ts: -------------------------------------------------------------------------------- 1 | export interface IMediaStreamTrackAudioSourceOptions { 2 | mediaStreamTrack: MediaStreamTrack; 3 | } 4 | -------------------------------------------------------------------------------- /src/interfaces/minimal-audio-context.ts: -------------------------------------------------------------------------------- 1 | import { ICommonAudioContext } from './common-audio-context'; 2 | import { IMinimalBaseAudioContext } from './minimal-base-audio-context'; 3 | 4 | export interface IMinimalAudioContext extends ICommonAudioContext, IMinimalBaseAudioContext {} 5 | -------------------------------------------------------------------------------- /src/interfaces/minimal-base-audio-context-event-map.ts: -------------------------------------------------------------------------------- 1 | export interface IMinimalBaseAudioContextEventMap extends Record { 2 | statechange: Event; 3 | } 4 | -------------------------------------------------------------------------------- /src/interfaces/minimal-offline-audio-context.ts: -------------------------------------------------------------------------------- 1 | import { ICommonOfflineAudioContext } from './common-offline-audio-context'; 2 | import { IMinimalBaseAudioContext } from './minimal-base-audio-context'; 3 | 4 | export interface IMinimalOfflineAudioContext extends ICommonOfflineAudioContext, IMinimalBaseAudioContext {} 5 | -------------------------------------------------------------------------------- /src/interfaces/offline-audio-completion-event.ts: -------------------------------------------------------------------------------- 1 | import { IAudioBuffer } from './audio-buffer'; 2 | 3 | export interface IOfflineAudioCompletionEvent extends Event { 4 | readonly renderedBuffer: IAudioBuffer; 5 | } 6 | -------------------------------------------------------------------------------- /src/interfaces/offline-audio-context-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IOfflineAudioContext } from './offline-audio-context'; 2 | import { IOfflineAudioContextOptions } from './offline-audio-context-options'; 3 | 4 | export interface IOfflineAudioContextConstructor { 5 | new (options: IOfflineAudioContextOptions): IOfflineAudioContext; 6 | new (numberOfChannels: number, length: number, sampleRate: number): IOfflineAudioContext; 7 | } 8 | -------------------------------------------------------------------------------- /src/interfaces/offline-audio-context-options.ts: -------------------------------------------------------------------------------- 1 | export interface IOfflineAudioContextOptions { 2 | length: number; 3 | 4 | numberOfChannels?: number; 5 | 6 | sampleRate: number; 7 | } 8 | -------------------------------------------------------------------------------- /src/interfaces/offline-audio-context.ts: -------------------------------------------------------------------------------- 1 | import { IBaseAudioContext } from './base-audio-context'; 2 | import { ICommonOfflineAudioContext } from './common-offline-audio-context'; 3 | 4 | export interface IOfflineAudioContext extends IBaseAudioContext, ICommonOfflineAudioContext { 5 | // @todo oncomplete 6 | } 7 | -------------------------------------------------------------------------------- /src/interfaces/oscillator-node.ts: -------------------------------------------------------------------------------- 1 | import { TContext, TOscillatorType } from '../types'; 2 | import { IAudioParam } from './audio-param'; 3 | import { IAudioScheduledSourceNode } from './audio-scheduled-source-node'; 4 | 5 | export interface IOscillatorNode extends IAudioScheduledSourceNode { 6 | readonly detune: IAudioParam; 7 | 8 | readonly frequency: IAudioParam; 9 | 10 | type: TOscillatorType; 11 | 12 | setPeriodicWave(periodicWave: PeriodicWave): void; 13 | } 14 | -------------------------------------------------------------------------------- /src/interfaces/oscillator-options.ts: -------------------------------------------------------------------------------- 1 | import { TOscillatorType } from '../types'; 2 | import { IAudioNodeOptions } from './audio-node-options'; 3 | import { IPeriodicWave } from './periodic-wave'; 4 | 5 | export interface IOscillatorOptions extends IAudioNodeOptions { 6 | detune: number; 7 | 8 | frequency: number; 9 | 10 | periodicWave?: IPeriodicWave; 11 | 12 | type: TOscillatorType; 13 | } 14 | -------------------------------------------------------------------------------- /src/interfaces/periodic-wave-constraints.ts: -------------------------------------------------------------------------------- 1 | export interface IPeriodicWaveConstraints { 2 | disableNormalization: boolean; 3 | } 4 | -------------------------------------------------------------------------------- /src/interfaces/periodic-wave-options.ts: -------------------------------------------------------------------------------- 1 | import { IPeriodicWaveConstraints } from './periodic-wave-constraints'; 2 | 3 | export interface IPeriodicWaveOptions extends IPeriodicWaveConstraints { 4 | imag: Iterable; 5 | 6 | real: Iterable; 7 | } 8 | -------------------------------------------------------------------------------- /src/interfaces/periodic-wave.ts: -------------------------------------------------------------------------------- 1 | export interface IPeriodicWave {} // tslint:disable-line:no-empty-interface 2 | -------------------------------------------------------------------------------- /src/interfaces/read-only-map.ts: -------------------------------------------------------------------------------- 1 | export interface IReadOnlyMap { 2 | readonly entries: Map['entries']; 3 | 4 | readonly get: Map['get']; 5 | 6 | readonly has: Map['has']; 7 | 8 | readonly keys: Map['keys']; 9 | 10 | readonly size: Map['size']; 11 | 12 | readonly values: Map['values']; 13 | 14 | /* 15 | * The signature of forEach() differs from the signature Map's forEach() function because the callback receives a IReadOnlyMap as third 16 | * argument. 17 | */ 18 | forEach(callback: (value: U, key: T, map: IReadOnlyMap) => void, thisArg?: any): void; 19 | 20 | // @todo Symbol.iterator 21 | } 22 | -------------------------------------------------------------------------------- /src/interfaces/stereo-panner-node.ts: -------------------------------------------------------------------------------- 1 | import { TContext } from '../types'; 2 | import { IAudioNode } from './audio-node'; 3 | import { IAudioParam } from './audio-param'; 4 | 5 | export interface IStereoPannerNode extends IAudioNode { 6 | readonly pan: IAudioParam; 7 | } 8 | -------------------------------------------------------------------------------- /src/interfaces/stereo-panner-options.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNodeOptions } from './audio-node-options'; 2 | 3 | export interface IStereoPannerOptions extends IAudioNodeOptions { 4 | pan: number; 5 | } 6 | -------------------------------------------------------------------------------- /src/interfaces/wave-shaper-node.ts: -------------------------------------------------------------------------------- 1 | import { TContext, TOverSampleType } from '../types'; 2 | import { IAudioNode } from './audio-node'; 3 | 4 | export interface IWaveShaperNode extends IAudioNode { 5 | curve: null | Float32Array; 6 | 7 | oversample: TOverSampleType; 8 | } 9 | -------------------------------------------------------------------------------- /src/interfaces/wave-shaper-options.ts: -------------------------------------------------------------------------------- 1 | import { TOverSampleType } from '../types'; 2 | import { IAudioNodeOptions } from './audio-node-options'; 3 | 4 | export interface IWaveShaperOptions extends IAudioNodeOptions { 5 | curve: null | Float32Array; 6 | 7 | oversample: TOverSampleType; 8 | } 9 | -------------------------------------------------------------------------------- /src/interfaces/worklet-options.ts: -------------------------------------------------------------------------------- 1 | // @todo This is currently named IWorkletOptions and not IAudioWorkletOptions because it defines the options of a generic Worklet. 2 | 3 | export interface IWorkletOptions { 4 | credentials: 'include' | 'omit' | 'same-origin'; 5 | } 6 | -------------------------------------------------------------------------------- /src/message-port.d.ts: -------------------------------------------------------------------------------- 1 | // tslint:disable-next-line:interface-name 2 | interface MessagePortEventMap { 3 | messageerror: MessageEvent; 4 | } 5 | 6 | // tslint:disable-next-line:interface-name 7 | interface MessagePort { 8 | onmessageerror: ((this: MessagePort, ev: MessageEvent) => any) | null; 9 | } 10 | -------------------------------------------------------------------------------- /src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "isolatedModules": true 4 | }, 5 | "extends": "tsconfig-holy-grail/src/tsconfig-browser" 6 | } 7 | -------------------------------------------------------------------------------- /src/types/abort-error-factory.ts: -------------------------------------------------------------------------------- 1 | export type TAbortErrorFactory = () => DOMException; 2 | -------------------------------------------------------------------------------- /src/types/active-audio-worklet-node-inputs-store.ts: -------------------------------------------------------------------------------- 1 | import { TActiveInputConnection } from './active-input-connection'; 2 | import { TContext } from './context'; 3 | import { TNativeAudioWorkletNode } from './native-audio-worklet-node'; 4 | 5 | export type TActiveAudioWorkletNodeInputsStore = WeakMap>[]>; 6 | -------------------------------------------------------------------------------- /src/types/active-input-connection.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TContext } from './context'; 3 | import { TInternalStateEventListener } from './internal-state-event-listener'; 4 | 5 | export type TActiveInputConnection = [IAudioNode, number, TInternalStateEventListener]; 6 | -------------------------------------------------------------------------------- /src/types/add-active-input-connection-to-audio-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { TAddActiveInputConnectionToAudioNodeFunction } from './add-active-input-connection-to-audio-node-function'; 2 | import { TInsertElementInSetFunction } from './insert-element-in-set-function'; 3 | 4 | export type TAddActiveInputConnectionToAudioNodeFactory = ( 5 | insertElementInSet: TInsertElementInSetFunction 6 | ) => TAddActiveInputConnectionToAudioNodeFunction; 7 | -------------------------------------------------------------------------------- /src/types/add-active-input-connection-to-audio-node-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TActiveInputConnection } from './active-input-connection'; 3 | import { TContext } from './context'; 4 | import { TPassiveAudioNodeInputConnection } from './passive-audio-node-input-connection'; 5 | 6 | export type TAddActiveInputConnectionToAudioNodeFunction = ( 7 | activeInputs: Set>[], 8 | source: IAudioNode, 9 | [output, input, eventListener]: TPassiveAudioNodeInputConnection, 10 | ignoreDuplicates: boolean 11 | ) => void; 12 | -------------------------------------------------------------------------------- /src/types/add-audio-node-connections-factory.ts: -------------------------------------------------------------------------------- 1 | import { TAddAudioNodeConnectionsFunction } from './add-audio-node-connections-function'; 2 | import { TAudioNodeConnectionsStore } from './audio-node-connections-store'; 3 | 4 | export type TAddAudioNodeConnectionsFactory = (audioNodeConnectionsStore: TAudioNodeConnectionsStore) => TAddAudioNodeConnectionsFunction; 5 | -------------------------------------------------------------------------------- /src/types/add-audio-node-connections-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode, IAudioNodeRenderer, IMinimalOfflineAudioContext, IOfflineAudioContext } from '../interfaces'; 2 | import { TContext } from './context'; 3 | import { TNativeAudioNode } from './native-audio-node'; 4 | 5 | export type TAddAudioNodeConnectionsFunction = ( 6 | audioNode: IAudioNode, 7 | audioNodeRenderer: T extends IMinimalOfflineAudioContext | IOfflineAudioContext ? IAudioNodeRenderer> : null, 8 | nativeAudioNode: TNativeAudioNode 9 | ) => void; 10 | -------------------------------------------------------------------------------- /src/types/add-audio-param-connections-factory.ts: -------------------------------------------------------------------------------- 1 | import { TAddAudioParamConnectionsFunction } from './add-audio-param-connections-function'; 2 | import { TAudioParamConnectionsStore } from './audio-param-connections-store'; 3 | 4 | export type TAddAudioParamConnectionsFactory = ( 5 | audioParamConnectionsStore: TAudioParamConnectionsStore 6 | ) => TAddAudioParamConnectionsFunction; 7 | -------------------------------------------------------------------------------- /src/types/add-audio-param-connections-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioParam } from '../interfaces'; 2 | 3 | export type TAddAudioParamConnectionsFunction = (audioParam: IAudioParam) => void; 4 | -------------------------------------------------------------------------------- /src/types/add-audio-worklet-module-function.ts: -------------------------------------------------------------------------------- 1 | import { IWorkletOptions } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TAddAudioWorkletModuleFunction = (context: TContext, moduleURL: string, options?: IWorkletOptions) => Promise; 5 | -------------------------------------------------------------------------------- /src/types/add-connection-to-audio-node-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TAddConnectionToAudioNodeFunction = ( 5 | source: IAudioNode, 6 | destination: IAudioNode, 7 | output: number, 8 | input: number, 9 | isOffline: boolean 10 | ) => boolean; 11 | -------------------------------------------------------------------------------- /src/types/add-passive-input-connection-to-audio-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { TAddPassiveInputConnectionToAudioNodeFunction } from './add-passive-input-connection-to-audio-node-function'; 2 | import { TInsertElementInSetFunction } from './insert-element-in-set-function'; 3 | 4 | export type TAddPassiveInputConnectionToAudioNodeFactory = ( 5 | insertElementInSet: TInsertElementInSetFunction 6 | ) => TAddPassiveInputConnectionToAudioNodeFunction; 7 | -------------------------------------------------------------------------------- /src/types/add-passive-input-connection-to-audio-node-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TActiveInputConnection } from './active-input-connection'; 3 | import { TContext } from './context'; 4 | import { TPassiveAudioNodeInputConnection } from './passive-audio-node-input-connection'; 5 | 6 | export type TAddPassiveInputConnectionToAudioNodeFunction = ( 7 | passiveInputs: WeakMap, Set>, 8 | input: number, 9 | [source, output, eventListener]: TActiveInputConnection, 10 | ignoreDuplicates: boolean 11 | ) => void; 12 | -------------------------------------------------------------------------------- /src/types/add-silent-connection-factory.ts: -------------------------------------------------------------------------------- 1 | import { TAddSilentConnectionFunction } from './add-silent-connection-function'; 2 | import { TNativeGainNodeFactory } from './native-gain-node-factory'; 3 | 4 | export type TAddSilentConnectionFactory = (createNativeGainNode: TNativeGainNodeFactory) => TAddSilentConnectionFunction; 5 | -------------------------------------------------------------------------------- /src/types/add-silent-connection-function.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioBufferSourceNode } from './native-audio-buffer-source-node'; 2 | import { TNativeConstantSourceNode } from './native-constant-source-node'; 3 | import { TNativeContext } from './native-context'; 4 | import { TNativeOscillatorNode } from './native-oscillator-node'; 5 | 6 | export type TAddSilentConnectionFunction = ( 7 | nativeContext: TNativeContext, 8 | nativeAudioScheduledSourceNode: TNativeAudioBufferSourceNode | TNativeConstantSourceNode | TNativeOscillatorNode 9 | ) => void; 10 | -------------------------------------------------------------------------------- /src/types/add-unrendered-audio-worklet-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { TAddUnrenderedAudioWorkletNodeFunction } from './add-unrendered-audio-worklet-node-function'; 2 | import { TGetUnrenderedAudioWorkletNodesFunction } from './get-unrendered-audio-worklet-nodes-function'; 3 | 4 | export type TAddUnrenderedAudioWorkletNodeFactory = ( 5 | getUnrenderedAudioWorkletNodes: TGetUnrenderedAudioWorkletNodesFunction 6 | ) => TAddUnrenderedAudioWorkletNodeFunction; 7 | -------------------------------------------------------------------------------- /src/types/add-unrendered-audio-worklet-node-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioWorkletNode, IMinimalOfflineAudioContext, IOfflineAudioContext } from '../interfaces'; 2 | import { TNativeContext } from './native-context'; 3 | 4 | export type TAddUnrenderedAudioWorkletNodeFunction = ( 5 | nativeContext: TNativeContext, 6 | audioWorkletNode: IAudioWorkletNode 7 | ) => void; 8 | -------------------------------------------------------------------------------- /src/types/analyser-node-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IAnalyserNode, IAnalyserOptions } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TAnalyserNodeConstructor = new (context: T, options?: Partial) => IAnalyserNode; 5 | -------------------------------------------------------------------------------- /src/types/any-audio-buffer.ts: -------------------------------------------------------------------------------- 1 | import { IAudioBuffer } from '../interfaces'; 2 | import { TNativeAudioBuffer } from './native-audio-buffer'; 3 | 4 | export type TAnyAudioBuffer = IAudioBuffer | TNativeAudioBuffer; 5 | -------------------------------------------------------------------------------- /src/types/any-context.ts: -------------------------------------------------------------------------------- 1 | import { TContext } from './context'; 2 | import { TNativeContext } from './native-context'; 3 | 4 | export type TAnyContext = TContext | TNativeContext; 5 | -------------------------------------------------------------------------------- /src/types/audio-buffer-constructor-factory.ts: -------------------------------------------------------------------------------- 1 | import { TAudioBufferConstructor } from './audio-buffer-constructor'; 2 | import { TAudioBufferStore } from './audio-buffer-store'; 3 | import { TNativeAudioBufferConstructor } from './native-audio-buffer-constructor'; 4 | 5 | export type TAudioBufferConstructorFactory = ( 6 | audioBufferStore: TAudioBufferStore, 7 | nativeAudioBufferConstructor: null | TNativeAudioBufferConstructor 8 | ) => TAudioBufferConstructor; 9 | -------------------------------------------------------------------------------- /src/types/audio-buffer-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IAudioBuffer, IAudioBufferOptions } from '../interfaces'; 2 | 3 | export type TAudioBufferConstructor = new (options: IAudioBufferOptions) => IAudioBuffer; 4 | -------------------------------------------------------------------------------- /src/types/audio-buffer-source-node-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IAudioBufferSourceNode, IAudioBufferSourceOptions } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TAudioBufferSourceNodeConstructor = new ( 5 | context: T, 6 | options?: Partial 7 | ) => IAudioBufferSourceNode; 8 | -------------------------------------------------------------------------------- /src/types/audio-buffer-store.ts: -------------------------------------------------------------------------------- 1 | import { IAudioBuffer } from '../interfaces'; 2 | 3 | export type TAudioBufferStore = WeakSet; 4 | -------------------------------------------------------------------------------- /src/types/audio-context-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IAudioContext, IAudioContextOptions } from '../interfaces'; 2 | 3 | export type TAudioContextConstructor = new (options?: IAudioContextOptions) => IAudioContext; 4 | -------------------------------------------------------------------------------- /src/types/audio-context-latency-category.ts: -------------------------------------------------------------------------------- 1 | export type TAudioContextLatencyCategory = 'balanced' | 'interactive' | 'playback'; 2 | -------------------------------------------------------------------------------- /src/types/audio-context-state.ts: -------------------------------------------------------------------------------- 1 | export type TAudioContextState = 'closed' | 'interrupted' | 'running' | 'suspended'; 2 | -------------------------------------------------------------------------------- /src/types/audio-destination-node-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IAudioDestinationNode } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TAudioDestinationNodeConstructor = new (context: T, channelCount: number) => IAudioDestinationNode; 5 | -------------------------------------------------------------------------------- /src/types/audio-listener-factory.ts: -------------------------------------------------------------------------------- 1 | import { IAudioListener } from '../interfaces'; 2 | import { TContext } from './context'; 3 | import { TNativeContext } from './native-context'; 4 | 5 | export type TAudioListenerFactory = (context: T, nativeContext: TNativeContext) => IAudioListener; 6 | -------------------------------------------------------------------------------- /src/types/audio-node-connections-store.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TAudioNodeConnections } from './audio-node-connections'; 3 | import { TContext } from './context'; 4 | 5 | export type TAudioNodeConnectionsStore = WeakMap, TAudioNodeConnections>; 6 | -------------------------------------------------------------------------------- /src/types/audio-node-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode, IAudioNodeRenderer, IMinimalOfflineAudioContext, IOfflineAudioContext } from '../interfaces'; 2 | import { TContext } from './context'; 3 | import { TNativeAudioNode } from './native-audio-node'; 4 | 5 | export type TAudioNodeConstructor = new = {}>( 6 | context: T, 7 | isActive: boolean, 8 | nativeAudioNode: TNativeAudioNode, 9 | audioNodeRenderer: T extends IMinimalOfflineAudioContext | IOfflineAudioContext ? IAudioNodeRenderer> : null 10 | ) => IAudioNode; 11 | -------------------------------------------------------------------------------- /src/types/audio-node-output-connection.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TAudioNodeOutputConnection = [IAudioNode, number, number]; 5 | -------------------------------------------------------------------------------- /src/types/audio-node-renderer.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode, IAudioNodeRenderer, IMinimalOfflineAudioContext, IOfflineAudioContext } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TAudioNodeRenderer = IAudioNode> = T extends 5 | | IMinimalOfflineAudioContext 6 | | IOfflineAudioContext 7 | ? IAudioNodeRenderer 8 | : null; 9 | -------------------------------------------------------------------------------- /src/types/audio-node-store.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TContext } from './context'; 3 | import { TNativeAudioNode } from './native-audio-node'; 4 | 5 | export type TAudioNodeStore = WeakMap, TNativeAudioNode>; 6 | -------------------------------------------------------------------------------- /src/types/audio-node-tail-time-store.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TAudioNodeTailTimeStore = WeakMap, number>; 5 | -------------------------------------------------------------------------------- /src/types/audio-param-audio-node-store.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode, IAudioParam } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TAudioParamAudioNodeStore = WeakMap>; 5 | -------------------------------------------------------------------------------- /src/types/audio-param-connections-store.ts: -------------------------------------------------------------------------------- 1 | import { IAudioParam } from '../interfaces'; 2 | import { TAudioParamConnections } from './audio-param-connections'; 3 | import { TContext } from './context'; 4 | 5 | export type TAudioParamConnectionsStore = WeakMap>; 6 | -------------------------------------------------------------------------------- /src/types/audio-param-connections.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TActiveInputConnection } from './active-input-connection'; 3 | import { TContext } from './context'; 4 | import { TPassiveAudioParamInputConnection } from './passive-audio-param-input-connection'; 5 | 6 | export type TAudioParamConnections = Readonly<{ 7 | activeInputs: Set>; 8 | 9 | passiveInputs: WeakMap, Set>; 10 | }>; 11 | -------------------------------------------------------------------------------- /src/types/audio-param-factory.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode, IAudioParam } from '../interfaces'; 2 | import { TContext } from './context'; 3 | import { TNativeAudioParam } from './native-audio-param'; 4 | 5 | export type TAudioParamFactory = ( 6 | audioNode: IAudioNode, 7 | isAudioParamOfOfflineAudioContext: boolean, 8 | nativeAudioParam: TNativeAudioParam, 9 | maxValue?: null | number, 10 | minValue?: null | number 11 | ) => IAudioParam; 12 | -------------------------------------------------------------------------------- /src/types/audio-param-map.ts: -------------------------------------------------------------------------------- 1 | import { IAudioParam, IReadOnlyMap } from '../interfaces'; 2 | 3 | export type TAudioParamMap = IReadOnlyMap; 4 | -------------------------------------------------------------------------------- /src/types/audio-param-output-connection.ts: -------------------------------------------------------------------------------- 1 | import { IAudioParam } from '../interfaces'; 2 | 3 | export type TAudioParamOutputConnection = [IAudioParam, number]; 4 | -------------------------------------------------------------------------------- /src/types/audio-param-store.ts: -------------------------------------------------------------------------------- 1 | import { IAudioParam } from '../interfaces'; 2 | import { TNativeAudioParam } from './native-audio-param'; 3 | 4 | export type TAudioParamStore = WeakMap; 5 | -------------------------------------------------------------------------------- /src/types/audio-worklet-node-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IAudioWorkletNode, IAudioWorkletNodeOptions } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TAudioWorkletNodeConstructor = new ( 5 | context: T, 6 | name: string, 7 | options?: Partial 8 | ) => IAudioWorkletNode; 9 | -------------------------------------------------------------------------------- /src/types/backup-offline-audio-context-store.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioContext } from './native-audio-context'; 2 | import { TNativeOfflineAudioContext } from './native-offline-audio-context'; 3 | 4 | export type TBackupOfflineAudioContextStore = WeakMap; 5 | -------------------------------------------------------------------------------- /src/types/base-audio-context-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IBaseAudioContext } from '../interfaces'; 2 | import { TContext } from './context'; 3 | import { TNativeContext } from './native-context'; 4 | 5 | export type TBaseAudioContextConstructor = new ( 6 | nativeContext: TNativeContext, 7 | numberOfChannels: number 8 | ) => IBaseAudioContext; 9 | -------------------------------------------------------------------------------- /src/types/biquad-filter-node-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IBiquadFilterNode, IBiquadFilterOptions } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TBiquadFilterNodeConstructor = new ( 5 | context: T, 6 | options?: Partial 7 | ) => IBiquadFilterNode; 8 | -------------------------------------------------------------------------------- /src/types/biquad-filter-type.ts: -------------------------------------------------------------------------------- 1 | export type TBiquadFilterType = 'allpass' | 'bandpass' | 'highpass' | 'highshelf' | 'lowpass' | 'lowshelf' | 'notch' | 'peaking'; 2 | -------------------------------------------------------------------------------- /src/types/cache-test-result-factory.ts: -------------------------------------------------------------------------------- 1 | import { TCacheTestResultFunction } from './cache-test-result-function'; 2 | 3 | export type TCacheTestResultFactory = ( 4 | ongoingTests: Map>, 5 | testResults: WeakMap 6 | ) => TCacheTestResultFunction; 7 | -------------------------------------------------------------------------------- /src/types/cache-test-result-function.ts: -------------------------------------------------------------------------------- 1 | export type TCacheTestResultFunction = (tester: object, test: () => boolean | Promise) => boolean | Promise; 2 | -------------------------------------------------------------------------------- /src/types/channel-count-mode.ts: -------------------------------------------------------------------------------- 1 | export type TChannelCountMode = 'clamped-max' | 'explicit' | 'max'; 2 | -------------------------------------------------------------------------------- /src/types/channel-interpretation.ts: -------------------------------------------------------------------------------- 1 | export type TChannelInterpretation = 'discrete' | 'speakers'; 2 | -------------------------------------------------------------------------------- /src/types/channel-merger-node-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode, IChannelMergerOptions } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TChannelMergerNodeConstructor = new (context: T, options?: Partial) => IAudioNode; 5 | -------------------------------------------------------------------------------- /src/types/channel-splitter-node-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode, IChannelSplitterOptions } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TChannelSplitterNodeConstructor = new ( 5 | context: T, 6 | options?: Partial 7 | ) => IAudioNode; 8 | -------------------------------------------------------------------------------- /src/types/connect-audio-param-factory.ts: -------------------------------------------------------------------------------- 1 | import { TConnectAudioParamFunction } from './connect-audio-param-function'; 2 | import { TRenderInputsOfAudioParamFunction } from './render-inputs-of-audio-param-function'; 3 | 4 | export type TConnectAudioParamFactory = (renderInputsOfAudioParam: TRenderInputsOfAudioParamFunction) => TConnectAudioParamFunction; 5 | -------------------------------------------------------------------------------- /src/types/connect-audio-param-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioParam } from '../interfaces'; 2 | import { TNativeAudioParam } from './native-audio-param'; 3 | import { TNativeOfflineAudioContext } from './native-offline-audio-context'; 4 | 5 | export type TConnectAudioParamFunction = ( 6 | nativeOfflineAudioContext: TNativeOfflineAudioContext, 7 | audioParam: IAudioParam, 8 | nativeAudioParam: TNativeAudioParam 9 | ) => Promise; 10 | -------------------------------------------------------------------------------- /src/types/connect-native-audio-node-to-native-audio-node-function.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioNode } from './native-audio-node'; 2 | 3 | export type TConnectNativeAudioNodeToNativeAudioNodeFunction = ( 4 | nativeSourceAudioNode: TNativeAudioNode, 5 | nativeDestinationAudioNode: TNativeAudioNode, 6 | output: number, 7 | input: number 8 | ) => [TNativeAudioNode, number, number]; 9 | -------------------------------------------------------------------------------- /src/types/connected-native-audio-buffer-source-node-factory-factory.ts: -------------------------------------------------------------------------------- 1 | import { TConnectedNativeAudioBufferSourceNodeFactory } from './connected-native-audio-buffer-source-node-factory'; 2 | import { TNativeAudioBufferSourceNodeFactory } from './native-audio-buffer-source-node-factory'; 3 | 4 | export type TConnectedNativeAudioBufferSourceNodeFactoryFactory = ( 5 | createNativeAudioBufferSourceNode: TNativeAudioBufferSourceNodeFactory 6 | ) => TConnectedNativeAudioBufferSourceNodeFactory; 7 | -------------------------------------------------------------------------------- /src/types/connected-native-audio-buffer-source-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioNode } from './native-audio-node'; 2 | import { TNativeContext } from './native-context'; 3 | 4 | export type TConnectedNativeAudioBufferSourceNodeFactory = (nativeContext: TNativeContext, nativeAudioNode: TNativeAudioNode) => () => void; 5 | -------------------------------------------------------------------------------- /src/types/constant-source-node-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IConstantSourceNode, IConstantSourceOptions } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TConstantSourceNodeConstructor = new ( 5 | context: T, 6 | options?: Partial 7 | ) => IConstantSourceNode; 8 | -------------------------------------------------------------------------------- /src/types/constructor.ts: -------------------------------------------------------------------------------- 1 | export type TConstructor = new (...args: any[]) => T; 2 | -------------------------------------------------------------------------------- /src/types/context-store.ts: -------------------------------------------------------------------------------- 1 | import { TContext } from './context'; 2 | import { TNativeContext } from './native-context'; 3 | 4 | export type TContextStore = WeakMap; 5 | -------------------------------------------------------------------------------- /src/types/context.ts: -------------------------------------------------------------------------------- 1 | import { IAudioContext, IMinimalAudioContext, IMinimalOfflineAudioContext, IOfflineAudioContext } from '../interfaces'; 2 | 3 | export type TContext = IAudioContext | IMinimalAudioContext | IMinimalOfflineAudioContext | IOfflineAudioContext; 4 | -------------------------------------------------------------------------------- /src/types/convolver-node-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IConvolverNode, IConvolverOptions } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TConvolverNodeConstructor = new (context: T, options?: Partial) => IConvolverNode; 5 | -------------------------------------------------------------------------------- /src/types/create-native-offline-audio-context-factory.ts: -------------------------------------------------------------------------------- 1 | import { TCreateNativeOfflineAudioContextFunction } from './create-native-offline-audio-context-function'; 2 | import { TNativeOfflineAudioContextConstructor } from './native-offline-audio-context-constructor'; 3 | 4 | export type TCreateNativeOfflineAudioContextFactory = ( 5 | nativeOfflineAudioContextConstructor: null | TNativeOfflineAudioContextConstructor 6 | ) => TCreateNativeOfflineAudioContextFunction; 7 | -------------------------------------------------------------------------------- /src/types/create-native-offline-audio-context-function.ts: -------------------------------------------------------------------------------- 1 | import { TNativeOfflineAudioContext } from './native-offline-audio-context'; 2 | 3 | export type TCreateNativeOfflineAudioContextFunction = ( 4 | numberOfChannels: number, 5 | length: number, 6 | sampleRate: number 7 | ) => TNativeOfflineAudioContext; 8 | -------------------------------------------------------------------------------- /src/types/cycle-counters.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TCycleCounters = WeakMap, number>; 5 | -------------------------------------------------------------------------------- /src/types/data-clone-error-factory.ts: -------------------------------------------------------------------------------- 1 | export type TDataCloneErrorFactory = () => DOMException; 2 | -------------------------------------------------------------------------------- /src/types/decode-audio-data-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioBuffer } from '../interfaces'; 2 | import { TAnyContext } from './any-context'; 3 | 4 | export type TDecodeAudioDataFunction = (anyContext: TAnyContext, audioData: ArrayBuffer) => Promise; 5 | -------------------------------------------------------------------------------- /src/types/decode-error-callback.ts: -------------------------------------------------------------------------------- 1 | export type TDecodeErrorCallback = (error: DOMException | TypeError) => void; 2 | -------------------------------------------------------------------------------- /src/types/decode-success-callback.ts: -------------------------------------------------------------------------------- 1 | import { IAudioBuffer } from '../interfaces'; 2 | 3 | export type TDecodeSuccessCallback = (decodedData: IAudioBuffer) => void; 4 | -------------------------------------------------------------------------------- /src/types/decrement-cycle-counter-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TDecrementCycleCounterFunction = (audioNode: IAudioNode, count: number) => void; 5 | -------------------------------------------------------------------------------- /src/types/delay-node-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IDelayNode, IDelayOptions } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TDelayNodeConstructor = new (context: T, options?: Partial) => IDelayNode; 5 | -------------------------------------------------------------------------------- /src/types/delete-active-input-connection-to-audio-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { TDeleteActiveInputConnectionToAudioNodeFunction } from './delete-active-input-connection-to-audio-node-function'; 2 | import { TPickElementFromSetFunction } from './pick-element-from-set-function'; 3 | 4 | export type TDeleteActiveInputConnectionToAudioNodeFactory = ( 5 | pickElementFromSet: TPickElementFromSetFunction 6 | ) => TDeleteActiveInputConnectionToAudioNodeFunction; 7 | -------------------------------------------------------------------------------- /src/types/delete-active-input-connection-to-audio-node-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TActiveInputConnection } from './active-input-connection'; 3 | import { TContext } from './context'; 4 | 5 | export type TDeleteActiveInputConnectionToAudioNodeFunction = ( 6 | activeInputs: Set>[], 7 | source: IAudioNode, 8 | output: number, 9 | input: number 10 | ) => TActiveInputConnection; 11 | -------------------------------------------------------------------------------- /src/types/delete-unrendered-audio-worklet-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { TDeleteUnrenderedAudioWorkletNodeFunction } from './delete-unrendered-audio-worklet-node-function'; 2 | import { TGetUnrenderedAudioWorkletNodesFunction } from './get-unrendered-audio-worklet-nodes-function'; 3 | 4 | export type TDeleteUnrenderedAudioWorkletNodeFactory = ( 5 | getUnrenderedAudioWorkletNodes: TGetUnrenderedAudioWorkletNodesFunction 6 | ) => TDeleteUnrenderedAudioWorkletNodeFunction; 7 | -------------------------------------------------------------------------------- /src/types/delete-unrendered-audio-worklet-node-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioWorkletNode, IMinimalOfflineAudioContext, IOfflineAudioContext } from '../interfaces'; 2 | import { TNativeContext } from './native-context'; 3 | 4 | export type TDeleteUnrenderedAudioWorkletNodeFunction = ( 5 | nativeContext: TNativeContext, 6 | audioWorkletNode: IAudioWorkletNode 7 | ) => void; 8 | -------------------------------------------------------------------------------- /src/types/detect-cycles-factory.ts: -------------------------------------------------------------------------------- 1 | import { TAudioParamAudioNodeStore } from './audio-param-audio-node-store'; 2 | import { TDetectCyclesFunction } from './detect-cycles-function'; 3 | import { TGetAudioNodeConnectionsFunction } from './get-audio-node-connections-function'; 4 | import { TGetValueForKeyFunction } from './get-value-for-key-function'; 5 | 6 | export type TDetectCyclesFactory = ( 7 | audioParamAudioNodeStore: TAudioParamAudioNodeStore, 8 | getAudioNodeConnections: TGetAudioNodeConnectionsFunction, 9 | getValueForKey: TGetValueForKeyFunction 10 | ) => TDetectCyclesFunction; 11 | -------------------------------------------------------------------------------- /src/types/detect-cycles-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode, IAudioParam } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TDetectCyclesFunction = ( 5 | chain: IAudioNode[], 6 | nextLink: IAudioNode | IAudioParam 7 | ) => IAudioNode[][]; 8 | -------------------------------------------------------------------------------- /src/types/disconnect-native-audio-node-from-native-audio-node-function.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioNode } from './native-audio-node'; 2 | 3 | export type TDisconnectNativeAudioNodeFromNativeAudioNodeFunction = ( 4 | nativeSourceAudioNode: TNativeAudioNode, 5 | nativeDestinationAudioNode: TNativeAudioNode, 6 | output: number, 7 | input: number 8 | ) => void; 9 | -------------------------------------------------------------------------------- /src/types/distance-model-type.ts: -------------------------------------------------------------------------------- 1 | export type TDistanceModelType = 'exponential' | 'inverse' | 'linear'; 2 | -------------------------------------------------------------------------------- /src/types/dynamics-compressor-node-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IDynamicsCompressorNode, IDynamicsCompressorOptions } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TDynamicsCompressorNodeConstructor = new ( 5 | context: T, 6 | options?: Partial 7 | ) => IDynamicsCompressorNode; 8 | -------------------------------------------------------------------------------- /src/types/error-event-handler.ts: -------------------------------------------------------------------------------- 1 | import { TEventHandler } from './event-handler'; 2 | 3 | export type TErrorEventHandler = TEventHandler; 4 | -------------------------------------------------------------------------------- /src/types/event-handler.ts: -------------------------------------------------------------------------------- 1 | export type TEventHandler = (ThisType & { handler(event: U): void })['handler']; 2 | -------------------------------------------------------------------------------- /src/types/event-target-constructor-factory.ts: -------------------------------------------------------------------------------- 1 | import { TEventTargetConstructor } from './event-target-constructor'; 2 | import { TWrapEventListenerFunction } from './wrap-event-listener-function'; 3 | 4 | export type TEventTargetConstructorFactory = (wrapEventListener: TWrapEventListenerFunction) => TEventTargetConstructor; 5 | -------------------------------------------------------------------------------- /src/types/event-target-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IEventTarget } from '../interfaces'; 2 | import { TNativeEventTarget } from './native-event-target'; 3 | 4 | export type TEventTargetConstructor = new >( 5 | nativeEventTarget: TNativeEventTarget 6 | ) => IEventTarget; 7 | -------------------------------------------------------------------------------- /src/types/fetch-source-factory.ts: -------------------------------------------------------------------------------- 1 | import { TAbortErrorFactory } from './abort-error-factory'; 2 | import { TFetchSourceFunction } from './fetch-source-function'; 3 | 4 | export type TFetchSourceFactory = (createAbortError: TAbortErrorFactory) => TFetchSourceFunction; 5 | -------------------------------------------------------------------------------- /src/types/fetch-source-function.ts: -------------------------------------------------------------------------------- 1 | export type TFetchSourceFunction = (url: string) => Promise<[string, string]>; 2 | -------------------------------------------------------------------------------- /src/types/gain-node-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IGainNode, IGainOptions } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TGainNodeConstructor = new (context: T, options?: Partial) => IGainNode; 5 | -------------------------------------------------------------------------------- /src/types/get-audio-node-connections-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TAudioNodeConnections } from './audio-node-connections'; 3 | import { TContext } from './context'; 4 | 5 | export type TGetAudioNodeConnectionsFunction = (audioNode: IAudioNode) => TAudioNodeConnections; 6 | -------------------------------------------------------------------------------- /src/types/get-audio-node-renderer-factory.ts: -------------------------------------------------------------------------------- 1 | import { TGetAudioNodeConnectionsFunction } from './get-audio-node-connections-function'; 2 | import { TGetAudioNodeRendererFunction } from './get-audio-node-renderer-function'; 3 | 4 | export type TGetAudioNodeRendererFactory = (getAudioNodeConnections: TGetAudioNodeConnectionsFunction) => TGetAudioNodeRendererFunction; 5 | -------------------------------------------------------------------------------- /src/types/get-audio-node-renderer-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode, IAudioNodeRenderer, IMinimalOfflineAudioContext, IOfflineAudioContext } from '../interfaces'; 2 | 3 | export type TGetAudioNodeRendererFunction = ( 4 | audioNode: IAudioNode 5 | ) => IAudioNodeRenderer>; 6 | -------------------------------------------------------------------------------- /src/types/get-audio-node-tail-time-factory.ts: -------------------------------------------------------------------------------- 1 | import { TAudioNodeTailTimeStore } from './audio-node-tail-time-store'; 2 | import { TGetAudioNodeTailTimeFunction } from './get-audio-node-tail-time-function'; 3 | 4 | export type TGetAudioNodeTailTimeFactory = (audioNodeTailTimeStore: TAudioNodeTailTimeStore) => TGetAudioNodeTailTimeFunction; 5 | -------------------------------------------------------------------------------- /src/types/get-audio-node-tail-time-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TGetAudioNodeTailTimeFunction = (audioNode: IAudioNode) => number; 5 | -------------------------------------------------------------------------------- /src/types/get-audio-param-connections-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioParam } from '../interfaces'; 2 | import { TAudioParamConnections } from './audio-param-connections'; 3 | import { TContext } from './context'; 4 | 5 | export type TGetAudioParamConnectionsFunction = (audioParam: IAudioParam) => TAudioParamConnections; 6 | -------------------------------------------------------------------------------- /src/types/get-backup-offline-audio-context-factory.ts: -------------------------------------------------------------------------------- 1 | import { TBackupOfflineAudioContextStore } from './backup-offline-audio-context-store'; 2 | import { TGetBackupOfflineAudioContextFunction } from './get-backup-offline-audio-context-function'; 3 | 4 | export type TGetBackupOfflineAudioContextFactory = ( 5 | backupOfflineAudioContextStore: TBackupOfflineAudioContextStore 6 | ) => TGetBackupOfflineAudioContextFunction; 7 | -------------------------------------------------------------------------------- /src/types/get-backup-offline-audio-context-function.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioContext } from './native-audio-context'; 2 | import { TNativeOfflineAudioContext } from './native-offline-audio-context'; 3 | 4 | export type TGetBackupOfflineAudioContextFunction = (nativeContext: TNativeAudioContext) => undefined | TNativeOfflineAudioContext; 5 | -------------------------------------------------------------------------------- /src/types/get-event-listeners-of-audio-node-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TContext } from './context'; 3 | import { TInternalStateEventListener } from './internal-state-event-listener'; 4 | 5 | export type TGetEventListenersOfAudioNodeFunction = (audioNode: IAudioNode) => Set; 6 | -------------------------------------------------------------------------------- /src/types/get-first-sample-function.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioBuffer } from './native-audio-buffer'; 2 | 3 | export type TGetFirstSampleFunction = (audioBuffer: TNativeAudioBuffer, buffer: Float32Array, channelNumber: number) => number; 4 | -------------------------------------------------------------------------------- /src/types/get-native-audio-node-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TContext } from './context'; 3 | import { TNativeAudioNode } from './native-audio-node'; 4 | 5 | export type TGetNativeAudioNodeFunction = (audioNode: IAudioNode) => U; 6 | -------------------------------------------------------------------------------- /src/types/get-native-audio-param-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioParam } from '../interfaces'; 2 | import { TNativeAudioParam } from './native-audio-param'; 3 | 4 | export type TGetNativeAudioParamFunction = (audioParam: IAudioParam) => TNativeAudioParam; 5 | -------------------------------------------------------------------------------- /src/types/get-native-context-factory.ts: -------------------------------------------------------------------------------- 1 | import { TContextStore } from './context-store'; 2 | import { TGetNativeContextFunction } from './get-native-context-function'; 3 | 4 | export type TGetNativeContextFactory = (contextStore: TContextStore) => TGetNativeContextFunction; 5 | -------------------------------------------------------------------------------- /src/types/get-native-context-function.ts: -------------------------------------------------------------------------------- 1 | import { IMinimalOfflineAudioContext, IOfflineAudioContext } from '../interfaces'; 2 | import { TContext } from './context'; 3 | import { TNativeAudioContext } from './native-audio-context'; 4 | import { TNativeOfflineAudioContext } from './native-offline-audio-context'; 5 | 6 | export type TGetNativeContextFunction = ( 7 | context: T 8 | ) => T extends IMinimalOfflineAudioContext | IOfflineAudioContext ? TNativeOfflineAudioContext : TNativeAudioContext; 9 | -------------------------------------------------------------------------------- /src/types/get-or-create-backup-offline-audio-context-factory.ts: -------------------------------------------------------------------------------- 1 | import { TBackupOfflineAudioContextStore } from './backup-offline-audio-context-store'; 2 | import { TGetOrCreateBackupOfflineAudioContextFunction } from './get-or-create-backup-offline-audio-context-function'; 3 | import { TNativeOfflineAudioContextConstructor } from './native-offline-audio-context-constructor'; 4 | 5 | export type TGetOrCreateBackupOfflineAudioContextFactory = ( 6 | backupOfflineAudioContextStore: TBackupOfflineAudioContextStore, 7 | nativeOfflineAudioContextConstructor: null | TNativeOfflineAudioContextConstructor 8 | ) => TGetOrCreateBackupOfflineAudioContextFunction; 9 | -------------------------------------------------------------------------------- /src/types/get-or-create-backup-offline-audio-context-function.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioContext } from './native-audio-context'; 2 | import { TNativeOfflineAudioContext } from './native-offline-audio-context'; 3 | 4 | export type TGetOrCreateBackupOfflineAudioContextFunction = (nativeContext: TNativeAudioContext) => TNativeOfflineAudioContext; 5 | -------------------------------------------------------------------------------- /src/types/get-unrendered-audio-worklet-nodes-factory.ts: -------------------------------------------------------------------------------- 1 | import { TGetUnrenderedAudioWorkletNodesFunction } from './get-unrendered-audio-worklet-nodes-function'; 2 | import { TUnrenderedAudioWorkletNodeStore } from './unrendered-audio-worklet-node-store'; 3 | 4 | export type TGetUnrenderedAudioWorkletNodesFactory = ( 5 | unrenderedAudioWorkletNodeStore: TUnrenderedAudioWorkletNodeStore 6 | ) => TGetUnrenderedAudioWorkletNodesFunction; 7 | -------------------------------------------------------------------------------- /src/types/get-unrendered-audio-worklet-nodes-function.ts: -------------------------------------------------------------------------------- 1 | import { TNativeContext } from './native-context'; 2 | import { TUnrenderedAudioWorkletNodes } from './unrendered-audio-worklet-nodes'; 3 | 4 | export type TGetUnrenderedAudioWorkletNodesFunction = (nativeContext: TNativeContext) => TUnrenderedAudioWorkletNodes; 5 | -------------------------------------------------------------------------------- /src/types/get-value-for-key-function.ts: -------------------------------------------------------------------------------- 1 | export type TGetValueForKeyFunction = (map: T extends object ? Map | WeakMap : Map, key: T) => U; 2 | -------------------------------------------------------------------------------- /src/types/iir-filter-node-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IIIRFilterNode, IIIRFilterOptions } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TIIRFilterNodeConstructor = new ( 5 | context: T, 6 | options: { feedback: IIIRFilterOptions['feedback']; feedforward: IIIRFilterOptions['feedforward'] } & Partial 7 | ) => IIIRFilterNode; 8 | -------------------------------------------------------------------------------- /src/types/increment-cycle-counter-factory.ts: -------------------------------------------------------------------------------- 1 | import { TIncrementCycleCounterFunction } from './increment-cycle-counter-function'; 2 | 3 | export type TIncrementCycleCounterFactory = (isOffline: boolean) => TIncrementCycleCounterFunction; 4 | -------------------------------------------------------------------------------- /src/types/increment-cycle-counter-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TIncrementCycleCounterFunction = (audioNode: IAudioNode, count: number) => void; 5 | -------------------------------------------------------------------------------- /src/types/index-size-error-factory.ts: -------------------------------------------------------------------------------- 1 | export type TIndexSizeErrorFactory = () => DOMException; 2 | -------------------------------------------------------------------------------- /src/types/insert-element-in-set-function.ts: -------------------------------------------------------------------------------- 1 | export type TInsertElementInSetFunction = ( 2 | set: Set, 3 | element: T, 4 | predicate: (element: T) => boolean, 5 | ignoreDuplicates: boolean 6 | ) => boolean; 7 | -------------------------------------------------------------------------------- /src/types/internal-state-event-listener.ts: -------------------------------------------------------------------------------- 1 | export type TInternalStateEventListener = (isActive: boolean) => void; 2 | -------------------------------------------------------------------------------- /src/types/invalid-access-error-factory.ts: -------------------------------------------------------------------------------- 1 | export type TInvalidAccessErrorFactory = () => DOMException; 2 | -------------------------------------------------------------------------------- /src/types/invalid-state-error-factory.ts: -------------------------------------------------------------------------------- 1 | export type TInvalidStateErrorFactory = () => DOMException; 2 | -------------------------------------------------------------------------------- /src/types/is-active-audio-node-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TIsActiveAudioNodeFunction = (audioNode: IAudioNode) => boolean; 5 | -------------------------------------------------------------------------------- /src/types/is-any-audio-context-factory.ts: -------------------------------------------------------------------------------- 1 | import { TContextStore } from './context-store'; 2 | import { TIsAnyAudioContextFunction } from './is-any-audio-context-function'; 3 | import { TIsNativeAudioContextFunction } from './is-native-audio-context-function'; 4 | 5 | export type TIsAnyAudioContextFactory = ( 6 | contextStore: TContextStore, 7 | isNativeAudioContext: TIsNativeAudioContextFunction 8 | ) => TIsAnyAudioContextFunction; 9 | -------------------------------------------------------------------------------- /src/types/is-any-audio-context-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioContext, IMinimalAudioContext } from '../interfaces'; 2 | import { TNativeAudioContext } from './native-audio-context'; 3 | 4 | export type TIsAnyAudioContextFunction = (anything: unknown) => anything is IAudioContext | IMinimalAudioContext | TNativeAudioContext; 5 | -------------------------------------------------------------------------------- /src/types/is-any-audio-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { TAudioNodeStore } from './audio-node-store'; 2 | import { TIsAnyAudioNodeFunction } from './is-any-audio-node-function'; 3 | import { TIsNativeAudioNodeFunction } from './is-native-audio-node-function'; 4 | 5 | export type TIsAnyAudioNodeFactory = ( 6 | audioNodeStore: TAudioNodeStore, 7 | isNativeAudioNode: TIsNativeAudioNodeFunction 8 | ) => TIsAnyAudioNodeFunction; 9 | -------------------------------------------------------------------------------- /src/types/is-any-audio-node-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TNativeAudioNode } from './native-audio-node'; 3 | 4 | export type TIsAnyAudioNodeFunction = (anything: unknown) => anything is IAudioNode | TNativeAudioNode; 5 | -------------------------------------------------------------------------------- /src/types/is-any-audio-param-factory.ts: -------------------------------------------------------------------------------- 1 | import { TAudioParamStore } from './audio-param-store'; 2 | import { TIsAnyAudioParamFunction } from './is-any-audio-param-function'; 3 | import { TIsNativeAudioParamFunction } from './is-native-audio-param-function'; 4 | 5 | export type TIsAnyAudioParamFactory = ( 6 | audioParamStore: TAudioParamStore, 7 | isNativeAudioParam: TIsNativeAudioParamFunction 8 | ) => TIsAnyAudioParamFunction; 9 | -------------------------------------------------------------------------------- /src/types/is-any-audio-param-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioParam } from '../interfaces'; 2 | import { TNativeAudioParam } from './native-audio-param'; 3 | 4 | export type TIsAnyAudioParamFunction = (anything: unknown) => anything is IAudioParam | TNativeAudioParam; 5 | -------------------------------------------------------------------------------- /src/types/is-any-offline-audio-context-factory.ts: -------------------------------------------------------------------------------- 1 | import { TContextStore } from './context-store'; 2 | import { TIsAnyOfflineAudioContextFunction } from './is-any-offline-audio-context-function'; 3 | import { TIsNativeOfflineAudioContextFunction } from './is-native-offline-audio-context-function'; 4 | 5 | export type TIsAnyOfflineAudioContextFactory = ( 6 | contextStore: TContextStore, 7 | isNativeOfflineAudioContext: TIsNativeOfflineAudioContextFunction 8 | ) => TIsAnyOfflineAudioContextFunction; 9 | -------------------------------------------------------------------------------- /src/types/is-any-offline-audio-context-function.ts: -------------------------------------------------------------------------------- 1 | import { IMinimalOfflineAudioContext, IOfflineAudioContext } from '../interfaces'; 2 | import { TNativeOfflineAudioContext } from './native-offline-audio-context'; 3 | 4 | export type TIsAnyOfflineAudioContextFunction = ( 5 | anything: unknown 6 | ) => anything is IMinimalOfflineAudioContext | IOfflineAudioContext | TNativeOfflineAudioContext; 7 | -------------------------------------------------------------------------------- /src/types/is-dc-curve-function.ts: -------------------------------------------------------------------------------- 1 | export type TIsDCCurveFunction = (curve: null | Float32Array) => boolean; 2 | -------------------------------------------------------------------------------- /src/types/is-native-audio-context-factory.ts: -------------------------------------------------------------------------------- 1 | import { TIsNativeAudioContextFunction } from './is-native-audio-context-function'; 2 | import { TNativeAudioContextConstructor } from './native-audio-context-constructor'; 3 | 4 | export type TIsNativeAudioContextFactory = ( 5 | nativeAudioContextConstructor: null | TNativeAudioContextConstructor 6 | ) => TIsNativeAudioContextFunction; 7 | -------------------------------------------------------------------------------- /src/types/is-native-audio-context-function.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioContext } from './native-audio-context'; 2 | 3 | export type TIsNativeAudioContextFunction = (anything: unknown) => anything is TNativeAudioContext; 4 | -------------------------------------------------------------------------------- /src/types/is-native-audio-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { TIsNativeAudioNodeFunction } from './is-native-audio-node-function'; 2 | import { TWindow } from './window'; 3 | 4 | export type TIsNativeAudioNodeFactory = (window: null | TWindow) => TIsNativeAudioNodeFunction; 5 | -------------------------------------------------------------------------------- /src/types/is-native-audio-node-function.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioNode } from './native-audio-node'; 2 | 3 | export type TIsNativeAudioNodeFunction = (anything: unknown) => anything is TNativeAudioNode; 4 | -------------------------------------------------------------------------------- /src/types/is-native-audio-param-factory.ts: -------------------------------------------------------------------------------- 1 | import { TIsNativeAudioParamFunction } from './is-native-audio-param-function'; 2 | import { TWindow } from './window'; 3 | 4 | export type TIsNativeAudioParamFactory = (window: null | TWindow) => TIsNativeAudioParamFunction; 5 | -------------------------------------------------------------------------------- /src/types/is-native-audio-param-function.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioParam } from './native-audio-param'; 2 | 3 | export type TIsNativeAudioParamFunction = (anything: unknown) => anything is TNativeAudioParam; 4 | -------------------------------------------------------------------------------- /src/types/is-native-context-factory.ts: -------------------------------------------------------------------------------- 1 | import { TIsNativeAudioContextFunction } from './is-native-audio-context-function'; 2 | import { TIsNativeContextFunction } from './is-native-context-function'; 3 | import { TIsNativeOfflineAudioContextFunction } from './is-native-offline-audio-context-function'; 4 | 5 | export type TIsNativeContextFactory = ( 6 | isNativeAudioContext: TIsNativeAudioContextFunction, 7 | isNativeOfflineAudioContext: TIsNativeOfflineAudioContextFunction 8 | ) => TIsNativeContextFunction; 9 | -------------------------------------------------------------------------------- /src/types/is-native-context-function.ts: -------------------------------------------------------------------------------- 1 | import { TNativeContext } from './native-context'; 2 | 3 | export type TIsNativeContextFunction = (anything: unknown) => anything is TNativeContext; 4 | -------------------------------------------------------------------------------- /src/types/is-native-offline-audio-context-factory.ts: -------------------------------------------------------------------------------- 1 | import { TIsNativeOfflineAudioContextFunction } from './is-native-offline-audio-context-function'; 2 | import { TNativeOfflineAudioContextConstructor } from './native-offline-audio-context-constructor'; 3 | 4 | export type TIsNativeOfflineAudioContextFactory = ( 5 | nativeOfflineAudioContextConstructor: null | TNativeOfflineAudioContextConstructor 6 | ) => TIsNativeOfflineAudioContextFunction; 7 | -------------------------------------------------------------------------------- /src/types/is-native-offline-audio-context-function.ts: -------------------------------------------------------------------------------- 1 | import { TNativeOfflineAudioContext } from './native-offline-audio-context'; 2 | 3 | export type TIsNativeOfflineAudioContextFunction = (anything: unknown) => anything is TNativeOfflineAudioContext; 4 | -------------------------------------------------------------------------------- /src/types/is-part-of-a-cycle-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TIsPartOfACycleFunction = (audioNode: IAudioNode) => boolean; 5 | -------------------------------------------------------------------------------- /src/types/is-passive-audio-node-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TIsPassiveAudioNodeFunction = (audioNode: IAudioNode) => boolean; 5 | -------------------------------------------------------------------------------- /src/types/is-secure-context-factory.ts: -------------------------------------------------------------------------------- 1 | import { TWindow } from './window'; 2 | 3 | export type TIsSecureContextFactory = (window: null | TWindow) => boolean; 4 | -------------------------------------------------------------------------------- /src/types/media-element-audio-source-node-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IAudioContext, IMediaElementAudioSourceNode, IMediaElementAudioSourceOptions, IMinimalAudioContext } from '../interfaces'; 2 | 3 | export type TMediaElementAudioSourceNodeConstructor = new ( 4 | context: T, 5 | options: IMediaElementAudioSourceOptions 6 | ) => IMediaElementAudioSourceNode; 7 | -------------------------------------------------------------------------------- /src/types/media-stream-audio-destination-node-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IAudioContext, IAudioNodeOptions, IMediaStreamAudioDestinationNode, IMinimalAudioContext } from '../interfaces'; 2 | 3 | export type TMediaStreamAudioDestinationNodeConstructor = new ( 4 | context: T, 5 | options?: Partial 6 | ) => IMediaStreamAudioDestinationNode; 7 | -------------------------------------------------------------------------------- /src/types/media-stream-audio-source-node-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IAudioContext, IMediaStreamAudioSourceNode, IMediaStreamAudioSourceOptions, IMinimalAudioContext } from '../interfaces'; 2 | 3 | export type TMediaStreamAudioSourceNodeConstructor = new ( 4 | context: T, 5 | options: IMediaStreamAudioSourceOptions 6 | ) => IMediaStreamAudioSourceNode; 7 | -------------------------------------------------------------------------------- /src/types/media-stream-track-audio-source-node-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IAudioContext, IMediaStreamTrackAudioSourceNode, IMediaStreamTrackAudioSourceOptions, IMinimalAudioContext } from '../interfaces'; 2 | 3 | export type TMediaStreamTrackAudioSourceNodeConstructor = new ( 4 | context: T, 5 | options: IMediaStreamTrackAudioSourceOptions 6 | ) => IMediaStreamTrackAudioSourceNode; 7 | -------------------------------------------------------------------------------- /src/types/minimal-audio-context-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IAudioContextOptions, IMinimalAudioContext } from '../interfaces'; 2 | 3 | export type TMinimalAudioContextConstructor = new (options?: IAudioContextOptions) => IMinimalAudioContext; 4 | -------------------------------------------------------------------------------- /src/types/minimal-base-audio-context-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IMinimalBaseAudioContext } from '../interfaces'; 2 | import { TContext } from './context'; 3 | import { TNativeContext } from './native-context'; 4 | 5 | export type TMinimalBaseAudioContextConstructor = new ( 6 | nativeContext: TNativeContext, 7 | numberOfChannels: number 8 | ) => IMinimalBaseAudioContext; 9 | -------------------------------------------------------------------------------- /src/types/minimal-offline-audio-context-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IMinimalOfflineAudioContext, IOfflineAudioContextOptions } from '../interfaces'; 2 | 3 | export type TMinimalOfflineAudioContextConstructor = new (options: IOfflineAudioContextOptions) => IMinimalOfflineAudioContext; 4 | -------------------------------------------------------------------------------- /src/types/monitor-connections-factory.ts: -------------------------------------------------------------------------------- 1 | import { TInsertElementInSetFunction } from './insert-element-in-set-function'; 2 | import { TIsNativeAudioNodeFunction } from './is-native-audio-node-function'; 3 | import { TMonitorConnectionsFunction } from './monitor-connections-function'; 4 | 5 | export type TMonitorConnectionsFactory = ( 6 | insertElementInSet: TInsertElementInSetFunction, 7 | isNativeAudioNode: TIsNativeAudioNodeFunction 8 | ) => TMonitorConnectionsFunction; 9 | -------------------------------------------------------------------------------- /src/types/monitor-connections-function.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioNode } from './native-audio-node'; 2 | 3 | export type TMonitorConnectionsFunction = ( 4 | nativeAudioNode: T, 5 | whenConnected: () => void, 6 | whenDisconnected: () => void 7 | ) => T; 8 | -------------------------------------------------------------------------------- /src/types/native-analyser-node-factory-factory.ts: -------------------------------------------------------------------------------- 1 | import { TIndexSizeErrorFactory } from './index-size-error-factory'; 2 | import { TNativeAnalyserNodeFactory } from './native-analyser-node-factory'; 3 | 4 | export type TNativeAnalyserNodeFactoryFactory = (createIndexSizeError: TIndexSizeErrorFactory) => TNativeAnalyserNodeFactory; 5 | -------------------------------------------------------------------------------- /src/types/native-analyser-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { IAnalyserOptions } from '../interfaces'; 2 | import { TNativeAnalyserNode } from './native-analyser-node'; 3 | import { TNativeContext } from './native-context'; 4 | 5 | export type TNativeAnalyserNodeFactory = (nativeContext: TNativeContext, options: IAnalyserOptions) => TNativeAnalyserNode; 6 | -------------------------------------------------------------------------------- /src/types/native-analyser-node.ts: -------------------------------------------------------------------------------- 1 | export type TNativeAnalyserNode = AnalyserNode; 2 | -------------------------------------------------------------------------------- /src/types/native-audio-buffer-constructor-factory.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioBufferConstructor } from './native-audio-buffer-constructor'; 2 | import { TWindow } from './window'; 3 | 4 | export type TNativeAudioBufferConstructorFactory = (window: null | TWindow) => null | TNativeAudioBufferConstructor; 5 | -------------------------------------------------------------------------------- /src/types/native-audio-buffer-constructor.ts: -------------------------------------------------------------------------------- 1 | export type TNativeAudioBufferConstructor = typeof AudioBuffer; 2 | -------------------------------------------------------------------------------- /src/types/native-audio-buffer-source-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { IAudioBufferSourceOptions } from '../interfaces'; 2 | import { TNativeAudioBufferSourceNode } from './native-audio-buffer-source-node'; 3 | import { TNativeContext } from './native-context'; 4 | 5 | export type TNativeAudioBufferSourceNodeFactory = ( 6 | nativeContext: TNativeContext, 7 | options: IAudioBufferSourceOptions 8 | ) => TNativeAudioBufferSourceNode; 9 | -------------------------------------------------------------------------------- /src/types/native-audio-buffer-source-node.ts: -------------------------------------------------------------------------------- 1 | export type TNativeAudioBufferSourceNode = AudioBufferSourceNode; 2 | -------------------------------------------------------------------------------- /src/types/native-audio-buffer.ts: -------------------------------------------------------------------------------- 1 | export type TNativeAudioBuffer = AudioBuffer; 2 | -------------------------------------------------------------------------------- /src/types/native-audio-context-constructor-factory.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioContextConstructor } from './native-audio-context-constructor'; 2 | import { TWindow } from './window'; 3 | 4 | export type TNativeAudioContextConstructorFactory = (window: null | TWindow) => null | TNativeAudioContextConstructor; 5 | -------------------------------------------------------------------------------- /src/types/native-audio-context-constructor.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioContext } from './native-audio-context'; 2 | 3 | export type TNativeAudioContextConstructor = new (options?: AudioContextOptions) => TNativeAudioContext; 4 | -------------------------------------------------------------------------------- /src/types/native-audio-context.ts: -------------------------------------------------------------------------------- 1 | import { SetOptional } from 'type-fest'; 2 | import { TNativeMediaStreamTrackAudioSourceNode } from './native-media-stream-track-audio-source-node'; 3 | import { TWithAdditionalProperty } from './with-additional-property'; 4 | 5 | // Bug #121: Only Firefox does yet support the MediaStreamTrackAudioSourceNode which is why it is marked as optional. 6 | export type TNativeAudioContext = SetOptional< 7 | TWithAdditionalProperty< 8 | AudioContext, 9 | 'createMediaStreamTrackSource', 10 | (mediaStreamTrack: MediaStreamTrack) => TNativeMediaStreamTrackAudioSourceNode 11 | >, 12 | 'createMediaStreamTrackSource' 13 | >; 14 | -------------------------------------------------------------------------------- /src/types/native-audio-destination-node-factory-factory.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioDestinationNodeFactory } from './native-audio-destination-node-factory'; 2 | import { TNativeGainNodeFactory } from './native-gain-node-factory'; 3 | import { TOverwriteAccessorsFunction } from './overwrite-accessors-function'; 4 | 5 | export type TNativeAudioDestinationNodeFactoryFactory = ( 6 | createNativeGainNode: TNativeGainNodeFactory, 7 | overwriteAccessors: TOverwriteAccessorsFunction 8 | ) => TNativeAudioDestinationNodeFactory; 9 | -------------------------------------------------------------------------------- /src/types/native-audio-destination-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioDestinationNode } from './native-audio-destination-node'; 2 | import { TNativeContext } from './native-context'; 3 | 4 | export type TNativeAudioDestinationNodeFactory = (nativeContext: TNativeContext, channelCount: number) => TNativeAudioDestinationNode; 5 | -------------------------------------------------------------------------------- /src/types/native-audio-destination-node.ts: -------------------------------------------------------------------------------- 1 | export type TNativeAudioDestinationNode = AudioDestinationNode; 2 | -------------------------------------------------------------------------------- /src/types/native-audio-listener.ts: -------------------------------------------------------------------------------- 1 | export type TNativeAudioListener = AudioListener; 2 | -------------------------------------------------------------------------------- /src/types/native-audio-node.ts: -------------------------------------------------------------------------------- 1 | export type TNativeAudioNode = AudioNode; 2 | -------------------------------------------------------------------------------- /src/types/native-audio-param-map.ts: -------------------------------------------------------------------------------- 1 | import { IReadOnlyMap } from '../interfaces'; 2 | import { TNativeAudioParam } from './native-audio-param'; 3 | 4 | // @todo Since there are no native types yet they need to be crafted. 5 | export type TNativeAudioParamMap = IReadOnlyMap; 6 | -------------------------------------------------------------------------------- /src/types/native-audio-param.ts: -------------------------------------------------------------------------------- 1 | export type TNativeAudioParam = AudioParam; 2 | -------------------------------------------------------------------------------- /src/types/native-audio-timestamp.ts: -------------------------------------------------------------------------------- 1 | import { IAudioTimestamp } from '../interfaces'; 2 | 3 | export type TNativeAudioTimestamp = AudioTimestamp extends Partial ? Required : never; 4 | -------------------------------------------------------------------------------- /src/types/native-audio-worklet-node-constructor-factory.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioWorkletNodeConstructor } from './native-audio-worklet-node-constructor'; 2 | import { TWindow } from './window'; 3 | 4 | export type TNativeAudioWorkletNodeConstructorFactory = (window: null | TWindow) => null | TNativeAudioWorkletNodeConstructor; 5 | -------------------------------------------------------------------------------- /src/types/native-audio-worklet-node-constructor.ts: -------------------------------------------------------------------------------- 1 | export type TNativeAudioWorkletNodeConstructor = typeof AudioWorkletNode; 2 | -------------------------------------------------------------------------------- /src/types/native-audio-worklet-node-factory-factory.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioWorkletNodeFactory } from './native-audio-worklet-node-factory'; 2 | import { TNotSupportedErrorFactory } from './not-supported-error-factory'; 3 | 4 | export type TNativeAudioWorkletNodeFactoryFactory = (createNotSupportedError: TNotSupportedErrorFactory) => TNativeAudioWorkletNodeFactory; 5 | -------------------------------------------------------------------------------- /src/types/native-audio-worklet-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { IAudioWorkletNodeOptions } from '../interfaces'; 2 | import { TNativeAudioWorkletNode } from './native-audio-worklet-node'; 3 | import { TNativeAudioWorkletNodeConstructor } from './native-audio-worklet-node-constructor'; 4 | import { TNativeContext } from './native-context'; 5 | 6 | export type TNativeAudioWorkletNodeFactory = ( 7 | nativeContext: TNativeContext, 8 | nativeAudioWorkletNodeConstructor: null | TNativeAudioWorkletNodeConstructor, 9 | name: string, 10 | options: Omit & Partial> 11 | ) => TNativeAudioWorkletNode; 12 | -------------------------------------------------------------------------------- /src/types/native-audio-worklet-node-options.ts: -------------------------------------------------------------------------------- 1 | export type TNativeAudioWorkletNodeOptions = AudioWorkletNodeOptions; 2 | -------------------------------------------------------------------------------- /src/types/native-audio-worklet-node.ts: -------------------------------------------------------------------------------- 1 | export type TNativeAudioWorkletNode = AudioWorkletNode; 2 | -------------------------------------------------------------------------------- /src/types/native-audio-worklet.ts: -------------------------------------------------------------------------------- 1 | export type TNativeAudioWorklet = AudioWorklet; 2 | -------------------------------------------------------------------------------- /src/types/native-biquad-filter-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { IBiquadFilterOptions } from '../interfaces'; 2 | import { TNativeBiquadFilterNode } from './native-biquad-filter-node'; 3 | import { TNativeContext } from './native-context'; 4 | 5 | export type TNativeBiquadFilterNodeFactory = (nativeContext: TNativeContext, options: IBiquadFilterOptions) => TNativeBiquadFilterNode; 6 | -------------------------------------------------------------------------------- /src/types/native-biquad-filter-node.ts: -------------------------------------------------------------------------------- 1 | export type TNativeBiquadFilterNode = BiquadFilterNode; 2 | -------------------------------------------------------------------------------- /src/types/native-channel-merger-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { IChannelMergerOptions } from '../interfaces'; 2 | import { TNativeChannelMergerNode } from './native-channel-merger-node'; 3 | import { TNativeContext } from './native-context'; 4 | 5 | export type TNativeChannelMergerNodeFactory = (nativeContext: TNativeContext, options: IChannelMergerOptions) => TNativeChannelMergerNode; 6 | -------------------------------------------------------------------------------- /src/types/native-channel-merger-node.ts: -------------------------------------------------------------------------------- 1 | export type TNativeChannelMergerNode = ChannelMergerNode; 2 | -------------------------------------------------------------------------------- /src/types/native-channel-splitter-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { IChannelSplitterOptions } from '../interfaces'; 2 | import { TNativeChannelSplitterNode } from './native-channel-splitter-node'; 3 | import { TNativeContext } from './native-context'; 4 | 5 | export type TNativeChannelSplitterNodeFactory = ( 6 | nativeContext: TNativeContext, 7 | options: IChannelSplitterOptions 8 | ) => TNativeChannelSplitterNode; 9 | -------------------------------------------------------------------------------- /src/types/native-channel-splitter-node.ts: -------------------------------------------------------------------------------- 1 | export type TNativeChannelSplitterNode = ChannelSplitterNode; 2 | -------------------------------------------------------------------------------- /src/types/native-constant-source-node-factory-factory.ts: -------------------------------------------------------------------------------- 1 | import { TAddSilentConnectionFunction } from './add-silent-connection-function'; 2 | import { TCacheTestResultFunction } from './cache-test-result-function'; 3 | import { TNativeConstantSourceNodeFactory } from './native-constant-source-node-factory'; 4 | import { TNativeContext } from './native-context'; 5 | 6 | export type TNativeConstantSourceNodeFactoryFactory = ( 7 | addSilentConnection: TAddSilentConnectionFunction, 8 | cacheTestResult: TCacheTestResultFunction, 9 | testAudioScheduledSourceNodeStopMethodNegativeParametersSupport: (nativeContext: TNativeContext) => boolean 10 | ) => TNativeConstantSourceNodeFactory; 11 | -------------------------------------------------------------------------------- /src/types/native-constant-source-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { IConstantSourceOptions } from '../interfaces'; 2 | import { TNativeConstantSourceNode } from './native-constant-source-node'; 3 | import { TNativeContext } from './native-context'; 4 | 5 | export type TNativeConstantSourceNodeFactory = ( 6 | nativeContext: TNativeContext, 7 | options: IConstantSourceOptions 8 | ) => TNativeConstantSourceNode; 9 | -------------------------------------------------------------------------------- /src/types/native-constant-source-node.ts: -------------------------------------------------------------------------------- 1 | export type TNativeConstantSourceNode = ConstantSourceNode; 2 | -------------------------------------------------------------------------------- /src/types/native-context.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioContext } from './native-audio-context'; 2 | import { TNativeOfflineAudioContext } from './native-offline-audio-context'; 3 | 4 | export type TNativeContext = TNativeAudioContext | TNativeOfflineAudioContext; 5 | -------------------------------------------------------------------------------- /src/types/native-convolver-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { IConvolverOptions } from '../interfaces'; 2 | import { TNativeContext } from './native-context'; 3 | import { TNativeConvolverNode } from './native-convolver-node'; 4 | 5 | export type TNativeConvolverNodeFactory = (nativeContext: TNativeContext, options: IConvolverOptions) => TNativeConvolverNode; 6 | -------------------------------------------------------------------------------- /src/types/native-convolver-node.ts: -------------------------------------------------------------------------------- 1 | export type TNativeConvolverNode = ConvolverNode; 2 | -------------------------------------------------------------------------------- /src/types/native-delay-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { IDelayOptions } from '../interfaces'; 2 | import { TNativeContext } from './native-context'; 3 | import { TNativeDelayNode } from './native-delay-node'; 4 | 5 | export type TNativeDelayNodeFactory = (nativeContext: TNativeContext, options: IDelayOptions) => TNativeDelayNode; 6 | -------------------------------------------------------------------------------- /src/types/native-delay-node.ts: -------------------------------------------------------------------------------- 1 | export type TNativeDelayNode = DelayNode; 2 | -------------------------------------------------------------------------------- /src/types/native-dynamics-compressor-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { IDynamicsCompressorOptions } from '../interfaces'; 2 | import { TNativeContext } from './native-context'; 3 | import { TNativeDynamicsCompressorNode } from './native-dynamics-compressor-node'; 4 | 5 | export type TNativeDynamicsCompressorNodeFactory = ( 6 | nativeContext: TNativeContext, 7 | options: IDynamicsCompressorOptions 8 | ) => TNativeDynamicsCompressorNode; 9 | -------------------------------------------------------------------------------- /src/types/native-dynamics-compressor-node.ts: -------------------------------------------------------------------------------- 1 | export type TNativeDynamicsCompressorNode = DynamicsCompressorNode; 2 | -------------------------------------------------------------------------------- /src/types/native-event-target.ts: -------------------------------------------------------------------------------- 1 | export type TNativeEventTarget = EventTarget; 2 | -------------------------------------------------------------------------------- /src/types/native-gain-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { IGainOptions } from '../interfaces'; 2 | import { TNativeContext } from './native-context'; 3 | import { TNativeGainNode } from './native-gain-node'; 4 | 5 | export type TNativeGainNodeFactory = (nativeContext: TNativeContext, options: IGainOptions) => TNativeGainNode; 6 | -------------------------------------------------------------------------------- /src/types/native-gain-node.ts: -------------------------------------------------------------------------------- 1 | export type TNativeGainNode = GainNode; 2 | -------------------------------------------------------------------------------- /src/types/native-iir-filter-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { IIIRFilterOptions } from '../interfaces'; 2 | import { TNativeContext } from './native-context'; 3 | import { TNativeIIRFilterNode } from './native-iir-filter-node'; 4 | 5 | export type TNativeIIRFilterNodeFactory = (nativeContext: TNativeContext, options: IIIRFilterOptions) => TNativeIIRFilterNode; 6 | -------------------------------------------------------------------------------- /src/types/native-iir-filter-node.ts: -------------------------------------------------------------------------------- 1 | export type TNativeIIRFilterNode = IIRFilterNode; 2 | -------------------------------------------------------------------------------- /src/types/native-media-element-audio-source-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { IMediaElementAudioSourceOptions } from '../interfaces'; 2 | import { TNativeAudioContext } from './native-audio-context'; 3 | import { TNativeMediaElementAudioSourceNode } from './native-media-element-audio-source-node'; 4 | 5 | export type TNativeMediaElementAudioSourceNodeFactory = ( 6 | nativeAudioContext: TNativeAudioContext, 7 | options: IMediaElementAudioSourceOptions 8 | ) => TNativeMediaElementAudioSourceNode; 9 | -------------------------------------------------------------------------------- /src/types/native-media-element-audio-source-node.ts: -------------------------------------------------------------------------------- 1 | export type TNativeMediaElementAudioSourceNode = MediaElementAudioSourceNode; 2 | -------------------------------------------------------------------------------- /src/types/native-media-stream-audio-destination-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNodeOptions } from '../interfaces'; 2 | import { TNativeAudioContext } from './native-audio-context'; 3 | import { TNativeMediaStreamAudioDestinationNode } from './native-media-stream-audio-destination-node'; 4 | 5 | export type TNativeMediaStreamAudioDestinationNodeFactory = ( 6 | nativeAudioContext: TNativeAudioContext, 7 | options: IAudioNodeOptions 8 | ) => TNativeMediaStreamAudioDestinationNode; 9 | -------------------------------------------------------------------------------- /src/types/native-media-stream-audio-destination-node.ts: -------------------------------------------------------------------------------- 1 | export type TNativeMediaStreamAudioDestinationNode = MediaStreamAudioDestinationNode; 2 | -------------------------------------------------------------------------------- /src/types/native-media-stream-audio-source-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { IMediaStreamAudioSourceOptions } from '../interfaces'; 2 | import { TNativeAudioContext } from './native-audio-context'; 3 | import { TNativeMediaStreamAudioSourceNode } from './native-media-stream-audio-source-node'; 4 | 5 | export type TNativeMediaStreamAudioSourceNodeFactory = ( 6 | nativeAudioContext: TNativeAudioContext, 7 | options: IMediaStreamAudioSourceOptions 8 | ) => TNativeMediaStreamAudioSourceNode; 9 | -------------------------------------------------------------------------------- /src/types/native-media-stream-audio-source-node.ts: -------------------------------------------------------------------------------- 1 | export type TNativeMediaStreamAudioSourceNode = MediaStreamAudioSourceNode; 2 | -------------------------------------------------------------------------------- /src/types/native-media-stream-track-audio-source-node-factory-factory.ts: -------------------------------------------------------------------------------- 1 | import { TInvalidStateErrorFactory } from './invalid-state-error-factory'; 2 | import { TNativeMediaStreamTrackAudioSourceNodeFactory } from './native-media-stream-track-audio-source-node-factory'; 3 | 4 | export type TNativeMediaStreamTrackAudioSourceNodeFactoryFactory = ( 5 | createInvalidStateError: TInvalidStateErrorFactory 6 | ) => TNativeMediaStreamTrackAudioSourceNodeFactory; 7 | -------------------------------------------------------------------------------- /src/types/native-media-stream-track-audio-source-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { IMediaStreamTrackAudioSourceOptions } from '../interfaces'; 2 | import { TNativeAudioContext } from './native-audio-context'; 3 | import { TNativeMediaStreamTrackAudioSourceNode } from './native-media-stream-track-audio-source-node'; 4 | 5 | export type TNativeMediaStreamTrackAudioSourceNodeFactory = ( 6 | nativeAudioContext: TNativeAudioContext, 7 | options: IMediaStreamTrackAudioSourceOptions 8 | ) => TNativeMediaStreamTrackAudioSourceNode; 9 | -------------------------------------------------------------------------------- /src/types/native-media-stream-track-audio-source-node.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioNode } from './native-audio-node'; 2 | 3 | export type TNativeMediaStreamTrackAudioSourceNode = typeof globalThis extends { MediaStreamTrackAudioSourceNode: any } 4 | ? never 5 | : TNativeAudioNode; 6 | -------------------------------------------------------------------------------- /src/types/native-offline-audio-context-constructor-factory.ts: -------------------------------------------------------------------------------- 1 | import { TNativeOfflineAudioContextConstructor } from './native-offline-audio-context-constructor'; 2 | import { TWindow } from './window'; 3 | 4 | export type TNativeOfflineAudioContextConstructorFactory = (window: null | TWindow) => null | TNativeOfflineAudioContextConstructor; 5 | -------------------------------------------------------------------------------- /src/types/native-offline-audio-context-constructor.ts: -------------------------------------------------------------------------------- 1 | export type TNativeOfflineAudioContextConstructor = typeof OfflineAudioContext; 2 | -------------------------------------------------------------------------------- /src/types/native-offline-audio-context.ts: -------------------------------------------------------------------------------- 1 | export type TNativeOfflineAudioContext = OfflineAudioContext; 2 | -------------------------------------------------------------------------------- /src/types/native-oscillator-node-factory-factory.ts: -------------------------------------------------------------------------------- 1 | import { TAddSilentConnectionFunction } from './add-silent-connection-function'; 2 | import { TCacheTestResultFunction } from './cache-test-result-function'; 3 | import { TNativeContext } from './native-context'; 4 | import { TNativeOscillatorNodeFactory } from './native-oscillator-node-factory'; 5 | 6 | export type TNativeOscillatorNodeFactoryFactory = ( 7 | addSilentConnection: TAddSilentConnectionFunction, 8 | cacheTestResult: TCacheTestResultFunction, 9 | testAudioScheduledSourceNodeStopMethodNegativeParametersSupport: (nativeContext: TNativeContext) => boolean 10 | ) => TNativeOscillatorNodeFactory; 11 | -------------------------------------------------------------------------------- /src/types/native-oscillator-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { IOscillatorOptions } from '../interfaces'; 2 | import { TNativeContext } from './native-context'; 3 | import { TNativeOscillatorNode } from './native-oscillator-node'; 4 | 5 | export type TNativeOscillatorNodeFactory = (nativeContext: TNativeContext, options: IOscillatorOptions) => TNativeOscillatorNode; 6 | -------------------------------------------------------------------------------- /src/types/native-oscillator-node.ts: -------------------------------------------------------------------------------- 1 | export type TNativeOscillatorNode = OscillatorNode; 2 | -------------------------------------------------------------------------------- /src/types/native-panner-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { IPannerOptions } from '../interfaces'; 2 | import { TNativeContext } from './native-context'; 3 | import { TNativePannerNode } from './native-panner-node'; 4 | 5 | export type TNativePannerNodeFactory = (nativeContext: TNativeContext, options: IPannerOptions) => TNativePannerNode; 6 | -------------------------------------------------------------------------------- /src/types/native-panner-node.ts: -------------------------------------------------------------------------------- 1 | // @todo This is removing the deprecated functions setOrientation() and setPosition() from the native PannerNode type. 2 | export type TNativePannerNode = Omit; 3 | -------------------------------------------------------------------------------- /src/types/native-periodic-wave-factory.ts: -------------------------------------------------------------------------------- 1 | import { IPeriodicWaveOptions } from '../interfaces'; 2 | import { TNativeContext } from './native-context'; 3 | import { TNativePeriodicWave } from './native-periodic-wave'; 4 | 5 | export type TNativePeriodicWaveFactory = (nativeContext: TNativeContext, options: IPeriodicWaveOptions) => TNativePeriodicWave; 6 | -------------------------------------------------------------------------------- /src/types/native-periodic-wave.ts: -------------------------------------------------------------------------------- 1 | export type TNativePeriodicWave = PeriodicWave; 2 | -------------------------------------------------------------------------------- /src/types/native-script-processor-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { TNativeContext } from './native-context'; 2 | import { TNativeScriptProcessorNode } from './native-script-processor-node'; 3 | 4 | export type TNativeScriptProcessorNodeFactory = ( 5 | nativeContext: TNativeContext, 6 | bufferSize: number, 7 | numberOfInputChannels: number, 8 | numberOfOutputChannels: number 9 | ) => TNativeScriptProcessorNode; 10 | -------------------------------------------------------------------------------- /src/types/native-script-processor-node.ts: -------------------------------------------------------------------------------- 1 | export type TNativeScriptProcessorNode = ScriptProcessorNode; // tslint:disable-line:deprecation 2 | -------------------------------------------------------------------------------- /src/types/native-stereo-panner-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { IStereoPannerOptions } from '../interfaces'; 2 | import { TNativeContext } from './native-context'; 3 | import { TNativeStereoPannerNode } from './native-stereo-panner-node'; 4 | 5 | export type TNativeStereoPannerNodeFactory = (nativeContext: TNativeContext, options: IStereoPannerOptions) => TNativeStereoPannerNode; 6 | -------------------------------------------------------------------------------- /src/types/native-stereo-panner-node.ts: -------------------------------------------------------------------------------- 1 | export type TNativeStereoPannerNode = StereoPannerNode; 2 | -------------------------------------------------------------------------------- /src/types/native-wave-shaper-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { IWaveShaperOptions } from '../interfaces'; 2 | import { TNativeContext } from './native-context'; 3 | import { TNativeWaveShaperNode } from './native-wave-shaper-node'; 4 | 5 | export type TNativeWaveShaperNodeFactory = (nativeContext: TNativeContext, options: IWaveShaperOptions) => TNativeWaveShaperNode; 6 | -------------------------------------------------------------------------------- /src/types/native-wave-shaper-node.ts: -------------------------------------------------------------------------------- 1 | export type TNativeWaveShaperNode = WaveShaperNode; 2 | -------------------------------------------------------------------------------- /src/types/not-supported-error-factory.ts: -------------------------------------------------------------------------------- 1 | export type TNotSupportedErrorFactory = () => DOMException; 2 | -------------------------------------------------------------------------------- /src/types/oscillator-node-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IOscillatorNode, IOscillatorOptions } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TOscillatorNodeConstructor = new (context: T, options?: Partial) => IOscillatorNode; 5 | -------------------------------------------------------------------------------- /src/types/oscillator-type.ts: -------------------------------------------------------------------------------- 1 | export type TOscillatorType = 'custom' | 'sawtooth' | 'sine' | 'square' | 'triangle'; 2 | -------------------------------------------------------------------------------- /src/types/output-connection.ts: -------------------------------------------------------------------------------- 1 | import { TAudioNodeOutputConnection } from './audio-node-output-connection'; 2 | import { TAudioParamOutputConnection } from './audio-param-output-connection'; 3 | import { TContext } from './context'; 4 | 5 | export type TOutputConnection = TAudioNodeOutputConnection | TAudioParamOutputConnection; 6 | -------------------------------------------------------------------------------- /src/types/over-sample-type.ts: -------------------------------------------------------------------------------- 1 | export type TOverSampleType = '2x' | '4x' | 'none'; 2 | -------------------------------------------------------------------------------- /src/types/overwrite-accessors-function.ts: -------------------------------------------------------------------------------- 1 | export type TOverwriteAccessorsFunction = ( 2 | object: object, 3 | property: string, 4 | createGetter: (get: Required['get']) => Required['get'], 5 | createSetter: (get: Required['set']) => Required['set'] 6 | ) => void; 7 | -------------------------------------------------------------------------------- /src/types/panner-node-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IPannerNode, IPannerOptions } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TPannerNodeConstructor = new (context: T, options?: Partial) => IPannerNode; 5 | -------------------------------------------------------------------------------- /src/types/panning-model-type.ts: -------------------------------------------------------------------------------- 1 | export type TPanningModelType = 'HRTF' | 'equalpower'; 2 | -------------------------------------------------------------------------------- /src/types/passive-audio-node-input-connection.ts: -------------------------------------------------------------------------------- 1 | import { TInternalStateEventListener } from './internal-state-event-listener'; 2 | 3 | export type TPassiveAudioNodeInputConnection = [number, number, TInternalStateEventListener]; 4 | -------------------------------------------------------------------------------- /src/types/passive-audio-param-input-connection.ts: -------------------------------------------------------------------------------- 1 | import { TInternalStateEventListener } from './internal-state-event-listener'; 2 | 3 | export type TPassiveAudioParamInputConnection = [number, TInternalStateEventListener]; 4 | -------------------------------------------------------------------------------- /src/types/periodic-wave-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IPeriodicWave, IPeriodicWaveOptions } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TPeriodicWaveConstructor = new (context: T, options?: Partial) => IPeriodicWave; 5 | -------------------------------------------------------------------------------- /src/types/pick-element-from-set-function.ts: -------------------------------------------------------------------------------- 1 | export type TPickElementFromSetFunction = (set: Set, predicate: (element: T) => boolean) => T; 2 | -------------------------------------------------------------------------------- /src/types/render-inputs-of-audio-node-factory.ts: -------------------------------------------------------------------------------- 1 | import { TGetAudioNodeConnectionsFunction } from './get-audio-node-connections-function'; 2 | import { TGetAudioNodeRendererFunction } from './get-audio-node-renderer-function'; 3 | import { TIsPartOfACycleFunction } from './is-part-of-a-cycle-function'; 4 | import { TRenderInputsOfAudioNodeFunction } from './render-inputs-of-audio-node-function'; 5 | 6 | export type TRenderInputsOfAudioNodeFactory = ( 7 | getAudioNodeConnections: TGetAudioNodeConnectionsFunction, 8 | getAudioNodeRenderer: TGetAudioNodeRendererFunction, 9 | isPartOfACycle: TIsPartOfACycleFunction 10 | ) => TRenderInputsOfAudioNodeFunction; 11 | -------------------------------------------------------------------------------- /src/types/render-inputs-of-audio-node-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode, IMinimalOfflineAudioContext, IOfflineAudioContext } from '../interfaces'; 2 | import { TNativeAudioNode } from './native-audio-node'; 3 | import { TNativeOfflineAudioContext } from './native-offline-audio-context'; 4 | 5 | export type TRenderInputsOfAudioNodeFunction = ( 6 | audioNode: IAudioNode, 7 | nativeOfflineAudioContext: TNativeOfflineAudioContext, 8 | nativeAudioNode: TNativeAudioNode 9 | ) => Promise; 10 | -------------------------------------------------------------------------------- /src/types/render-inputs-of-audio-param-factory.ts: -------------------------------------------------------------------------------- 1 | import { TGetAudioNodeRendererFunction } from './get-audio-node-renderer-function'; 2 | import { TGetAudioParamConnectionsFunction } from './get-audio-param-connections-function'; 3 | import { TIsPartOfACycleFunction } from './is-part-of-a-cycle-function'; 4 | import { TRenderInputsOfAudioParamFunction } from './render-inputs-of-audio-param-function'; 5 | 6 | export type TRenderInputsOfAudioParamFactory = ( 7 | getAudioNodeRenderer: TGetAudioNodeRendererFunction, 8 | getAudioParamConnections: TGetAudioParamConnectionsFunction, 9 | isPartOfACycle: TIsPartOfACycleFunction 10 | ) => TRenderInputsOfAudioParamFunction; 11 | -------------------------------------------------------------------------------- /src/types/render-inputs-of-audio-param-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioParam } from '../interfaces'; 2 | import { TNativeAudioParam } from './native-audio-param'; 3 | import { TNativeOfflineAudioContext } from './native-offline-audio-context'; 4 | 5 | export type TRenderInputsOfAudioParamFunction = ( 6 | audioParam: IAudioParam, 7 | nativeOfflineAudioContext: TNativeOfflineAudioContext, 8 | nativeAudioParam: TNativeAudioParam 9 | ) => Promise; 10 | -------------------------------------------------------------------------------- /src/types/sanitize-channel-splitter-options-function.ts: -------------------------------------------------------------------------------- 1 | import { IChannelSplitterOptions } from '../interfaces'; 2 | 3 | export type TSanitizeChannelSplitterOptionsFunction = (options: IChannelSplitterOptions) => IChannelSplitterOptions; 4 | -------------------------------------------------------------------------------- /src/types/sanitize-periodic-wave-options-function.ts: -------------------------------------------------------------------------------- 1 | import { IPeriodicWaveOptions } from '../interfaces'; 2 | 3 | export type TSanitizePeriodicWaveOptionsFunction = ( 4 | options: { disableNormalization: boolean } & Partial 5 | ) => IPeriodicWaveOptions; 6 | -------------------------------------------------------------------------------- /src/types/set-active-audio-worklet-node-inputs-factory.ts: -------------------------------------------------------------------------------- 1 | import { TActiveAudioWorkletNodeInputsStore } from './active-audio-worklet-node-inputs-store'; 2 | import { TSetActiveAudioWorkletNodeInputsFunction } from './set-active-audio-worklet-node-inputs-function'; 3 | 4 | export type TSetActiveAudioWorkletNodeInputsFactory = ( 5 | activeAudioWorkletNodeInputsStore: TActiveAudioWorkletNodeInputsStore 6 | ) => TSetActiveAudioWorkletNodeInputsFunction; 7 | -------------------------------------------------------------------------------- /src/types/set-active-audio-worklet-node-inputs-function.ts: -------------------------------------------------------------------------------- 1 | import { TActiveInputConnection } from './active-input-connection'; 2 | import { TContext } from './context'; 3 | import { TNativeAudioWorkletNode } from './native-audio-worklet-node'; 4 | 5 | export type TSetActiveAudioWorkletNodeInputsFunction = ( 6 | nativeAudioWorkletNode: TNativeAudioWorkletNode, 7 | activeInputs: Set>[] 8 | ) => void; 9 | -------------------------------------------------------------------------------- /src/types/set-audio-node-tail-time-factory.ts: -------------------------------------------------------------------------------- 1 | import { TAudioNodeTailTimeStore } from './audio-node-tail-time-store'; 2 | import { TSetAudioNodeTailTimeFunction } from './set-audio-node-tail-time-function'; 3 | 4 | export type TSetAudioNodeTailTimeFactory = (audioNodeTailTimeStore: TAudioNodeTailTimeStore) => TSetAudioNodeTailTimeFunction; 5 | -------------------------------------------------------------------------------- /src/types/set-audio-node-tail-time-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioNode } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TSetAudioNodeTailTimeFunction = (audioNode: IAudioNode, tailTime: number) => void; 5 | -------------------------------------------------------------------------------- /src/types/start-rendering-factory.ts: -------------------------------------------------------------------------------- 1 | import { TAudioBufferStore } from './audio-buffer-store'; 2 | import { TGetAudioNodeRendererFunction } from './get-audio-node-renderer-function'; 3 | import { TGetUnrenderedAudioWorkletNodesFunction } from './get-unrendered-audio-worklet-nodes-function'; 4 | import { TStartRenderingFunction } from './start-rendering-function'; 5 | 6 | export type TStartRenderingFactory = ( 7 | audioBufferStore: TAudioBufferStore, 8 | getAudioNodeRenderer: TGetAudioNodeRendererFunction, 9 | getUnrenderedAudioWorkletNodes: TGetUnrenderedAudioWorkletNodesFunction 10 | ) => TStartRenderingFunction; 11 | -------------------------------------------------------------------------------- /src/types/start-rendering-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioDestinationNode, IMinimalOfflineAudioContext, IOfflineAudioContext } from '../interfaces'; 2 | import { TNativeAudioBuffer } from './native-audio-buffer'; 3 | import { TNativeOfflineAudioContext } from './native-offline-audio-context'; 4 | 5 | export type TStartRenderingFunction = ( 6 | destination: IAudioDestinationNode, 7 | nativeOfflineAudioContext: TNativeOfflineAudioContext 8 | ) => Promise; 9 | -------------------------------------------------------------------------------- /src/types/stereo-panner-node-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IStereoPannerNode, IStereoPannerOptions } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TStereoPannerNodeConstructor = new ( 5 | context: T, 6 | options?: Partial 7 | ) => IStereoPannerNode; 8 | -------------------------------------------------------------------------------- /src/types/test-audio-buffer-constructor-support-factory.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioBufferConstructor } from './native-audio-buffer-constructor'; 2 | 3 | export type TTestAudioBufferConstructorSupportFactory = ( 4 | nativeAudioBufferConstructor: null | TNativeAudioBufferConstructor 5 | ) => () => boolean; 6 | -------------------------------------------------------------------------------- /src/types/test-audio-buffer-copy-channel-methods-subarray-support-factory.ts: -------------------------------------------------------------------------------- 1 | import { TNativeOfflineAudioContextConstructor } from './native-offline-audio-context-constructor'; 2 | 3 | export type TTestAudioBufferCopyChannelMethodsSubarraySupportFactory = ( 4 | nativeOfflineAudioContextConstructor: null | TNativeOfflineAudioContextConstructor 5 | ) => () => boolean; 6 | -------------------------------------------------------------------------------- /src/types/test-audio-context-close-method-support-factory.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioContextConstructor } from './native-audio-context-constructor'; 2 | 3 | export type TTestAudioContextCloseMethodSupportFactory = ( 4 | nativeAudioContextConstructor: null | TNativeAudioContextConstructor 5 | ) => () => boolean; 6 | -------------------------------------------------------------------------------- /src/types/test-audio-context-decode-audio-data-method-type-error-support-factory.ts: -------------------------------------------------------------------------------- 1 | import { TNativeOfflineAudioContextConstructor } from './native-offline-audio-context-constructor'; 2 | 3 | export type TTestAudioContextDecodeAudioDataMethodTypeErrorSupportFactory = ( 4 | nativeOfflineAudioContextConstructor: null | TNativeOfflineAudioContextConstructor 5 | ) => () => Promise; 6 | -------------------------------------------------------------------------------- /src/types/test-audio-context-options-support-factory.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioContextConstructor } from './native-audio-context-constructor'; 2 | 3 | export type TTestAudioContextOptionsSupportFactory = ( 4 | nativeAudioContextConstructor: null | TNativeAudioContextConstructor 5 | ) => () => boolean; 6 | -------------------------------------------------------------------------------- /src/types/test-audio-worklet-node-options-clonability-function.ts: -------------------------------------------------------------------------------- 1 | import { IAudioWorkletNodeOptions } from '../interfaces'; 2 | 3 | export type TTestAudioWorkletNodeOptionsClonabilityFunction = ( 4 | audioWorkletNodeOptions: Omit & 5 | Partial> 6 | ) => void; 7 | -------------------------------------------------------------------------------- /src/types/test-audio-worklet-processor-no-outputs-support-factory.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioWorkletNodeConstructor } from './native-audio-worklet-node-constructor'; 2 | import { TNativeOfflineAudioContextConstructor } from './native-offline-audio-context-constructor'; 3 | 4 | export type TTestAudioWorkletProcessorNoOutputsSupportFactory = ( 5 | nativeAudioWorkletNodeConstructor: null | TNativeAudioWorkletNodeConstructor, 6 | nativeOfflineAudioContextConstructor: null | TNativeOfflineAudioContextConstructor 7 | ) => () => Promise; 8 | -------------------------------------------------------------------------------- /src/types/test-audio-worklet-processor-post-message-support-factory.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioWorkletNodeConstructor } from './native-audio-worklet-node-constructor'; 2 | import { TNativeOfflineAudioContextConstructor } from './native-offline-audio-context-constructor'; 3 | 4 | export type TTestAudioWorkletProcessorPostMessageSupportFactory = ( 5 | nativeAudioWorkletNodeConstructor: null | TNativeAudioWorkletNodeConstructor, 6 | nativeOfflineAudioContextConstructor: null | TNativeOfflineAudioContextConstructor 7 | ) => () => Promise; 8 | -------------------------------------------------------------------------------- /src/types/test-channel-merger-node-channel-count-support-factory.ts: -------------------------------------------------------------------------------- 1 | import { TNativeOfflineAudioContextConstructor } from './native-offline-audio-context-constructor'; 2 | 3 | export type TTestChannelMergerNodeChannelCountSupportFactory = ( 4 | nativeOfflineAudioContextConstructor: null | TNativeOfflineAudioContextConstructor 5 | ) => () => boolean; 6 | -------------------------------------------------------------------------------- /src/types/test-constant-source-node-accurate-scheduling-support-factory.ts: -------------------------------------------------------------------------------- 1 | import { TNativeOfflineAudioContextConstructor } from './native-offline-audio-context-constructor'; 2 | 3 | export type TTestConstantSourceNodeAccurateSchedulingSupportFactory = ( 4 | nativeOfflineAudioContextConstructor: null | TNativeOfflineAudioContextConstructor 5 | ) => () => boolean; 6 | -------------------------------------------------------------------------------- /src/types/test-convolver-node-buffer-reassignability-support-factory.ts: -------------------------------------------------------------------------------- 1 | import { TNativeOfflineAudioContextConstructor } from './native-offline-audio-context-constructor'; 2 | 3 | export type TTestConvolverNodeBufferReassignabilitySupportFactory = ( 4 | nativeOfflineAudioContextConstructor: null | TNativeOfflineAudioContextConstructor 5 | ) => () => boolean; 6 | -------------------------------------------------------------------------------- /src/types/test-convolver-node-channel-count-support-factory.ts: -------------------------------------------------------------------------------- 1 | import { TNativeOfflineAudioContextConstructor } from './native-offline-audio-context-constructor'; 2 | 3 | export type TTestConvolverNodeChannelCountSupportFactory = ( 4 | nativeOfflineAudioContextConstructor: null | TNativeOfflineAudioContextConstructor 5 | ) => () => boolean; 6 | -------------------------------------------------------------------------------- /src/types/test-is-secure-context-support-factory.ts: -------------------------------------------------------------------------------- 1 | import { TWindow } from './window'; 2 | 3 | export type TTestIsSecureContextSupportFactory = (window: null | TWindow) => () => boolean; 4 | -------------------------------------------------------------------------------- /src/types/test-media-stream-audio-source-node-media-stream-without-audio-track-support.ts: -------------------------------------------------------------------------------- 1 | import { TNativeAudioContextConstructor } from './native-audio-context-constructor'; 2 | 3 | export type TTestMediaStreamAudioSourceNodeMediaStreamWithoutAudioTrackSupportFactory = ( 4 | nativeAudioContextConstructor: null | TNativeAudioContextConstructor 5 | ) => () => boolean; 6 | -------------------------------------------------------------------------------- /src/types/test-stereo-panner-node-default-value-support-factory.ts: -------------------------------------------------------------------------------- 1 | import { TNativeOfflineAudioContextConstructor } from './native-offline-audio-context-constructor'; 2 | 3 | export type TTestStereoPannerNodeDefaultValueSupportFactory = ( 4 | nativeOfflineAudioContextConstructor: null | TNativeOfflineAudioContextConstructor 5 | ) => () => Promise; 6 | -------------------------------------------------------------------------------- /src/types/unrendered-audio-worklet-node-store.ts: -------------------------------------------------------------------------------- 1 | import { TNativeContext } from './native-context'; 2 | import { TUnrenderedAudioWorkletNodes } from './unrendered-audio-worklet-nodes'; 3 | 4 | export type TUnrenderedAudioWorkletNodeStore = WeakMap; 5 | -------------------------------------------------------------------------------- /src/types/unrendered-audio-worklet-nodes.ts: -------------------------------------------------------------------------------- 1 | import { IAudioWorkletNode, IMinimalOfflineAudioContext, IOfflineAudioContext } from '../interfaces'; 2 | 3 | export type TUnrenderedAudioWorkletNodes = Set>; 4 | -------------------------------------------------------------------------------- /src/types/wave-shaper-node-constructor.ts: -------------------------------------------------------------------------------- 1 | import { IWaveShaperNode, IWaveShaperOptions } from '../interfaces'; 2 | import { TContext } from './context'; 3 | 4 | export type TWaveShaperNodeConstructor = new (context: T, options?: Partial) => IWaveShaperNode; 5 | -------------------------------------------------------------------------------- /src/types/window-factory.ts: -------------------------------------------------------------------------------- 1 | import { TWindow } from './window'; 2 | 3 | export type TWindowFactory = () => null | TWindow; 4 | -------------------------------------------------------------------------------- /src/types/window.ts: -------------------------------------------------------------------------------- 1 | export type TWindow = Window & typeof globalThis; 2 | -------------------------------------------------------------------------------- /src/types/with-additional-property.ts: -------------------------------------------------------------------------------- 1 | export type TWithAdditionalProperty = 2 | BaseType extends Record ? never : BaseType & Record; 3 | -------------------------------------------------------------------------------- /src/types/wrap-event-listener-function.ts: -------------------------------------------------------------------------------- 1 | export type TWrapEventListenerFunction = (target: T, eventListener: EventListenerOrEventListenerObject) => EventListener; 2 | -------------------------------------------------------------------------------- /test/expectation/chrome/canary/audio-buffer-source-node.js: -------------------------------------------------------------------------------- 1 | describe('AudioBufferSourceNode', () => { 2 | let audioContext; 3 | 4 | afterEach(() => audioContext.close()); 5 | 6 | beforeEach(() => (audioContext = new AudioContext())); 7 | 8 | describe('detune', () => { 9 | describe('defaultValue', () => { 10 | // bug #196 11 | 12 | it('should not reflect the initial value', () => { 13 | const audioBufferSourceNode = new AudioBufferSourceNode(audioContext, { detune: 3 }); 14 | 15 | expect(audioBufferSourceNode.detune.defaultValue).to.equal(0); 16 | }); 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /test/expectation/chrome/current/audio-buffer-source-node.js: -------------------------------------------------------------------------------- 1 | describe('AudioBufferSourceNode', () => { 2 | let audioContext; 3 | 4 | afterEach(() => audioContext.close()); 5 | 6 | beforeEach(() => (audioContext = new AudioContext())); 7 | 8 | describe('detune', () => { 9 | describe('defaultValue', () => { 10 | // bug #196 11 | 12 | it('should not reflect the initial value', () => { 13 | const audioBufferSourceNode = new AudioBufferSourceNode(audioContext, { detune: 3 }); 14 | 15 | expect(audioBufferSourceNode.detune.defaultValue).to.equal(0); 16 | }); 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /test/expectation/chrome/penultimate/audio-buffer-source-node.js: -------------------------------------------------------------------------------- 1 | describe('AudioBufferSourceNode', () => { 2 | let audioContext; 3 | 4 | afterEach(() => audioContext.close()); 5 | 6 | beforeEach(() => (audioContext = new AudioContext())); 7 | 8 | describe('detune', () => { 9 | describe('defaultValue', () => { 10 | // bug #196 11 | 12 | it('should not reflect the initial value', () => { 13 | const audioBufferSourceNode = new AudioBufferSourceNode(audioContext, { detune: 3 }); 14 | 15 | expect(audioBufferSourceNode.detune.defaultValue).to.equal(0); 16 | }); 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /test/expectation/chrome/previous/audio-buffer-source-node.js: -------------------------------------------------------------------------------- 1 | describe('AudioBufferSourceNode', () => { 2 | let audioContext; 3 | 4 | afterEach(() => audioContext.close()); 5 | 6 | beforeEach(() => (audioContext = new AudioContext())); 7 | 8 | describe('detune', () => { 9 | describe('defaultValue', () => { 10 | // bug #196 11 | 12 | it('should not reflect the initial value', () => { 13 | const audioBufferSourceNode = new AudioBufferSourceNode(audioContext, { detune: 3 }); 14 | 15 | expect(audioBufferSourceNode.detune.defaultValue).to.equal(0); 16 | }); 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /test/expectation/firefox/current/audio-buffer-source-node.js: -------------------------------------------------------------------------------- 1 | describe('AudioBufferSourceNode', () => { 2 | let audioContext; 3 | 4 | afterEach(() => audioContext.close()); 5 | 6 | beforeEach(() => (audioContext = new AudioContext())); 7 | 8 | describe('detune', () => { 9 | describe('defaultValue', () => { 10 | // bug #196 11 | 12 | it('should not reflect the initial value', () => { 13 | const audioBufferSourceNode = new AudioBufferSourceNode(audioContext, { detune: 3 }); 14 | 15 | expect(audioBufferSourceNode.detune.defaultValue).to.equal(0); 16 | }); 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /test/expectation/firefox/current/audio-element.js: -------------------------------------------------------------------------------- 1 | describe('AudioElement', () => { 2 | let audioElement; 3 | 4 | beforeEach(() => { 5 | audioElement = new Audio(); 6 | }); 7 | 8 | describe('captureStream()', () => { 9 | // bug #65 10 | 11 | it('should not be implemented', () => { 12 | expect(audioElement.captureStream).to.be.undefined; 13 | }); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /test/expectation/firefox/current/media-stream-track-generator.js: -------------------------------------------------------------------------------- 1 | describe('MediaStreamTrackGenerator', () => { 2 | // bug #209 3 | 4 | it('should not be implemented', () => { 5 | expect(typeof MediaStreamTrackGenerator).to.equal('undefined'); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /test/expectation/firefox/developer/audio-buffer-source-node.js: -------------------------------------------------------------------------------- 1 | describe('AudioBufferSourceNode', () => { 2 | let audioContext; 3 | 4 | afterEach(() => audioContext.close()); 5 | 6 | beforeEach(() => (audioContext = new AudioContext())); 7 | 8 | describe('detune', () => { 9 | describe('defaultValue', () => { 10 | // bug #196 11 | 12 | it('should not reflect the initial value', () => { 13 | const audioBufferSourceNode = new AudioBufferSourceNode(audioContext, { detune: 3 }); 14 | 15 | expect(audioBufferSourceNode.detune.defaultValue).to.equal(0); 16 | }); 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /test/expectation/firefox/developer/audio-element.js: -------------------------------------------------------------------------------- 1 | describe('AudioElement', () => { 2 | let audioElement; 3 | 4 | beforeEach(() => { 5 | audioElement = new Audio(); 6 | }); 7 | 8 | describe('captureStream()', () => { 9 | // bug #65 10 | 11 | it('should not be implemented', () => { 12 | expect(audioElement.captureStream).to.be.undefined; 13 | }); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /test/expectation/firefox/developer/media-stream-track-generator.js: -------------------------------------------------------------------------------- 1 | describe('MediaStreamTrackGenerator', () => { 2 | // bug #209 3 | 4 | it('should not be implemented', () => { 5 | expect(typeof MediaStreamTrackGenerator).to.equal('undefined'); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /test/expectation/firefox/penultimate/audio-buffer-source-node.js: -------------------------------------------------------------------------------- 1 | describe('AudioBufferSourceNode', () => { 2 | let audioContext; 3 | 4 | afterEach(() => audioContext.close()); 5 | 6 | beforeEach(() => (audioContext = new AudioContext())); 7 | 8 | describe('detune', () => { 9 | describe('defaultValue', () => { 10 | // bug #196 11 | 12 | it('should not reflect the initial value', () => { 13 | const audioBufferSourceNode = new AudioBufferSourceNode(audioContext, { detune: 3 }); 14 | 15 | expect(audioBufferSourceNode.detune.defaultValue).to.equal(0); 16 | }); 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /test/expectation/firefox/penultimate/audio-element.js: -------------------------------------------------------------------------------- 1 | describe('AudioElement', () => { 2 | let audioElement; 3 | 4 | beforeEach(() => { 5 | audioElement = new Audio(); 6 | }); 7 | 8 | describe('captureStream()', () => { 9 | // bug #65 10 | 11 | it('should not be implemented', () => { 12 | expect(audioElement.captureStream).to.be.undefined; 13 | }); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /test/expectation/firefox/penultimate/media-stream-track-generator.js: -------------------------------------------------------------------------------- 1 | describe('MediaStreamTrackGenerator', () => { 2 | // bug #209 3 | 4 | it('should not be implemented', () => { 5 | expect(typeof MediaStreamTrackGenerator).to.equal('undefined'); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /test/expectation/firefox/previous/audio-buffer-source-node.js: -------------------------------------------------------------------------------- 1 | describe('AudioBufferSourceNode', () => { 2 | let audioContext; 3 | 4 | afterEach(() => audioContext.close()); 5 | 6 | beforeEach(() => (audioContext = new AudioContext())); 7 | 8 | describe('detune', () => { 9 | describe('defaultValue', () => { 10 | // bug #196 11 | 12 | it('should not reflect the initial value', () => { 13 | const audioBufferSourceNode = new AudioBufferSourceNode(audioContext, { detune: 3 }); 14 | 15 | expect(audioBufferSourceNode.detune.defaultValue).to.equal(0); 16 | }); 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /test/expectation/firefox/previous/audio-element.js: -------------------------------------------------------------------------------- 1 | describe('AudioElement', () => { 2 | let audioElement; 3 | 4 | beforeEach(() => { 5 | audioElement = new Audio(); 6 | }); 7 | 8 | describe('captureStream()', () => { 9 | // bug #65 10 | 11 | it('should not be implemented', () => { 12 | expect(audioElement.captureStream).to.be.undefined; 13 | }); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /test/expectation/firefox/previous/media-stream-track-generator.js: -------------------------------------------------------------------------------- 1 | describe('MediaStreamTrackGenerator', () => { 2 | // bug #209 3 | 4 | it('should not be implemented', () => { 5 | expect(typeof MediaStreamTrackGenerator).to.equal('undefined'); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /test/expectation/safari/current/audio-element.js: -------------------------------------------------------------------------------- 1 | describe('AudioElement', () => { 2 | let audioElement; 3 | 4 | beforeEach(() => { 5 | audioElement = new Audio(); 6 | }); 7 | 8 | describe('captureStream()', () => { 9 | // bug #65 10 | 11 | it('should not be implemented', () => { 12 | expect(audioElement.captureStream).to.be.undefined; 13 | }); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /test/expectation/safari/current/media-stream-track-generator.js: -------------------------------------------------------------------------------- 1 | describe('MediaStreamTrackGenerator', () => { 2 | // bug #209 3 | 4 | it('should not be implemented', () => { 5 | expect(typeof MediaStreamTrackGenerator).to.equal('undefined'); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /test/expectation/safari/penultimate/audio-element.js: -------------------------------------------------------------------------------- 1 | describe('AudioElement', () => { 2 | let audioElement; 3 | 4 | beforeEach(() => { 5 | audioElement = new Audio(); 6 | }); 7 | 8 | describe('captureStream()', () => { 9 | // bug #65 10 | 11 | it('should not be implemented', () => { 12 | expect(audioElement.captureStream).to.be.undefined; 13 | }); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /test/expectation/safari/penultimate/media-stream-track-generator.js: -------------------------------------------------------------------------------- 1 | describe('MediaStreamTrackGenerator', () => { 2 | // bug #209 3 | 4 | it('should not be implemented', () => { 5 | expect(typeof MediaStreamTrackGenerator).to.equal('undefined'); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /test/expectation/safari/previous/audio-element.js: -------------------------------------------------------------------------------- 1 | describe('AudioElement', () => { 2 | let audioElement; 3 | 4 | beforeEach(() => { 5 | audioElement = new Audio(); 6 | }); 7 | 8 | describe('captureStream()', () => { 9 | // bug #65 10 | 11 | it('should not be implemented', () => { 12 | expect(audioElement.captureStream).to.be.undefined; 13 | }); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /test/expectation/safari/previous/media-stream-track-generator.js: -------------------------------------------------------------------------------- 1 | describe('MediaStreamTrackGenerator', () => { 2 | // bug #209 3 | 4 | it('should not be implemented', () => { 5 | expect(typeof MediaStreamTrackGenerator).to.equal('undefined'); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /test/fixtures/1000-frames-of-noise-mono.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisguttandin/standardized-audio-context/3efd17925abcb3f7a47676da5576e887cc9e70e1/test/fixtures/1000-frames-of-noise-mono.wav -------------------------------------------------------------------------------- /test/fixtures/1000-frames-of-noise-stereo.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisguttandin/standardized-audio-context/3efd17925abcb3f7a47676da5576e887cc9e70e1/test/fixtures/1000-frames-of-noise-stereo.wav -------------------------------------------------------------------------------- /test/fixtures/1000-hertz-for-ten-seconds.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisguttandin/standardized-audio-context/3efd17925abcb3f7a47676da5576e887cc9e70e1/test/fixtures/1000-hertz-for-ten-seconds.wav -------------------------------------------------------------------------------- /test/fixtures/constant.js: -------------------------------------------------------------------------------- 1 | export const constant = 2; 2 | -------------------------------------------------------------------------------- /test/fixtures/dependent-processor.js: -------------------------------------------------------------------------------- 1 | class DependentProcessor extends AudioWorkletProcessor { 2 | constructor() { 3 | super(); 4 | 5 | this.port.onmessage = () => { 6 | const typeOfLibrary = typeof library; 7 | 8 | this.port.postMessage({ typeOfLibrary }); 9 | }; 10 | } 11 | 12 | // eslint-disable-next-line class-methods-use-this 13 | process() { 14 | return true; 15 | } 16 | } 17 | 18 | registerProcessor('dependent-processor', DependentProcessor); 19 | -------------------------------------------------------------------------------- /test/fixtures/duplicate-gain-processor.js: -------------------------------------------------------------------------------- 1 | class GainProcessor extends AudioWorkletProcessor { 2 | constructor() { 3 | super(); 4 | } 5 | 6 | // eslint-disable-next-line class-methods-use-this 7 | process() { 8 | return true; 9 | } 10 | } 11 | 12 | registerProcessor('gain-processor', GainProcessor); 13 | -------------------------------------------------------------------------------- /test/fixtures/empty-string-processor.js: -------------------------------------------------------------------------------- 1 | class EmptyStringProcessor extends AudioWorkletProcessor { 2 | constructor() { 3 | super(); 4 | } 5 | 6 | // eslint-disable-next-line class-methods-use-this 7 | process() { 8 | return true; 9 | } 10 | } 11 | 12 | registerProcessor('', EmptyStringProcessor); 13 | -------------------------------------------------------------------------------- /test/fixtures/failing-processor.js: -------------------------------------------------------------------------------- 1 | class FailingProcessor extends AudioWorkletProcessor { 2 | constructor() { 3 | super(); 4 | } 5 | 6 | // eslint-disable-next-line class-methods-use-this 7 | process() { 8 | throw new Error('This is an error thrown inside the process() method.'); 9 | 10 | return true; 11 | } 12 | } 13 | 14 | registerProcessor('failing-processor', FailingProcessor); 15 | -------------------------------------------------------------------------------- /test/fixtures/gibberish-processor.js: -------------------------------------------------------------------------------- 1 | import { constant } from './constant.js'; 2 | 3 | class GibberishProcessor extends AudioWorkletProcessor { 4 | // eslint-disable-next-line class-methods-use-this 5 | process(inputs, outputs) { 6 | const output = outputs[0]; 7 | const length = outputs[0][0].length; 8 | 9 | for (let i = 0; i < length; i += 1) { 10 | output[0][i] = -1 + Math.random() * constant; 11 | output[1][i] = -1 + Math.random() * constant; 12 | } 13 | 14 | return true; 15 | } 16 | } 17 | 18 | registerProcessor('gibberish-processor', GibberishProcessor); 19 | -------------------------------------------------------------------------------- /test/fixtures/invalid-parameter-descriptors-property-processor.js: -------------------------------------------------------------------------------- 1 | class InvalidParameterDescriptorsPropertyProcessor extends AudioWorkletProcessor { 2 | constructor() { 3 | super(); 4 | } 5 | 6 | // eslint-disable-next-line class-methods-use-this 7 | process() { 8 | return true; 9 | } 10 | } 11 | 12 | InvalidParameterDescriptorsPropertyProcessor.parameterDescriptors = null; 13 | 14 | registerProcessor('invalid-parameter-descriptors-property-processor', InvalidParameterDescriptorsPropertyProcessor); 15 | -------------------------------------------------------------------------------- /test/fixtures/library.js: -------------------------------------------------------------------------------- 1 | const library = 'a fake library'; // eslint-disable-line no-unused-vars 2 | -------------------------------------------------------------------------------- /test/fixtures/one-pixel-of-transparency.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisguttandin/standardized-audio-context/3efd17925abcb3f7a47676da5576e887cc9e70e1/test/fixtures/one-pixel-of-transparency.png -------------------------------------------------------------------------------- /test/fixtures/processless-processor.js: -------------------------------------------------------------------------------- 1 | function ProcesslessProcessor() {} 2 | 3 | registerProcessor('processless-processor', ProcesslessProcessor); 4 | -------------------------------------------------------------------------------- /test/fixtures/prototypeless-processor.js: -------------------------------------------------------------------------------- 1 | function PrototypelessProcessor() {} 2 | 3 | PrototypelessProcessor.prototype = null; 4 | 5 | registerProcessor('prototypeless-processor', PrototypelessProcessor); 6 | -------------------------------------------------------------------------------- /test/fixtures/transferring-processor.js: -------------------------------------------------------------------------------- 1 | class TransferringProcessor extends AudioWorkletProcessor { 2 | process(inputs, outputs, parameters) { 3 | this.port.postMessage({ inputs, outputs, parameters }, [ 4 | ...inputs.reduce((buffers, input) => [...buffers, ...input.map((channelData) => channelData.buffer)], []), 5 | ...outputs.reduce((buffers, output) => [...buffers, ...output.map((channelData) => channelData.buffer)], []), 6 | ...Array.from(Object.values(parameters)).map((parameter) => parameter.buffer) 7 | ]); 8 | 9 | return true; 10 | } 11 | } 12 | 13 | registerProcessor('transferring-processor', TransferringProcessor); 14 | -------------------------------------------------------------------------------- /test/fixtures/unconstructible-processor.js: -------------------------------------------------------------------------------- 1 | registerProcessor('unconstructible-processor', {}); 2 | -------------------------------------------------------------------------------- /test/fixtures/unparsable-processor.xs: -------------------------------------------------------------------------------- 1 | // @todo The filename is .xs instead of .js to prevent eslint from linting this file. 2 | 3 | class UnparsableProcessor extends AudioWorkletProcessor { 4 | 5 | some 'unparsable' syntax () 6 | 7 | } 8 | 9 | registerProcessor('unparsable-processor', UnparsableProcessor); 10 | -------------------------------------------------------------------------------- /test/helper/create-audio-context.js: -------------------------------------------------------------------------------- 1 | import { AudioContext } from '../../src/module'; 2 | 3 | export const createAudioContext = () => new AudioContext({ latencyHint: 'playback' }); 4 | -------------------------------------------------------------------------------- /test/helper/create-minimal-audio-context.js: -------------------------------------------------------------------------------- 1 | import { MinimalAudioContext } from '../../src/module'; 2 | 3 | export const createMinimalAudioContext = () => new MinimalAudioContext({ latencyHint: 'playback' }); 4 | -------------------------------------------------------------------------------- /test/helper/create-minimal-offline-audio-context.js: -------------------------------------------------------------------------------- 1 | import { MinimalOfflineAudioContext } from '../../src/module'; 2 | 3 | export const createMinimalOfflineAudioContext = (options) => { 4 | const { length } = { length: 5, ...options }; 5 | 6 | return new MinimalOfflineAudioContext({ length, sampleRate: 44100 }); 7 | }; 8 | -------------------------------------------------------------------------------- /test/helper/create-native-audio-context.js: -------------------------------------------------------------------------------- 1 | import { createNativeAudioContextConstructor } from '../../src/factories/native-audio-context-constructor'; 2 | import { createWindow } from '../../src/factories/window'; 3 | 4 | const nativeAudioContextConstructor = createNativeAudioContextConstructor(createWindow()); 5 | 6 | export const createNativeAudioContext = () => new nativeAudioContextConstructor(); // eslint-disable-line new-cap 7 | -------------------------------------------------------------------------------- /test/helper/create-native-offline-audio-context.js: -------------------------------------------------------------------------------- 1 | import { createNativeOfflineAudioContextConstructor } from '../../src/factories/native-offline-audio-context-constructor'; 2 | import { createWindow } from '../../src/factories/window'; 3 | 4 | const nativeOfflineAudioContextConstructor = createNativeOfflineAudioContextConstructor(createWindow()); 5 | 6 | export const createNativeOfflineAudioContext = () => new nativeOfflineAudioContextConstructor(1, 1, 44100); // eslint-disable-line new-cap 7 | -------------------------------------------------------------------------------- /test/helper/create-offline-audio-context.js: -------------------------------------------------------------------------------- 1 | import { OfflineAudioContext } from '../../src/module'; 2 | 3 | export const createOfflineAudioContext = (options) => { 4 | const { length } = { length: 5, ...options }; 5 | 6 | return new OfflineAudioContext({ length, sampleRate: 44100 }); 7 | }; 8 | -------------------------------------------------------------------------------- /test/helper/is-safari.js: -------------------------------------------------------------------------------- 1 | // This is for sure not enough magic to reliably detect Safari but it is sufficient enough for this use case. 2 | export const isSafari = ({ userAgent }) => !/Chrome/.test(userAgent) && /Safari/.test(userAgent); 3 | -------------------------------------------------------------------------------- /test/helper/load-fixture.js: -------------------------------------------------------------------------------- 1 | export const loadFixtureAsArrayBuffer = (fixture) => fetch(`/base/test/fixtures/${fixture}`).then((response) => response.arrayBuffer()); 2 | -------------------------------------------------------------------------------- /test/helper/round-to-samples.js: -------------------------------------------------------------------------------- 1 | export const roundToSamples = (time, sampleRate, samples = 0) => 2 | new Float64Array([(Math.round(time * sampleRate) + samples) / sampleRate])[0]; 3 | -------------------------------------------------------------------------------- /test/integration/is-supported.js: -------------------------------------------------------------------------------- 1 | import { isSupported } from '../../src/module'; 2 | 3 | describe('isSupported', () => { 4 | it(`should resolve to ${typeof window !== 'undefined'}`, async () => { 5 | expect(await isSupported()).to.equal(typeof window !== 'undefined'); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /test/unit/factories/window.js: -------------------------------------------------------------------------------- 1 | import { createWindow } from '../../../src/factories/window'; 2 | 3 | describe('createWindow()', () => { 4 | it('should return the global window', () => { 5 | expect(createWindow()).to.equal(window); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /test/unit/helpers/sanitize-channel-splitter-options.js: -------------------------------------------------------------------------------- 1 | import { sanitizeChannelSplitterOptions } from '../../../src/helpers/sanitize-channel-splitter-options'; 2 | 3 | describe('sanitizeChannelSplitterOptions()', () => { 4 | let numberOfOutputs; 5 | let options; 6 | 7 | beforeEach(() => { 8 | numberOfOutputs = 4; 9 | options = { channelCount: 2, numberOfOutputs }; 10 | }); 11 | 12 | it('should return an object with the channelCount property set to the value of the numberOfOutputs property', () => { 13 | expect(sanitizeChannelSplitterOptions(options)).to.deep.equal({ ...options, channelCount: numberOfOutputs }); 14 | }); 15 | }); 16 | --------------------------------------------------------------------------------