Friday, 11 November 2011

Unapplying Envelopes

If you haven't read applying envelopes, it would probably be a good idea.  Otherwise, I'll continue where I left off - after writing a program to apply an envelope to a soundfile, the reverse would be extracting an envelope from a soundfile.

If we're going to extract an envelope, we're basically approximating the sound wave.  The way I did this was by taking sets of or "windows" of samples, and then picking the sample with the biggest absolute (negative or positive) value to represent this window.  If we had a window of 1 sample, we'd just be copying the wave exactly, and so the envelope's not an approximation.  Actually, we want to lose all the detail of the waveform, and just get the rough, overall amplitude fluctuation.  That means taking a suitably large window.

Programming this was similar to the last problem, and didn't pose any major problems.  Once I got it up an running, the possibilities were endless.  Here are some envelopes extracted from various sounds:
A MIDI-sounding snare drum sample, enveloped with 1ms windows
When I enveloped a sample of a MIDI-sounding snare drum hit, I got this.  I took windows of 1ms (milliseconds), so I preserved quite a lot of the details.  It looks almost like there's a secondary peak before the sound dies away, maybe this accounts for the distinct sound of the snare drum.  Anyway, all sound samples are below and can be downloaded if you go through the my soundcloud thingy.

"moo" (15ms windows)
Next, for no real reason I tried it with a sample of a cow mooing.  Because I had a longer sound, and I didn't need the same detail as with the snare drum, I used windows of 15ms.  You can see the overall shape of the waveform pretty clearly.  There's no reason for the choice of sounds, they're not some kind of audio standard... or at least I doubt it. 

Finally I tried my program with a audio track i.e. a song.  Again, based on what was at hand, I made a random selection, and chose the J Dilla produced song "Move (part 2)".  Because of compression, the envelope of the whole song just looked pretty much like a solid block, so here is the first 3 seconds, again with 15ms windows:

J Dilla and Roc C - Move Part 2 (0:00 to 0:03), partially redeeming my street cred?
What was cool about this, was the envelope makes it really clear where the beat lies - the peaks are where the drum hits come.

The last couple of samples below are when I extracted envelopes and then applied these envelopes to other sound files.  The first is a snare envelope applied to a sine tone, and because of the detail, you get some of the frequencies of the snare sound too.  The last sample is the envelope taken from "Move (Part 2)" applied to a 440Hz sine tone.  The effect isn't that spectacular, but that's the thing with experimenting, often it isn't.


Enveloping by Boyley

No comments:

Post a Comment