Enable recording with four channels with Behringer UMC404HD sound card (#30)

* Enable recording with four channels with Behringer UMC404HD sound card

- Add udev rule to enable capture on 4 channels and set volume to max
- Move audio-recorder.nix to modules/audio-recorder/
- Update flake inputs

Signed-off-by: Satu Koskinen <satu.a.koskinen@gmail.com>

* Rename modules/audio-recorder/audio-recorder.nix to default.nix

Signed-off-by: Satu Koskinen <satu.a.koskinen@gmail.com>

---------

Signed-off-by: Satu Koskinen <satu.a.koskinen@gmail.com>
This commit is contained in:
Satu Koskinen 2023-10-14 12:09:30 +02:00 committed by GitHub
parent 32c96fb031
commit 150749feae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 15 deletions

View File

@ -7,11 +7,11 @@
"utils": "utils"
},
"locked": {
"lastModified": 1694158470,
"narHash": "sha256-yWx9eBDHt6WR3gr65+J85KreHdMypty/P6yM35tIYYM=",
"lastModified": 1694513707,
"narHash": "sha256-wE5kHco3+FQjc+MwTPwLVqYz4hM7uno2CgXDXUFMCpc=",
"owner": "serokell",
"repo": "deploy-rs",
"rev": "d0cfc042eba92eb206611c9e8784d41a2c053bab",
"rev": "31c32fb2959103a796e07bbe47e0a5e287c343a8",
"type": "github"
},
"original": {
@ -41,11 +41,11 @@
"systems": "systems"
},
"locked": {
"lastModified": 1692799911,
"narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=",
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {
@ -93,11 +93,11 @@
},
"nixos-hardware": {
"locked": {
"lastModified": 1693718952,
"narHash": "sha256-+nGdJlgTk0MPN7NygopipmyylVuAVi7OItIwTlwtGnw=",
"lastModified": 1694591211,
"narHash": "sha256-NPP7XGZH+Q5ey7nE2zGLrBrzKmLYPhj8YgsTSdhH0D4=",
"owner": "NixOS",
"repo": "nixos-hardware",
"rev": "793de77d9f83418b428e8ba70d1e42c6507d0d35",
"rev": "3ccd87fcdae4732fe33773cefa4375c641a057e7",
"type": "github"
},
"original": {
@ -141,11 +141,11 @@
},
"nixpkgs_3": {
"locked": {
"lastModified": 1694183432,
"narHash": "sha256-YyPGNapgZNNj51ylQMw9lAgvxtM2ai1HZVUu3GS8Fng=",
"lastModified": 1694422566,
"narHash": "sha256-lHJ+A9esOz9vln/3CJG23FV6Wd2OoOFbDeEs4cMGMqc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "db9208ab987cdeeedf78ad9b4cf3c55f5ebd269b",
"rev": "3a2786eea085f040a66ecde1bc3ddc7099f6dbeb",
"type": "github"
},
"original": {

View File

@ -39,7 +39,7 @@
specialArgs = {inherit pkgs;};
modules = [
./targets/raspberry-pi-4
./modules/audio-recorder.nix
./modules/audio-recorder
./modules/real-time-clock/i2c-rtc.nix
./modules/shutdown-button/service.nix
nixos-hardware.nixosModules.raspberry-pi-4
@ -53,7 +53,7 @@
specialArgs = {inherit pkgs;};
modules = [
./targets/raspberry-pi-3
./modules/audio-recorder.nix
./modules/audio-recorder
./modules/real-time-clock/i2c-rtc.nix
hydrophonitor-gps.nixosModules.hydrophonitor-gps
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix"

View File

@ -41,6 +41,14 @@
};
config = lib.mkIf config.services.audio-recorder.enable {
# Configure the Behringer UMC404HD to turn capture on for all four mics and set the mic volume to max
# Sound card idVendor and idProduct fields can be checked from /proc/asound/card1/usbid (when card number is 1, check with arecord -l)
services.udev.extraRules = ''
# Behringer Uphoria UMC404HD rules
# On connect, turn capture on for all mics and set the mic volume to max
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1397", ATTRS{idProduct}=="0509", RUN+="${pkgs.writeShellScriptBin "umc404hd-autocapture" (builtins.readFile ./umc404hd-autocapture.sh)}"
'';
systemd.services.audio-recorder = {
description = "Audio Recording Service";
wantedBy = ["multi-user.target"];

View File

@ -0,0 +1,8 @@
#!/bin/sh
# Enable capture and set input volume to 100% on all Behringer Uphoria 404HD inputs
set -ex
CARD=$(aplay -l | grep "USB Audio" | sed -e 's/^card\ \([0-9]\+\).*/\1/')
amixer -c $CARD cset "name=Mic Capture Switch,index=0" 1,1,1,1
amixer -c $CARD cset "name=Mic Capture Switch,index=1" 1
amixer -c $CARD cset "name=Mic Capture Volume,index=0" 127,127,127,127
amixer -c $CARD cset "name=Mic Capture Volume,index=1" 127

View File

@ -41,7 +41,7 @@ in {
sample-rate = 192000;
sample-format = "S32_LE";
channels = 4;
max-file-time-secs = 300;
max-file-time-secs = 60;
};
services.gps-recorder = {