
Catting weird things to /dev/audio - mattyb
http://everything2.com/node/660740
======
RiderOfGiraffes
In 1979 I was debugging some Z80 assembler by putting a radio next to the
processsor and picking up the RF noise. I could tell by the quality of the
sound which loop it was in, and trace the execution as it happened. This was
on a device that only had a serial line as its interface, and the problem was
in the processing of the data, so it would occasionally just hang, making
"standard" debugging impossible.

Later (1980) when I wrote a BASIC to Z80 compiler I used the same technique to
profile the code and achieved a 5x speed-up by knowing which loops ran slowly.

------
cubix
Several years ago I was stuck in a data centre over night upgrading our
systems with other team members who were working remotely. I was desperately
tired and done my part, but had to wait around to monitor things while the
rest finished up. Instead of staring at the screen, trying in vain to keep my
eyes open, I put /dev/audio to good use by writing a simple script to wake me
when tcpdump picked up the traffic I was looking for. I was able to lay my
head down, guilt free, and steal 20 or 30 minutes of precious sleep between
testing sessions.

~~~
sown
Could you tell us more? This sounds like a near-epic hack. I have an idea of
how it would work. Whenever I tried dumping to /dev/audio it always came out
too fast.

~~~
joshu
could have been as easy as 'tcpdump port XXYY' and nothing was being output
until the event he was looking for... would have made a fast screech, i bet.

~~~
cubix
That was basically it. I knew I would start to see traffic on a certain port
when the service was restored.

------
philh
>a good place to start, would be yes > /dev/audio, which outputs a high
whining as the value 'y' is sent as audio over and over.

The key point of this combination is that yes outputs "y\ny\ny\n...". If you
just send one character over and over you don't hear anything - I think the
difference between adjacent character values determines the frequency of the
output.

>Plus if there are any sound files on your drive saved in a lossless format
they just play at random and then disappear back into the soup.

They need to be uncompressed (ie. contain raw audio data), not just lossless.

------
jodrellblank
One of the better stories I've read was the guy who piped the output of ping
to his speakers, turned the volume up, and went around the office wiggling the
token ring cable listening out for the place with the unreliable connection.

------
10ren

      cat /dev/urandom > /dev/audio
    

I use it as a white noise generator, to cover ambient noise at night. Anyone
know how to make a low pass filter (to make pink/red/brown noise)? I tried
repeating the random source, to increase the wavelength, but it gets little
R2D2 chirps and clicks in it (because of the step-like waveform):

    
    
      cat /dev/urandom | sed 's/./&&&&&&/g' > /dev/audio

~~~
mark_h
I know it's probably not what you're asking for, but if you just want a
white/pink/brown noise generator this is an excellent little flash app:
<http://www.simplynoise.com/>

~~~
10ren
Thanks, that's what I'm using at the moment. I'd prefer a local solution
rather than a webapp (but perhaps it doesn't make any difference?).

I tried their download brown noise loop, but it doesn't (always) loop
seamlessly, even using:

    
    
      mplayer /home/user/8usb/SimplyNoise.com\ -\ Brown\ Noise.m4a -loop 0
    

I also tried downloading their flash swf itself, but it doesn't run locally (I
expect it needs to phone home for the sound files).

~~~
kaens
You could try loading the swf in a browser, letting everything load up, and
then checking /tmp.

~~~
10ren
An intriguing idea, but nothing there unfortunately (guess they keep it in
ram.)

~~~
kaens
Weird. I would guess that would be browser/configuration dependent? I use
firefox for this, and whenever I load up a flash movie (to be honest, I
haven't tried it with anything else), it sits in ram until it's loaded, and
then it gets cached in /tmp as a file named something like Fla[0-9a-z]+ .

In about:config there's the options:

browser.cache.memory.enable

browser.cache.disk.enable

and related settings. Disabling the memory cache might let you grab it.

If I get the spare time today, I'll see if I can't get the swf to pull out.

------
SwellJoe
Many years ago this facet of Linux was the thing that really made me realize
just how astonishingly wonderful the central idea of UNIX (everything is a
file) really is. It also puts in stark contrast those systems that haven't
grokked this beautifully simple idea.

~~~
windsurfer
The irony is that the only reason Linus Torvalds spent so much time on Linux
in the early days is because he accidentally made his dialer program use his
minix partition to dial up his university. The dialer was fine with it... it
even 'talked' back, destroying the data. He couldn't re-install Minix because
he didn't have a copy of it. So he was stuck with Linux, and he was forced to
improve it if he wanted to use his expensive computer.

~~~
eru
Interesting. Sources?

~~~
windsurfer
<http://www.youtube.com/watch?v=WVTWCPoUt8w#t=22m12s>

------
windsurfer
It sounded like a dial up modem when I did this:

    
    
      cat /dev/mem > /dev/audio
    

Also, for some reason, this command makes it "beep" on every eleventh
character you type. Probably something to do with buffers.

    
    
      cat /dev/input/by-path/platform-i8042-serio-0-event-kbd > /dev/audio

~~~
eru
Or try it with core dumps.
[http://everything2.com/title/How%2520to%2520get%2520people%2...](http://everything2.com/title/How%2520to%2520get%2520people%2520to%2520clean%2520up%2520their%2520core%2520dumps)

------
erikwiffin
even more fun

    
    
      wget http://www.wikipedia.com --output-document=- > /dev/audio
    

Download a webpage, output to soundcard. Works pretty well, I need to find a
bigger page to work with though.

~~~
lucumo
In a way it sounds a bit like modems of yore connecting :)

Edit: For a cool audio representation of the file size, try comparing
Wikipedia with the Google homepage :)

------
swivelmaster
Is this possible on a Mac?

~~~
blasdel
Yes, but you'll need to do the mknod yourself, and have a program running in
userspace reading from the block special file (or fifo).

I've used portaudio from Python on OS X before for doing this kind of audio
manipulation.

------
windsurfer
Find all the .wav files and play them: find . -name '*.wav' -exec cat {} >
/dev/audio \;

I guess I don't have any at the right frequency, though :(

------
kaens
If you have a remote machine that has a microphone plugged into it, you can
use this to listen to what's going on in the room remotely.

------
joshu
From the original document:

> In order for noise to happen there must be at least some variation.

It's pretty neat. The data pretty much represents the position of the speaker.

Audio stuff is pretty fascinating; I read a great book on explaining DSPs for
audio processing. I'll have to dig it out of my closet.

------
chanux
Reminds me old days I tried to listen to the linux kernel :D. A small typo I
did filled up the terminal with lots of garbage. Later I learned I can rcover
such a situation with..

$reset

------
windsurfer
If your terminal gets messed up from catting random characters to stdout, type
'reset' and press enter.

------
barrkel
If you have Windows, you can play along to a degree using Cygwin and /dev/dsp
instead.

