25 const auto size = fftSize / 2 + 1;
27 std::vector<float> tmp(
end);
28 for (
size_t i = 0; i <
end; ++i)
30 const int int_pos = i / factor;
31 const float frac_pos = 1.f * i / factor - int_pos;
34 tmp[i] = (1 - frac_pos) * x[k] + frac_pos * x[l];
38 std::fill(x +
end, x +
size, 0.f);
46 : cutoffQuefrency { cutoffQuefrency }
54 mFft = std::make_unique<staffpad::audio::FourierTransform>(fftSize);
55 const auto numBins = fftSize / 2 + 1;
68 const float* powSpec, std::complex<float>* spec,
double factor)
74 const auto fftSize =
mFft->getSize();
75 const auto numBins = fftSize / 2 + 1;
82 const float normalizer =
FastLog2(fftSize);
83 std::transform(powSpec, powSpec + numBins, pEnv, [&](
float power) {
94 if (binCutoff < fftSize / 2)
95 std::fill(pCepst + binCutoff + 1, pCepst + fftSize - binCutoff, 0.f);
96 mLogger.
Log(pCepst, fftSize,
"cepstrumLiftered");
102 [fftSize = fftSize](
const std::complex<float>& env) {
103 return std::exp2(env.real() / fftSize);
111 [](
float env) { return std::isnormal(env) ? 1.f / env : 0.f; });
113 const auto lastNonZeroedBin =
119 mWeights.begin(), [](
float env,
float weight) {
124 return std::min(env * weight, 100.f);
139 spec, numBins,
"magnitude",
140 [fftSize = fftSize](
const std::complex<float>& spec) {
141 return std::abs(spec) / fftSize;
146 spec, spec + numBins,
mWeights.begin(), spec,
147 std::multiplies<std::complex<float>>());
150 spec, numBins,
"weightedMagnitude",
151 [fftSize = fftSize](
const std::complex<float>& spec) {
152 return std::abs(spec) / fftSize;
constexpr auto MapToPositiveHalfIndex(int index, int fullSize)
Useful when dealing with symmetric spectra reduced only to their positive half. See tests below for m...
constexpr float FastLog2(float x)
Approximates the base-2 logarithm of a float to two decimal places, adapted from https://stackoverflo...
void setSize(int32_t numChannels, int32_t samples)
T * getPtr(int32_t channel)
constexpr auto sampleRate
const char * end(const char *str) noexcept
constexpr fastfloat_really_inline int32_t power(int32_t q) noexcept
void copy(const T *src, T *dst, int32_t n)