enigma_0Z
Joined: Jun 06, 2011 Posts: 1 Location: Jupiter
|
Posted: Mon Jun 13, 2011 8:39 am Post subject:
High Pass Filter cutoff freq changes cause clicks?? Subject description: Changing my HPF freq makes the sound click, even if output is cut while the freq is changed... |
 |
|
(If you follow the ChucK mailing list, you'll notice this looks familiar. I prefer message boards to mailing lists, but whatever you like doesn't really matter to me. I figured a solution would be advantageous to more than a few.)
First, a bit of context. I'm working on a subtractive synth program for ChucK, in ChucK, and have run across some (annoying and anomalous) clicks in my patch. If I play a low note, and then a high note, the patch produced a click just prior to the sound, similar to if you patch into the DAC while a sound is already being produced. I tracked it down to my high pass filter, which I was changing dynamically based on the key I was playing, to produce something that resembles MIDI key tracking - the higher you go, the higher the cutoff freq on the filter, the lower, the opposite. I do the same with an LPF without any issue, but for whatever reason, the high pass filter, whenever it changes drastically, whether or not the program is actually issuing sound at the time, there's a pop.
I've written a small program that illustrates the example by itself, with a little bit of additional code for experimentation. The program just jumps back and forth between two midi note numbers, changing the HPF value akin to how I was changing it in my original patch. If you make the HPF static, there is no issue any more. If you set the sound to fade in and out, there isn't an issue, but I think this is more just masking the problem than anything.
Anyway, the example code is here: http://pastebin.com/vc2W0UNW ... There's only 41 lines of code, but with my comments explaining it, it's more like 80 lines. The offending line is #54 - comment that out and no more pop. The attack/decay stuff has no effect on whether or not it clicks, except that a slow attack (fade in) masks it. You can take out the Attack/Decay code and replace that with a chuck to now (like noteLen => now) if you want to just peel that bit out. If you want to experiment with a static HPF, lines 37 or 38 can be used to set that up when you comment out #54, and that conclusively gets rid of the click.
There is still a small pop if the filter is set real high, but considering it's a "high pass" filter, I'm ready to write that bit off as the nature of the beast. That pop is nothing like the one I get from changing the filter around... FWIW this doesn't happen with an LPF IME.
It also seems that it's not actually affected by how the HPF is related to the output freq, if you change the *4 to *1 on line 54, it actually gets louder, at least to my ears.
Does anyone have a suggestion or idea as to what to do? |
|