Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Currently I am trying to use cdparanoia to play from an audio cd directly without making any temporary files. I can play the first track of a cd realtime by doing

cdparanoia -e 1 /dev/shm/tmp.wav 2>/dev/null &
play /dev/shm/tmp.wav

however I don't want to use this method because it makes temporary files, sometimes my /dev/shm is full and because I want a more elegant solution which can be written in one line.

I tried two solutions on Linux using bash.

The first:

cdparanoia -e 1 - 2>/dev/null | play -

did nothing. The second:

cdparanoia -pe 1 - 2>/dev/null 1>/dev/sound

This just made random scratching sounds showing that the data is not formatted correctly. I suspect it may be 16bit instead of 8bit.

If anyone has a solution let me know. I am looking for a POSIX Bash solution in one line with no temporary files.

share|improve this question

1 Answer 1

I know, very old question, but nobody answered ...

Piping cdparanoia output directly into an audio output sink is not very practical. The first problem is that any sort of error detection and correction will not be done in real time, in fact it will take as long as necessary to get the correct output. Even when there are no errors detected, the repeated overlapped reads mean that it is unlikely to produce output in real time. Lastly, even with all the detection and correction modes turned off (PARANOIA_MODE_DISABLE), the library reads massive chunks of data at a time (over 10 seconds worth) to enable multiple passes over that data. Then it dumps that and tries to get another 10 seconds, meanwhile your audio is likely to pause even on the fastest drive and CPU.

Running cdparanoia with a small cache (1-2 seconds) and with all error correction disabled, you can get data out of cdparanoia in real time. The -p option will produce 16 bit raw PCM data. 16 bit should be fine. You may need to specify the endianness using -r/R. I don't think you can just pipe raw audio into /dev/sound any more, that's from the history books, but depending on your sound drivers maybe it will work. Piping to play is a better idea, but play could be anything so hard to say what options you'd need. aplay is handy with alsa but you will need to tell it what the raw data is, something like: aplay -c 2 -f S16_LE -r 44100

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.