Пример #1
0
def octave_filters(Nbands, BandsPerOctave):
	# Bandpass Filter Generation
	pbrip = .5	# Pass band ripple
	sbrip = 50	# Stop band rejection
	#Filter order
	order = 2

	fi, f_low, f_high = octave_frequencies(Nbands, BandsPerOctave)

	fs = 44100 # sampling rate
	wi = fi/(fs/2.) # normalized frequencies
	w_low = f_low/(fs/2.)
	w_high = f_high/(fs/2.)

	B = []
	A = []
	
	# For each band
	for w, wl, wh in zip(wi, w_low, w_high):
		# normalized frequency vector
		freq = [wl, wh]
	
		# could be another IIR filter
		[b, a] = ellip(order, pbrip, sbrip, freq, btype='bandpass')
		
		B += [b]
		A += [a]
		
	return [B, A, fi, f_low, f_high]
Пример #2
0
def octave_filters(Nbands, BandsPerOctave):
    # Bandpass Filter Generation
    pbrip = .5  # Pass band ripple
    sbrip = 50  # Stop band rejection
    #Filter order
    order = 2

    fi, f_low, f_high = octave_frequencies(Nbands, BandsPerOctave)

    fs = 44100  # sampling rate
    wi = fi / (fs / 2.)  # normalized frequencies
    w_low = f_low / (fs / 2.)
    w_high = f_high / (fs / 2.)

    B = []
    A = []

    # For each band
    for w, wl, wh in zip(wi, w_low, w_high):
        # normalized frequency vector
        freq = [wl, wh]

        # could be another IIR filter
        [b, a] = ellip(order, pbrip, sbrip, freq, btype='bandpass')

        B += [b]
        A += [a]

    return [B, A, fi, f_low, f_high]
Пример #3
0
def octave_filters_oneoctave(Nbands, BandsPerOctave):
    # Bandpass Filter Generation
    pbrip = .5  # Pass band ripple
    sbrip = 50  # Stop band rejection
    #Filter order
    order = 2

    fi, f_low, f_high = octave_frequencies(Nbands, BandsPerOctave)

    fi = fi[-BandsPerOctave:]
    f_low = f_low[-BandsPerOctave:]
    f_high = f_high[-BandsPerOctave:]

    fs = 44100  # sampling rate
    wi = fi / (fs / 2.)  # normalized frequencies
    w_low = f_low / (fs / 2.)
    w_high = f_high / (fs / 2.)

    B = []
    A = []

    # For each band
    for w, wl, wh, f, fl, fh in zip(wi, w_low, w_high, fi, f_low, f_high):
        # normalized frequency vector
        freq = [wl, wh]

        # could be another IIR filter
        #[b, a] = ellip(order, pbrip, sbrip, freq, btype='bandpass')
        a = (fh - fl) / f * 0.3
        bands = [
            0., fl / fs * (1 - a), fl / fs * (1 + a), fh / fs * (1 - a),
            fh / fs * (1 + a), 0.5
        ]
        b = remez(numtaps=BandsPerOctave / 24. * 1000,
                  bands=bands,
                  desired=[0., 1., 0.])
        a = [1.]

        B += [b]
        A += [a]

    return [B, A, fi, f_low, f_high]
Пример #4
0
def octave_filters_oneoctave(Nbands, BandsPerOctave):
	# Bandpass Filter Generation
	pbrip = .5	# Pass band ripple
	sbrip = 50	# Stop band rejection
	#Filter order
	order = 2

	fi, f_low, f_high = octave_frequencies(Nbands, BandsPerOctave)

	fi     = fi[-BandsPerOctave:]
	f_low  = f_low[-BandsPerOctave:]
	f_high = f_high[-BandsPerOctave:]

	fs = 44100 # sampling rate
	wi = fi/(fs/2.) # normalized frequencies
	w_low = f_low/(fs/2.)
	w_high = f_high/(fs/2.)

	B = []
	A = []
	
	# For each band
	for w, wl, wh, f, fl, fh in zip(wi, w_low, w_high, fi, f_low, f_high):
		# normalized frequency vector
		freq = [wl, wh]
	
		# could be another IIR filter
		#[b, a] = ellip(order, pbrip, sbrip, freq, btype='bandpass')
		a = (fh - fl)/f*0.3
		bands = [0.,fl/fs*(1-a),fl/fs*(1+a),fh/fs*(1-a),fh/fs*(1+a),0.5]
		b = remez(numtaps=BandsPerOctave/24.*1000, bands=bands, desired=[0.,1.,0.]); a = [1.]
		
		B += [b]
		A += [a]
		
	return [B, A, fi, f_low, f_high]