What does Transition band mean in band-pass filters?

Asked

Viewed 169 times

3

Hello, I am working on a band pass filter in python, and while searching I found this link, which states a code variable:

"b is the transition band also as a function of the sampling rate"

What does that mean? And how would one do to a 360Hz frequency ?

fL = 0.1
fH = 0.3
b = 0.08
N = int(np.ceil((4 / b)))
if not N % 2: N += 1  # Make sure that N is odd.
n = np.arange(N)

# low-pass filter
hlpf = np.sinc(2 * fH * (n - (N - 1) / 2.))
hlpf *= np.blackman(N)
hlpf = hlpf / np.sum(hlpf)

# high-pass filter 
hhpf = np.sinc(2 * fL * (n - (N - 1) / 2.))
hhpf *= np.blackman(N)
hhpf = hhpf / np.sum(hhpf)
hhpf = -hhpf
hhpf[(N - 1) / 2] += 1

h = np.convolve(hlpf, hhpf)
s = list(data['10 Min Std Dev'])
new_signal = np.convolve(s, h)
  • you have some example of band-pass filter ? could post ?

  • Sorry, unfortunately not..

1 answer

5


That’s what you’re literally saying, is the amount of frequencies that are between the transition curve of the filter, starting from one state and going to the other state.

inserir a descrição da imagem aqui

In this image is easy to see, the transition began to be applied around 1500hz(1.5kHz) and had its action completely effective in approximately 2kHz, ie had approximately 500Hz transitional ...

The example of the site is so basic that it gets kind of complicated someone who is studying to understand how to apply the filter of your code, just to leave something more tangible I wrote a code that applies the equations directly on an audio signal, created three audio signals (senoids)each senoid is at a different frequency 200hz, 400hz and 800hz, after creating the signs I mixed them all to mix ... while applying Fourier, you can see the 3 signals with their respective frequencies:

inserir a descrição da imagem aqui

So using the above band pass filter will it actually works to remove signals below 200Hz and above 800Hz, then in theory the filter would have to keep only the senoid in 400Hz, right ?

With a little noise at the base of the senoid, but the others were removed by the filter...

inserir a descrição da imagem aqui

from matplotlib import pyplot as plt
import numpy as np


#gerando sinal de teste
Fs = 44100
freq1 = 200
freq2 = 400
freq3 = 800
nsamples = 4096
sinal = np.arange(nsamples)
sinal1 = np.sin(2 * np.pi * freq1 * sinal / Fs)
sinal2 = np.sin(2 * np.pi * freq2 * sinal / Fs)
sinal3 = np.sin(2 * np.pi * freq3 * sinal / Fs)

sinalmix = sinal1 + sinal2 + sinal3;

#fim, sinal criado




#Inicio do filtro

fL = 350/Fs
fH = 450/Fs
b = 200/Fs
N = int(np.ceil((4 / b)))
if not N % 2: N += 1  # Make sure that N is odd.
n = np.arange(N)

# low-pass filter
hlpf = np.sinc(2 * fH * (n - (N - 1) / 2.))
hlpf *= np.blackman(N)
hlpf = hlpf / np.sum(hlpf)

# high-pass filter 
hhpf = np.sinc(2 * fL * (n - (N - 1) / 2.))
hhpf *= np.blackman(N)
hhpf = hhpf / np.sum(hhpf)
hhpf = -hhpf
hhpf[(N - 1) / 2] += 1

h = np.convolve(hlpf, hhpf)
sinalfiltred = np.convolve(sinalmix, h)

#Final do filtro 


#análise de Fourier no sinal Original e no Sinal Filtrado
AmplitudeJaneladaF=sinalfiltred*np.hamming(len(sinalfiltred)); 
FourierF=abs(np.fft.rfft(AmplitudeJaneladaF))

AmplitudeJaneladaO=sinalmix*np.hamming(len(sinalmix)); 
FourierO=abs(np.fft.rfft(AmplitudeJaneladaO))


NyquistTeorema = (Fs / 2)

MinFrequencia=NyquistTeorema / (len(sinalfiltred) / 2);

MinFrequencia2=NyquistTeorema / (len(sinalmix) / 2);

Frequencias=np.linspace(MinFrequencia, NyquistTeorema, num=(len(sinalfiltred) / 2))

Frequencias2=np.linspace(MinFrequencia2, NyquistTeorema, num=(len(sinalmix) / 2))

#Plot dos dois Sinais

plt.figure(1)
plt.title('Fourier original')
plt.plot(Frequencias2[1:90],FourierO[1:90])


plt.figure(2)
plt.title('Fourier Filtrado')
plt.plot(Frequencias[1:110],FourierF[1:110])


plt.show()

Above the code that creates the sounds, applies the filters (copied and pasted the code of your post this part), does Fourier analysis to capture the frequencies and does the Plots, is practically proof of the concept, I am filtering everything below 350Hz and anything above 450Hz and used a transition band on 200Hz...

You will see that I am choosing the frequencies and applying depending on the sampling rate (sampling rate Fs=44100Hz)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.