From owner-freebsd-questions@freebsd.org Thu Apr 23 15:51:30 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 1B9662BAF57 for ; Thu, 23 Apr 2020 15:51:30 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.135]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "mout.kundenserver.de", Issuer "TeleSec ServerPass Class 2 CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 497MH50Khzz3xMg for ; Thu, 23 Apr 2020 15:51:28 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r56.edvax.de ([178.12.34.44]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPA (Nemesis) id 1MiuGK-1ixnYY3pBs-00et3G for ; Thu, 23 Apr 2020 17:51:27 +0200 Date: Thu, 23 Apr 2020 17:51:26 +0200 From: Polytropon To: FreeBSD Questions Subject: Audio recording on demand (level + duration) Message-Id: <20200423175126.e9eea9fb.freebsd@edvax.de> Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:Mi0WJ/MMsoi4ww3A6UgaKOG+jJVbDVw9J06Oh61ZRBh5D3pfSvy KNpoH776+gRh3Ig5HI+OnAeCHDoMeQioiNX7OAtQlLWQyLCLn2uEwpDh2bSn3PExYF5OohP ZdCH/WQn/HS4PEyijjqo4JSeBiQzZNrZpdxjw/qfGArOdOc9JYBAjnROHw2xTzfaGZcAkMH lF4Y4Xri5B8fmEeJWHJnw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:VsrIeL883Mg=:WmWUmkQ4Rx+lqx4Fw/R4Xk BngoFHSpHFZTjsGfQwS3tfqYDs6rj/XGc08sgLypbqwMs8fP7D0wwINjz3joDFZkym8jSVEFG QB1ZZL79Z0VTZ44HdaxF8tWJ2lXqbyFescV2oes/LRSclk1LlwumgJMr6kKzq66VuQLMlrqhb NVMQDrQ7P6NcR2sAb2xIsi2aLgQseiNDMHAXb//1EneOP9dmL3Q3j+24VmyxsGtcyZBWnKPRY gtDDondb8tNrKlw7GDhpLu+sOmsufyGFkd+F7vJAuDJhBOn6PmzlqtE7IqPLkGMk0SdfDXcSW pJs09NkLB6T1+yCjeXppEHYCYL5M8XoCanzULLxs30I6rRts+lGIoYyargzBU/0JUUcGvcro5 qdpuCvnG3903z8B5Cytj7zkIwyP/ZSRFPWzD1caN3e1jhe3mIJR7BxIw5IjADkQakPpqVuWap /44z3io9qhNUuGizAXQwWYVqnWYIn2OYYWhIVbedMq9zCwhu1zUtp6yQVjica7NSZcEuwarB3 rknzLWzY83h7FtJo9OHal7yQjQtgPHR0vRxUk3SSuhiyt0sOXVcgtJogPufQFWuYnSJHfmnaN JCUXnkFQxZkaO6CVXaQQaBQqe6eZ6EpFvEpgiolgydwfAwBS0509HUqbVHo4IgyGpyYmJ2nR7 3aSccUhGMiRBNKFe7otPPpGLyRvb+VCVOqO6f0TjRnvfd4kdBiOioCZxiB+SDgfitcVRYDX+v TawL5yAaqVYV4/fuQW4iiHR5/1L2LH41UOsRe42khIip127Gqp348f8IymOxbKFxTEDhkJ87M AyYfMS63rZuGytNX7EHAZko1T97KZzNMgm5MMs6Hn6ELdBLEg1jxhkYyfH8JUCaQOapOxDR X-Rspamd-Queue-Id: 497MH50Khzz3xMg X-Spamd-Bar: ++++ Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of freebsd@edvax.de has no SPF policy when checking 212.227.126.135) smtp.mailfrom=freebsd@edvax.de X-Spamd-Result: default: False [4.48 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; HAS_REPLYTO(0.00)[freebsd@edvax.de]; MV_CASE(0.50)[]; HAS_ORG_HEADER(0.00)[]; TO_DN_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:8560, ipnet:212.227.0.0/16, country:DE]; MIME_TRACE(0.00)[0:+]; RECEIVED_SPAMHAUS_PBL(0.00)[44.34.12.178.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.11]; ARC_NA(0.00)[]; REPLYTO_EQ_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; DMARC_NA(0.00)[edvax.de]; AUTH_NA(1.00)[]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_SPAM_MEDIUM(0.86)[0.858,0]; IP_SCORE(0.23)[ip: (0.30), ipnet: 212.227.0.0/16(-1.20), asn: 8560(2.07), country: DE(-0.02)]; NEURAL_SPAM_LONG(0.99)[0.995,0]; MID_CONTAINS_FROM(1.00)[]; RCVD_IN_DNSWL_NONE(0.00)[135.126.227.212.list.dnswl.org : 127.0.5.0]; R_SPF_NA(0.00)[]; RCVD_COUNT_TWO(0.00)[2] 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: Thu, 23 Apr 2020 15:51:30 -0000 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, ...