Audio recording on demand (level + duration)

Polytropon freebsd at edvax.de
Thu Apr 23 15:51:30 UTC 2020


For an amateur radio project, I need a way to have a system
that does "record on demand". This will be the setting:

I have a receiver on a specific frequency. It uses a built-in
squelch in FM mode, so when there is no signal, the device is
silent - it works like a typical scanner, but for one frequency.

What I want a connected computer (using the line-in or the
microphone input, need to check levels) is to do something
like in this pseudocode:

	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
		else:
			remove file

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

	2020-04-23_17:00:01.mp3
	2020-04-23_17:35:28.mp3
	2020-04-23_21:19:57.mp3
	... and so on ...

which are all more than 10 seconds in duration and contain
what has been received on the frequency. The restriction on
the duration will make sure no noise will be recorded, only
the desired signals. 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).

My question is:

What file can I monitor (and how) to obtain an information
about _if_ there is some audio input? I'd probably use the
rec command from the sox package for recording, and probably
something like lame for MP3 conversion.

Any pointers are welcome.




-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...


More information about the freebsd-questions mailing list