Audacity 3.2.0
Functions | Variables
MIR::anonymous_namespace{StftFrameProvider.cpp} Namespace Reference

Functions

int GetFrameSize (int sampleRate)
 
double GetHopSize (int sampleRate, long long numSamples)
 

Variables

constexpr auto twoPi = 2 * 3.14159265358979323846
 

Function Documentation

◆ GetFrameSize()

int MIR::anonymous_namespace{StftFrameProvider.cpp}::GetFrameSize ( int  sampleRate)

Definition at line 26 of file StftFrameProvider.cpp.

27{
28 // 2048 frame size for sample rate 44.1kHz
29 return 1 << (11 + (int)std::round(std::log2(sampleRate / 44100.)));
30}
fastfloat_really_inline void round(adjusted_mantissa &am, callback cb) noexcept
Definition: fast_float.h:2512

References fast_float::round(), and anonymous_namespace{ClipSegmentTest.cpp}::sampleRate.

Here is the call graph for this function:

◆ GetHopSize()

double MIR::anonymous_namespace{StftFrameProvider.cpp}::GetHopSize ( int  sampleRate,
long long  numSamples 
)

Definition at line 32 of file StftFrameProvider.cpp.

33{
34 // Aim for a hop size closest to 10ms, yet dividing `numSamples` to a power
35 // of two. This will spare us the need for resampling when we need to get the
36 // autocorrelation of the ODF using an FFT.
37 const auto idealHopSize = 0.01 * sampleRate;
38 const int exponent = std::round(std::log2(numSamples / idealHopSize));
39 if (exponent < 0)
40 return 0;
41 const auto numFrames = 1 << exponent;
42 return 1. * numSamples / numFrames;
43}

References fast_float::round(), and anonymous_namespace{ClipSegmentTest.cpp}::sampleRate.

Here is the call graph for this function:

Variable Documentation

◆ twoPi

constexpr auto MIR::anonymous_namespace{StftFrameProvider.cpp}::twoPi = 2 * 3.14159265358979323846
constexpr

Definition at line 24 of file StftFrameProvider.cpp.