diff --git a/dist/Superpowered.js b/dist/Superpowered.js index e048ae5..6391569 100644 --- a/dist/Superpowered.js +++ b/dist/Superpowered.js @@ -31,7 +31,7 @@ class LinearMemoryBuffer { } class SuperpoweredGlue { - static wasmCDNUrl = 'https://cdn.jsdelivr.net/npm/@superpoweredsdk/web@2.7.4/dist/superpowered-npm.wasm'; + static wasmCDNUrl = 'https://cdn.jsdelivr.net/npm/@superpoweredsdk/web@2.7.5/dist/superpowered-npm.wasm'; /**@type {number}*/id = Math.floor(Math.random() * Date.now()); /**@type {ArrayBuffer}*/linearMemory; @@ -584,10 +584,16 @@ class SuperpoweredWebAudio { /**@type {object} */Superpowered; /**@type {AudioContext} */audioContext; - constructor(/**@type {number}*/minimumSamplerate, /**@type {object}*/superpowered) { + constructor(/**@type {number}*/minimumSamplerate, /**@type {object}*/superpowered, /**@type {AudioContext}*/audioContext) { this.Superpowered = superpowered; - this.audioContext = new AudioContext(); + if (audioContext && !(audioContext instanceof AudioContext)) { + throw new Error('Invalid AudioContext provided to SuperpoweredWebAudio constructor.'); + } + this.audioContext = audioContext ?? new AudioContext(); if (this.audioContext.sampleRate < minimumSamplerate) { + if (audioContext) { + throw new Error(`The provided AudioContext has a sample rate of ${this.audioContext.sampleRate}, but the minimum required sample rate is ${minimumSamplerate}.`); + } this.audioContext.close(); this.audioContext = new AudioContext({ sampleRate: minimumSamplerate }); } diff --git a/dist/superpowered-npm.wasm b/dist/superpowered-npm.wasm index 162506f..4e3a2b2 100755 Binary files a/dist/superpowered-npm.wasm and b/dist/superpowered-npm.wasm differ diff --git a/dist/superpowered.wasm b/dist/superpowered.wasm index 1d2224a..f7f873e 100755 Binary files a/dist/superpowered.wasm and b/dist/superpowered.wasm differ diff --git a/examples/example_effects/Superpowered.js b/examples/example_effects/Superpowered.js index e048ae5..6391569 100644 --- a/examples/example_effects/Superpowered.js +++ b/examples/example_effects/Superpowered.js @@ -31,7 +31,7 @@ class LinearMemoryBuffer { } class SuperpoweredGlue { - static wasmCDNUrl = 'https://cdn.jsdelivr.net/npm/@superpoweredsdk/web@2.7.4/dist/superpowered-npm.wasm'; + static wasmCDNUrl = 'https://cdn.jsdelivr.net/npm/@superpoweredsdk/web@2.7.5/dist/superpowered-npm.wasm'; /**@type {number}*/id = Math.floor(Math.random() * Date.now()); /**@type {ArrayBuffer}*/linearMemory; @@ -584,10 +584,16 @@ class SuperpoweredWebAudio { /**@type {object} */Superpowered; /**@type {AudioContext} */audioContext; - constructor(/**@type {number}*/minimumSamplerate, /**@type {object}*/superpowered) { + constructor(/**@type {number}*/minimumSamplerate, /**@type {object}*/superpowered, /**@type {AudioContext}*/audioContext) { this.Superpowered = superpowered; - this.audioContext = new AudioContext(); + if (audioContext && !(audioContext instanceof AudioContext)) { + throw new Error('Invalid AudioContext provided to SuperpoweredWebAudio constructor.'); + } + this.audioContext = audioContext ?? new AudioContext(); if (this.audioContext.sampleRate < minimumSamplerate) { + if (audioContext) { + throw new Error(`The provided AudioContext has a sample rate of ${this.audioContext.sampleRate}, but the minimum required sample rate is ${minimumSamplerate}.`); + } this.audioContext.close(); this.audioContext = new AudioContext({ sampleRate: minimumSamplerate }); } diff --git a/examples/example_guitardistortion/Superpowered.js b/examples/example_guitardistortion/Superpowered.js index e048ae5..6391569 100644 --- a/examples/example_guitardistortion/Superpowered.js +++ b/examples/example_guitardistortion/Superpowered.js @@ -31,7 +31,7 @@ class LinearMemoryBuffer { } class SuperpoweredGlue { - static wasmCDNUrl = 'https://cdn.jsdelivr.net/npm/@superpoweredsdk/web@2.7.4/dist/superpowered-npm.wasm'; + static wasmCDNUrl = 'https://cdn.jsdelivr.net/npm/@superpoweredsdk/web@2.7.5/dist/superpowered-npm.wasm'; /**@type {number}*/id = Math.floor(Math.random() * Date.now()); /**@type {ArrayBuffer}*/linearMemory; @@ -584,10 +584,16 @@ class SuperpoweredWebAudio { /**@type {object} */Superpowered; /**@type {AudioContext} */audioContext; - constructor(/**@type {number}*/minimumSamplerate, /**@type {object}*/superpowered) { + constructor(/**@type {number}*/minimumSamplerate, /**@type {object}*/superpowered, /**@type {AudioContext}*/audioContext) { this.Superpowered = superpowered; - this.audioContext = new AudioContext(); + if (audioContext && !(audioContext instanceof AudioContext)) { + throw new Error('Invalid AudioContext provided to SuperpoweredWebAudio constructor.'); + } + this.audioContext = audioContext ?? new AudioContext(); if (this.audioContext.sampleRate < minimumSamplerate) { + if (audioContext) { + throw new Error(`The provided AudioContext has a sample rate of ${this.audioContext.sampleRate}, but the minimum required sample rate is ${minimumSamplerate}.`); + } this.audioContext.close(); this.audioContext = new AudioContext({ sampleRate: minimumSamplerate }); } diff --git a/examples/example_pitchbend/Superpowered.js b/examples/example_pitchbend/Superpowered.js index e048ae5..6391569 100644 --- a/examples/example_pitchbend/Superpowered.js +++ b/examples/example_pitchbend/Superpowered.js @@ -31,7 +31,7 @@ class LinearMemoryBuffer { } class SuperpoweredGlue { - static wasmCDNUrl = 'https://cdn.jsdelivr.net/npm/@superpoweredsdk/web@2.7.4/dist/superpowered-npm.wasm'; + static wasmCDNUrl = 'https://cdn.jsdelivr.net/npm/@superpoweredsdk/web@2.7.5/dist/superpowered-npm.wasm'; /**@type {number}*/id = Math.floor(Math.random() * Date.now()); /**@type {ArrayBuffer}*/linearMemory; @@ -584,10 +584,16 @@ class SuperpoweredWebAudio { /**@type {object} */Superpowered; /**@type {AudioContext} */audioContext; - constructor(/**@type {number}*/minimumSamplerate, /**@type {object}*/superpowered) { + constructor(/**@type {number}*/minimumSamplerate, /**@type {object}*/superpowered, /**@type {AudioContext}*/audioContext) { this.Superpowered = superpowered; - this.audioContext = new AudioContext(); + if (audioContext && !(audioContext instanceof AudioContext)) { + throw new Error('Invalid AudioContext provided to SuperpoweredWebAudio constructor.'); + } + this.audioContext = audioContext ?? new AudioContext(); if (this.audioContext.sampleRate < minimumSamplerate) { + if (audioContext) { + throw new Error(`The provided AudioContext has a sample rate of ${this.audioContext.sampleRate}, but the minimum required sample rate is ${minimumSamplerate}.`); + } this.audioContext.close(); this.audioContext = new AudioContext({ sampleRate: minimumSamplerate }); } diff --git a/examples/example_timestretching/Superpowered.js b/examples/example_timestretching/Superpowered.js index e048ae5..6391569 100644 --- a/examples/example_timestretching/Superpowered.js +++ b/examples/example_timestretching/Superpowered.js @@ -31,7 +31,7 @@ class LinearMemoryBuffer { } class SuperpoweredGlue { - static wasmCDNUrl = 'https://cdn.jsdelivr.net/npm/@superpoweredsdk/web@2.7.4/dist/superpowered-npm.wasm'; + static wasmCDNUrl = 'https://cdn.jsdelivr.net/npm/@superpoweredsdk/web@2.7.5/dist/superpowered-npm.wasm'; /**@type {number}*/id = Math.floor(Math.random() * Date.now()); /**@type {ArrayBuffer}*/linearMemory; @@ -584,10 +584,16 @@ class SuperpoweredWebAudio { /**@type {object} */Superpowered; /**@type {AudioContext} */audioContext; - constructor(/**@type {number}*/minimumSamplerate, /**@type {object}*/superpowered) { + constructor(/**@type {number}*/minimumSamplerate, /**@type {object}*/superpowered, /**@type {AudioContext}*/audioContext) { this.Superpowered = superpowered; - this.audioContext = new AudioContext(); + if (audioContext && !(audioContext instanceof AudioContext)) { + throw new Error('Invalid AudioContext provided to SuperpoweredWebAudio constructor.'); + } + this.audioContext = audioContext ?? new AudioContext(); if (this.audioContext.sampleRate < minimumSamplerate) { + if (audioContext) { + throw new Error(`The provided AudioContext has a sample rate of ${this.audioContext.sampleRate}, but the minimum required sample rate is ${minimumSamplerate}.`); + } this.audioContext.close(); this.audioContext = new AudioContext({ sampleRate: minimumSamplerate }); }

AltStyle によって変換されたページ (->オリジナル) /