diff --git a/index.js b/index.js index 56ff597..9735d92 100644 --- a/index.js +++ b/index.js @@ -31,16 +31,6 @@ pulse.on('error', function(error) { audioEnabled = false; console.log('Kclient was unable to init audio, it is possible your host lacks support!!!!'); }); -if (audioEnabled) { - var stream = pulse.createPlaybackStream({ - stream: "LSIOMic", - device: "LSIOMic", - format: "S16LE", - rate: 44100, - channels: 1, - latency: 100, - }); -} //// Server Paths Main //// @@ -190,9 +180,7 @@ aio.on('connection', function (socket) { // Dump blobs to pulseaudio sink async function micData(buffer) { - if (audioEnabled) { - stream.write(buffer); - } + await fsw.writeFile('/defaults/mic.sock', buffer); } // Incoming socket requests diff --git a/public/js/kclient.js b/public/js/kclient.js index 28dc66c..bdd5aae 100644 --- a/public/js/kclient.js +++ b/public/js/kclient.js @@ -103,18 +103,20 @@ function mic() { function onMediaSuccess(stream) { audio_context = new window.AudioContext; let source = audio_context.createMediaStreamSource(stream); - let processor = audio_context.createScriptProcessor(2048, 1, 1); + let processor = audio_context.createScriptProcessor(512, 1, 1); source.connect(processor); processor.connect(audio_context.destination); processor.onaudioprocess = function (audioEvent) { let int16Array = Int16Array.from(audioEvent.inputBuffer.getChannelData(0), x => x * 32767); let arraySize = new Blob([JSON.stringify(int16Array)]).size; - if (arraySize > 20000) { + if (arraySize > 4100) { socket.emit('micdata', int16Array.buffer); } }; } function onMediaError(e) { console.error('media error', e); + $('#micButton').removeClass("icons-selected"); + micEnabled = false; } }