### QtVST: a Chamberlin Variable Filter

(No Ratings Yet)

After my last post on QtAgain, I’ve decided to test a few simple digital filters. I’ve tried to make them as generic as possible, and with a VST interface.

#### A templated Chamberlin filter

A Chamberlin filter is a IIR (Infinite Impulse Response) filter, and it is possible to make it output high-, band- or low-pass signals. It has only two parameters that are independent.

The equations are very simple:

Each of the series is either the low-pass, the band-pass or the high-pass output.

There are some factors that are pre-computed:

The first is a function of the Cut frequency and the Sampling frequency, a “numerical frequency”. The second one is the numerical attenuation, between 0 and 2.

This is an excerpt of the actual code, I’ve only displayed the relevant code.

```template
class VariableFilter
{
public:
typedef Data_Type DataType;

void process(const DataType* in, DataType* out, unsigned long nb_samples)
{
for(unsigned long i = 0; i < nb_samples; ++i)
{
yh = in[i] - yl - numerical_attenuation * yb;
yb = numerical_frequency * yh + yb;
yl = numerical_frequency * yb + yl;
if(selected == 0)
{
out[i] = yl;
}
else if(selected == 1)
{
out[i] = yb;
}
else
{
out[i] = yh;
}
}
}

protected:
void compute_factors()
{
numerical_frequency = 2 * std::sin(M_PI * cutoff_frequency / sampling_frequency);
numerical_attenuation = 2 * attenuation;
}
};
```

Now, I've written a simple GUI for this plugin.

#### GUI with Qt

I've used the QtAgain skeletton to wrap the filter and to make it available to PyVST. It's really easy to add other parameters to the skeletton, so I will not write everything here again. There are three parameters, 2 numerical ones, and one three-state variable.

#### Results

I've recorded the filter's outputs for 6kHz as central frequency, and an attenuation factor of .3. The output signal was generated from a random signal, and then an FFT was performed on the inputs and the outputs and displayed.

Note: I didn't convert the scale to dB.

As you may have noted, the filter amplifies the signal near the central frequency for each output for the attenuation I've selected. The issue is that selecting a higher one has also an impact on the stability of the filter at higher frequencies. The sum of the numerical attenuation and the numerical frequency should always be inferior to 2.

#### Conclusion

This numerical is really simple to implement, and it has few parameters. The dark side of this filter is that is not always stable and the central frequency seems to be always amplified. Other filters can be better balanced.

The code is available on Launchpad.

## 4 thoughts on “`QtVST: a Chamberlin Variable Filter`”

1. xtrium says:

Hi,

Congratulations on using Qt to create VSTs such as this one or AGain 🙂 This makes me hope that someday, we’ll have some cool VSTs working both on windows and linux.

Speaking of which, i’ve been searching for a clean solution for quite a long time. I mean, using QWinWidget makes integrating the GUI quite simple it seems, but for the synth i’m developing, it’s a no-go since i want to keep it fully multiplatform and the same problem happens on linux.

I tried using QWidget::create(WId handle). It, well, kinda works : keyboard input is OK on every host, but while mouse input works in Renoise, it does not in FL Studio for example (well… mouse scrolling works, context menu too, but not the simple “press” event – focus goes from one widget to another, but clicks are just ignored (ie. buttons are not pressed).

Did you continue trying to get the QWidget::create(hnd) solution working once finding about this one ? Or have you found a multiplatform solution ?