Skip to content

Commit

Permalink
send float32 to client to reduce processing, optimze pcm client, opti…
Browse files Browse the repository at this point in the history
…mize junk filter for audio
  • Loading branch information
thelamer committed Feb 26, 2023
1 parent 064be26 commit f13e661
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,15 @@ aio.on('connection', function (socket) {
record = pulse.createRecordStream({
channels: 2,
rate: 44100,
format: 'S16LE',
format: 'F32LE',
});
record.on('connection', function(){
record.on('data', function(chunk) {
// Only send real audio data
let arr = chunk.toJSON().data;
if (! arr.every(item => item === 0)) {
if (arr.length < 26456) {
aio.sockets.to(id).emit('audio', chunk);
}
}
});
});
}
Expand Down
3 changes: 1 addition & 2 deletions public/js/kclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ function audio() {
}

function processAudio(data) {
let buf = new Uint16Array(data);
player.feed(buf);
player.feed(data);
}

socket.on('audio', processAudio);
2 changes: 1 addition & 1 deletion public/js/pcm-player.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion public/js/pcm-player.min.js

This file was deleted.

0 comments on commit f13e661

Please sign in to comment.