Firefox 37 throwing error when trying to add microphone volume control for WebRTC audio context

Since firefox 37 I cannot add volume control to the input(microphone), i get the error :

IndexSizeError: Index or size is negative or greater than the allowed amount

It works fine on Chrome.

Here is the code sample :

var audioContext    = new (window.AudioContext || window.webkitAudioContext)(); // define audio context
var microphone      = audioContext.createMediaStreamDestination();
var gain            = audioContext.createGain();
var speaker         = audioContext.createMediaStreamDestination(gain);
gain.gain.value = 1;
microphone.connect(gain);
gain.connect(speaker);

The error is thrown here :

microphone.connect(gain);

weirdly it works on firefox nightly.

This error is similar to this stackoverflow :link

Related link : link on StackOverflow

Upvotes: 0

Views: 223

Answers (2)

Obscure Geek
Obscure Geek

Reputation: 749

Firstly I think it should be

var microphone      = audioContext.createMediaStreamSource(stream);

Here stream is the microphone audio stream. Find more info here.

Also check out this demo with elaboration here. It is similar to what you are trying. Replace createMediaElementSource with createMediaStreamSource will work.

Upvotes: 0

dors
dors

Reputation: 1152

Shouldn't you use this for microphone?

 var microphone      = audioContext.createMediaStreamSource();

instead of this

 var microphone      = audioContext.createMediaStreamDestination();

A microphone is not a destination. It is a source.

Upvotes: 1

Related Questions