A few signal-bits tests

This commit is contained in:
Chris Cannam
2022-06-08 10:35:51 +01:00
parent 95a1d6df25
commit 0b8b0742c1
5 changed files with 155 additions and 9 deletions

View File

@@ -205,15 +205,15 @@ public:
}
// Convenience function that applies a given filter to an array
// in-place. Array must have length equal to getSize(). Modifies
// both the filter and the array.
// in-place. Array has length n. Modifies both the filter and the
// array.
//
static void filter(MovingMedian<T> &mm, T *v) {
int n = mm.getSize();
int lag = n / 2;
static void filter(MovingMedian<T> &mm, T *v, int n) {
int fn = mm.getSize();
int lag = fn / 2;
mm.reset();
for (int i = 0; i < lag; ++i) {
mm.push(v[i]);
if (i < n) mm.push(v[i]);
}
for (int i = lag; i < n; ++i) {
mm.push(v[i]);
@@ -224,6 +224,12 @@ public:
v[i-lag] = mm.get();
}
}
// As above but with a vector argument
//
static void filter(MovingMedian<T> &mm, std::vector<T> &v) {
filter(mm, v.data(), v.size());
}
private:
MovingMedianStack<T> m_mm;