Rantanen/node-mumble

Voice from client pauses every couple seconds.

Closed this issue · 2 comments

Hey I was following along with the mp3 example you had. I changed it up a little bit though for it to only play audio when a chat command was given. But then I noticed that when the audio was long enough, it would play for 2-3 seconds and then cut out for about a second and then play for 2-3 more seconds again. I also noticed that the red lips in mumble turned back to grey during the audio cut outs. I simplified my code down to the point where I discovered that this short amount of code reproduces the issue:

var fs = require('fs');

var lame = require('lame');
var mumble = require('mumble');

var play = function(file, client) {
    var stream = fs.createReadStream(file);
    var decoder = new lame.Decoder();

    decoder.on('format', function(format) {
        var input = client.inputStream(format);
        decoder.pipe(input);
    });
    stream.pipe(decoder);
};

mumble.connect('mumble://127.0.0.1', function(error, client) {
    if(error) { throw new Error(error); }

    client.authenticate('music-test');
    client.on('initialized', function() {
        // comment out the setTimeout to make it work perfectly.
        setTimeout(function() {
            play('test2.mp3', client);
        }, 2000);
    });
});

It seems like if you don't play audio ASAP, the issue happens. Any idea why this could be happening?

Thanks for the library by the way!

Could you try lowering the bitrate? I think client.connection.setBitrate() should do this at least. Currently the library doesn't respect the server specified max_bitrate. See #44.

This seems to fix the issue right up. I was able to get away with 24000 which sounds good enough to me (but I probably could have gone higher):

client.connection.setBitrate(24000);

Thanks for the help!