MCPcopy Create free account
hub / github.com/SFML/SFML / LowPassFilter

Method LowPassFilter

examples/sound_effects/SoundEffects.cpp:835–851  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

833struct LowPassFilter : BiquadFilter
834{
835 LowPassFilter() : BiquadFilter("Low-pass Filter")
836 {
837 static constexpr auto cutoffFrequency = 500.f;
838
839 const auto c = 1.f / std::tan(pi * cutoffFrequency /
840 static_cast<float>(sf::PlaybackDevice::getDeviceSampleRate().value_or(44100)));
841
842 Coefficients coefficients;
843
844 coefficients.a0 = 1.f / (1.f + sqrt2 * c + std::pow(c, 2.f));
845 coefficients.a1 = 2.f * coefficients.a0;
846 coefficients.a2 = coefficients.a0;
847 coefficients.b1 = 2.f * coefficients.a0 * (1.f - std::pow(c, 2.f));
848 coefficients.b2 = coefficients.a0 * (1.f - sqrt2 * c + std::pow(c, 2.f));
849
850 setCoefficients(coefficients);
851 }
852};
853
854

Callers

nothing calls this directly

Calls 1

getDeviceSampleRateFunction · 0.85

Tested by

no test coverage detected