# Band Stop Filter

Started by December 7, 2019
```Someone is using this algorithm for high, low and band pass filter coefficients and wants to adapt it for band stop filters.

( y% is an integer value that goes from
filter length / 2   to  +filter length / 2 )

IF y% = 0 THEN
c = 1
ELSE
IF BandPass THEN
th1 = (fh - fl) * pi * y% ' Fhigh and Flow of passband
th2 = (fh + fl) * pi * y%
c = SIN(th1) * COS(th2) / th1
ELSE
th = y% * 2 * pi * fc
c = SIN(th) / th      '
IF HighPass  THEN IF y% MOD 2 = 1 THEN c = -c
END IF
END IF

c is the resulting coefficient for each tap in succession

Is there a simple equivalent algorithm for this?

--

Rick C.

- Get 1,000 miles of free Supercharging
- Tesla referral code - https://ts.la/richard11209
```
```On 07/12/2019 22.46, Rick C wrote:
> Someone is using this algorithm for high, low and band pass filter coefficients and wants to adapt it for band stop filters.
>
> ( y% is an integer value that goes from
>    filter length / 2   to  +filter length / 2 )
>
> IF y% = 0 THEN
>      c = 1
> ELSE
>    IF BandPass THEN
>      th1 = (fh - fl) * pi * y% ' Fhigh and Flow of passband
>      th2 = (fh + fl) * pi * y%
>      c = SIN(th1) * COS(th2) / th1
>    ELSE
>      th = y% * 2 * pi * fc
>      c = SIN(th) / th      '
>      IF HighPass  THEN IF y% MOD 2 = 1 THEN c = -c
>    END IF
> END IF
>
> c is the resulting coefficient for each tap in succession
>
>
> Is there a simple equivalent algorithm for this?

I guess that, if bandpass, then 1-bandpass
is band stop.
From that it is possible to compute the
coefficients.

bye,

--

piergiorgio
```
```On Saturday, December 7, 2019 at 5:19:27 PM UTC-5, Piergiorgio Sartor wrote:
> On 07/12/2019 22.46, Rick C wrote:
> > Someone is using this algorithm for high, low and band pass filter coefficients and wants to adapt it for band stop filters.
> >
> > ( y% is an integer value that goes from
> >    filter length / 2   to  +filter length / 2 )
> >
> > IF y% = 0 THEN
> >      c = 1
> > ELSE
> >    IF BandPass THEN
> >      th1 = (fh - fl) * pi * y% ' Fhigh and Flow of passband
> >      th2 = (fh + fl) * pi * y%
> >      c = SIN(th1) * COS(th2) / th1
> >    ELSE
> >      th = y% * 2 * pi * fc
> >      c = SIN(th) / th      '
> >      IF HighPass  THEN IF y% MOD 2 = 1 THEN c = -c
> >    END IF
> > END IF
> >
> > c is the resulting coefficient for each tap in succession
> >
> >
> > Is there a simple equivalent algorithm for this?
>
> I guess that, if bandpass, then 1-bandpass
> is band stop.
>  From that it is possible to compute the
> coefficients.

For a filter with odd length, the "1" would be the tap at the center of the delay line.  The algorithm above sets the coefficient of odd length filters to 1, so setting this coefficient to zero and inverting all the other taps would accomplish that.

What does the "1" look like for even length filters?

--

Rick C.

+ Get 1,000 miles of free Supercharging
+ Tesla referral code - https://ts.la/richard11209
```
```On 08/12/2019 19.21, Rick C wrote:
[...]
> For a filter with odd length, the "1" would be the tap at the center of the delay line.  The algorithm above sets the coefficient of odd length filters to 1, so setting this coefficient to zero and inverting all the other taps would accomplish that.

I'm not sure this is correct, but it
could be.

I think it is:

1 - filter_equation

or

1 - (ax+...)/(by+....)

Or whatever the filter equation is.

> What does the "1" look like for even length filters?

1 is 1, it is the allpass filter.

I do not think it's relevant to be
as Dirac with same length.

But again, it was long time ago, I'm
not really sure, I just intended to
give you an hint to search further.

bye,

--

piergiorgio
```
```On Sunday, December 8, 2019 at 1:28:34 PM UTC-5, Piergiorgio Sartor wrote:
> On 08/12/2019 19.21, Rick C wrote:
> [...]
> > For a filter with odd length, the "1" would be the tap at the center of the delay line.  The algorithm above sets the coefficient of odd length filters to 1, so setting this coefficient to zero and inverting all the other taps would accomplish that.
>
> I'm not sure this is correct, but it
> could be.
>
> I think it is:
>
> 1 - filter_equation
>
> or
>
> 1 - (ax+...)/(by+....)
>
> Or whatever the filter equation is.
>
> > What does the "1" look like for even length filters?
>
> 1 is 1, it is the allpass filter.
>
> I do not think it's relevant to be
> as Dirac with same length.
>
> But again, it was long time ago, I'm
> not really sure, I just intended to
> give you an hint to search further.

The context is not the basic equation, but rather the filter coefficients.  For the odd length filters in this algorithm the center coefficient is 1.  I'm asking what the coefficients would be for an even length filter for an allpass.

--

Rick C.

- Get 1,000 miles of free Supercharging
- Tesla referral code - https://ts.la/richard11209
```
```On 08/12/2019 21.16, Rick C wrote:
[...]
> The context is not the basic equation, but rather the filter coefficients.  For the odd length filters in this algorithm the center coefficient is 1.  I'm asking what the coefficients would be for an even length filter for an allpass.
>

The coefficients must be applied to
an equation.

What it is?
FIR? IIR?

The rest will be automatically, I guess.

Nevertheless, as wrote before, this was
just an hint.

bye,

--

piergiorgio
```
```On Sunday, December 8, 2019 at 4:09:29 PM UTC-5, Piergiorgio Sartor wrote:
> On 08/12/2019 21.16, Rick C wrote:
> [...]
> > The context is not the basic equation, but rather the filter coefficients.  For the odd length filters in this algorithm the center coefficient is 1.  I'm asking what the coefficients would be for an even length filter for an allpass.
> >
>
> The coefficients must be applied to
> an equation.
>
> What it is?
> FIR? IIR?
>
> The rest will be automatically, I guess.
>
> Nevertheless, as wrote before, this was
> just an hint.
>
> bye,
>
> --
>
> piergiorgio

Did you not read the first post where I provided the code to produce the coefficients?  Was that not clear?

--

Rick C.

-- Get 1,000 miles of free Supercharging
-- Tesla referral code - https://ts.la/richard11209
```
```Rick C.
You're being unreasonable by posting uncommented code here and then expecting someone to "simplify" that code for you. Then as Piergiorgio struggles to try to help, you replied to him in a rude way.
```
```On 09/12/2019 07.59, Rick C wrote:
[...]
> Did you not read the first post where I provided the code to produce the coefficients?  Was that not clear?

No, I do not usually read code posted
on usenet.

I can try to point you one way which
might, or might not, help in solving
your problem, but I will not debug,
extend, improve or else some code.

For that, you'll have to pay... :-)

Sorry...

bye,

--

piergiorgio
```
```On Monday, December 9, 2019 at 4:27:01 AM UTC-5, Richard (Rick) Lyons wrote:
> Rick C.
> You're being unreasonable by posting uncommented code here and then expecting someone to "simplify" that code for you. Then as Piergiorgio struggles to try to help, you replied to him in a rude way.

Sorry if anyone thought I was rude.  I was asking what was not clear about the code.

Not sure what you mean about "simplifying" the code.  I listed the rather simple and straightforward code so it could be seen how the coefficients are being generated.  I don't even know what the language is and I was able to undertstand was it was doing to a large degree.

Sorry if my posts are not appropriate.  I'm not sure what to say that would be better.

--

Rick C.

-+ Get 1,000 miles of free Supercharging
-+ Tesla referral code - https://ts.la/richard11209
```