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

Method PitchVolume

examples/sound_effects/SoundEffects.cpp:175–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173{
174public:
175 PitchVolume() :
176 Effect("Pitch / Volume"),
177 m_pitchText(getFont(), "Pitch: " + std::to_string(m_pitch)),
178 m_volumeText(getFont(), "Volume: " + std::to_string(m_volume))
179 {
180 // Load the music file
181 if (!m_music.openFromFile(resourcesDir() / "doodle_pop.ogg"))
182 {
183 std::cerr << "Failed to load " << (resourcesDir() / "doodle_pop.ogg").string() << std::endl;
184 std::abort();
185 }
186
187 // Set the music to loop
188 m_music.setLooping(true);
189
190 // We don't care about attenuation in this effect
191 m_music.setAttenuation(0.f);
192
193 // Set initial pitch
194 m_music.setPitch(m_pitch);
195
196 // Set initial volume
197 m_music.setVolume(m_volume);
198
199 m_pitchText.setPosition({windowWidth / 2.f - 120.f, windowHeight / 2.f - 80.f});
200 m_volumeText.setPosition({windowWidth / 2.f - 120.f, windowHeight / 2.f - 30.f});
201 }
202
203 void onUpdate(float /*time*/, float x, float y) override
204 {

Callers

nothing calls this directly

Calls 7

setAttenuationMethod · 0.80
setPitchMethod · 0.80
setVolumeMethod · 0.80
resourcesDirFunction · 0.70
openFromFileMethod · 0.45
setLoopingMethod · 0.45
setPositionMethod · 0.45

Tested by

no test coverage detected