Home Audio recording plays back at inconsistent rate
Reply: 0

Audio recording plays back at inconsistent rate

user1910 Published in July 23, 2018, 1:27 pm

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.onstop = function(e) {
            var blob = new Blob(chunks, { 'type' : 'audio/ogg; codecs=opus' })
            var audioURL = URL.createObjectURL(blob);
            if (recordData.id) {
                socket.emit('audio', {
        mediaRecorder.ondataavailable = function(e) {
var stopRecord = function(recordData){
    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.39856 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO