Create a MovingMedianStack to contain a stack of filters with contiguous addressing - does not appear to be notably beneficial, though I quite like the api

This commit is contained in:
Chris Cannam
2022-06-07 09:50:33 +01:00
parent c31839ef93
commit 0cd622d0da
3 changed files with 140 additions and 8 deletions

View File

@@ -66,16 +66,13 @@ public:
BinClassifier(Parameters parameters) :
m_parameters(parameters),
m_hFilters(new MovingMedianStack<double>(m_parameters.binCount,
m_parameters.horizontalFilterLength)),
m_vFilter(new MovingMedian<double>(m_parameters.verticalFilterLength)),
m_vfQueue(parameters.horizontalFilterLag)
{
int n = m_parameters.binCount;
for (int i = 0; i < n; ++i) {
m_hFilters.push_back(std::make_shared<MovingMedian<double>>
(m_parameters.horizontalFilterLength));
}
m_hf = allocate_and_zero<double>(n);
m_vf = allocate_and_zero<double>(n);
@@ -96,12 +93,17 @@ public:
deallocate(m_vf);
}
void reset()
{
m_hFilters->reset();
}
void classify(const double *const mag, Classification *classification) {
const int n = m_parameters.binCount;
for (int i = 0; i < n; ++i) {
m_hFilters[i]->push(mag[i]);
m_hf[i] = m_hFilters[i]->get();
m_hFilters->push(i, mag[i]);
m_hf[i] = m_hFilters->get(i);
}
v_copy(m_vf, mag, n);
@@ -134,7 +136,7 @@ public:
protected:
Parameters m_parameters;
std::vector<std::shared_ptr<MovingMedian<double>>> m_hFilters;
std::unique_ptr<MovingMedianStack<double>> m_hFilters;
std::unique_ptr<MovingMedian<double>> m_vFilter;
// We manage the queued frames through pointer swapping, hence
// bare pointers here

View File

@@ -201,6 +201,7 @@ protected:
formant(new FormantData(segmenterParameters.fftSize)) { }
void reset() {
haveReadahead = false;
classifier->reset();
segmentation = BinSegmenter::Segmentation();
prevSegmentation = BinSegmenter::Segmentation();
nextSegmentation = BinSegmenter::Segmentation();