50 for(
int i = 0; i < batch_size; ++i)
52 state_1_[i] = state_2_[i] = 0.0f;
56 template <FilterMode mode,
bool add>
57 void Process(
const float* f,
65 float r_plus_g[batch_size];
67 float state_1[batch_size];
68 float state_2[batch_size];
69 float gains[batch_size];
70 for(
int i = 0; i < batch_size; ++i)
74 h[i] = 1.0f / (1.0f + r[i] * g[i] + g[i] * g[i]);
75 r_plus_g[i] = r[i] + g[i];
76 state_1[i] = state_1_[i];
77 state_2[i] = state_2_[i];
83 for(
int i = 0; i < batch_size; ++i)
86 = (s_in - r_plus_g[i] * state_1[i] - state_2[i]) * h[i];
87 const float bp = g[i] * hp + state_1[i];
88 state_1[i] = g[i] * hp + bp;
89 const float lp = g[i] * bp + state_2[i];
90 state_2[i] = g[i] * bp + lp;
91 s_out += gains[i] * ((mode == LOW_PASS) ? lp : bp);
102 for(
int i = 0; i < batch_size; ++i)
104 state_1_[i] = state_1[i];
105 state_2_[i] = state_2[i];
110 static constexpr float kPiPow3 = PI_F * PI_F * PI_F;
111 static constexpr float kPiPow5 = kPiPow3 * PI_F * PI_F;
112 static inline float fasttan(
float f)
114 const float a = 3.260e-01 * kPiPow3;
115 const float b = 1.823e-01 * kPiPow5;
117 return f * (PI_F + f2 * (a + b * f2));
120 float state_1_[batch_size];
121 float state_2_[batch_size];
144 void Init(
float position,
int resolution,
float sample_rate);
173 float frequency_, brightness_, structure_, damping_;
175 static constexpr int kMaxNumModes = 24;
176 static constexpr int kModeBatchSize = 4;
177 static constexpr float ratiofrac_ = 1.f / 12.f;
178 static constexpr float stiff_frac_ = 1.f / 64.f;
179 static constexpr float stiff_frac_2 = 1.f / .6f;
183 float CalcStiff(
float sig);
185 float mode_amplitude_[kMaxNumModes];