cosplay-pi-tk-voice-modulator
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -6,2 +6,4 @@ "use strict"; | ||
const init = async () => { | ||
console.log(`This module uses these sounds from freesound:`); | ||
console.log(`- "radio click 7.wav" by ERH ( https://freesound.org/people/ERH/sounds/30331/ ) licensed under CCBY 4.0`); | ||
const recArgs = [ | ||
@@ -28,20 +30,47 @@ `--buffer`, | ||
]; | ||
let soxProcess; | ||
const startSoxProcess = () => { | ||
soxProcess = (0, child_process_1.spawn)(`nice -n 8 play "|rec ${recArgs.join(` `)}"`, { | ||
const startSox = () => { | ||
let soxInputProcess = (0, child_process_1.spawn)(`nice -n 8 sox -d -t wav - ${recArgs.join(` `)}`, { | ||
shell: true, | ||
stdio: `inherit`, | ||
}); | ||
soxProcess.on(`exit`, async () => { | ||
await new Promise((resolvePromise) => setTimeout(resolvePromise, 1000)); | ||
startSoxProcess(); | ||
let soxOutputProcess = (0, child_process_1.spawn)(`play -t wav -`, { | ||
shell: true, | ||
}); | ||
soxProcess.on(`error`, async () => { | ||
soxInputProcess.stdout.pipe(soxOutputProcess.stdin); | ||
soxInputProcess.stderr.on(`data`, () => { | ||
}); | ||
soxOutputProcess.stdout.pipe(process.stdout); | ||
soxOutputProcess.stderr.on(`data`, () => { | ||
}); | ||
const onSoxTerminated = async () => { | ||
await new Promise((resolvePromise) => setTimeout(resolvePromise, 1000)); | ||
startSoxProcess(); | ||
}); | ||
if (soxInputProcess !== undefined) { | ||
try { | ||
soxInputProcess.kill(); | ||
} | ||
catch (_a) { | ||
} | ||
finally { | ||
soxInputProcess = undefined; | ||
} | ||
} | ||
if (soxOutputProcess !== undefined) { | ||
try { | ||
soxOutputProcess.kill(); | ||
} | ||
catch (_b) { | ||
} | ||
finally { | ||
soxOutputProcess = undefined; | ||
} | ||
} | ||
startSox(); | ||
}; | ||
soxInputProcess.on(`exit`, onSoxTerminated); | ||
soxInputProcess.on(`error`, onSoxTerminated); | ||
soxOutputProcess.on(`exit`, onSoxTerminated); | ||
soxOutputProcess.on(`error`, onSoxTerminated); | ||
}; | ||
startSoxProcess(); | ||
startSox(); | ||
}; | ||
init(); | ||
//# sourceMappingURL=main.js.map |
{ | ||
"name": "cosplay-pi-tk-voice-modulator", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"main": "dist/index.js", | ||
"files": [ | ||
"dist", | ||
"click.wav", | ||
"default-settings.json" | ||
@@ -8,0 +9,0 @@ ], |
Sorry, the diff of this file is not supported yet
141955
15
127