From c8fa520919a24702f80d55de5476ae1f6231cbc4 Mon Sep 17 00:00:00 2001 From: b-ma Date: Mon, 6 Jan 2025 17:32:46 +0100 Subject: [PATCH] chore: use package.json instead of .mjs for examples --- examples/{all-nodes.mjs => all-nodes.js} | 0 ...tude-modulation.mjs => amplitude-modulation.js} | 0 examples/{analyser.mjs => analyser.js} | 0 examples/{audio-buffer.mjs => audio-buffer.js} | 0 ...er.mjs => audio-worklet-shared-array-buffer.js} | 0 ...ebassembly.mjs => audio-worklet-webassembly.js} | 0 examples/{audio-worklet.mjs => audio-worklet.js} | 0 examples/{benchmarks.mjs => benchmarks.js} | 0 examples/{biquad.mjs => biquad.js} | 0 examples/{change-state.mjs => change-state.js} | 0 ...site-audio-node.mjs => composite-audio-node.js} | 14 +++++++++----- examples/{compressor.mjs => compressor.js} | 0 .../{constant-source.mjs => constant-source.js} | 0 examples/{convolution.mjs => convolution.js} | 0 .../{decoding-legacy.mjs => decoding-legacy.js} | 0 examples/{decoding.mjs => decoding.js} | 0 examples/{disconnect.mjs => disconnect.js} | 0 examples/{doppler.mjs => doppler.js} | 0 examples/{ended-event.mjs => ended-event.js} | 0 examples/{feedback-delay.mjs => feedback-delay.js} | 0 examples/{granular-scrub.mjs => granular-scrub.js} | 0 examples/{iir-filter.mjs => iir-filter.js} | 0 ...atency-attributes.mjs => latency-attributes.js} | 0 ...s-with-env.mjs => many-oscillators-with-env.js} | 0 examples/{microphone.mjs => microphone.js} | 0 examples/{multichannel.mjs => multichannel.js} | 0 ...{multiple-contexts.mjs => multiple-contexts.js} | 0 examples/{offline.mjs => offline.js} | 0 examples/{oscillators.mjs => oscillators.js} | 0 examples/package.json | 3 +++ examples/{panner.mjs => panner.js} | 0 examples/{resampling.mjs => resampling.js} | 0 .../{script-processor.mjs => script-processor.js} | 0 examples/{sink-id.mjs => sink-id.js} | 0 examples/{stereo-panner.mjs => stereo-panner.js} | 0 ...rigger-soundfiles.mjs => trigger-soundfiles.js} | 0 examples/{waveshaper.mjs => waveshaper.js} | 0 37 files changed, 12 insertions(+), 5 deletions(-) rename examples/{all-nodes.mjs => all-nodes.js} (100%) rename examples/{amplitude-modulation.mjs => amplitude-modulation.js} (100%) rename examples/{analyser.mjs => analyser.js} (100%) rename examples/{audio-buffer.mjs => audio-buffer.js} (100%) rename examples/{audio-worklet-shared-array-buffer.mjs => audio-worklet-shared-array-buffer.js} (100%) rename examples/{audio-worklet-webassembly.mjs => audio-worklet-webassembly.js} (100%) rename examples/{audio-worklet.mjs => audio-worklet.js} (100%) rename examples/{benchmarks.mjs => benchmarks.js} (100%) rename examples/{biquad.mjs => biquad.js} (100%) rename examples/{change-state.mjs => change-state.js} (100%) rename examples/{composite-audio-node.mjs => composite-audio-node.js} (93%) rename examples/{compressor.mjs => compressor.js} (100%) rename examples/{constant-source.mjs => constant-source.js} (100%) rename examples/{convolution.mjs => convolution.js} (100%) rename examples/{decoding-legacy.mjs => decoding-legacy.js} (100%) rename examples/{decoding.mjs => decoding.js} (100%) rename examples/{disconnect.mjs => disconnect.js} (100%) rename examples/{doppler.mjs => doppler.js} (100%) rename examples/{ended-event.mjs => ended-event.js} (100%) rename examples/{feedback-delay.mjs => feedback-delay.js} (100%) rename examples/{granular-scrub.mjs => granular-scrub.js} (100%) rename examples/{iir-filter.mjs => iir-filter.js} (100%) rename examples/{latency-attributes.mjs => latency-attributes.js} (100%) rename examples/{many-oscillators-with-env.mjs => many-oscillators-with-env.js} (100%) rename examples/{microphone.mjs => microphone.js} (100%) rename examples/{multichannel.mjs => multichannel.js} (100%) rename examples/{multiple-contexts.mjs => multiple-contexts.js} (100%) rename examples/{offline.mjs => offline.js} (100%) rename examples/{oscillators.mjs => oscillators.js} (100%) create mode 100644 examples/package.json rename examples/{panner.mjs => panner.js} (100%) rename examples/{resampling.mjs => resampling.js} (100%) rename examples/{script-processor.mjs => script-processor.js} (100%) rename examples/{sink-id.mjs => sink-id.js} (100%) rename examples/{stereo-panner.mjs => stereo-panner.js} (100%) rename examples/{trigger-soundfiles.mjs => trigger-soundfiles.js} (100%) rename examples/{waveshaper.mjs => waveshaper.js} (100%) diff --git a/examples/all-nodes.mjs b/examples/all-nodes.js similarity index 100% rename from examples/all-nodes.mjs rename to examples/all-nodes.js diff --git a/examples/amplitude-modulation.mjs b/examples/amplitude-modulation.js similarity index 100% rename from examples/amplitude-modulation.mjs rename to examples/amplitude-modulation.js diff --git a/examples/analyser.mjs b/examples/analyser.js similarity index 100% rename from examples/analyser.mjs rename to examples/analyser.js diff --git a/examples/audio-buffer.mjs b/examples/audio-buffer.js similarity index 100% rename from examples/audio-buffer.mjs rename to examples/audio-buffer.js diff --git a/examples/audio-worklet-shared-array-buffer.mjs b/examples/audio-worklet-shared-array-buffer.js similarity index 100% rename from examples/audio-worklet-shared-array-buffer.mjs rename to examples/audio-worklet-shared-array-buffer.js diff --git a/examples/audio-worklet-webassembly.mjs b/examples/audio-worklet-webassembly.js similarity index 100% rename from examples/audio-worklet-webassembly.mjs rename to examples/audio-worklet-webassembly.js diff --git a/examples/audio-worklet.mjs b/examples/audio-worklet.js similarity index 100% rename from examples/audio-worklet.mjs rename to examples/audio-worklet.js diff --git a/examples/benchmarks.mjs b/examples/benchmarks.js similarity index 100% rename from examples/benchmarks.mjs rename to examples/benchmarks.js diff --git a/examples/biquad.mjs b/examples/biquad.js similarity index 100% rename from examples/biquad.mjs rename to examples/biquad.js diff --git a/examples/change-state.mjs b/examples/change-state.js similarity index 100% rename from examples/change-state.mjs rename to examples/change-state.js diff --git a/examples/composite-audio-node.mjs b/examples/composite-audio-node.js similarity index 93% rename from examples/composite-audio-node.mjs rename to examples/composite-audio-node.js index 222f0b4d..52eb0922 100644 --- a/examples/composite-audio-node.mjs +++ b/examples/composite-audio-node.js @@ -1,23 +1,24 @@ +import { sleep } from '@ircam/sc-utils'; import { AudioContext, AudioNode } from '../index.mjs'; // Monkeypatching AudioNode.connect to allow for composite nodes. // https://github.com/GoogleChromeLabs/web-audio-samples/wiki/CompositeAudioNode -class CompositeAudioNode { +class CompositeAudioNode { get _isCompositeAudioNode() { return true; } - + constructor(context) { this.context = context; this._input = this.context.createGain(); this._output = this.context.createGain(); } - + connect() { this._output.connect.apply(this._output, arguments); } - + disconnect() { this._output.disconnect.apply(this._output, arguments); } @@ -32,7 +33,7 @@ AudioNode.prototype.connect = function() { if (args[0]._isCompositeAudioNode) { args[0] = args[0]._input; } - + this._connect.apply(this, args); }; @@ -65,3 +66,6 @@ gainNode.connect(context.destination); oscNode.start(); oscNode.stop(1.0); + +await sleep(1.5); +await context.close(); diff --git a/examples/compressor.mjs b/examples/compressor.js similarity index 100% rename from examples/compressor.mjs rename to examples/compressor.js diff --git a/examples/constant-source.mjs b/examples/constant-source.js similarity index 100% rename from examples/constant-source.mjs rename to examples/constant-source.js diff --git a/examples/convolution.mjs b/examples/convolution.js similarity index 100% rename from examples/convolution.mjs rename to examples/convolution.js diff --git a/examples/decoding-legacy.mjs b/examples/decoding-legacy.js similarity index 100% rename from examples/decoding-legacy.mjs rename to examples/decoding-legacy.js diff --git a/examples/decoding.mjs b/examples/decoding.js similarity index 100% rename from examples/decoding.mjs rename to examples/decoding.js diff --git a/examples/disconnect.mjs b/examples/disconnect.js similarity index 100% rename from examples/disconnect.mjs rename to examples/disconnect.js diff --git a/examples/doppler.mjs b/examples/doppler.js similarity index 100% rename from examples/doppler.mjs rename to examples/doppler.js diff --git a/examples/ended-event.mjs b/examples/ended-event.js similarity index 100% rename from examples/ended-event.mjs rename to examples/ended-event.js diff --git a/examples/feedback-delay.mjs b/examples/feedback-delay.js similarity index 100% rename from examples/feedback-delay.mjs rename to examples/feedback-delay.js diff --git a/examples/granular-scrub.mjs b/examples/granular-scrub.js similarity index 100% rename from examples/granular-scrub.mjs rename to examples/granular-scrub.js diff --git a/examples/iir-filter.mjs b/examples/iir-filter.js similarity index 100% rename from examples/iir-filter.mjs rename to examples/iir-filter.js diff --git a/examples/latency-attributes.mjs b/examples/latency-attributes.js similarity index 100% rename from examples/latency-attributes.mjs rename to examples/latency-attributes.js diff --git a/examples/many-oscillators-with-env.mjs b/examples/many-oscillators-with-env.js similarity index 100% rename from examples/many-oscillators-with-env.mjs rename to examples/many-oscillators-with-env.js diff --git a/examples/microphone.mjs b/examples/microphone.js similarity index 100% rename from examples/microphone.mjs rename to examples/microphone.js diff --git a/examples/multichannel.mjs b/examples/multichannel.js similarity index 100% rename from examples/multichannel.mjs rename to examples/multichannel.js diff --git a/examples/multiple-contexts.mjs b/examples/multiple-contexts.js similarity index 100% rename from examples/multiple-contexts.mjs rename to examples/multiple-contexts.js diff --git a/examples/offline.mjs b/examples/offline.js similarity index 100% rename from examples/offline.mjs rename to examples/offline.js diff --git a/examples/oscillators.mjs b/examples/oscillators.js similarity index 100% rename from examples/oscillators.mjs rename to examples/oscillators.js diff --git a/examples/package.json b/examples/package.json new file mode 100644 index 00000000..3dbc1ca5 --- /dev/null +++ b/examples/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/examples/panner.mjs b/examples/panner.js similarity index 100% rename from examples/panner.mjs rename to examples/panner.js diff --git a/examples/resampling.mjs b/examples/resampling.js similarity index 100% rename from examples/resampling.mjs rename to examples/resampling.js diff --git a/examples/script-processor.mjs b/examples/script-processor.js similarity index 100% rename from examples/script-processor.mjs rename to examples/script-processor.js diff --git a/examples/sink-id.mjs b/examples/sink-id.js similarity index 100% rename from examples/sink-id.mjs rename to examples/sink-id.js diff --git a/examples/stereo-panner.mjs b/examples/stereo-panner.js similarity index 100% rename from examples/stereo-panner.mjs rename to examples/stereo-panner.js diff --git a/examples/trigger-soundfiles.mjs b/examples/trigger-soundfiles.js similarity index 100% rename from examples/trigger-soundfiles.mjs rename to examples/trigger-soundfiles.js diff --git a/examples/waveshaper.mjs b/examples/waveshaper.js similarity index 100% rename from examples/waveshaper.mjs rename to examples/waveshaper.js