maad.sound.sinc

maad.sound.sinc(s, cutoff, fs, atten=80, transition_bw=0.05, bandpass=True)[source]

Filter 1D signal with a Kaiser-windowed filter.

Parameters:
sndarray

input 1D signal

cutoffndarray

upper and lower frequencies (min_f, max_f) in Hertz

attenfloat

attenuation in dB

transition_bwfloat

transition bandwidth in percent default 5% of total band

bandpassbool

bandpass (True) or bandreject (False) filter, default is bandpass

Returns:
s_filtarray

signal filtered

Examples

>>> import maad
>>> s, fs = maad.sound.load('../data/spinetail.wav')
>>> import numpy as np
>>> tn = np.arange(0,len(s))/fs
>>> s_filt_7_12kHz = maad.sound.sinc(s, cutoff=[7000,12000], fs=fs, atten=80, transition_bw=0.8)
>>> s_filt_4_8kHz = maad.sound.sinc(s, cutoff=[4500,8000], fs=fs, atten=80, transition_bw=0.8)
>>> import matplotlib.pyplot as plt
>>> fig, (ax0, ax1,ax2) = plt.subplots(3,1, sharex=True, squeeze=True)
>>> ax0, fig = maad.util.plot1d(tn,s,ax=ax0, figtitle='original')
>>> ax1, fig = maad.util.plot1d(tn,s_filt_7_12kHz,ax=ax1, figtitle='Kaiser-windowed filter 7-12kHz')
>>> a2 , fig = maad.util.plot1d(tn,s_filt_4_8kHz,ax=ax2, figtitle='Kaiser-windowed filter 4.5-8kHz')
>>> fig.tight_layout()