Construction of FIR filters in Reaktor?
Hello everyone. I want to be able to create a relatively simple FIR filter (specifically lowpass, highpass, bandpass, notch and the like) for a DWG ensemble I'm working on. The reason I want to use FIR filter is because the default primary Reaktor filters (which I assume to be IIR) alters the phase of the delay line which in turn changes the pitch, which I want to get rid of easily.
The idea of using an FIR filter popped straight into my head when I found this reply (#10) by Robin Davies on decoupling the pitch delay from filters.
The only issue here is that I have no idea how to properly construct a filter, because my knowledge of maths is a little behind compared to most DSP people, so I want to learn how this can be done.
Thanks, cs5947
Comments

There's no easy way to solve this, and it's hard to recommend anything without more information on the context: which filters are you using, with which purpose.
A FIR filter is just a polynomial on the input, so implementing it in Reaktor is trivial. What is not trivial is getting the coefficients for a given response. There are different methods for different kinds of responses. All of them are complicated and very difficult to implement in Reaktor. When people use (nontrivial) FIR filters in Reaktor, they compute the coefficients somewhere else. It's not reasonably possible to implement variablecutoff FIR filters in Reaktor.
If I were doing this, I'd use IIR filters and compensate for their phase delay. The phase delay formulas for simple filters are not that complicated. For example, for a 2pole lowpass you have
where fc is the filter cutoff and f is your frequency of interest. This gives a result in samples which amounts to the delay caused by the filter at that frequency, so you would subtract that from your delay time. As Robin explained, you'll get the fundamental in tune, with the harmonics slightly skewed. The arctan there is the "a" output of the xy2polar macro, tan[pi f/sr] is the output of the "F to half w" macro.
Of course, this means learning how to compute the phase delay of your filters. Learning how to model linear phase FIR filters with arbitrary responses is not any easier though.
2 
remember that filter you made on the old forum... that got linear phase by IIR filtering backwards and forwards?
found it, its here:
might this be helpful for what OP wants to do? i don't understand karplus strong or DWG well, but in that thread robin davies said the latency in samples could be subtracted from the delay line... not sure how that would work but robin davies said it so afaict the principle is sound?
@cs5947 so this filter as stated above the filters in the ensemble get a something like a FIR by filtering twice, once forward and once in reverse... this requires splitting up audio into chunks for the reverse part which introduces latency (as would be the case with a proper FIR) and if i remember correctly the window size for this process is adjusted here:
the advantage of course being regular modulatable control of cutoff instead of having to dink around with coefficients. one thing to note is lower cutoffs need larger window size as to not truncate the impulse response of the reverse pass... also given that it uses SVFs you can get lp bp hp (and i believe notch as well) but as the filtering is performed twice you'd be stuck with 4p. its kind of a goofy concept but if it has one application it seems your desired use case could possibly be it!
1 
I actually did some work on this like a month ago, but life is being such a hog (?) that I didn't have the time to write the corresponding overlong comment π
1 
my level of executive function can understand that. without even being very busy. if the world's a hog, surely it is one of the feral texas hogs (dumb and wants its bite of everything. lacks general manners)
if i had to guess about this business with FIRs, i'd say you you probably went with a more conventional solution for getting coefficients rather than messing around with the filter that attempts two things at once to affront time
i mean ig you could have used it, just doesn't sound like your style.
people tell me my style is not understanding how time can be subtracted from a delay line and assuming its impossible.
ohhhh, wait, its must be figuring out how much delay the filter is adding and subtracting that from the delay frequency calculation. lol don't mind me.. took a minute to work out how subtracting time didn't mean breaking causality. long feedback delay lines must be poorly represented in my mental model
0 
I have used simple FIR filters long time ago and calculated coeffitiens somehow. It was pretty straightforward, but I do not remember how exactly I did it. I needed to smooth hispeed camera measurements for my dad's research....
I know the only thing. I have started with polynom describing filter in complex plane. And got somehow the coefittients. It was easy. Then I converted it to marix interpretation (continuous state space). Again, easy. Then I made simple conversion to matrices in discrete state space and then to polynomial in zplane.
The most difficult part was to find way to convert matrices from continuous state space to discrete one, but I have found the way. It took me week or two. I had a lot of time as beeing at obligatory military service and nothing to do really for one year....
It was 20+ years ago, so I do not remember more. I am not sure, if I would be able to find the math equations I have used that time. I still may have notes somewhere in heaps of sheets of paper. And I have for sure the source code in Pascal. What I definitely know, I lost my math ability to discover it again. :(
1 
You can play around with this filter, It's low or high pass with a variable slope. Haven't noticed any pitch changes. It's similar to simple analog filters using an all pass circuit to create a phase shift and the phase shift is used to create the filter slope. Seems the simple subtraction filters like this sound pretty good.
This is a notch with a variable depth.
Flipping the switch changes it to a variable depth band pass.
This is a graphical representation of the filter, you need to remove the sine input and use the audio in and remove the graphic stuff for a simple filter. These are all one pole and seems to work well for most audio applications of natural instruments in a mixing environment.
0 
you say simple but it sounds like magic to me. tried to get coefficients from a website once for a FIR lowpass across FFT frames (very interesting that filters can be constructed around FFT frames like that) . realized i was out of my depth and resorted to a simple moving average lol
0 
It was simple to calculate coeffitients of filter. At the end. Just few matrix multiplications. There may be simpler way, but back then I had no book on digital filters. That time personal computing was at very beginning... I have studied automatic control, but we did mostly analog domain stuff, and just a bit digital....
I was happy to find transformation from continuous state space to disctere one. As we were not taught how to do it at my university lessons....
0 
Like Loriano says, It's very easy to integrate but very difficult to differentiate. I think differentiators cause excessive overflow. Since the two functions are complimentary, there might be a way to extract the differential from the integral. That's why I like the above filters. You can also string these simple filters for sharper slopes. But look at the two filters with the above file. The fir has a delay and also has an inconsistent rolloff frequency.
0 
Well, differentiate is easy  one just substracts two following samples.... But yes, there may be problem if one divides by difference. It may be zerro or close to zerro.... And leading to overflow. Not sure if that may happen in FIR filter.
1 
Yah man, I was thinking about an integrator and a differentiator though. Sorry I didn't explain that well. The two functions are inverse functions. We have an integrator in the library but no differentiator. Loreano told me once that a differentiator is best to avoid for some reason. Wish I could tell ya more but I didn't study the calculus so I'm illiterate. Just saying the subtraction filters seem to have little idiosyncrasies. Probably because their phase shift is limited from 0 to 180 degrees.
0 
Well it depends, there is differentiation and differentiation...
If we speak about filters in zplane one massively diferentiate, but I guess it works OK. It looks like black magic. but it is relatively simple math. It is much more straitforward to implement digitally than anything in complex (p/s) plane. (That is why I took analog FIR filter design and mathematically transformed it to zplane representation, which is easy to implement, just few substractions, multiplications and maybe one division..)
But I guess Loreano spoke more about general, "analog" (non zplane) design, where one needs implement differentiator and that product from differentiator is later on somewhere used as divisor.
0 
I don't understand much, only took pre calculus . Made analog filters with op amps for the band. Mostly speaker crossovers and shelving filters. It's crazy though how a filter can cause a pitch change, why would the delay modulate to even cause such a thing. The whole thing is bizarre.
0
Categories
 All Categories
 21 Welcome
 2.1K Hangout
 85 NI News
 1.4K Tech Talks
 2.3K Native Access
 13.3K Komplete
 1.3K Komplete General
 2.8K Komplete Kontrol
 3.8K Kontakt
 3.5K Reaktor
 327 Battery 4
 596 Guitar Rig & FX
 315 Massive X & Synths
 701 Other Software & Hardware
 4K Maschine
 4.9K Traktor
 4.6K Traktor Software & Hardware
 Check out everything you can do
 Create an account
 See member benefits
 Answer questions
 Ask the community
 See product news
 Connect with creators