mirror of
https://github.com/scratchfoundation/scratch-audio.git
synced 2024-12-22 22:12:48 -05:00
Merge pull request #70 from towerofnix/fix-firefox-loudness
Don't use mediaStream property, which is missing on Firefox
This commit is contained in:
commit
84fdf5c76a
1 changed files with 2 additions and 1 deletions
|
@ -271,6 +271,7 @@ class AudioEngine {
|
||||||
if (!this.mic && !this.connectingToMic) {
|
if (!this.mic && !this.connectingToMic) {
|
||||||
this.connectingToMic = true; // prevent multiple connection attempts
|
this.connectingToMic = true; // prevent multiple connection attempts
|
||||||
navigator.mediaDevices.getUserMedia({audio: true}).then(stream => {
|
navigator.mediaDevices.getUserMedia({audio: true}).then(stream => {
|
||||||
|
this.audioStream = stream;
|
||||||
this.mic = this.audioContext.createMediaStreamSource(stream);
|
this.mic = this.audioContext.createMediaStreamSource(stream);
|
||||||
this.analyser = this.audioContext.createAnalyser();
|
this.analyser = this.audioContext.createAnalyser();
|
||||||
this.mic.connect(this.analyser);
|
this.mic.connect(this.analyser);
|
||||||
|
@ -282,7 +283,7 @@ class AudioEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the microphone is set up and active, measure the loudness
|
// If the microphone is set up and active, measure the loudness
|
||||||
if (this.mic && this.mic.mediaStream.active) {
|
if (this.mic && this.audioStream.active) {
|
||||||
this.analyser.getFloatTimeDomainData(this.micDataArray);
|
this.analyser.getFloatTimeDomainData(this.micDataArray);
|
||||||
let sum = 0;
|
let sum = 0;
|
||||||
// compute the RMS of the sound
|
// compute the RMS of the sound
|
||||||
|
|
Loading…
Reference in a new issue