bls wrote: ↑
Thu Feb 06, 2020 8:45 pm
I've started looking at the changes to accomplish the OP's goals (as I understand them), but that's still on the side.
I have something up and running now. Still needs some polishing, but here's what it does at the moment. Command is called tbd
until I decide what to name it
While it's running, it listens for keyboard input, and accepts the following commands:
- h - Print help text
- k - Show current Peak and Threshold levels
- p - Print observed peak every second until another p command
- v - Set a new Threshold
- q - Quit the program
Here are some sample commands:
- tbd listen --reportpeak - Runs until a peak sound is heard or until q is typed on the keyboard. Reports the Peak observed level on exit.
- tbd listen --threshold nn --bash "some-bash-command" - Runs until the peak level exceeds the specified threshold, at which time it executes the specified command. If --echo is specified, the command is echoed before it's executed. If --output is specified, the output of the command is printed on the terminal. some-bash-command can be any command you can type at the bash command line.
- tbd listdevs - List the sound devices and exit
For the OP, using this program you would run the script one or more nights to measure the peak observed sound, and then set it up to run with a --threshold that is higher than the observed peak. Once you have that threshold, you can run it with the --bash and --threshold switches to do exactly what you want.