Haar DWT POC Lab
Haar wavelet decomposition (DWT) proof-of-concept lab
DESCRIPTION
For real-time stuff, check out the Fast Wavelet Transform project: http://www.native-instruments.com/en/reaktor-community/reaktor-user-library/entry/show/10025/
* check the bottom for edits/updates *
THIS IS ABSOLUTELY USELESS EXCEPT AS A DEMONSTRATION. Moreover, it is badly coded. However, if you would like to see an implementation of the Discrete Wavelet Transform using Haar wavelets in Reaktor, then this is the (only?) place to go - at least for now.
THIS IS A DEMONSTRATION ONLY. The ensemble is setup as a walk-through lab where each step demonstrates a step of the decomposition/graphing/recomposition process. It is not designed to be used with other instruments/macros/ensembles/whatever. Its sole purpose is to walk through 6 or 7 steps to show that the DWT is possible in Reaktor (well, duh).
THESE PROBABLY AREN'T THE WAVELETS YOU'RE LOOKING FOR. These are the wrong kind of wavelets (and probably the wrong transform, too) to use for serious audio analysis, by which I mean editing audio via a frequency/time/magnitude plot. The Haar wavelet is the simplest to implement, and I chose it because, well, this is a proof-of-concept (and I'm not very good at Reaktor, yet).
THIS IS HARD TO MAKE WORK PROPERLY. Even though I tried to document it extensively (via the Ensemble's Info Property), you still have to know how to import audio files into Event Tables, and you have to use audio files that have a number of SAMPLES equal to a power-of-two (up to 65536). Well, you don't HAVE to - it's actually an exercise to see what happens when you don't. I've included two WAV files (that probably won't play in WMP) for demonstration purposes: "sound_65536.wav" (a frequency sweep at 44.1khz) and "cup_zpd.wav" (a spoken sentence at 11,025Hz).
THE CODE IS AWFUL. Please feel free to scoff at my abominable code, but know that such activity provides absolutely zero value - at least to me. I already know it's terrible, and very buggy too. The actual Haar code is in Core and it's not too terrible, but it's also the easiest bit in the whole thing. Do not expect to be able to use the code as a reference for your own project - I can barely reference it myself for this project.
So... why did I post something so poorly-executed? Because as of May 4, 2016 (in the US) there are zero projects in the User Library utilizing wavelet technology (they've been around since at least the '90s) and I thought that if I posted a particularly bad project (the kind I'm capable of) then lots of other people would think to themselves, "Surely I can do better than THAT!" - and then they would!
Ok, I think that's enough disclaiming. Try it out and make a pretty graph. In a future release I am going to put a Mouse Area over the graph and make the coefficients adjustable by clicking/dragging or whatever. But for now you have to just draw on the "COEFFICIENTS" table which, if you don't know about DWT decomposition, is going to be somewhat counter-intuitive.
For more info about wavelets in general check out this horrible website (with very good info): http://users.rowan.edu/~polikar/WAVELETS/WTpart1.html
To read up specifically on the Discrete Wavelet Transform, check out: http://users.rowan.edu/~polikar/WAVELETS/WTpart4.html
EDIT: there was a bug where the magnitude of the "Y" min and max of the "COEFFICIENTS" table was not large enough to hold the lowest frequency data for the frequency sweep WAV, thus causing the lowest frequencies to be chopped off. I fixed this now in ver. 0.0.1 so now there's only the mysterious "click" about 2/3rds of the way through the reconstructed WAV to figure out.
EDIT: I found several indexing errors that are now corrected. Currently there is/are bug(s) which cause the 40,239th and 63,292nd values out of 65,536 to be off by more than 1e-8 (they're off by more than 1, actually) using the freq. sweep sound file provided. These are detectable as audible "clicks" while playing back the reconstructed signal. Why those two? No idea, yet. Otherwise reconstruction errors are typically on the order of 1e-8, which isn't too bad.
EDIT: cleaned up the code a bit and made sure there's a file properly loaded when you first load the ensemble.
EDIT: seems like I fixed the recomposition errors indicated above. I don't know why, exactly (I just did some housecleaning on the thing), but the clicks are gone.
COMMENTS (17)