Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
tray.startCastingVisibility = false;
tray.setStatusMessage('Starting internal things...');
let Client = browser.createClient(name);
let contentType;
let audioConfig;
if(quality === 'flac') {
audioConfig = { deviceName: audioDevice, bps: 16, samplerate: 44100 };
enc = new flac.StreamEncoder();
contentType = 'audio/flac';
logger.info('Using FLAC encoder');
} else if(quality === 'flac-hd') {
audioConfig = { deviceName: audioDevice, bps: 24, samplerate: 96000 };
enc = new flac.StreamEncoder({ bitsPerSample: 24, samplerate: 96000 });
contentType = 'audio/flac';
logger.info('Using FLAC encoder with 96KHz and 24bit');
} else if(quality === 'wav') {
audioConfig = { deviceName: audioDevice, bps: 16, samplerate: 44100 };
enc = new wav.Writer();
contentType = 'audio/wav';
logger.info('Using WAV container, no encoding done');
} else if(quality === 'wav-hd') {
audioConfig = { deviceName: audioDevice, bps: 24, samplerate: 96000 };
enc = new wav.Writer({ sampleRate: 96000, bitDepth: 24 });
contentType = 'audio/wav';
logger.info('Using WAV container, no encoding done');
} else {
audioConfig = { deviceName: audioDevice, bps: 16, samplerate: 44100 };
contentType = 'audio/mpeg';
logger.info('Using lame encoder');
module.exports.Player = function () {
function writeSamples(leftSamples, rightSamples) {
let out = new Int16Array(leftSamples.length * 2);
for (var i = 0; i < leftSamples.length; ++i) {
out[i * 2] =
Math.floor(Math.max(-1, Math.min(1, leftSamples[i])) * 32767);
out[i * 2 + 1] =
Math.floor(Math.max(-1, Math.min(1, rightSamples[i])) * 32767);
}
return Buffer.from(out.buffer);
}
let writer = new flac.StreamEncoder({ samplerate: 48000, bitsPerSample: 16, compressionLevel: 0 });
let fileWriter;
let audioElement;
let recording = false;
let muted = false;
let server = httpServer.Server(1337, writer);
const pause = () => {
server.stop();
if (userSettings.get('localPlayer') && audioElement) {
audioElement.pause();
}
};
const start = () => {
server.start();