0

I want to access the microphone input with navigator.getUserMedia(), but am unsure of how to proceed.

I can start the audio just fine, but I have no idea what to do with it after that.

if (!navigator.getUserMedia) {
    navigator.getUserMedia = navigator.getUserMedia 
                           || navigator.webkitGetUserMedia 
                           || navigator.mozGetUserMedia 
                           || navigator.msGetUserMedia;    
}

if (navigator.getUserMedia) {
    navigator.getUserMedia({audio: true}, function (e) {
        // what goes here?
    }, function (e) {
        alert('Error capturing audio.');
    });
} else {
    alert('getUserMedia not supported in this browser.');
}

I would like to access it as a stream. I don't even need stereo, just a way to get the data.

EDIT: I want to send the data back to the server using websockets, to create a sort of intercom system. Here, i need to be able to access a simple audio stream, stopping and starting it on certain events.

6
  • 1
    github.com/mattdiamond/Recorderjs Commented Jan 21, 2014 at 19:50
  • 1
    I'm no expert on this, but I've been reading about the Web Real Time Communication project. webrtc.org and I found this hopefully helpful blog post: html5rocks.com/en/tutorials/getusermedia/intro Commented Jan 21, 2014 at 19:52
  • @HarveyA.Ramer I saw that html5rocks post, but it talked mostly about video. Commented Jan 21, 2014 at 19:53
  • It would be helpful to know exactly what you want to do. Are you trying to add effects? Record the audio? Analyze it? Commented Jan 21, 2014 at 23:02
  • 1
    @KevinEnnis I want to send it back to the server using websockets, to create a sort of intercom. Commented Jan 22, 2014 at 7:24

1 Answer 1

5

If you mean you want access to the raw samples of the ongoing audio stream - use a ScriptProcessorNode in Web Audio (http://webaudio.github.io/web-audio-api/#ScriptProcessorNode). RecordJS, mentioned above, will help show you how to do this.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.