Sonny K
Sonny K

Reputation: 63

Muting/unmutting & changing volume via Web Audio API in JavaScript

I have a few quick questions regarding the Web Audio API. I am developing in JavaScript (AngularJS).

A great demo app that I am using is at: https://webaudiodemos.appspot.com/AudioRecorder/index.html

Once I grant access to my audio microphone in my Chrome browser, using the Audio API, is there a way to:

  1. Mute and un-mute the microphone?
  2. Manually changing the microphone volume from JavaScript?
  3. An Audio API function returning a Boolean flag (or any object) letting me know if the microphone is inaccessible (not working)?

I have found a few links on StackOverflow, but they have not given me the key information that I can use for my need:

Upvotes: 3

Views: 2715

Answers (1)

cwilso
cwilso

Reputation: 13928

1) Just run the MediaStreamSource node through a Gain node, and set gain to 0 or 1 to mute or unmute.

2) Ditto. Just use the same gain node.

3) Not really - what do you mean by "not working"? If it's really not working, you'll never get the stream.

Upvotes: 5

Related Questions