Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Apr 2020 17:51:26 +0200
From:      Polytropon <freebsd@edvax.de>
To:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Audio recording on demand (level + duration)
Message-ID:  <20200423175126.e9eea9fb.freebsd@edvax.de>

next in thread | raw e-mail | index | archive | help
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, ...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20200423175126.e9eea9fb.freebsd>