From owner-freebsd-questions@freebsd.org Fri Apr 24 06:53:35 2020 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BDF012A9D52 for ; Fri, 24 Apr 2020 06:53:35 +0000 (UTC) (envelope-from kremels@kreme.com) Received: from mail.covisp.net (mail.covisp.net [65.121.55.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 497lHy6VXdz3R5d for ; Fri, 24 Apr 2020 06:53:33 +0000 (UTC) (envelope-from kremels@kreme.com) From: "@lbutlr" Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: Audio recording on demand (level + duration) Date: Fri, 24 Apr 2020 00:53:28 -0600 References: <20200423175126.e9eea9fb.freebsd@edvax.de> To: FreeBSD In-Reply-To: <20200423175126.e9eea9fb.freebsd@edvax.de> Message-Id: X-Mailer: Apple Mail (2.3608.80.23.2.2) X-Rspamd-Queue-Id: 497lHy6VXdz3R5d X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of kremels@kreme.com designates 65.121.55.42 as permitted sender) smtp.mailfrom=kremels@kreme.com X-Spamd-Result: default: False [-0.49 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.98)[-0.980,0]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; MISSING_MIME_VERSION(2.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DMARC_NA(0.00)[kreme.com]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-1.00)[-0.998,0]; IP_SCORE(-0.12)[ip: (-0.33), ipnet: 65.112.0.0/12(-0.06), asn: 209(-0.14), country: US(-0.05)]; TO_DN_ALL(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; RCVD_IN_DNSWL_LOW(-0.10)[42.55.121.65.list.dnswl.org : 127.0.5.1]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:209, ipnet:65.112.0.0/12, country:US]; MID_RHS_MATCH_FROM(0.00)[]; FROM_EQ_ENVFROM(0.00)[] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Apr 2020 06:53:35 -0000 On 23 Apr 2020, at 09:51, Polytropon wrote: > continuously monitor audio input > if volume > 0: > create UTC timestamp (YYYY-MM-DD_HH:MM:SS) > start recording (in background) > if volume still =3D 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 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. >=20 > So when this system runs for a while, I will have certain > files, let's say >=20 > 2020-04-23_17:00:01.mp3 > 2020-04-23_17:35:28.mp3 > 2020-04-23_21:19:57.mp3 > ... 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=E2=80=99m guessing here, but hopefully this will help at = least look at another direction and maybe figure out or find the answer = you need. --=20 I intend to live forever. So far, so good.