LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Cant hear sound from "cat /dev/urandom > /dev/audio" (https://www.linuxquestions.org/questions/linux-general-1/cant-hear-sound-from-cat-dev-urandom-dev-audio-883996/)

hd_pulse 06-01-2011 02:41 PM

Cant hear sound from "cat /dev/urandom > /dev/audio"
 
Hello,

I found this command somewhere which claims to produce sounds
Quote:

cat /dev/urandom > /dev/audio
Quote:

cat /vmlinuz > /dev/audio
But it generates error:
Quote:

~$ cat /dev/urandom > /dev/audio
bash: /dev/audio: Permission denied
Quote:

cat /vmlinuz > /dev/audio
bash: /dev/audio: Permission denied

I tried it from root even then also :
Quote:

# cat vmlinuz > /dev/audio
cat: vmlinuz: No such file or directory

Is the above command fake?
Or I don't know to make it run?!?

Kindly teach me if its so.

andywebsdale 06-01-2011 03:36 PM

cat /dev/urandom > /dev/audio
should produce an annoying random noise. I would think you have to be a member of the 'audio' group to do this (on my Debian Wheezy system anyway)
When you submit a question, its probably a good idea to mention what Linux distro you're using(as the answer to your question could be very different depending on your distro) & perhaps some hardware details if relevant.
If you 'ls -l ' the file you've been denied access to, it will tell you which user & group owns the file (or device like /dev/audio )
e.g.
crw-rw----+ 1 root audio 14, 4 Jun 1 19:57 /dev/audio

MrCode 06-01-2011 03:38 PM

The issue is that you need to have root permissions to write directly to any of the /dev "files". Get to a root shell (or use sudo, if it's installed/configured, or if you're using Ubuntu :p), and then try the command.

What the command should do is produce white noise at an 8000 Hz sample rate. Make sure you turn your speakers way down before you do it, though…it's really loud.

EDIT: Ninja'd.

hd_pulse 06-02-2011 03:29 PM

I am using Ubuntu 10.10
I supplied the above command from root but nothing happened.
The prompt just went to the next line.

Quote:

root@hemant-G41M-Combo:/home/hemant# cat /vmlinuz > /dev/audio
root@hemant-G41M-Combo:/home/hemant#
do i need to download any package to run this?
Why ain't working then ?

andywebsdale 06-02-2011 04:12 PM

I'm not too sure about the "cat /vmlinuz" version - I just tried it and it scrolled the binary down the screen accompanied by system beeps. I'd never heard of anyone using that command before.
However the "cat /dev/urandom > /dev/audio " version should as MrCode says, produce white noise. I presume your sound works OK for "normal" stuff, like playing music or YouTube etc. If it does, then you haven't got much to worry about on the audio front, believe me.
The cat <file> >/dev/audio command plays *.au sound files I believe, but that type of sound file probably isn't even on your system.

MrCode 06-02-2011 06:09 PM

Quote:

The cat <file> >/dev/audio command plays *.au sound files I believe, but that type of sound file probably isn't even on your system.
Actually, AFAIK, cat <file> > /dev/audio (or /dev/dsp, if applicable) will play any uncompressed PCM audio file (*.au, *.wav) at 8000 Hz. I'm not sure if it has to be signed or unsigned, though. :scratch:

EDIT: /vmlinuz should yield similar white noise (although it won't be perfect), as the kernel image is compressed, and hence the entropy is higher (it would probably be more interesting uncompressed ;))…did you remember to redirect output to /dev/audio or /dev/dsp?

andywebsdale 06-03-2011 10:06 AM

I thought so too, although /dev/urandom is the only version that produces white noise for me. I tried re-directing a wav file but that produced the same result as /vmlinuz did. I have got pulseaudio installed, though - to use the dsp device the sound file has to be processed by 'padsp' for example, so I'm not suprised at these results. As long as my 7.1 sound works OK I'm happy,anyway


All times are GMT -5. The time now is 10:23 AM.