StuffShell to Wav - Shell scripts!

 
 
 
   An experiment in creating .wav samples from the /dev/urandom!
 
 
 
wave1.png wave2.png wave3.png wave4.png

 

 


 
Download:

 
Includes starter wav, a whole bunch of shell scripts, a sample mp3, and a logic file with .exs instruments.




This was a little experiment in using the shell & /dev/urandom to generate some .wavs , as the tittle suggests...

First I took a single crotchet note in Logic Pro, and bounced it at full and zero volume to discern the differences.  - much quicker than studying the headers =)
(okay, later I found this to be untrue)

For the record, I'm ripping this straight from an Email, and cant rightly remember what I did..

Anyway, after comparing with hexdump -c, i found that the header ends after roughly 64 bytes and the metadata started about 89000 bytes later, so I found it was safe to mess with  bytes 64 to 88000+64 bytes, containing the raw data.

Anyway, here's how it went:

cat /dev/urandom | dd of=/wav1.wav bs=1 count=88000 oseek=64
Piping the random number generator into the data part of the .wav,
1byte at a time, 88k times, from byte 65.

Used cat instead of dd, basically on account of it being much
harder to make a big mess from a little oversight.. 

So yeah, I made white noise from a blank file. Win!

As I wrote in the original email:
Kinda reminds me of having something draw random pixels
within a given space :
As much as you want it to draw pictures, it just doesn't happen.
Sure someone once must have heard something strange in 
white noise, but I guess the odds are stacked..


Next mixing it up a little:

cat /dev/urandom | hexdump -C | hexdump -C | dd of=wav2.wav

So with the output being ASCII chars, with many repeated symbols
the dump produced a much more uniform sound  - with a bit of hiss in there.

After debating for a while whether ASCII data alone would produce enough variation in waveform, I figured that the four byte grouping of the integers probably would since the 2nd 3rd & 4th bytes represent an increases by the power of 16..
(or as a float.. general insanity)



             At this point, i'm just pasting from the email completely..


So yeah, I found an old shell script that draws a fairly dull chess board in the terminal, and figured it could be tuned to produce a buzz or a tone, due to the repetition of patterns ..  black/white/black/white/black/
white,  I included these scripts, and some to 'compile' - You can try getting different tones and buzzes just by altering patterns, and words within the string section of the nested loops.


So, with no real attack/decay, you get a fairly square wave.. woo.. yay.. etc!
Also - very interesting things at lower / higher frequencies, i.e. if you make then an EXS instrument in Logic - chirps, and so forth.

To overcome this, i thought about combining a pattern with randomish data XORed
over etc, or taking every 2nd float from another file, but... right now just cant be bothered.

A couple of other ideas:

having the speech program dump words to an audio file, as opposed to speakers,
'say -o  output.aiff hello!'

and
 
using dd to copy a header directly to the first sector of a hard disk... then using
/dev/disk2 as an audio file.
This was noisy, but as it found preexisting waves,stored randomly as remains of mp3s, wavs etc, VLC began trying to read those... mostly garbled, but quite interesting!


Well, that's basically about it, here's a list of the files...
you might have to:
cd ~/Desktop    ( assuming it's on the desktop)
then
chmod +x *.sh     
to be able to run them,
then just do 
./ch.sh          to compile the first wav,   
./ch2.sh       for the second , etc.


They all use starter.wav as a template.

ch -  random gibberish data.
ch2 - gibberish, through hexdump, almost produces a tone.
ch3 - the chess program dumped.
ch4 - the chess program with random-er strings.
ch5 - another, different tone.
ch6.- another take on the same thing..
ch7 - similar
ch8 - WOP!  dumped from the speech thing.

./chess  and  ./chess2 can be run standalone, for the record...







 
     
All material (C) 2006-2009.
Musical content protected by www.musiciansunion.org.uk/ 

Last update : 03/05/2009 : 17:59 || Page read 400 times ||   Text Only


react.gifReactions to this article


Nobody gave a comment yet.
Be the first one to do it!


 How about leaving a message and playing with the poll? Fabulous prizes to be won!