WaaromZoMoeilijk / rpi-audio

0 stars 0 forks source link

Automated mixer lvl & recording #4

Closed WaaromZoMoeilijk closed 2 years ago

WaaromZoMoeilijk commented 3 years ago

As a preliminary demonstration, using the proposed architecture, have the system adjust mixer level and start recording (to compress to Opus) upon power on. Determine the basic security for that. Should the process start as an administrator that's able to sudo? Or would sudo not be needed if that user happens to have (read?) access to the audio device? Would this be a systemd service or a modern equivalent of rc.local? Note that it doesn't need to be fancy here but should still work predictably and in the right order. Note that later inclusion of ZeroTier or a LTE connection suggests that the startup may need to summon a root-level script. This initial step can store the recording locally (on the SD card)

Find out a way to ensure that the mixer level is set to the right value assuming the microphone level will usually be the same - not too high of a level since it may over-saturate, and not too low since it would lose information potentially. Also ensure that the recording input is definitely referencing the right audio input. In pulseaudio I sometimes found it hard to parse the command line input but there must be standard conventions to do so. I want to make sure not to record the wrong thing, or to record noise or an empty sound. Put together a means for minor system update for security patches (some apt-get update && apt-get dist-upgrade equivalent or something that follows the provisioning conventions)

WaaromZoMoeilijk commented 3 years ago

For now i aim to have the least permissions needed to perform the tasks. Will unfold as we go and i'll keep you informed. As for the service, i'm leaning more towards rc.local + cron with a check that it only runs once. It might be that i install certain components another way in order to set priority on boot. If you have other thoughts please share them.

Own reference: https://askubuntu.com/questions/279407/how-to-disable-microphone-from-auto-adjusting-its-input-volume https://wiki.ubuntu.com/Audio/Alsamixer https://unix.stackexchange.com/questions/374085/lower-or-increase-pulseaudio-volume-on-all-outputs https://stackoverflow.com/questions/34936783/watch-for-volume-changes-in-alsa-pulseaudio https://wiki.archlinux.org/title/PulseAudio/Examples

WaaromZoMoeilijk commented 2 years ago

Right now its set to 80% but still looking for a more dynamic approach to set arecord values in regards to the microphone being used.

https://github.com/WaaromZoMoeilijk/rpi-audio/tree/main/scripts/audio.sh

WaaromZoMoeilijk commented 2 years ago

Right now the initial installation needs to be run as root, in order to provision. If we provide an already provisioned image/container we could limit the script execution to a dedicated user. Though we can separate parts we need to run as root or normal user.

My intent is to keep using root for now during dev since I don't expect it to be a hassle to change it once we containerize or get another deployment solution. Let me know if you think otherwise.