Audacity 3.2.0
Functions
MapToPositiveHalfIndex.h File Reference
#include <cassert>
Include dependency graph for MapToPositiveHalfIndex.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

constexpr auto MapToPositiveHalfIndex (int index, int fullSize)
 Useful when dealing with symmetric spectra reduced only to their positive half. See tests below for more details. More...
 

Function Documentation

◆ MapToPositiveHalfIndex()

constexpr auto MapToPositiveHalfIndex ( int  index,
int  fullSize 
)
constexpr

Useful when dealing with symmetric spectra reduced only to their positive half. See tests below for more details.

Parameters
fullSizeThe size of the original vector. Must be strictly positive and even, or the function will return 0.
Precondition
fullSize > 0 && fullSize % 2 == 0

Definition at line 12 of file MapToPositiveHalfIndex.h.

13{
14 assert(fullSize > 0 && fullSize % 2 == 0);
15 if (index >= 0)
16 index = index % fullSize;
17 else
18 index = fullSize - (-index % fullSize);
19 if (index > fullSize / 2)
20 index = fullSize - index;
21 return index;
22}

Referenced by MIR::anonymous_namespace{GetMeterUsingTatumQuantizationFit.cpp}::GetBeatSelfSimilarityScore(), and anonymous_namespace{FormantShifter.cpp}::ResampleFreqDomain().

Here is the caller graph for this function: