not understand why, but it does not work, already researched everything on google, I do not see any error in the code, but the sound is played as if playing a song on the computer
can someone help me?
#include <SFML\Audio.hpp>
#include <iostream>
#include <chrono>
#include <thread>
bool iniciarsom(const std::string &nomeficheiro) {
sf::Music musica;
if(musica.openFromFile(nomeficheiro)) {
musica.setPosition(10.f, 1.f, 1.f);
musica.setRelativeToListener(false);
musica.setMinDistance(15.f);
musica.setAttenuation(10.f);
musica.play();
//std::this_thread::sleep_for(std::chrono::seconds((int)musica.getDuration().asSeconds()));
std::this_thread::sleep_for(std::chrono::seconds(5));
}
else {
std::cout << "Erro ao abrir ficheiro" << std::endl;
return false;
}
return true;
}
bool main() {
// Move the listener to the position (1, 0, -5)
sf::Listener::setPosition(20.f, 1.f, 1.f);
// Make it face the right axis (1, 0, 0)
sf::Listener::setDirection(0.f, 1.f, 0.f);
// Reduce the global volume
sf::Listener::setGlobalVolume(90.f);
std::thread musica(iniciarsom,"c:\\musica.wav");
musica.detach();
std::this_thread::sleep_for(std::chrono::seconds(4));
system("pause");
return true;
}