26

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?

c2h2
  • 11,911
  • 13
  • 48
  • 60

3 Answers3

33

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
TomH
  • 8,900
  • 2
  • 32
  • 30
  • any pipe way for this? from stdin? – c2h2 Jun 24 '11 at 10:32
  • 1
    @c2h2 So, it would be fun to pipe it directly from stdin, but there is not enough energy to register. Specifically most typing is not at an audible rate. You would need to upshift the signal which can be done via piping it from your own program. This is how you make friends and enemies in cube world. – Mikhail Nov 30 '12 at 04:19
  • White noise! (also prepending aoss or other compatibility layers should work) – minmaxavg Aug 04 '14 at 14:31
  • 5
    Alternatively, this syntax also seems to work: `cat /dev/urandom | aplay -t raw -f cd -` – sdaau Jan 25 '15 at 11:58
  • @sdaau That's not merely a syntax change, your solution unnecessarily uses cat and a pipe, so it's not advised to do it that way. – Matthew Mitchell Jan 09 '16 at 11:42
13

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

RedEyed
  • 2,062
  • 1
  • 23
  • 26
2
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 10 | sed 1000000000q |aplay

cat /dev/urandom | tr -dc '0-9' | fold -w 10 | sed 1000000000q |aplay

cat /dev/urandom | tr -dc '0-9' | fold -w 10 | sed 1000000000q |aplay



cat /dev/urandom | tr -dc '&*(&(^)' | fold -w 10 | sed 1000000000q |aplay

cat /dev/urandom | tr -dc '&*(&(^)' | fold -w 10 | sed 1000000000q |aplay

cat /dev/urandom | tr -dc '~`!@#$%^&*()' | fold -w 1 | sed 1000000000q |aplay

cat /dev/urandom | tr -dc "0-9a-z" |aplay

cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 |aplay -r 192000
eli-k
  • 10,898
  • 11
  • 40
  • 44
Mihai
  • 31
  • 2