Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Spatialization error!  (Read 3297 times)

0 Members and 2 Guests are viewing this topic.

obernardovieira

  • Newbie
  • *
  • Posts: 3
  • Learning ...
    • View Profile
    • Email
Spatialization error!
« 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;
}
Sorry for my bad english :|

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Spatialization error!
« Reply #1 on: August 06, 2013, 08:43:33 pm »
Is it a mono sound?
Laurent Gomila - SFML developer

obernardovieira

  • Newbie
  • *
  • Posts: 3
  • Learning ...
    • View Profile
    • Email
Re: Spatialization error!
« Reply #2 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 -

PS. I'm listening to the speakers of my computer
Sorry for my bad english :|

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Spatialization error!
« Reply #3 on: August 06, 2013, 09:56:06 pm »
Quote
I think not
And what does the first red paragraph says in the tutorial?
Laurent Gomila - SFML developer

obernardovieira

  • Newbie
  • *
  • Posts: 3
  • Learning ...
    • View Profile
    • Email
Re: Spatialization error!
« Reply #4 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
Sorry for my bad english :|

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Spatialization error!
« Reply #5 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?
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Spatialization error!
« Reply #6 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.
Laurent Gomila - SFML developer

 

anything