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

Method HighPassFilter

examples/sound_effects/SoundEffects.cpp:810–826  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

808struct HighPassFilter : BiquadFilter
809{
810 HighPassFilter() : BiquadFilter("High-pass Filter")
811 {
812 static constexpr auto cutoffFrequency = 2000.f;
813
814 const auto c = std::tan(
815 pi * cutoffFrequency / static_cast<float>(sf::PlaybackDevice::getDeviceSampleRate().value_or(44100)));
816
817 Coefficients coefficients;
818
819 coefficients.a0 = 1.f / (1.f + sqrt2 * c + std::pow(c, 2.f));
820 coefficients.a1 = -2.f * coefficients.a0;
821 coefficients.a2 = coefficients.a0;
822 coefficients.b1 = 2.f * coefficients.a0 * (std::pow(c, 2.f) - 1.f);
823 coefficients.b2 = coefficients.a0 * (1.f - sqrt2 * c + std::pow(c, 2.f));
824
825 setCoefficients(coefficients);
826 }
827};
828
829

Callers

nothing calls this directly

Calls 1

getDeviceSampleRateFunction · 0.85

Tested by

no test coverage detected