Csound Csound-dev Csound-tekno Search About

[Csnd] Butterworth filters and signal splitting

Date2024-12-14 00:25
From"Jeanette C."
Subject[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

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

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

Date2024-12-14 12:42
FromOeyvind Brandtsegg
SubjectRe: [Csnd] Butterworth filters and signal splitting
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 ;-)

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

--
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

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

Date2024-12-14 13:43
FromLovre Bogdanić
SubjectRe: [Csnd] Butterworth filters and signal splitting
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



On Sat, Dec 14, 2024 at 1:42 PM Oeyvind Brandtsegg <obrandts@gmail.com> wrote:
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 ;-)

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

--
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

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

Date2024-12-14 14:18
From"Jeanette C."
SubjectRe: [Csnd] Butterworth filters and signal splitting
Hi Lovre,
Dec 14 2024, Lovre Bogdanić has written:

> This is one nice and helpful library for filter design:
> https://github.com/chipmuenk/pyfda
...
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. :)

Thanks anyway for stepping in and suggesting that tool.

Best wishes,

Jeanette

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

Skip on the drinks Head to the floor
Makin' my way Past the show
My body's taken over And I want some more <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

Date2024-12-14 14:39
From"Jeanette C."
SubjectRe: [Csnd] Butterworth filters and signal splitting
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

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

Skip on the drinks Head to the floor
Makin' my way Past the show
My body's taken over And I want some more <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

Date2024-12-14 18:10
From"Jeanette C."
SubjectRe: [Csnd] Butterworth filters and signal splitting
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

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

Don't worry, you're gonna be alright,
But Cinderella's got to go <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

Date2024-12-14 22:25
From"Dr. Richard Boulanger"
SubjectRe: [Csnd] Butterworth filters and signal splitting
jeanette,

nice!  thanks for sharing.

- Dr.B


Dr. Richard Boulanger

Professor

Electronic Production and Design

Berklee College of Music

Professional Writing & Technology Division



On Sat, Dec 14, 2024 at 1:10 PM Jeanette C. <julien@mail.upb.de> wrote:
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

--
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

Don't worry, you're gonna be alright,
But Cinderella's got to go <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

Date2024-12-14 23:17
From"Jeanette C."
SubjectRe: [Csnd] Butterworth filters and signal splitting
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:
https://shop.befaco.org/Assembled/1330-bandit-assembled-module.html
DivKid has also done a nice Youtube video on that:
https://youtu.be/ExeBPLxMV2o
In that respect my code lacks quite a few features. :) -- Well, this
code will shortly disappear. I think I'll leave it there till tomorrow
night or so.

Best wishes,

jeanette

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

Don't worry, you're gonna be alright,
But Cinderella's got to go <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