Monitoring an audio line.
Posted
by Stefan Liebenberg
on Stack Overflow
See other posts from Stack Overflow
or by Stefan Liebenberg
Published on 2010-04-10T11:16:44Z
Indexed on
2010/04/10
11:23 UTC
Read the original article
Hit count: 230
I need to monitor my audio line-in in linux, and in the event that audio is played, the sound must be recorded and saved to a file. Similiar to how motion monitors the video feed.
Is it possible to do this with bash? something along the lines of:
#!/bin/bash
# audio device
device=/dev/audio-line-in
# below this threshold audio will not be recorded.
noise_threshold=10
# folder where recordings are stored
storage_folder=~/recordings
# run indefenitly, until Ctrl-C is pressed
while true; do
# noise_level() represents a function to determine
# the noise level from device
if noise_level( $device ) > $noise_threshold; then
# stream from device to file, can be encoded to mp3 later.
cat $device > $storage_folder/`date`.raw
fi;
done;
© Stack Overflow or respective owner