[Csnd] Butterworth filters and signal splitting

Hey hey,
I am just experimenting with multiband stuff. I try to split a signal into three or four bands. The lowest band uses a lowpass filter and the highest a ighpass filter. In between there should be one or two bandpass filters. I have started work with Butterworth filters. I try to filter the signal so, that the outputs of the filters, taken together, (nearly) reconstruct the original signal. I am not set on the Butterworth filters and the crossing points
in the setup below, can be purely nominal. They don't actually have to
represent a frequency of one of the filters, if it makes all the
calculations easier.

So, I have some issues with half-power points. Here's my current setup, with a few hardcoded values.
iCross1 init 200 ; nominal lowpass frequency
iCross2 init 800 ; nominal highpass frequency
iCentre init (iCross1 + iCross2) / 2 ; the mid-point between the two
iBandwidth init (iCross2 - iCross1) * 2 ; The bandwidth
The output sounds not too bad. But there are issues. A bandwidth of 1200 with a centre of 500 would result in a negative frequency for the lower "edge" of teh bandpass filter.

I was working from the following, possibly wrong or misunderstood, example:
a second-order Butterworth Bandpass filter centred at 400Hz with a bandwidth of 400 has the half-power points at 300Hz and 500Hz. So I'd assume that it would have the half-power points at 200Hz and 600Hz with a bandwidth of 800.

Can anyone suggest a better approach or point out my wooly thinking, please?

Best wishes,

Jeanette

Hi Jeanette,

It looks like your estimation of crossover frequencies are off (or at least different than what I think).
You write “a second-order Butterworth Bandpass filter centred at 400Hz with a bandwidth of 400 has the half-power points at 300Hz and 500Hz.”
With a bandwidth of 400, the difference between the lower and upper cutoff frequencies is 400, so if we think of it linearly (which is not correct, but simple and intuitive), the lower cutoff would be 200 and the upper cutoff 600. As we are working with logarithmic representation, I think the numbers would be more like approx 240 and 640.
Others here will know with better mathematical precision :wink:

There is a quite clear explanation of filter bandwidth formulas on this page https://www.ranecommercial.com/legacy/note170.html
I keep coming back to that resource

all best
Øyvind

lør. 14. des. 2024 kl. 01:24 skrev Jeanette C. <julien@mail.upb.de>:

Hey hey,
I am just experimenting with multiband stuff. I try to split a signal into
three or four bands. The lowest band uses a lowpass filter and the highest a
ighpass filter. In between there should be one or two bandpass filters. I have
started work with Butterworth filters. I try to filter the signal so, that the
outputs of the filters, taken together, (nearly) reconstruct the original
signal. I am not set on the Butterworth filters and the crossing points
in the setup below, can be purely nominal. They don’t actually have to
represent a frequency of one of the filters, if it makes all the
calculations easier.

So, I have some issues with half-power points. Here’s my current
setup, with a few hardcoded values.
iCross1 init 200 ; nominal lowpass frequency
iCross2 init 800 ; nominal highpass frequency
iCentre init (iCross1 + iCross2) / 2 ; the mid-point between the two
iBandwidth init (iCross2 - iCross1) * 2 ; The bandwidth
The output sounds not too bad. But there are issues. A bandwidth of 1200 with
a centre of 500 would result in a negative frequency for the lower “edge” of
teh bandpass filter.

I was working from the following, possibly wrong or misunderstood, example:
a second-order Butterworth Bandpass filter centred at 400Hz with a bandwidth
of 400 has the half-power points at 300Hz and 500Hz. So I’d assume that it
would have the half-power points at 200Hz and 600Hz with a bandwidth of 800.

Can anyone suggest a better approach or point out my wooly thinking, please?

Best wishes,

Jeanette

There’s no time to loose
And next week,
You might not see me here <3
(Britney Spears)

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

This is one nice and helpful library for filter design: https://github.com/chipmuenk/pyfda

You don’t need to know python to use it, you just need to install it. You do everything using GUI

Steps typically are that you specify the type of filter you want (LP, HP, BP …), choose implementation FIR or IIR (Butterworth among others), define filter order and wanted frequencies and the tool will then show you filter characteristics and calculate filter coefficients for you.

Then you can use those coefficients with filter2 opcode (https://csound.com/manual/filter2.html).

I haven’t used filter2 but I think it will do the trick.

Best,
Lovre

Hi Lovre,
Dec 14 2024, Lovre Bogdanić has written:

This is one nice and helpful library for filter design:
GitHub - chipmuenk/pyfda: Python Filter Design Analysis Tool · GitHub

...
Do you know if this tool works completely without a GUI too? If not, I
can always check, but it will take a little more time. :slight_smile:

Thanks anyway for stepping in and suggesting that tool.

Best wishes,

Jeanette

Hi Oeyvind,
many thanks for sharing that resource. The article seems quite conciise. Alas, the formulas are all in images. But it's a nice start.

Best wishes,

Jeanette

Hey hey,
here's a demo version of the idea with two instruments, one for simple usage, the other for more creative usage:
https://www.dropbox.com/scl/fi/lypivjdcp2o2ndnkk07cr/m_ws_fork.csd?rlkey=k87k1885x1tn9yijjqbx9isiy

If you have further pointers to improve the crossover between the bands, please let me know.

Best wishes,

jeanette

jeanette,

nice! thanks for sharing.

Hello Richard!
Dec 14 2024, Dr. Richard Boulanger has written:

jeanette,

nice! thanks for sharing.

Thanks for the feedback. I wasn't sure if this is really ready and I
might add more functionality. It was inspired by the Befaco Bandit
module:

DivKid has also done a nice Youtube video on that:

In that respect my code lacks quite a few features. :slight_smile: -- Well, this
code will shortly disappear. I think I'll leave it there till tomorrow
night or so.

Best wishes,

jeanette