예제 #1
0
def apply_filt (x, fs, freq, Q, gain):
    filt = adsp.Filter(2, fs)
    y = np.zeros_like(x)

    b, a = adsp.design_bell(freq, Q, 10**(-60/20), fs)
    filt.set_coefs(b, a)

    for n in range(len(x)):
        curGain = gain**n
        y[n] = filt.process_sample(x[n]) * (1.0 - curGain) + x[n] * curGain
    return y
예제 #2
0
    def add_bell(self, fc, Q, gain):
        """
        Add a bell filter to the EQ

        Parameters
        ----------
        fc : float
            Cutoff frequency
        Q : float
            Q factor
        gain : float
            gain in linear units
        """
        string = 'Bell, Freq: {}, Q: {}, gain: {}'.format(fc, Q, gain)
        filter = adsp.Filter(2, self.fs, type=string)
        b, a = adsp.design_bell(fc, Q, gain, self.fs)
        filter.set_coefs(b, a)
        self.add_filter(filter)
예제 #3
0
 def test_eq_bell_design(self):
     b, a = adsp.design_bell(_fs_ / 2, 0.707, 1, _fs_)
     checkCoefs(self, b, a, [1, 2, 1], [1, 2, 1])
예제 #4
0
def static_filt(freq, bandwidth, gainDB, sig):
    sig_filt = np.copy(sig)
    b,a = adsp.design_bell(freq, freq/bandwidth, 10**(gainDB/20), fs)
    sig_filt = signal.lfilter(b, a, sig_filt)
    return sig_filt
예제 #5
0
 def time_bell_filter(self):
     for _ in range(_num_):
         adsp.design_bell(_fc_, _Q_, _gain_, _fs_)
fs = 44100
sweep = adsp.sweep_log(20, 22000, 2, fs)
y = np.copy(sweep)

mags = np.array([0.99, 0.99])
poles = np.array([1000, -1000])
# b, a = design_allpole (mags, poles, fs=fs)

#%%
freqs = np.logspace(1, 3.4, num=1000, base=20)
for g in [0.00001, 0.001, 0.01, 0.1, 0.5, 0.8]:
    cur_sweep = np.copy(sweep) * g
    y = np.copy(cur_sweep)

    filter = Biquad()
    b, a = adsp.design_bell(1000, 0.707, 2, fs)
    filter.setCoefs(b, a)
    # filter.set_coefs (a)
    filter.fb_lambda = lambda a, x: a * np.tanh(x)  # adsp.soft_clipper (x)
    y = filter.process_block(y)

    h = adsp.normalize(adsp.sweep2ir(cur_sweep, y))
    adsp.plot_magnitude_response(h, [1], worN=freqs, fs=fs)

# plt.ylim (-15)

#%%
filter = AllPole()
filter.set_coefs(a)
filter.fb_lambda = lambda a, x: a * adsp.soft_clipper(x)
y = filter.process_block(y)