cosplay-pi-tk-voice-modulator
Advanced tools
Comparing version 1.1.1 to 1.1.2
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const child_process_1 = require("child_process"); | ||
const path = require("path"); | ||
const tk_voice_modulator_settings_1 = require("./tk-voice-modulator-settings"); | ||
@@ -26,3 +27,9 @@ const init = async () => { | ||
]; | ||
let isMicOn = false; | ||
let lastOnTime = new Date(); | ||
let wasClickPlayed = true; | ||
const startSox = () => { | ||
isMicOn = false; | ||
lastOnTime = new Date(); | ||
wasClickPlayed = true; | ||
let soxInputProcess = (0, child_process_1.spawn)(`nice -n 8 sox -d -t wav --buffer ${tk_voice_modulator_settings_1.tkVoiceModulatorEffectiveSettings.bufferSize} - ${recArgs.join(` `)}`, { | ||
@@ -38,3 +45,5 @@ shell: true, | ||
soxOutputProcess.stdout.pipe(process.stdout); | ||
soxOutputProcess.stderr.on(`data`, () => { | ||
soxOutputProcess.stderr.on(`data`, (chunk) => { | ||
const strChunk = String(chunk); | ||
isMicOn = strChunk.includes(`=`); | ||
}); | ||
@@ -71,4 +80,20 @@ const onSoxTerminated = async () => { | ||
startSox(); | ||
setInterval(() => { | ||
const now = new Date(); | ||
if (isMicOn) { | ||
wasClickPlayed = false; | ||
lastOnTime = now; | ||
} | ||
else { | ||
if (!wasClickPlayed) { | ||
if (now.getTime() - lastOnTime.getTime() > 600) { | ||
const clickPlaySoundFilePath = path.resolve(__dirname, `..`, `click.wav`); | ||
(0, child_process_1.exec)(`play ${clickPlaySoundFilePath} gain -20`); | ||
wasClickPlayed = true; | ||
} | ||
} | ||
} | ||
}, 50); | ||
}; | ||
init(); | ||
//# sourceMappingURL=main.js.map |
{ | ||
"name": "cosplay-pi-tk-voice-modulator", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
143518
149