Audacity 3.2.0
Functions
anonymous_namespace{FormantShifter.cpp} Namespace Reference

Functions

size_t ResampleFreqDomain (float *x, size_t fftSize, double factor)
 

Detailed Description


Audacity: A Digital Audio Editor

FormantShifter.cpp

Matthieu Hodgkinson

Function Documentation

◆ ResampleFreqDomain()

size_t anonymous_namespace{FormantShifter.cpp}::ResampleFreqDomain ( float *  x,
size_t  fftSize,
double  factor 
)

Definition at line 23 of file FormantShifter.cpp.

24{
25 const auto size = fftSize / 2 + 1;
26 const auto end = std::min(size, size_t(size * factor));
27 std::vector<float> tmp(end);
28 for (size_t i = 0; i < end; ++i)
29 {
30 const int int_pos = i / factor;
31 const float frac_pos = 1.f * i / factor - int_pos;
32 const auto k = MapToPositiveHalfIndex(int_pos, fftSize);
33 const auto l = MapToPositiveHalfIndex(int_pos + 1, fftSize);
34 tmp[i] = (1 - frac_pos) * x[k] + frac_pos * x[l];
35 }
36 std::copy(tmp.begin(), tmp.begin() + end, x);
37 if (end < size)
38 std::fill(x + end, x + size, 0.f);
39 return end;
40}
int min(int a, int b)
constexpr auto MapToPositiveHalfIndex(int index, int fullSize)
Useful when dealing with symmetric spectra reduced only to their positive half. See tests below for m...
const char * end(const char *str) noexcept
Definition: StringUtils.h:106
void copy(const T *src, T *dst, int32_t n)
Definition: VectorOps.h:40

References staffpad::vo::copy(), details::end(), MapToPositiveHalfIndex(), min(), and size.

Referenced by FormantShifter::Process().

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