fix: solve compatibility issues with older browser versions

- Firefox 52 does not support the OfflineAudioContext constructor
- versions before Chrome 62, Firefox 57, and Opera 42 do not support
passing OfflineAudioContext parameters as a single object

Closes #3.
pull/73/head
dessant 6 years ago
parent b047efde72
commit 8be30076e1

@ -31,7 +31,7 @@
},
"browserslist": [
"Chrome >= 55",
"Firefox >= 52",
"Firefox >= 53",
"FirefoxAndroid >= 57",
"Opera >= 42"
],

@ -49,12 +49,12 @@ async function prepareAudio(audio) {
const data = await ctx.decodeAudioData(audio);
await ctx.close();
const offlineCtx = new OfflineAudioContext({
const offlineCtx = new OfflineAudioContext(
// force mono output
numberOfChannels: 1,
length: 16000 * data.duration,
sampleRate: 16000
});
1,
16000 * data.duration,
16000
);
const source = offlineCtx.createBufferSource();
source.buffer = data;
source.connect(offlineCtx.destination);

Loading…
Cancel
Save