Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 820
c2h2 Avatar asked Jun 24 '11 09:06

c2h2


People also ask

What is the output of this cat Dev Urandom?

/dev/urandom is a continuous stream of random data. It will never produce an end of file. Buffered reads will fill the read buffer, so even if you are piping the output of cat into some other program, the read won't be terminated until the pipe is closed.

What is Dev SND?

The following /dev/snd/* device nodes shown in Figure 13.3 are created and managed by the ALSA core: /dev/snd/controlC0 is a control node (that applications use for controlling volume gain and such), /dev/snd/pcmC0D0p is a playback device (p at the end of the device name stands for playback), and /dev/snd/pcmC0D0c is a ...

What is Dev DSP?

/dev/dsp is the default audio device in the system. It's connected to the main speakers and the primary recording source (such as microphone). The system administrator can set /dev/dsp to be a symbolic link to the desired default device.


2 Answers

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 
like image 130
TomH Avatar answered Sep 20 '22 06:09

TomH


pacat /dev/urandom
Works on ubuntu without any additional installation.

like image 20
RedEyed Avatar answered Sep 22 '22 06:09

RedEyed