25#ifndef LMMS_OVERSAMPLING_HELPERS_H
26#define LMMS_OVERSAMPLING_HELPERS_H
31#include <hiir/PolyphaseIir2Designer.h>
34#include <hiir/Downsampler2xSse.h>
35#include <hiir/Upsampler2xSse.h>
37#include <hiir/Downsampler2xFpu.h>
38#include <hiir/Upsampler2xFpu.h>
48template<
int MaxStages,
int MaxCoefs = 8>
58 hiir::PolyphaseIir2Designer::compute_coefs_spec_order_tbw(coefsFirst,
s_firstCoefCount, bw);
61 bw = (bw + 0.5f) * 0.5f;
65 hiir::PolyphaseIir2Designer::compute_coefs_spec_order_tbw(coefsSecond,
s_secondCoefCount, bw);
68 bw = (bw + 0.5f) * 0.5f;
74 hiir::PolyphaseIir2Designer::compute_coefs_spec_order_tbw(coefsRest,
s_restCoefCount, bw);
77 bw = (bw + 0.5f) * 0.5f;
83 assert(stages <= MaxStages);
94 outSamples[0] = inSample;
99 m_upsampleFirst.process_sample(outSamples[0], outSamples[gap1], outSamples[0]);
105 m_upsampleSecond.process_sample(outSamples[0], outSamples[gap2], outSamples[0]);
106 m_upsampleSecond.process_sample(outSamples[gap1], outSamples[gap1 + gap2], outSamples[gap1]);
112 int gap = total /
count;
116 m_upsampleRest[
i - 2].process_sample(outSamples[temp], outSamples[temp + gap / 2], outSamples[temp]);
136 std::array<hiir::Upsampler2xSse<s_restCoefCount>, MaxStages - 2>
m_upsampleRest;
149template<
int MaxStages,
int MaxCoefs = 8>
159 hiir::PolyphaseIir2Designer::compute_coefs_spec_order_tbw(coefsFirst,
s_firstCoefCount, bw);
162 bw = (bw + 0.5f) * 0.5f;
166 hiir::PolyphaseIir2Designer::compute_coefs_spec_order_tbw(coefsSecond,
s_secondCoefCount, bw);
169 bw = (bw + 0.5f) * 0.5f;
175 hiir::PolyphaseIir2Designer::compute_coefs_spec_order_tbw(coefsRest,
s_restCoefCount, bw);
178 bw = (bw + 0.5f) * 0.5f;
184 assert(stages <= MaxStages);
196 for (
int j = 0;
j < 1 <<
i; ++
j)
204 for (
int j = 0;
j < 2; ++
j)
233 std::array<hiir::Downsampler2xSse<s_restCoefCount>, MaxStages - 2>
m_downsampleRest;
constexpr int HIIR_DEFAULT_MAX_COEFS
Definition OversamplingHelpers.h:43
constexpr float HIIR_DEFAULT_PASSBAND
Definition OversamplingHelpers.h:42
Definition OversamplingHelpers.h:151
void setup(int stages, float sampleRate, float passband=HIIR_DEFAULT_PASSBAND)
Definition OversamplingHelpers.h:182
float m_passband
Definition OversamplingHelpers.h:242
static constexpr int s_firstCoefCount
Definition OversamplingHelpers.h:227
int getStages() const
Definition OversamplingHelpers.h:218
float m_sampleRate
Definition OversamplingHelpers.h:241
void reset()
Definition OversamplingHelpers.h:153
std::array< hiir::Downsampler2xFpu< s_restCoefCount >, MaxStages - 2 > m_downsampleRest
Definition OversamplingHelpers.h:237
hiir::Downsampler2xFpu< s_firstCoefCount > m_downsampleFirst
Definition OversamplingHelpers.h:235
float getPassband() const
Definition OversamplingHelpers.h:220
hiir::Downsampler2xFpu< s_secondCoefCount > m_downsampleSecond
Definition OversamplingHelpers.h:236
int m_stages
Definition OversamplingHelpers.h:240
float getSampleRate() const
Definition OversamplingHelpers.h:219
static constexpr int s_restCoefCount
Definition OversamplingHelpers.h:229
void setPassband(float passband)
Definition OversamplingHelpers.h:224
float processSample(float *inSamples)
Definition OversamplingHelpers.h:192
void setSampleRate(float sampleRate)
Definition OversamplingHelpers.h:223
static constexpr int s_secondCoefCount
Definition OversamplingHelpers.h:228
void setStages(int stages)
Definition OversamplingHelpers.h:222
Definition OversamplingHelpers.h:50
void setup(int stages, float sampleRate, float passband=HIIR_DEFAULT_PASSBAND)
Definition OversamplingHelpers.h:81
static constexpr int s_firstCoefCount
Definition OversamplingHelpers.h:130
float getPassband() const
Definition OversamplingHelpers.h:123
void setPassband(float passband)
Definition OversamplingHelpers.h:127
int getStages() const
Definition OversamplingHelpers.h:121
void processSample(float *outSamples, float inSample)
Definition OversamplingHelpers.h:91
void reset()
Definition OversamplingHelpers.h:52
float m_sampleRate
Definition OversamplingHelpers.h:144
float m_passband
Definition OversamplingHelpers.h:145
static constexpr int s_restCoefCount
Definition OversamplingHelpers.h:132
int m_stages
Definition OversamplingHelpers.h:143
hiir::Upsampler2xFpu< s_firstCoefCount > m_upsampleFirst
Definition OversamplingHelpers.h:138
static constexpr int s_secondCoefCount
Definition OversamplingHelpers.h:131
std::array< hiir::Upsampler2xFpu< s_restCoefCount >, MaxStages - 2 > m_upsampleRest
Definition OversamplingHelpers.h:140
hiir::Upsampler2xFpu< s_secondCoefCount > m_upsampleSecond
Definition OversamplingHelpers.h:139
float getSampleRate() const
Definition OversamplingHelpers.h:122
void setStages(int stages)
Definition OversamplingHelpers.h:125
void setSampleRate(float sampleRate)
Definition OversamplingHelpers.h:126
register unsigned j
Definition inflate.c:1576
register unsigned i
Definition inflate.c:1575
Definition AudioAlsa.cpp:35
_WDL_CSTRING_PREFIX void INT_PTR count
Definition wdlcstring.h:263