How to pipe /dev/urandom to linux sound output?
Asked Answered
C

3

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?

Chirp answered 24/6, 2011 at 9:1 Comment(5)
Trying to listen to the sound of randomness?Frigate
Does your sound work at all? ALSA frequently starts at boot Muted.Papaverine
yes, wondering if /dev/dsp is correct device?Chirp
I guess that means that with alsa/pulse it's no longer possible to write audio data to sound card as if it was a simple file; anyone to confirm ?Compliancy
@Jocelyndelalande Here is a working example how to write pcm data directly to the device file: github.com/igor-liferenko/pcmElectrotechnics
E
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
Excoriate answered 24/6, 2011 at 10:8 Comment(6)
any pipe way for this? from stdin?Chirp
@Chirp 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.Inimitable
White noise! (also prepending aoss or other compatibility layers should work)Saharanpur
Alternatively, this syntax also seems to work: cat /dev/urandom | aplay -t raw -f cd -Avent
@Avent 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.Reserpine
How can I get the aplay binary for armel CPU?Blastocyst
C
13

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

Carven answered 6/4, 2017 at 10:50 Comment(0)
C
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
Campeche answered 8/12, 2016 at 16:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.