Working equalizer
This commit is contained in:
parent
47a2e9972c
commit
76dbdfb526
@ -81,6 +81,7 @@ AvPowerSpectra::AvPowerSpectra(const us nfft, const Window::WindowType w,
|
||||
void AvPowerSpectra::reset() {
|
||||
_timeBuf.reset();
|
||||
_est.reset();
|
||||
n_averages=0;
|
||||
|
||||
}
|
||||
|
||||
|
@ -34,21 +34,21 @@ bool RtAps::inCallback_threaded(const DaqData &data) {
|
||||
if (_filterPrototype) {
|
||||
|
||||
// Adjust number of filters, if necessary
|
||||
if (nchannels > _freqWeightingFilter.size()) {
|
||||
while (nchannels > _freqWeightingFilter.size()) {
|
||||
_freqWeightingFilter.emplace_back(_filterPrototype->clone());
|
||||
if (nchannels > _freqWeightingFilters.size()) {
|
||||
while (nchannels > _freqWeightingFilters.size()) {
|
||||
_freqWeightingFilters.emplace_back(_filterPrototype->clone());
|
||||
}
|
||||
|
||||
for (auto &filter : _freqWeightingFilter) {
|
||||
for (auto &filter : _freqWeightingFilters) {
|
||||
filter->reset();
|
||||
}
|
||||
}
|
||||
|
||||
// Apply filtering
|
||||
#pragma omp parallel for
|
||||
/* #pragma omp parallel for */
|
||||
for (us i = 0; i < nchannels; i++) {
|
||||
vd col = fltdata.col(i);
|
||||
_freqWeightingFilter.at(i)->filter(col);
|
||||
_freqWeightingFilters.at(i)->filter(col);
|
||||
fltdata.col(i) = col;
|
||||
}
|
||||
} // End of if(_filterPrototype)
|
||||
|
@ -23,7 +23,7 @@ class RtAps : public ThreadedInDataHandler {
|
||||
|
||||
std::mutex _mtx;
|
||||
std::unique_ptr<Filter> _filterPrototype;
|
||||
std::vector<std::unique_ptr<Filter>> _freqWeightingFilter;
|
||||
std::vector<std::unique_ptr<Filter>> _freqWeightingFilters;
|
||||
|
||||
AvPowerSpectra _ps;
|
||||
|
||||
|
@ -235,12 +235,20 @@ class SosFilterBank:
|
||||
|
||||
self.fs = fs
|
||||
self.xs = list(range(xmin, xmax + 1))
|
||||
|
||||
# The number of parallel filters
|
||||
nfilt = len(self.xs)
|
||||
|
||||
self.nfilt = nfilt
|
||||
self._fb = pyxSosFilterBank(nfilt, 5)
|
||||
|
||||
sos = None
|
||||
for i, x in enumerate(self.xs):
|
||||
sos = self.designer.createSOSFilter(x)
|
||||
self._fb.setFilter(i, sos)
|
||||
channel = self.designer.createSOSFilter(x)
|
||||
if sos is None:
|
||||
sos = np.empty((channel.size, len(self.xs)))
|
||||
sos[:, i] = channel.flatten()
|
||||
|
||||
self._fb = BiquadBank(sos)
|
||||
|
||||
self.xmin = xmin
|
||||
self.xmax = xmax
|
||||
@ -250,13 +258,14 @@ class SosFilterBank:
|
||||
"""
|
||||
Filter input data
|
||||
"""
|
||||
assert data.ndim == 2
|
||||
assert data.shape[1] == 1, "invalid number of channels, should be 1"
|
||||
|
||||
if data.ndim > 1 and data.shape[1] != 1:
|
||||
raise RuntimeError("invalid number of channels, should be 1")
|
||||
|
||||
if data.shape[0] == 0:
|
||||
return {}
|
||||
|
||||
filtered_data = self._fb.filter_(data)
|
||||
filtered_data = self._fb.filter(data)
|
||||
|
||||
# Output given as a dictionary with nom_txt as the key
|
||||
output = {}
|
||||
|
Loading…
Reference in New Issue
Block a user