154 const float envelope_decay
155 = 1.0f - 0.003f * SemitonesToRatio(-decay_ * 84.0f);
156 const float cut_decay
157 = 1.0f - 0.0025f * SemitonesToRatio(-decay_ * 36.0f);
164 = (1.5f + 0.5f * (1.0f - decay_)) * (0.3f + 0.7f * accent_);
168 float out = metallic_noise_.Process(2.0f * f0_);
171 float cutoff = 150.0f / sample_rate_ * SemitonesToRatio(tone_ * 72.0f);
173 cutoff =
fclamp(cutoff, 0.0f, 16000.0f / sample_rate_);
176 noise_coloration_svf_.
SetFreq(cutoff * sample_rate_);
177 noise_coloration_svf_.
SetRes(resonance ? 3.0f + 6.0f * tone_ : 1.0f);
179 noise_coloration_svf_.
Process(out);
180 out = noise_coloration_svf_.
Band();
185 float noise_f = f0_ * (16.0f + 16.0f * (1.0f - noisiness_));
186 noise_f =
fclamp(noise_f, 0.0f, 0.5f);
188 noise_clock_ += noise_f;
189 if(noise_clock_ >= 1.0f)
191 noise_clock_ -= 1.0f;
192 noise_sample_ = rand() * kRandFrac - 0.5f;
194 out += noisiness_ * (noise_sample_ - out);
197 sustain_gain_ = accent_ * decay_;
199 envelope_ *= envelope_ > 0.5f ? envelope_decay : cut_decay;
200 out = vca(out, sustain_ ? sustain_gain_ : envelope_);
202 hpf_.
SetFreq(cutoff * sample_rate_);
260 float accent_, f0_, tone_, decay_, noisiness_;