Search code examples
linuxalsapulseaudio

How to pipe /dev/urandom to linux sound output?


This doesn't seem to work at all:

cat /dev/urandom > /dev/dsp    #from wikipedia.org

Is it because of pulseaudio? or I need to do some settings?


Solution

  • I'm not sure there is a simple device you can just send the bytes to these days - the /dev/dsp device is an old OSS thing and probably won't exist on a modern ALSA based system where the sound card is controlled by the devices in /dev/snd.

    You're probably better off using aplay or something to "play" the data from /dev/random though you will probably need to give it a load of switches to tell it what format to assume the data is in. To make it play as if it were WAV data you want something like:

    aplay -c 2 -f S16_LE -r 44100 /dev/random