A Collection of Useful C++ Classes for Signal Processing
-
- KVRian
- 1091 posts since 28 May, 2010 from Finland
I want to be able to modulate the parameters with custom envelopes.
Wonder if I could use a shorter transition length e.g. 64 samples in the SmoothFilterDesign and then kind of interpolate the frequency points in the interval of 1024 samples. So that every 64 samples the next cutoff frequency (for the next 64 samples) would be calculated by a custom envelope, which may not be linear.
But this wouldn't work smootly with transition length = 1, even if the parameter changes would be very small? Surely the transition of the SmoothFilterDesign cannot be smaller than very small, since it seems like it's linear? So I could merely recreate the same transition, by reading processing one sample at a time?
Or how else would one create e.g. a LFO controlled filter using this lib?
Wonder if I could use a shorter transition length e.g. 64 samples in the SmoothFilterDesign and then kind of interpolate the frequency points in the interval of 1024 samples. So that every 64 samples the next cutoff frequency (for the next 64 samples) would be calculated by a custom envelope, which may not be linear.
But this wouldn't work smootly with transition length = 1, even if the parameter changes would be very small? Surely the transition of the SmoothFilterDesign cannot be smaller than very small, since it seems like it's linear? So I could merely recreate the same transition, by reading processing one sample at a time?
Or how else would one create e.g. a LFO controlled filter using this lib?
-
- KVRer
- 22 posts since 20 Feb, 2013 from So Cal
I still don't believe you will get usable results 1 sample at a time. It sounds like you want to modulate a parameter with something like a sine wave (or triangle, sawtooth, etc.) I believe you still need to do it in sample blocks. Every 64 samples you update the parameter you're modulating. I wouldn't go smaller than 64. You probably don't need smaller than 128 which is ~2.5 milliseconds at 48 kHz. The transitions will still sound smooth unless you drastically change the params.
-
- KVRian
- 653 posts since 4 Apr, 2010
It's been a while since I've looked at this library (and it doesn't run on my current system without recompiling, and the project needs a bunch of changes to do that, so no quick look for me), but in a nutshell, this library isn't well-suited to what you're trying to do. For example, direct form biquads are not well-suited to modulation (they're stable when linearly interpolating the coefficients between two points for smoothing, but not necessarily accurate, for instance). It's a lot simpler to modulate a parametrized (single variables for frequency, Q, gain) filter. There are other coding details that would make it more convenient for having modulation elements, but the parameter issue is a sufficient reason this library is probably not what you want. It does other things well, but is not a good fit for you, I think.Fluky wrote:I want to be able to modulate the parameters with custom envelopes.
...Or how else would one create e.g. a LFO controlled filter using this lib?
My audio DSP blog: earlevel.com
-
- KVRian
- 1379 posts since 26 Apr, 2004 from UK
One of the drawbacks is that the coefficients are functions of the roots of the polynomials, and changing the roots (changing the frequency for instance) can make big changes in the coefficients. A small explanation on the 4 different usual forms: https://ccrma.stanford.edu/~jos/fp/Four ... Forms.html
-
- KVRian
- 1091 posts since 28 May, 2010 from Finland
So any alternatives/pointers, if this is not a library suited for real-time parameter modulated filters?
Was looking at AudioTK, but can it automate Q and gain as well?
I thought the DSPFilters library does have "parametrized (single variables for frequency, Q, gain) filters"? Since it has those parameters?
Was looking at AudioTK, but can it automate Q and gain as well?
I thought the DSPFilters library does have "parametrized (single variables for frequency, Q, gain) filters"? Since it has those parameters?
- KVRAF
- 12555 posts since 7 Dec, 2004
What is the purpose of the filter? Are you trying to use this in a subtractive synthesizer?
This lib as far as I'm aware is aimed at accurately designing static filters like those used for EQ or anti-aliasing filters.
If you want a generic four pole lowpass filter with frequency and feedback parameters, try this thread:
http://www.kvraudio.com/forum/viewtopic ... &start=285
This lib as far as I'm aware is aimed at accurately designing static filters like those used for EQ or anti-aliasing filters.
If you want a generic four pole lowpass filter with frequency and feedback parameters, try this thread:
http://www.kvraudio.com/forum/viewtopic ... &start=285
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.
-
- KVRian
- 1091 posts since 28 May, 2010 from Finland
I'm trying to build some sort of dynamic equalizer, so I need to be able to modulate the gain parameter.
-
- KVRian
- 1379 posts since 26 Apr, 2004 from UK
No, ATK can't automate on Q and Gain at the moment, because I don't recompute even coeffs for frequency changes, I'm using a precomputed LUT for this.
You can automate DSPFilter, but the issue is that it recompute coefficients for each sample (so really slow). Then you have to use the Transposed Direct Form 2 as well (I think it's a template parameter somewhere?)
You can automate DSPFilter, but the issue is that it recompute coefficients for each sample (so really slow). Then you have to use the Transposed Direct Form 2 as well (I think it's a template parameter somewhere?)
- KVRAF
- 12555 posts since 7 Dec, 2004
You can compute a band from the four pole filter in the thread I linked (using pole mixing) and adjust the gain. You can also take the zero-delay output (the input to the feedback point before clipping) which will keep the signal in phase. For pole mixing however you'd need to split the computation into each individual pole (since it computes the fourth this is easy.)
Alternatively as people have said you could use some other filter. It is reasonably trivial to design a zero-delay bandpass filter of adjustable slope in exactly the same manner you would design such analog filters.
Actually one of your best options is to use the Kerwin-Huelsman-Newcomb filter (described as "state-variable", although this is a misnomer and always has been) from that thread. Take the scaled feedback signal as the output. This is a unity gain bandpass with variable width.
Alternatively you might design a similar filter based upon the usual "twin-T" or "gyrator" circuits.
https://en.wikipedia.org/wiki/Gyrator
One of the most computationally efficient methods to implement a gyrator for parametric EQ (frequency/bandwidth/gain peaks or notches) is to apply twin all-pass filters, a "second order" all-pass.
This is all very complicated stuff however and I'm not sure you'll find a lib to accomplish it. You may have to roll your own.
Alternatively as people have said you could use some other filter. It is reasonably trivial to design a zero-delay bandpass filter of adjustable slope in exactly the same manner you would design such analog filters.
Actually one of your best options is to use the Kerwin-Huelsman-Newcomb filter (described as "state-variable", although this is a misnomer and always has been) from that thread. Take the scaled feedback signal as the output. This is a unity gain bandpass with variable width.
Alternatively you might design a similar filter based upon the usual "twin-T" or "gyrator" circuits.
https://en.wikipedia.org/wiki/Gyrator
One of the most computationally efficient methods to implement a gyrator for parametric EQ (frequency/bandwidth/gain peaks or notches) is to apply twin all-pass filters, a "second order" all-pass.
This is all very complicated stuff however and I'm not sure you'll find a lib to accomplish it. You may have to roll your own.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.
-
- KVRian
- 1091 posts since 28 May, 2010 from Finland
How do you use the envelope follower there?
https://github.com/vinniefalco/DSPFilte ... ies.h#L682
It seems like its returning only a single sample eventhough it takes in size_t samples?
https://github.com/vinniefalco/DSPFilte ... ies.h#L682
It seems like its returning only a single sample eventhough it takes in size_t samples?
- KVRian
- Topic Starter
- 775 posts since 30 Nov, 2008
If I did it over again I would definitely use different techniques that would make it easier to comprehend/maintain. I realize that its hard to use, when I get a break from my current commercial activities I will revisit the library.Xenakios wrote:The code in the library is so overcomplicated I hardly ever look at the insides at all. It's hard enough to just try using the library.
My Open Source:
Beast, rippled, DSPFilters, LayerEffects, SimpleDJ
Beast, rippled, DSPFilters, LayerEffects, SimpleDJ
-
- KVRian
- 1091 posts since 28 May, 2010 from Finland
How do you process only one channel, since the process function of a filter wants a 2D array (double * const * arrayOfChannels)?
-
- KVRian
- 1265 posts since 9 Sep, 2005 from Oulu, Finland
Hello! Cool of you to pop in!thevinn wrote:If I did it over again I would definitely use different techniques that would make it easier to comprehend/maintain. I realize that its hard to use, when I get a break from my current commercial activities I will revisit the library.Xenakios wrote:The code in the library is so overcomplicated I hardly ever look at the insides at all. It's hard enough to just try using the library.
I didn't mean to criticize too harshly but I did for example get a bit frustrated lately when I was updating some code to do multichannel (instead of mono/stereo) operation that uses the DSPFilters library. I wanted the code to dynamically adjust the channel count at runtime. But now, of course the number of channels used by the library is a template parameter, so you might see what that lead into...Obviously, another solution would be to have mono instances of the filter (or pointers to them) in a vector, but it's unclear which option should be preferred...If you went to the trouble of making the channel count a template parameter, surely there is some benefit of giving the channel count like that into the library?
So, what I ended up doing :
http://pastebin.com/v2hKa97t
If there is some other way to do this, it sure isn't obvious.
- KVRian
- Topic Starter
- 775 posts since 30 Nov, 2008
Nope, you're absolutely right the design of the classes is garbage.Xenakios wrote:I didn't mean to criticize too harshly but I did for example get a bit frustrated lately...
My Open Source:
Beast, rippled, DSPFilters, LayerEffects, SimpleDJ
Beast, rippled, DSPFilters, LayerEffects, SimpleDJ
- KVRian
- Topic Starter
- 775 posts since 30 Nov, 2008
The intent is that you set the template argument to the MAX number of channels you might want to process and then pass a smaller number later with the actual number of channels to process.Xenakios wrote:I wanted the code to dynamically adjust the channel count at runtime. But now, of course the number of channels used by the library is a template parameter, so you might see what that lead into...
My Open Source:
Beast, rippled, DSPFilters, LayerEffects, SimpleDJ
Beast, rippled, DSPFilters, LayerEffects, SimpleDJ