From 643d33e482f7c7a1f31663cd46dc8d567e0c9b93 Mon Sep 17 00:00:00 2001 From: Eric Rosenbaum Date: Fri, 21 Jul 2017 10:50:15 -0400 Subject: [PATCH 1/2] Use audio-context module for shared audiocontext To prevent creating multiple audio contexts --- package.json | 1 + src/index.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 60f5821..1cd6927 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ }, "homepage": "https://github.com/LLK/scratch-audio#readme", "devDependencies": { + "audio-context": "^1.0.1", "babel-core": "^6.24.1", "babel-eslint": "^7.2.2", "babel-loader": "^6.4.1", diff --git a/src/index.js b/src/index.js index a0841d9..355bb02 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,7 @@ const log = require('./log'); +const AudioContext = require('audio-context'); + const PitchEffect = require('./effects/PitchEffect'); const PanEffect = require('./effects/PanEffect'); @@ -149,7 +151,6 @@ class AudioPlayer { */ class AudioEngine { constructor () { - const AudioContext = window.AudioContext || window.webkitAudioContext; this.audioContext = new AudioContext(); this.input = this.audioContext.createGain(); From 63cf44b2698bb66afa97b2c23d185f8693a65323 Mon Sep 17 00:00:00 2001 From: Eric Rosenbaum Date: Tue, 25 Jul 2017 10:06:53 -0400 Subject: [PATCH 2/2] Pin to exact version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1cd6927..acd09e2 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ }, "homepage": "https://github.com/LLK/scratch-audio#readme", "devDependencies": { - "audio-context": "^1.0.1", + "audio-context": "1.0.1", "babel-core": "^6.24.1", "babel-eslint": "^7.2.2", "babel-loader": "^6.4.1",