Audio recording on demand (level + duration)
kremels at kreme.com
Fri Apr 24 06:53:35 UTC 2020
On 23 Apr 2020, at 09:51, Polytropon <freebsd at edvax.de> wrote:
> continuously monitor audio input
> if volume > 0:
> create UTC timestamp (YYYY-MM-DD_HH:MM:SS)
> start recording (in background)
> if volume still = 0 again
> send TERM signal do recorder
> recorder closes file (valid file!)
> if duration of file > 10 seconds:
> convert file to MP3 (in background)
> rename file using timestamp
> remove file
My guess is that you need to do something like this:
cat /dev/dsp > tmpfile
Periodically copy and scan tmpfile for portions that have sound levels above x%
Clip those parts into new file
Repeat scan until reaching ends fo file
When entire file is scanned, delete copy and cat > /dev/null tmpfile
The exact methods probably depend on the output of cat /dev/sndstat
> I'd like to create the "wrapper" as a simple shell script.
> So when this system runs for a while, I will have certain
> files, let's say
> ... and so on ...
If you process the file once per day, this is trivial, simply get the start of the sound duration from the copy and add this to the dat eyesteray. Even if you want to process the sound more frequently, it is not difficult, just more tedious.
> An option would be to add the duration
> to the filename (2020-04-23_21:19:57_00:24:13.mp3 - a file
> that contains 24 min 13 sec audio).
Very easy to get the duration of your sound file from, for example, ffmpeg.
Keep in mind, I’m guessing here, but hopefully this will help at least look at another direction and maybe figure out or find the answer you need.
I intend to live forever. So far, so good.
More information about the freebsd-questions