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

Author Topic: SFML In Windows Won't Play Sound  (Read 3532 times)

0 Members and 1 Guest are viewing this topic.

malkierian

  • Newbie
  • *
  • Posts: 39
    • View Profile
SFML In Windows Won't Play Sound
« on: January 29, 2014, 07:12:40 am »
OK, here's the stats:

Windows 7
Visual Studio 2012
SFML 2.1 custom build (through VS)

So I'm trying to make a setup to test my playback device selection modification to SFML, but I can't get a sound to play in the first place.  I have the libs, includes, dlls and path setup properly (it's finding everything).  I copied the code over from the VS setup tutorial, and the window shows up, the green circle is drawn.

I have load a sound into a buffer and set it to a Sound, and also set it to change the circle's color on mouse click (which is where I have the Sound.play() call), but though it seems to load the sound file just fine (no errors, no returning -1 before the window opens), it just doesn't play at all.  Here's my code:

http://pastebin.com/naP4ub28

The only place I can think of that it would be disconnecting is the buffer set on Sound.  But I have no way of diagnosing or debugging that.  I am using a custom build of SFML, of course.  Any idea what's wrong?
« Last Edit: January 29, 2014, 07:21:42 am by malkierian »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
AW: SFML In Windows Won't Play Sound
« Reply #1 on: January 29, 2014, 07:58:13 am »
Sorry to ask stupid questions: Can you hear other sound, i.e. is you volume turnes up?
Does the circle change to red?

Also you should always use forward slashes in path names and you can init the classes just fine by writting: sf::Sound sound;
No need for = sf::Sound();
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

malkierian

  • Newbie
  • *
  • Posts: 39
    • View Profile
Re: SFML In Windows Won't Play Sound
« Reply #2 on: January 29, 2014, 08:08:12 am »
Yes, I hear the volume from Zune and VLC just fine.  In fact, I've had the sound mixer open while trying this just to see if I can see the meter jump, and it hasn't, though it does show up in the list for the default and active device.

I fixed the initialization and changed the double back slashes to single forward slashes.  Still no sound, though the circle has changed color successfully ever since I first put that code in there.

malkierian

  • Newbie
  • *
  • Posts: 39
    • View Profile
Re: SFML In Windows Won't Play Sound
« Reply #3 on: January 29, 2014, 07:02:46 pm »
Aha!  I got it!  For some reason, it wasn't liking the WAV file I fed it.  Changed it over to a full length song in OGG format and it's working just fine...  Why didn't it like the WAV?

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: SFML In Windows Won't Play Sound
« Reply #4 on: January 29, 2014, 07:23:25 pm »
It is possible that the .wav file is broken, that happens sometimes, but usually you get a message in the console when trying to play a broken file. Maybe upload the file, so others can test it.

edit: you can also try to open the .wav file in a sound editor and export it as a .wav again, to make sure the file isn't malformatted.
« Last Edit: January 29, 2014, 07:25:21 pm by Foaly »

 

anything