Created
May 8, 2020 23:30
-
-
Save shikaan/23e057207c564d08586c2043d96c0a71 to your computer and use it in GitHub Desktop.
Use ALSA to perform loopback record
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
DATE_HASH=$(date '+%Y%m%d%H%M%S') | |
DEFAULT_LOCATION="$HOME/recording-$DATE_HASH.wav" | |
printf "\e[1mCreating loopback devices...\e[0m\n\n" | |
sudo modprobe snd-aloop | |
RAW_LOOPBACK_DEVICES=$(aplay -l | grep Loopback | sed -E "s/card\s([0-9]+).*device\s([0-9]*).*/hw:\1,\2/g" -) | |
LOOPBACK_DEVICES=($RAW_LOOPBACK_DEVICES) | |
printf "\e[1mFound loopback devices\e[0m\n" | |
printf '* %s\n' "${LOOPBACK_DEVICES[@]}" | |
USED_DEVICE=${LOOPBACK_DEVICES[${#LOOPBACK_DEVICES[@]}-1]} | |
printf "\n\e[1mSelect \e[7m$USED_DEVICE\e[27m as default ALSA device\n" | |
read -p "Press Enter to continue..." | |
printf "\n\e[1mRecording using \e[7m$USED_DEVICE\e[27m on \e[7m$DEFAULT_LOCATION\e[27m \n(Use Ctrl+C to stop)\e[0m\n" | |
arecord -D $USED_DEVICE -f cd -vv $DEFAULT_LOCATION |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment