DSPRelated.com
Forums

Make a bandreject filter by frequency shifting a highpass filter?

Started by Gsparky2004 1 month ago16 replieslatest reply 1 month ago177 views

I'm reading this document from Analog Devices and it states that, when creating a band reject filter, its possible to first create a lowpass filter, convert that into a highpass filter, then shift its center frequency to the desired frequency.

Specifically, it says: "Just as the band-pass case is a direct transformation of the low-pass prototype, where dc is transformed to F0 , the notch filter can be first transformed to the high-pass case, and then dc, which is now a zero, is transformed to F0 ."

I've been attempting to recreate this and have been unsuccessful so far. Here's what I've been doing:

  1. Create the lowpass filter using a sinc function.
  2. Transform the lowpass to highpass using spectral inversion (Impulse minus the sinc curve)
  3. Multipy the resulting impulse response by a cosine with a frequency of the desired center frequency of the band reject filter.
  4. Window the resulting impulse to create a windowed-sinc filter.

Steps 1 and 2 work perfectly. But at step 3, it all goes to hell. Obviously, I'm missing some (probably simple) concept here, and was wondering if anyone here could enlighten me.

NOTE: This procedure works perfectly for converting a lowpass directly into bandpass (create lowpass prototype and frequency shift to desired BP center frequency), just not for band reject.

[ - ]
Reply by dgshaw6March 8, 2026

I don't know if this is the problem, but have you made sure that the multiplicative cosine wave is centered on time over the delay of the high pass transformed filter?

I.E. Is a peak of the cosine wave consistent with the peak of the filter that is being transformed?

[ - ]
Reply by Gsparky2004March 8, 2026

"Is a peak of the cosine wave consistent with the peak of the filter that is being transformed?" Yes, I did. I had that same thought, though I don't know why the phase shift would affect it. (Another conceptual issue I need to address.)

[ - ]
Reply by kazMarch 8, 2026

Check aliasing when shifting frequency centre.

The stopband of HPF will double when moved away from dc. Make sure that the new frequency centre can accommodate that width.

[ - ]
Reply by Gsparky2004March 8, 2026

Thank you for the suggestion. Aliasing should not be a problem. I'm using a 50 kHz highpass filter (100 kHz bandwidth total at baseband) with a 2.4 MHz sample rate. I'm trying to shift it to a center of 300 kHz.

[ - ]
Reply by PlatybelMarch 9, 2026

Hello Gsparky2004: Designing this band reject filter involves a few simple steps.  Since you are having problems at Step#3, perhaps you could share the code and a few figures so that we could look at it and find the bug.

[ - ]
Reply by Gsparky2004March 9, 2026

Thanks for the offer. I think DirkBell hit it on the head by suggesting that the method that Analog Devices suggests doesn't work. 

Also, I'm using Gnu Radio Companion, which will create a rather lengthy Python script. I don't think you'd want to wade through that! :)

[ - ]
Reply by DirkBellMarch 9, 2026

Step 3 is wrong.

You do not want to multiply a HP filter by a cosine. Draw the HP frequency response. Shift HP response to the right, then add HP response shifted to the left. You just added part of each pass band to the other reject band. So you get nominally 50% rejection, which is really poor.

Roughly (you fill in the details):

Design a LP with PB gain 1. (I would design an odd length even symmetric digital filter, assumed in comments() below)

Multiply by 2*cosine. (Make sure the peak (cos(0)) lines up with the center coefficient of the LP)

Invert the spectrum. (Take the negative of the previous result and add 1 to the center coefficient)

[ - ]
Reply by Gsparky2004March 9, 2026

Ah! That makes sense. In other words, you can't get there from here. I was trying to figure out all of the different methods for creating a band reject filter, and the one you suggested (essentially make a bandpass filter and invert it) seems to be the only method that works. Thanks for the feedback.

[ - ]
Reply by kazMarch 9, 2026

I don't see problems with either method. I tried this octave code:

h = fir1(130,100e3/2.4e6,'high');

f=cos(2*pi*(0:130)*300e3/2.4e6);

hf = h.*f;

freqz(hf,1, 0:100:2.4e6/2, 2.4e6)


screenshot 2026-03-09 093751_29313.png

[ - ]
Reply by DirkBellMarch 9, 2026

The problem I see right away is the filter you designed has very little attenuation in the reject band. That is something that I noted would happen previously. Not much band reject.

[ - ]
Reply by kazMarch 9, 2026

You are right. If I set it to complex frequency it shifts the filter correctly without that attenuation.


screenshot 2026-03-09 143429_86639.png

[ - ]
Reply by DirkBellMarch 9, 2026

Correct. The poor attenuation comes from essentially taking the plot you have and adding a second plot made from flipping the first left-to-right, so each plot's passband is being added to the other's reject band.

He is designing a filter for real signals, based on his design method,  so the problem happens using a HP filter and mixing with a cosine (1/2 sum of 2 complex exponentials).

[ - ]
Reply by DirkBellMarch 9, 2026

Unfortunately the cosine has two complex exponentials so when the mix happens the passband from one overlaps the reject band of the other and you get poor attenuation. Similar to taking the data from your plot (not in dB) and adding a L-R flipped copy of it and dividing by 2.

[ - ]
Reply by Gsparky2004March 9, 2026

Thanks for confirming my untested hypothesis that this would work with a complex shift, since DirkBell stated that trying to shift with a real cosine would cause the passband of one to overlap the stopband of the other.

[ - ]
Reply by DirkBellMarch 9, 2026

Note that the single complex mix filter applied to a real signal is not going to give you anything meaningful. Applied to a complex IQ signal it can.

[ - ]
Reply by Gsparky2004March 9, 2026

Yup, totally understood!

[ - ]
Reply by kazMarch 9, 2026

Post deleted by author