Inspired by Antonio Roberts’s excellent tutorial on how to databend with Audacity, and following on from my previous tutorial on how to data bend audio, this post explores how to glitch audio using image software. Many of the required tools use the command line. This will work with linux, unix and mac. If you want to use windows, you will need to edit the autobmp.sh bash script so that it does not use the /tmp directory.
You will need
- The autobmp.sh script
- Imagemagick (You probably already have this if you use linux.)
- BASH (you already have this if you use linux or if you have a terminal on your mac)
- A utility to convert between audio formats that supports the .au format. I use sox, which is cross-platform and available via apt-get.
- Audacity
Why these formats?
.au and .bmp are both uncompressed formats, so every sample of audio becomes the R, G or B value of a pixel. AIFF and WAV files are also uncompressed, but the files have more structure to them that is not sound data, so .au seems easier.
Getting Started
10 seconds of a sawtooth wave
Using sox to convert between uncompressed audio formats is really easy. To convert a file called foo.wav to an au file, you would just type: sox foo.wav foo.au It looks at the extension and does the right thing.
Put the script in a directory in your path, OR just put it in your current working directory.
Once you’ve got foo.au, to convert it to a bmp, you’d type: ./autobmp.sh foo.au foo.bmp This will give you a file called foo.bmp, which is the bmp image of your audio.
Let’s say, you’ve done a bunch of transformations and now have a file called bar.bmp. To turn that back into audio, you would type: convert -depth 16 bar.bmp rgb:bar.pcm It is now back in an audio format, but the header has gotten slightly tweaked, so we’re not done. Open Audacity, and under the File mean, select, ‘import’ and then ‘raw audio’. Pick bar.pcm in the file chooser. On the popup window, tell it that the file is ’16-bit linear’ and ‘little endian’. There will be a few samples of crap at the beginning of the imported audio. That’s what’s left of your old .au header. you can delete it if you want. there will also be a bit of silence at the end of the file. This was padding added to make the image rectangular. To convert this into AIFF or WAV or MP3 or whatever, select ‘Export’ from the file menu.
If you have ended up with a different image format, such as jpeg or whatever, you don’t need to first convert back to bmp. To get from baz.jpeg back to audio, use convert directly and carry on as above. convert -depth 16 baz.jpeg rgb:baz.pcm
What to do while it’s a graphics file?
This is the creative bit! Converting to a lossy graphics format, such as jpeg adds some noise, so that might be fun. If you do that, you can glitch the jpeg by opening it in a text editor and doing a bit of typing at various points in the file. This causes weird visual distortions, which will become audio distortions when you convert back.
You can also try opening the graphics file in a graphics program. Some of the graphics effects may make interesting sound changes, although many won’t. Experimentation is needed. You can also try drawing on the image. Wide lines of a solid colour will create weird DC offsets, so if you want to avoid that, consider either using very thin lines or else setting an opacity of under 100%.
Have fun!
Music commissions make great gifts. Order now for this holiday season!