Here it goes. I removed most of what was unrelated to the problem, and I verified that the problem is still there.
#include <iostream>
#include <cstdlib>
#include <SFML/Window.hpp>
#include <SFML/Audio.hpp>
int main() {
sf::Window window;
window.create(sf::VideoMode(800,600), "SFML Audio Test");
// Load sound data
sf::SoundBuffer sample_sb;
if (!sample_sb.loadFromFile("sfx/Sample.wav")) {
std::cerr << "Can't open \"sfx/Sample.wav\"\n";
std::exit(1);
}
sf::Sound sound;
sound.setBuffer(sample_sb);
while (window.isOpen()) {
// Process events
sf::Event event;
while (window.pollEvent(event)) {
switch (event.type) {
case sf::Event::Closed:
window.close();
break;
case sf::Event::KeyPressed:
switch (event.key.code) {
case sf::Keyboard::Escape:
window.close();
break;
case sf::Keyboard::Space:
sound.play();
default:;
}
break;
default:;
}
}
}
}