For anyone looking for answers here:
I couldn't figure out a way to get cdparanoia
to output to stdout, but cd-read
from libcdio-utils
is able to output straight from the CD. You can use this command to play the CD:
cd-read -m audio -s <start> -n <sectors> --no-hexdump | pv -L 176400 | aplay -c 2 -f S16_BE -r 44100
This will read <sectors>
sectors starting at <start>
, throttle them to the correct bitrate, and play the output through the speakers. I used 0 for <start>
and 40000 for <sectors>
as a test, but you can get the correct values from cdparanoia -Q
.
If you want pv
to show the current position/length, add --size <sectors*2352>
to the end of pv -L 176400
.
EDIT: Here's a shell script that I wrote that can play CD's from the command line. You can type no arguments (first -> last), the start track (start -> last), the start and end tracks (start -> end), or ~
for shuffle (? -> ?).
#!/bin/bash
CDINFO="$(cdparanoia -Q 2>&1 | grep -E "[0-9]+\. ")";
TRACKS=$(echo "$CDINFO" | wc -l);
if [ $# -lt 1 ]; then START=1; else if [ $1 == '~' ]; then RAND=1; START=$(expr $RANDOM \% $TRACKS + 1); else START=$1; fi;$
if [ $# -lt 2 ]; then END=-1; else END=$2; fi;
while (true); do
STARTBLOCK=$(echo "$CDINFO" | grep " $START\. " | awk '{print $4}');
LENGTH=$(echo "$CDINFO" | grep " $START\. " | awk '{print $2}');
echo "Playing track $START...";
cd-read -m audio -s $STARTBLOCK -n $LENGTH --no-hexdump | pv -L 176400 --size $(expr $LENGTH \* 2352) | aplay -c 2 -f S1$
if [ "$RAND" == "1" ]; then START=$(expr $RANDOM \% $TRACKS + 1); else START=$(( $START + 1 )); fi;
if [ $END -ne -1 ]; then if [ $START -gt $END ]; then break; fi; fi;
if [ $START -gt $TRACKS ]; then break; fi;
done;