|
From: Fmiser <fm...@gm...> - 2012-01-23 00:47:00
|
> > Philip wrote: > > > > This one-liner runs on my Linux computer. > > > > "sox" converts the audio to 8 kHz sample rate, 8 bit depth, > > mono. "od" dumps the raw values. > > "cut" trims the first 9 characters off each line 'cause they > > are not audio levels > > "sed" removes extra spaces and then inserts a comma. > > "tr" removes the linefeeds so it becomes one long line. > > > > sox in.wav -b 8 -c 1 -r 8000 -t raw - |\ > > od -t u1 -v - |\ > > cut -c 9- |\ > > sed -e 's/\ / /g' -e 's/ / /g' -e 's/ /,/g' |\ > > tr '\n' ',' > out.file > Hendrikus Godvliet wrote: > > I am curios for what do you need this text data or what are > you doing with this text data? > I mean is it possible to change the audio data by change the > data in the text file and to convert it back in a .wav? Yes, I suppose you could. But I don't have a command to make audio again. My project was quite different. I work with a local drama group and we were doing the play "You Can't Take It With You". One scene calls for a small firework that can be lit on a kitchen table and called "red fire". Because of the dangers of real pyrotechnics inside a building we decided to fake it. I build three sets of bright red LEDs, mounted them to magnets, attached the magnets to the side of a cast iron pot. The actor sets the pot on the table and the LEDs shine on his face. Because the pot is tall enough, the audience can't see the LEDs, only the red light on the actor. But steady light won't look like a sputtering firework thing - so we used an Arduino microcontroller to independently drive the three channels of LEDs using pulse width modulation. The PWM needs an 8 bit value. We first tried random, which worked but didn't look right. So I took the sound of a sparkler sputtering, processed the audio a bit (lots of dynamic range compression, then applied the equivalent of a DC offset so the 0% values became 50%), then ran it through the above command to get values for a large array for the Arduino to step through. In the end, it really looked pretty good! Thing I consider to be key points: * three light sources not synchronized * bright - each channel was a set of four 20 ma LEDs driven at 50 ma. * trigged both on and off by a push button switch in the pot * battery powered - I used a 6-cell AA battery holder * easy - more or less. *smiles* Between building and programming it the two of us spent probably less than 6 man hours. * contain in the pot, so it's fully portable. -- Philip |