|
|
@ -1,29 +1,34 @@ |
|
|
|
#!/usr/bin/env sh |
|
|
|
#!/usr/bin/env sh |
|
|
|
RECDIR=~/Recordings |
|
|
|
[ -z "$SXMO_RECDIR" ] && SXMO_RECDIR=~/Recordings |
|
|
|
OLDAUDIOF="$(mktemp)" |
|
|
|
mkdir -p "$SXMO_RECDIR" |
|
|
|
alsactl --file "$OLDAUDIOF" store |
|
|
|
|
|
|
|
mkdir -p "$RECDIR" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
restoreaudio() { |
|
|
|
getdur() { |
|
|
|
alsactl --file "$OLDAUDIOF" restore |
|
|
|
mediainfo "$1" | |
|
|
|
|
|
|
|
grep ^Duration | |
|
|
|
|
|
|
|
head -n1 | |
|
|
|
|
|
|
|
cut -d: -f2 | |
|
|
|
|
|
|
|
tr -d " " | |
|
|
|
|
|
|
|
sed -E 's/[0-9]+ms//' |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
record() { |
|
|
|
record() { |
|
|
|
|
|
|
|
PRETTYNAME="$1" |
|
|
|
|
|
|
|
DEVICE="$2" |
|
|
|
|
|
|
|
CHANNELS="$3" |
|
|
|
|
|
|
|
|
|
|
|
TEMPFILE="$(mktemp --suffix=.wav)" |
|
|
|
TEMPFILE="$(mktemp --suffix=.wav)" |
|
|
|
NOW="$(date '+%y%m%d_%H%M%S')" |
|
|
|
NOW="$(date '+%y%m%d_%H%M%S')" |
|
|
|
sxmo_megiaudioroute "$1" |
|
|
|
st -e arecord -D plug:"$DEVICE" -vv -f cd -c "$CHANNELS" "$TEMPFILE" |
|
|
|
st -e arecord -vv -f cd -c 1 "$TEMPFILE" |
|
|
|
FILENAME="${NOW}_${PRETTYNAME}_$(getdur).wav" |
|
|
|
restoreaudio |
|
|
|
FILE="${SXMO_RECDIR}/${FILENAME}" |
|
|
|
DUR="$( |
|
|
|
|
|
|
|
mediainfo "$TEMPFILE" | |
|
|
|
|
|
|
|
grep ^Duration | |
|
|
|
|
|
|
|
head -n1 | |
|
|
|
|
|
|
|
cut -d: -f2 | |
|
|
|
|
|
|
|
tr -d " " |
|
|
|
|
|
|
|
)" |
|
|
|
|
|
|
|
FILENAME="${NOW}_${DUR}.wav" |
|
|
|
|
|
|
|
FILE="${RECDIR}/${FILENAME}" |
|
|
|
|
|
|
|
mv "$TEMPFILE" "$FILE" |
|
|
|
mv "$TEMPFILE" "$FILE" |
|
|
|
|
|
|
|
echo "$FILE" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
recordconfirm() { |
|
|
|
|
|
|
|
FILE="$1" |
|
|
|
|
|
|
|
FILENAME="$(basename "$FILE")" |
|
|
|
|
|
|
|
DUR="$(getdur "$FILE")" |
|
|
|
|
|
|
|
|
|
|
|
while true; do |
|
|
|
while true; do |
|
|
|
PICK="$( |
|
|
|
PICK="$( |
|
|
@ -47,20 +52,51 @@ record() { |
|
|
|
done |
|
|
|
done |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
recordmenu() { |
|
|
|
while true; do |
|
|
|
while true; do |
|
|
|
NRECORDINGS="$(find "$RECDIR" -type f | wc -l)" |
|
|
|
NRECORDINGS="$(find "$SXMO_RECDIR" -type f | wc -l)" |
|
|
|
|
|
|
|
OPTIONS=" |
|
|
|
|
|
|
|
Line Jack |
|
|
|
|
|
|
|
Microphone |
|
|
|
|
|
|
|
System Audio |
|
|
|
|
|
|
|
($NRECORDINGS) Recordings |
|
|
|
|
|
|
|
Close Menu |
|
|
|
|
|
|
|
" |
|
|
|
OPTION="$( |
|
|
|
OPTION="$( |
|
|
|
printf %b "Line Jack\nMicrophone\n($NRECORDINGS) Recordings\nClose Menu" | |
|
|
|
printf %b "$OPTIONS" | |
|
|
|
|
|
|
|
xargs -0 echo | |
|
|
|
|
|
|
|
sed '/^[[:space:]]*$/d' | |
|
|
|
|
|
|
|
awk '{$1=$1};1' | |
|
|
|
dmenu -fn Terminus-30 -c -p "Record" -l 20 |
|
|
|
dmenu -fn Terminus-30 -c -p "Record" -l 20 |
|
|
|
)" |
|
|
|
)" |
|
|
|
|
|
|
|
|
|
|
|
if [ "$OPTION" = "Line Jack" ]; then |
|
|
|
if [ "$OPTION" = "Line Jack" ]; then |
|
|
|
record -l |
|
|
|
OLDAUDIOF="$(mktemp)" |
|
|
|
|
|
|
|
alsactl --file "$OLDAUDIOF" store |
|
|
|
|
|
|
|
sxmo_megiaudioroute -l |
|
|
|
|
|
|
|
FILE="$(record line dsnoop 1)" |
|
|
|
|
|
|
|
alsactl --file "$OLDAUDIOF" restore |
|
|
|
|
|
|
|
recordconfirm "$FILE" |
|
|
|
|
|
|
|
|
|
|
|
elif [ "$OPTION" = "Microphone" ]; then |
|
|
|
elif [ "$OPTION" = "Microphone" ]; then |
|
|
|
record -m |
|
|
|
OLDAUDIOF="$(mktemp)" |
|
|
|
|
|
|
|
alsactl --file "$OLDAUDIOF" store |
|
|
|
|
|
|
|
sxmo_megiaudioroute -m |
|
|
|
|
|
|
|
FILE="$(record mic dsnoop 1)" |
|
|
|
|
|
|
|
alsactl --file "$OLDAUDIOF" restore |
|
|
|
|
|
|
|
recordconfirm "$FILE" |
|
|
|
|
|
|
|
|
|
|
|
elif echo "$OPTION" | grep "Recordings$"; then |
|
|
|
elif echo "$OPTION" | grep "Recordings$"; then |
|
|
|
sxmo_files.sh "$RECDIR" |
|
|
|
sxmo_files.sh "$SXMO_RECDIR" |
|
|
|
elif [ "$OPTION" = "Close Menu" ]; then |
|
|
|
elif [ "$OPTION" = "Close Menu" ]; then |
|
|
|
exit 0 |
|
|
|
exit 0 |
|
|
|
fi |
|
|
|
fi |
|
|
|
done |
|
|
|
done |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ -z "$1" ]; then |
|
|
|
|
|
|
|
recordmenu |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
"$1" "$2" "$3" |
|
|
|
|
|
|
|
fi |
|
|
|