Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .