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

Author Topic: [SOLVED] Doesn't play a Mono.wav  (Read 2710 times)

0 Members and 1 Guest are viewing this topic.

er4zox

  • Newbie
  • *
  • Posts: 7
    • View Profile
[SOLVED] Doesn't play a Mono.wav
« on: February 05, 2015, 06:14:40 pm »
Hey guys, I wanted to experiment with spatialized sounds but I'm already stuck on playing a normal Mono file.

I know that spatialized sounds have to be mono, but it doesn't even play the mono sound. However, it  does play the sound rendered in stereo. I really dont know why this happens.

Is there anything special I have to care for while rendering a mono file so SFML can use it?

The 2 sounds (Mono/Sterero) are attached.

Thanks for your help!

Greetings
Er4zoX

#include <SFML/System.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(500, 500), "SFML works!");

        sf::SoundBuffer sb_Sound;
        sf::Sound snd_Sound;

        sb_Sound.loadFromFile("SFMLSoundTestMono.wav"); // Sound in Mono
        //sb_Sound.loadFromFile("SFMLSoundTest.wav");   // Sound in Stereo
        snd_Sound.setBuffer(sb_Sound);

        sf::RectangleShape shape;
        shape.setSize(sf::Vector2f(50.0f,50.0f));
        shape.setPosition(200,200);

        snd_Sound.setLoop(true);
        snd_Sound.play();

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();        
        }
        window.clear();
                window.draw(shape);
        window.display();
    }
    return 0;
}
 
« Last Edit: February 05, 2015, 09:24:51 pm by er4zox »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Doesn't play a Mono.wav
« Reply #1 on: February 05, 2015, 08:40:46 pm »
Any error in the console output? Have you tried to convert your mono sound to stereo, and your stereo sound to mono, to see if it's the sound itself which is corrupt? Have you tried other mono sounds?
Laurent Gomila - SFML developer

er4zox

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Doesn't play a Mono.wav
« Reply #2 on: February 05, 2015, 08:55:44 pm »
No error in the console. I tried another converter (Audacity) and now it works.
But its weird that it wasn't played, because every player I tried (iTunes,Vlc,WinPlayer) played the file.

Thanks for your reply :)