[sharing is squaring] decomposing a signal into squarewaves, and reconstructing it again

    Jul 13 2017 | 1:47 pm
    This came up in a different thread (https://cycling74.com/forums/efficient-constant-q-transform ) but I thought it might be interesting for some people on here to explore. It's a Haar wavelet analyzer/synthesizer in gen~. This is probably the simplest and most naive of all wavelet basis functions -- it's a single period of a square wave. The analysis is a bit like a fourier transform using squares instead of sines. The advantages are that this can be fairly easily done in the time domain, resynthesis can perfectly reconstruct the original, the number of bins is more manageable and more naturally spaced. The main disadvantage, and the reason why this analysis/resynthesis method is rarely used, is that most transformations in the encoded domain add aliasing artifacts. Which is not surprising: each encoded band is a kind of bandpass filter by sampling rate decimation. Nevertheless it serves as a simple introduction to wavelets, and has some nice crunchy distortion when that is needed.
    The patcher has a couple of examples of transforms in the haar domain, including amplitude scaling and 'spectral' delay. Maybe an interesting trick I came up with (not sure if this is used elsewhere) is in interleaving the haar domain signals in a kind of fractal structure, which has the advantage that samples for each bin are evenly spaced, rather than chunked as they would be in the ordered wavelet transform (and which would make building delays a lot more messy). Curious if anyone finds other interesting ways to build on this.