index.js
/*
* Creates an AudioInput object for the system's default device with the specified sample rate
*/
Creates an AudioInput object for the system's default device with the specified sample rate
Creates an AudioInput object for the system ' s default device with the specified sample rate
function createAudioInput(audio_sample_rate) {
	var ai = new portAudio.AudioInput({
		channelCount: 1,
		sampleFormat: portAudio.SampleFormat16Bit,
		sampleRate: audio_sample_rate,
		deviceId: -1 
	});
	ai.on('error', err => logger.error);
	ai.on('readable', function () {
		var chunk;
		while (null !== (chunk = ai.read())) {
			var f = { format: format.parse('int16 mono le ' + audio_sample_rate) };
			var buffer = createBuffer(chunk, f);
			io.sockets.emit('microphone', { x: buffer.getChannelData(0) });
		}
	})
	ai.on('end', function () {
		logger.info("Audio stream closed");
	});
	return (ai);
}
function createAudioInput ( audio_sample_rate ) { var ai = new portAudio . AudioInput ( { channelCount : 1 , sampleFormat : portAudio . SampleFormat16Bit , sampleRate : audio_sample_rate , deviceId : - 1 } ) ; ai . on ( 'error' , err => logger . error ) ; ai . on ( 'readable' , function ( ) { var chunk ; while ( null !== ( chunk = ai . read ( ) ) ) { var f = { format : format . parse ( 'int16 mono le ' + audio_sample_rate ) } ; var buffer = createBuffer ( chunk , f ) ; io . sockets . emit ( 'microphone' , { x : buffer . getChannelData ( 0 ) } ) ; } } ) ai . on ( 'end' , function ( ) { logger . info ( "Audio stream closed" ) ; } ) ; return ( ai ) ; }
Creates an AudioInput object for the system's default device with the specified sample rate
Creates an AudioInput object for the system ' s default device with the specified sample rate
// Create an instance of AudioInput, which is a ReadableStream // Use -1 or omit the deviceId to select the default device // handle errors from the AudioInput