Anyone who’s done audio editing has probably learned that if you cut off the audio at a sample far from zero you create a pop at that point. Signals that instantly drop to zero or instantly rise to some value are called step functions, a waveform that theoretically speaking contains all harmonics, and practically speaking makes an awful pop sound. In audio editing, you can just pick a sample at or near zero and like magic, there’s no pop. The alternative is to quickly fade to or from zero.
In an effort to improve sound quality when capturing audio to delay nodes in Audulus, I decided I needed to create a fast windowing function to create crossfades and or fade outs at the endpoints. I learned a bit about using Audulus to manipulate values at the sample rate.
I started with a module I made a while back to slowly modulate a value from one value to another over a number of steps, with slope zero at the start and end. To accomplish this I’d made a counter to count up or down a value n, stored n in a S/H node, then feeding the n value into an expression involving the cosine function (which has slope zero at angle 0 and pi). That expression scales the ends of the curve to fit the desired start and stop values.
To get this to work at audio frequencies, I needed an audio-rate clock signal. This proved to be out of the realm of the Osc and Phaser nodes, so I tried putting together a circuit that might generate it naturally. This is what I came up with.
The timer node responds to a step at the input. Any value above zero is fed through the unit delay back to the node, retriggering it. The result is an impulse that repeats at the sample Rate. We can’t really visualize it in Audulus, but its frequency can be measured by the Zero Cross node.
To get my counter to operate at the audio sample rate, I replaced the Feedback Delay node with a Unit Delay node. Although is does work reliably at the audio rate, the counter ended up working a little differently from what I expected, because the translation occurs over twice the value of N it’s fed. I’m guessing this might have to do with the use of another unit delay in the counter, but whatever the reason, it’s been useful enough to work in my loopers to create quick crossfades (that’ll be coming out pretty soon, once I get some operational bugs worked out.) One application would have it drive the c input of a cross fade node, accomplishing a smooth cross fade between a and b inputs.
Here’s the experimental setup, which helps explain why I was trying to build an o-scope!
Sample Stepping Crossfade controller.audulus (1.2 MB)
In the setup in the attached patch, I’ve set up the module to translate from -2 to 1 (those values can be any value and don’t need to straddle zero).