dsp module now creates a mel filterbank
Mel filterbank generated based on settings in config.py. Other small pep8 formatting changes. Renamed ExponentialFilter to ExpFilter.
This commit is contained in:
parent
696d684c79
commit
65d35c2724
|
@ -2,9 +2,10 @@ from __future__ import print_function
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from scipy.interpolate import interp1d
|
from scipy.interpolate import interp1d
|
||||||
import config
|
import config
|
||||||
|
import melbank
|
||||||
|
|
||||||
|
|
||||||
class ExponentialFilter:
|
class ExpFilter:
|
||||||
"""Simple exponential smoothing filter"""
|
"""Simple exponential smoothing filter"""
|
||||||
def __init__(self, val=0.0, alpha_decay=0.5, alpha_rise=0.5):
|
def __init__(self, val=0.0, alpha_decay=0.5, alpha_rise=0.5):
|
||||||
"""Small rise / decay factors = more smoothing"""
|
"""Small rise / decay factors = more smoothing"""
|
||||||
|
@ -141,10 +142,10 @@ def onset(yt):
|
||||||
SF = np.nan_to_num(SF)
|
SF = np.nan_to_num(SF)
|
||||||
NWPD = np.nan_to_num(NWPD)
|
NWPD = np.nan_to_num(NWPD)
|
||||||
RCD = np.nan_to_num(RCD)
|
RCD = np.nan_to_num(RCD)
|
||||||
|
# Convert onset detection to logarithmically spaced bins
|
||||||
_, SF = log_partition(xs, SF, subbands=config.N_SUBBANDS)
|
_, SF = log_partition(xs, SF, subbands=config.N_SUBBANDS)
|
||||||
_, NWPD = log_partition(xs, NWPD, subbands=config.N_SUBBANDS)
|
_, NWPD = log_partition(xs, NWPD, subbands=config.N_SUBBANDS)
|
||||||
_, RCD = log_partition(xs, RCD, subbands=config.N_SUBBANDS)
|
_, RCD = log_partition(xs, RCD, subbands=config.N_SUBBANDS)
|
||||||
|
|
||||||
return SF, NWPD, RCD
|
return SF, NWPD, RCD
|
||||||
|
|
||||||
|
|
||||||
|
@ -173,3 +174,11 @@ def log_partition(xs, ys, subbands):
|
||||||
X.append(np.mean(xs_log[i:i + 24]))
|
X.append(np.mean(xs_log[i:i + 24]))
|
||||||
Y.append(np.mean(ys_log[i:i + 24]))
|
Y.append(np.mean(ys_log[i:i + 24]))
|
||||||
return np.array(X), np.array(Y)
|
return np.array(X), np.array(Y)
|
||||||
|
|
||||||
|
|
||||||
|
samples = int(round(config.MIC_RATE * config.N_ROLLING_HISTORY / (2.0 * config.FPS)))
|
||||||
|
mel_y, (_, mel_x) = melbank.compute_melmat(num_mel_bands=config.N_SUBBANDS,
|
||||||
|
freq_min=config.MIN_FREQUENCY,
|
||||||
|
freq_max=config.MAX_FREQUENCY,
|
||||||
|
num_fft_bands=samples,
|
||||||
|
sample_rate=config.MIC_RATE)
|
Loading…
Reference in New Issue
Block a user