An important part of my own Linux paradise is the very cheap Hi-Fi player and recorder in the body of an old and efficient thin client device. Also, my main server works as a file manager/server and a proxy server.

I decided to expand my knowledge to something bigger and more challenging, so I offered to the guys who work at the local art space/night club that usually make recordings on the analog recorder and then upload them to slow cloud providers with limited content lifetime to be able to share recordings with the artists or upload them themselves.

The diagram, shown on the picture I showed to the customer, is a working scheme that shows the solution that I made.

There are two types of devices: a [recorder] (Raspberry Pi) and a [server] (mini-ATX pc), both running Debian or Debian-based distro.

The recorder contains:
SOX recorder, Alsa sound driver, SSH-server and samba server.

The server contains:
FileBrowser, Nginx Server, AWS Cli, Authelia, SSH-server and samba client.
Works as a Bastion Host.

Functionality:
Personal Cloud: Read/Write/Access files over the Internet, file sharing Digital Recorder: Hi-Res power-loss efficient audio recording device SSH connection: Written scripts for starting recordings and other functions can be launched with a smartphone Data Backup: All data are backed up to the Amazon S3 Glacier

Future plans:
Audio stream via Internet
Ability to play records via sound card to the master channel

Some scripts, used to develop this infrastructure, are shown below.

#!/bin/bash

# Specify the card searching script.
card_search_script=".card_script.sh/"

# Get the card number from the card searching script.
card_number="$($card_search_script)"

# Check if the audio device was found.
if [ -n "$card_number" ]; then
# Get the current date and time.
day=$(date +%d)
month=$(date +%m)
year=$(date +%Y)
powerloss="-"
recd_dir="./records/CLOSER-$month-$day-$year"
ntfy="https://ntfy.sh/G4mG4RtjBeeImT4V-"

# Calculate the recording time in seconds.
rec_time=$(echo "$1 * 60" | bc)

# Create a directory for the recording if it does not exist.
mkdir -p "$recd_dir"

# Touch the record log file if it does not exist.
touch "$recd_dir/record-$powerloss.log"

# Trap the SIGINT signal to handle graceful exit.
trap 'kill -INT $record_pid; exit 1' INT

# Start the recording with nohup.
while true; do
# Get the current hour and minute.
hour=$(date +%H)
minute=$(date +%M)

# Send a curl request to notify that the recording has started.
curl -d "Recording started" "$ntfy"

# Start the recording process.
record_pid=$(nohup sox -t alsa "hw:$card_number" "$recd_dir/REC-$month-$day-$year-$hour-$minute-$powerloss.wav" trim 0 $rec_time : newfile : restart > "$recd_dir/record-$powerloss.log" 2>&1 &)

# Wait for the recording process to finish.
wait $record_pid

# Check if the audio device is still available.
while ! aplay -l | grep "X1"; do
sleep 1
done

# Send a curl request to notify that the device has been found.
curl -d "Device found at $(date +%H)-$(date +%M)" "$ntfy"

# Add the power loss event to the record log file.
touch "$recd_dir/powerloss.log"
echo "$(date +%H)-$(date +%M)" >> "$recd_dir/powerloss.log"

# Sleep for 1 second before checking the device again.
sleep 1
done
else
echo "Recording device not found. Check the card searching script."
fi




#!/bin/bash

# Function to find the card number for a given card name.
find_card_number() {
  local card_name="$1"
  local card_number

  # Get the output of the `aplay -l` command and search for the card name.
  card_number=$(aplay -l | grep "$card_name" | cut -d ' ' -f 2 | tr -d ':')

  if [[ -n "$card_number" ]]; then
    echo "Card '$card_name' found with number: $card_number"
  else
    echo "Card '$card_name' not found."
  fi
}

# Specify the card name you want to search for.
card_to_find="X1"

# Call the find_card_number function with the specified card name.
find_card_number "$card_to_find"