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

Method Doppler

examples/sound_effects/SoundEffects.cpp:529–546  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

527{
528public:
529 Doppler() :
530 Effect("Doppler Shift"),
531 m_currentVelocity(getFont(), "Velocity: " + std::to_string(m_velocity)),
532 m_currentFactor(getFont(), "Doppler Factor: " + std::to_string(m_factor))
533 {
534 m_listener.setPosition({(windowWidth - 20.f) / 2.f, (windowHeight - 20.f) / 2.f});
535 m_listener.setFillColor(sf::Color::Red);
536
537 m_position.y = (windowHeight - 20.f) / 2.f - 40.f;
538
539 m_currentVelocity.setPosition({windowWidth / 2.f - 150.f, windowHeight * 3.f / 4.f - 50.f});
540 m_currentFactor.setPosition({windowWidth / 2.f - 150.f, windowHeight * 3.f / 4.f});
541
542 // Set attenuation to a nice value
543 setAttenuation(0.05f);
544
545 sf::SoundStream::initialize(1, sampleRate, {sf::SoundChannel::Mono});
546 }
547
548 void onUpdate(float time, float x, float y) override
549 {

Callers

nothing calls this directly

Calls 3

initializeFunction · 0.85
setPositionMethod · 0.45
setFillColorMethod · 0.45

Tested by

no test coverage detected