Login / Register  0 items | $0.00 New What is KVR? Submit News Advertise
Fluky
KVRist
 
383 posts since 28 May, 2010, from Finland

Postby Fluky; Tue Jul 28, 2015 5:10 pm Re: A Collection of Useful C++ Classes for Signal Processing

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?
ChocoBilly
KVRer
 
22 posts since 19 Feb, 2013, from So Cal

Postby ChocoBilly; Tue Jul 28, 2015 6:34 pm Re: A Collection of Useful C++ Classes for Signal Processing

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.
earlevel
KVRist
 
386 posts since 4 Apr, 2010

Postby earlevel; Tue Jul 28, 2015 8:56 pm Re: A Collection of Useful C++ Classes for Signal Processing

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?

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.
My audio DSP blog: earlevel.com
Miles1981
KVRian
 
1129 posts since 26 Apr, 2004, from UK

Postby Miles1981; Wed Jul 29, 2015 12:04 am Re: A Collection of Useful C++ Classes for Signal Processing

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
Fluky
KVRist
 
383 posts since 28 May, 2010, from Finland

Postby Fluky; Wed Jul 29, 2015 1:13 am Re: A Collection of Useful C++ Classes for Signal Processing

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?
User avatar
aciddose
KVRAF
 
10968 posts since 7 Dec, 2004, from Vancouver, Canada

Postby aciddose; Wed Jul 29, 2015 2:12 am Re: A Collection of Useful C++ Classes for Signal Processing

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:

viewtopic.php?f=33&t=349859&start=285
Fluky
KVRist
 
383 posts since 28 May, 2010, from Finland

Postby Fluky; Wed Jul 29, 2015 2:14 am Re: A Collection of Useful C++ Classes for Signal Processing

I'm trying to build some sort of dynamic equalizer, so I need to be able to modulate the gain parameter.
Miles1981
KVRian
 
1129 posts since 26 Apr, 2004, from UK

Postby Miles1981; Wed Jul 29, 2015 2:20 am Re: A Collection of Useful C++ Classes for Signal Processing

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?)
User avatar
aciddose
KVRAF
 
10968 posts since 7 Dec, 2004, from Vancouver, Canada

Postby aciddose; Wed Jul 29, 2015 2:33 am Re: A Collection of Useful C++ Classes for Signal Processing

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.
Fluky
KVRist
 
383 posts since 28 May, 2010, from Finland

Postby Fluky; Wed Jul 29, 2015 6:27 am Re: A Collection of Useful C++ Classes for Signal Processing

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?
User avatar
thevinn
KVRian
 
772 posts since 30 Nov, 2008

Postby thevinn; Wed Jul 29, 2015 12:52 pm Re: A Collection of Useful C++ Classes for Signal Processing

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.


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.
Fluky
KVRist
 
383 posts since 28 May, 2010, from Finland

Postby Fluky; Fri Jul 31, 2015 3:28 am Re: A Collection of Useful C++ Classes for Signal Processing

How do you process only one channel, since the process function of a filter wants a 2D array (double * const * arrayOfChannels)?
Xenakios
KVRian
 
898 posts since 9 Sep, 2005, from Oulu, Finland

Postby Xenakios; Fri Jul 31, 2015 4:16 am Re: A Collection of Useful C++ Classes for Signal Processing

thevinn wrote:
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.


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.


Hello! Cool of you to pop in! :)

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.
User avatar
thevinn
KVRian
 
772 posts since 30 Nov, 2008

Postby thevinn; Fri Jul 31, 2015 6:43 am Re: A Collection of Useful C++ Classes for Signal Processing

Xenakios wrote:I didn't mean to criticize too harshly but I did for example get a bit frustrated lately...


Nope, you're absolutely right the design of the classes is garbage.
User avatar
thevinn
KVRian
 
772 posts since 30 Nov, 2008

Postby thevinn; Fri Jul 31, 2015 6:44 am Re: A Collection of Useful C++ Classes for Signal Processing

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...


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.
PreviousNext

Moderator: Moderators (Main)

Return to DSP and Plug-in Development