SFML community forums

Help => Audio => Topic started by: obernardovieira on August 06, 2013, 08:33:18 pm

Title: Spatialization error!
Post by: obernardovieira on August 06, 2013, 08:33:18 pm
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;
}
Title: Re: Spatialization error!
Post by: Laurent on August 06, 2013, 08:43:33 pm
Is it a mono sound?
Title: Re: Spatialization error!
Post by: obernardovieira on August 06, 2013, 09:19:28 pm
I think not, and I read some things about it but did not understand much  :-[ or nothing!

this is the sound - http://www.youtube.com/watch?v=QUjagJaB03w

PS. I'm listening to the speakers of my computer
Title: Re: Spatialization error!
Post by: Laurent on August 06, 2013, 09:56:06 pm
Quote
I think not
And what does the first red paragraph says in the tutorial?
Title: Re: Spatialization error!
Post by: obernardovieira on August 06, 2013, 10:20:36 pm
"A sound can be spatialized only if it has a single channel, i.e. if it's a mono sound.
Spatialization is disabled for sounds with more channels, since they already explicitly decide how to use the speakers. This is very important to keep in mind."

so, i can't spatialize sounds like it?  :-\
My objective was to make something like teamspeak but specialized to enter into a game
Title: Re: Spatialization error!
Post by: zsbzsb on August 07, 2013, 03:30:15 am
so, i can't spatialize sounds like it?  :-\

Well ever thought of converting it to a format that can be spatialized?
Title: Re: Spatialization error!
Post by: Laurent on August 07, 2013, 07:50:39 am
Quote
so, i can't spatialize sounds like it?
Just merge the channels to make it a mono sound. Any decent audio editor should be able to do that.