Audacity 3.2.0
Functions
MIR::anonymous_namespace{MirDsp.cpp} Namespace Reference

Functions

float GetNoveltyMeasure (const PffftFloatVector &prevPowSpec, const PffftFloatVector &powSpec)
 
std::vector< float > GetMovingAverage (const std::vector< float > &x, double hopRate)
 

Function Documentation

◆ GetMovingAverage()

std::vector< float > MIR::anonymous_namespace{MirDsp.cpp}::GetMovingAverage ( const std::vector< float > &  x,
double  hopRate 
)

Definition at line 39 of file MirDsp.cpp.

40{
41 constexpr auto smoothingWindowDuration = 0.2;
42 // An odd number.
43 const int M = std::round(smoothingWindowDuration * hopRate / 4) * 2 + 1;
44 const auto window = GetNormalizedHann(2 * M + 1);
45 auto n = 0;
46 std::vector<float> movingAverage(x.size());
47 std::transform(x.begin(), x.end(), movingAverage.begin(), [&](float) {
48 const auto m = IotaRange(-M, M + 1);
49 const auto y =
50 std::accumulate(m.begin(), m.end(), 0.f, [&](float y, int i) {
51 auto k = n + i;
52 while (k < 0)
53 k += x.size();
54 while (k >= x.size())
55 k -= x.size();
56 return y + x[k] * window[i + M];
57 });
58 ++n;
59 // The moving average of the raw ODF will be subtracted from it to yield
60 // the final ODF, negative results being set to 0. (This is to remove
61 // noise of small ODF peaks before the method's quantization step.) The
62 // larger this multiplier, the less peaks will remain. This value was
63 // found by trial and error, using the benchmarking framework
64 // (see TatumQuantizationFitBenchmarking.cpp)
65 constexpr auto thresholdRaiser = 1.5f;
66 return y * thresholdRaiser;
67 });
68 return movingAverage;
69}
std::vector< float > GetNormalizedHann(int size)
Definition: MirUtils.cpp:80
fastfloat_really_inline void round(adjusted_mantissa &am, callback cb) noexcept
Definition: fast_float.h:2512

References MIR::GetNormalizedHann(), and fast_float::round().

Referenced by MIR::GetOnsetDetectionFunction().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetNoveltyMeasure()

float MIR::anonymous_namespace{MirDsp.cpp}::GetNoveltyMeasure ( const PffftFloatVector prevPowSpec,
const PffftFloatVector powSpec 
)

Definition at line 28 of file MirDsp.cpp.

30{
31 auto k = 0;
32 return std::accumulate(
33 powSpec.begin(), powSpec.end(), 0.f, [&](float a, float mag) {
34 // Half-wave-rectified stuff
35 return a + std::max(0.f, mag - prevPowSpec[k++]);
36 });
37}

Referenced by MIR::GetOnsetDetectionFunction().

Here is the caller graph for this function: