Home Audio recording plays back at inconsistent rate
Reply: 0

Audio recording plays back at inconsistent rate

MikeyB
1#
MikeyB Published in 2018-01-12 12:12:34Z

I am using the code below to record audio in the browser, then use socket.io to send the resulting blob to a node.js server. The data is then saved to a mysql database or as an .ogg file.

The playback from either is strangely garbled at times - in different moments the sound will suddenly accelerate then return to normal. I've not been able to find anything online about this issue.

UPDATE: Further testing leads me to believe it is a hardware/software/compatibility with the Asus D1 soundcard I'm using. recording off of other devices does not result in the same behavior.

 var mediaRecorder;
    var startRecord = function(recordData){
    if (!navigator.getUserMedia)
        navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia ||
        navigator.mozGetUserMedia || navigator.msGetUserMedia;
    if (navigator.getUserMedia) {
        navigator.getUserMedia({audio:true}, success, function(stream) {
            alert('Error capturing audio.');
        });
    } else alert('getUserMedia not supported in this browser.');
    function success(stream) {
        var chunks = [];
        mediaRecorder = new MediaRecorder(stream);
        mediaRecorder.start();
        mediaRecorder.onstop = function(e) {
            stream.getAudioTracks()[0].stop()
            var blob = new Blob(chunks, { 'type' : 'audio/ogg; codecs=opus' })
            var audioURL = URL.createObjectURL(blob);
            if (recordData.id) {
                socket.emit('audio', {
                    'id':recordData.id,
                    'audio':blob,
                    'option':recordData.type
                });
        }
        mediaRecorder.ondataavailable = function(e) {
            chunks.push(e.data);
        }
    }
};
var stopRecord = function(recordData){
    mediaRecorder.stop();
    mediaRecorder.state = 'recording'
};
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.298341 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO