Audacity 3.2.0
Functions | Variables
staffpad::anonymous_namespace{TimeAndPitch.cpp} Namespace Reference

Functions

float lagrange6 (const float(&smp)[6], float t)
 
void generateRandomPhaseVector (float *dst, size_t size, std::mt19937 &gen)
 
float _unwrapPhase (float arg)
 
void _unwrapPhaseVec (float *v, int n)
 
void _fft_shift (float *v, int n)
 rotate even-sized array by half its size to align fft phase at the center More...
 
void _lr_to_ms (float *ch1, float *ch2, int n)
 
void _ms_to_lr (float *ch1, float *ch2, int n)
 

Variables

constexpr double twoPi = 6.28318530717958647692f
 

Function Documentation

◆ _fft_shift()

void staffpad::anonymous_namespace{TimeAndPitch.cpp}::_fft_shift ( float *  v,
int  n 
)

rotate even-sized array by half its size to align fft phase at the center

Definition at line 205 of file TimeAndPitch.cpp.

206{
207 assert((n & 1) == 0);
208 int n2 = n >> 1;
209 audio::simd::perform_parallel_simd_aligned(v, v + n2, n2, [](auto& a, auto& b) {
210 auto tmp = a;
211 a = b;
212 b = tmp;
213 });
214}
void perform_parallel_simd_aligned(const std::complex< float > *input, float *output, int n, const fnc &f)

References staffpad::audio::simd::perform_parallel_simd_aligned().

Referenced by staffpad::TimeAndPitch::_process_hop().

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

◆ _lr_to_ms()

void staffpad::anonymous_namespace{TimeAndPitch.cpp}::_lr_to_ms ( float *  ch1,
float *  ch2,
int  n 
)

Definition at line 216 of file TimeAndPitch.cpp.

217{
218 audio::simd::perform_parallel_simd_aligned(ch1, ch2, n, [](auto& a, auto& b) {
219 auto l = a, r = b;
220 a = 0.5f * (l + r);
221 b = 0.5f * (l - r);
222 });
223}

References staffpad::audio::simd::perform_parallel_simd_aligned().

Referenced by staffpad::TimeAndPitch::_process_hop().

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

◆ _ms_to_lr()

void staffpad::anonymous_namespace{TimeAndPitch.cpp}::_ms_to_lr ( float *  ch1,
float *  ch2,
int  n 
)

Definition at line 225 of file TimeAndPitch.cpp.

226{
227 audio::simd::perform_parallel_simd_aligned(ch1, ch2, n, [](auto& a, auto& b) {
228 auto m = a, s = b;
229 a = m + s;
230 b = m - s;
231 });
232}

References staffpad::audio::simd::perform_parallel_simd_aligned().

Referenced by staffpad::TimeAndPitch::_process_hop().

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

◆ _unwrapPhase()

float staffpad::anonymous_namespace{TimeAndPitch.cpp}::_unwrapPhase ( float  arg)
inline

Definition at line 193 of file TimeAndPitch.cpp.

194{
195 using namespace audio::simd;
196 return arg - rint(arg * 0.15915494309f) * 6.283185307f;
197}
__finl float __vecc rint(float a)

References staffpad::audio::simd::rint().

Referenced by staffpad::TimeAndPitch::_time_stretch().

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

◆ _unwrapPhaseVec()

void staffpad::anonymous_namespace{TimeAndPitch.cpp}::_unwrapPhaseVec ( float *  v,
int  n 
)

Definition at line 199 of file TimeAndPitch.cpp.

200{
201 audio::simd::perform_parallel_simd_aligned(v, n, [](auto& a) { a = a - rint(a * 0.15915494309f) * 6.283185307f; });
202}

References staffpad::audio::simd::perform_parallel_simd_aligned(), and staffpad::audio::simd::rint().

Referenced by staffpad::TimeAndPitch::_process_hop().

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

◆ generateRandomPhaseVector()

void staffpad::anonymous_namespace{TimeAndPitch.cpp}::generateRandomPhaseVector ( float *  dst,
size_t  size,
std::mt19937 &  gen 
)

Definition at line 48 of file TimeAndPitch.cpp.

49{
50 std::vector<std::complex<float>> v(size);
51 std::uniform_real_distribution<float> dis(
52 -3.14159265358979323846f, 3.14159265358979323846f);
53 std::for_each(dst, dst + size, [&dis, &gen](auto& a) { a = dis(gen); });
54}

References size.

Referenced by staffpad::TimeAndPitch::setup().

Here is the caller graph for this function:

◆ lagrange6()

float staffpad::anonymous_namespace{TimeAndPitch.cpp}::lagrange6 ( const float(&)  smp[6],
float  t 
)
inline

6-point lagrange interpolator SNR ~ -35.2db interpolates between samples 2 and 3 using t.

smp pointer to a memory region containing 6 samples t fractional sample to interpolate t >= 0 && t < 1 return value the interpolated sample

Definition at line 30 of file TimeAndPitch.cpp.

31{
32 auto* y = &smp[2];
33
34 auto ym1_y1 = y[-1] + y[1];
35 auto twentyfourth_ym2_y2 = 1.f / 24.f * (y[-2] + y[2]);
36 auto c0 = y[0];
37 auto c1 = 0.05f * y[-2] - 0.5f * y[-1] - 1.f / 3.f * y[0] + y[1] - 0.25f * y[2] + 1.f / 30.f * y[3];
38 auto c2 = 2.f / 3.f * ym1_y1 - 1.25f * y[0] - twentyfourth_ym2_y2;
39 auto c3 = 5.f / 12.f * y[0] - 7.f / 12.f * y[1] + 7.f / 24.f * y[2] - 1.f / 24.f * (y[-2] + y[-1] + y[3]);
40 auto c4 = 0.25f * y[0] - 1.f / 6.f * ym1_y1 + twentyfourth_ym2_y2;
41 auto c5 = 1.f / 120.f * (y[3] - y[-2]) + 1.f / 24.f * (y[-1] - y[2]) + 1.f / 12.f * (y[1] - y[0]);
42
43 // Estrin's scheme
44 auto t2 = t * t;
45 return (c0 + c1 * t) + (c2 + c3 * t) * t2 + (c4 + c5 * t) * t2 * t2;
46}

Referenced by staffpad::TimeAndPitch::feedAudio().

Here is the caller graph for this function:

Variable Documentation

◆ twoPi

constexpr double staffpad::anonymous_namespace{TimeAndPitch.cpp}::twoPi = 6.28318530717958647692f
constexpr

Definition at line 20 of file TimeAndPitch.cpp.

Referenced by staffpad::TimeAndPitch::setup().