Rantanen / node-mumble

Mumble client in Node.js
MIT License
155 stars 48 forks source link

Audio capture and playback #57

Closed justinmchase closed 9 years ago

justinmchase commented 9 years ago

I created a new project compatible with node-mumble, specifically to live stream captured microphone data and playback what comes from the server. It's not super robust yet but I plan on adding mac builds and pre-built binaries in the near future. It uses openal to capture and playback the audio and seems to perform quite well.

I was previously attempting to use html5 web audio apis in electron but they are, frankly, not good enough. Either in stability or performance, I'm not sure. But this works like a champ so there it is :)

Project: node-mumble-audio

Example code to work with node-mumble:

var audio = require('./index');
var mumble = require('electron-mumble');
var speaker = new audio.PlaybackDevice();
var source = new audio.CaptureDevice();
var out_stream = null;

console.log( 'Connecting...' );
mumble.connect( process.env.MUMBLE_SERVER, {}, function ( error, connection ) {
    if( error ) { throw new Error( error ); }

    console.log( 'Connected.' );
    console.log( 'Authenticating...' );

    out_stream = connection.inputStream({sampleRate: 48000});

    connection.authenticate( process.env.MUMBLE_USER, process.env.MUMBLE_PASS );
    connection.on( 'initialized', onInit );
    connection.on( 'voice', onVoice );
});

var onInit = function() {
    console.log( 'Authenticated.' );

    source.on('data', function (data) {
        out_stream.write(data);
    })
    source.start();

    // Connection is authenticated and usable.
    speaker.play();
};

var onVoice = function( pcmData ) {
    speaker.write(pcmData);
}

Enjoy, and that is all :)

Prior99 commented 9 years ago

Thanks for the notice but as this is not a real issue I recommend closing this issue.

Maybe we can mention projects utilizing node-mumble in the README.md?

I suggest adding this to the examples.

justinmchase commented 9 years ago

I think there is a label for info but I can't edit them. But yes not an issue, I'll close it.

Rantanen commented 9 years ago

Including these at the end of the readme sounds good! On Aug 13, 2015 08:57, "Justin Chase" notifications@github.com wrote:

I think there is a label for info but I can't edit them. But yes not an issue, I'll close it.

— Reply to this email directly or view it on GitHub https://github.com/Rantanen/node-mumble/issues/57#issuecomment-130547933 .