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