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

Author Topic: Sf::Sound for music  (Read 6109 times)

0 Members and 4 Guests are viewing this topic.

wogoo

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Sf::Sound for music
« on: February 02, 2014, 02:32:00 pm »
I have to use the Sf::Sound to play music instead of sound effects, loading first the entire file from memory.
However on my slow computer the music plays terribly (cracks, blocks, etc).

Is there a way to do this?
Thanks.

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Sf::Sound for music
« Reply #1 on: February 02, 2014, 03:08:29 pm »
Clean up your pc or buy a new one that can at least handle streaming a single file from the hdd  ;)
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

wogoo

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: Sf::Sound for music
« Reply #2 on: February 02, 2014, 03:39:01 pm »
I think Sf::Sound does not stream the file, Sf::Music does this, am i wrong?


zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Sf::Sound for music
« Reply #3 on: February 02, 2014, 03:58:07 pm »
sf::Sound loads all audio data into memory before playing.
sf::Music streams audio data from the disk while playing.

I thought you meant in your original post that sf::Music has issues while playing...
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

wogoo

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: Sf::Sound for music
« Reply #4 on: February 02, 2014, 04:04:40 pm »
No, i don't.
I have to play music with Sf::Sound (for a reason i can't explain here) but when i do this on slow computers i get a very bad sound.
Is Sf::Sound played in a separate thread?

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: Sf::Sound for music
« Reply #5 on: February 02, 2014, 04:51:56 pm »
Yes sf::Sounds are played back in a different thread.
Just to get this right: You are loading a "music file" (a long sound file) in a sf::SoundBuffer and when you play it you get cracks and other distortions?

wogoo

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: Sf::Sound for music
« Reply #6 on: February 02, 2014, 05:03:11 pm »
Yes, the music does not play smoothly, like it's not played in an other thread (the cracks and distorsions are dued to the lag of the sound).

I tried also some games on the same pc and the audio works properly.
« Last Edit: February 02, 2014, 05:05:17 pm by wogoo »

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Sf::Sound for music
« Reply #7 on: February 02, 2014, 05:15:44 pm »
What are the specs of the pc in question?
And what are the specs of the sound file? (length, format, sample rate, channel count)
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

wogoo

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: Sf::Sound for music
« Reply #8 on: February 02, 2014, 06:19:23 pm »
My fault, now i tried Sf::Music and i get the same issue :/

The specs of the computer are not relevant, i played and developed games for years with it without problems.
Regarding the music i tried a lot of files and formats but i get the same behaviour.
I create also an empty project with only a single music played and i get the same issue.

Could it be an OpenAl/Libsnd problem?

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Sf::Sound for music
« Reply #9 on: February 02, 2014, 06:27:02 pm »
It could also be a driver issue. Try updating your audio drivers and using the latest version of SFML (build it from github source) and also make sure you are using the latest version of OpenAL/libsnd from the github source bin folder.  ;)
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Sf::Sound for music
« Reply #10 on: February 02, 2014, 06:37:25 pm »
.ogg files that weren't normalized tend to crack. Post the file you have problem with if you can or try find or make another cracking one that you can share.
Back to C++ gamedev with SFML in May 2023

wogoo

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: Sf::Sound for music
« Reply #11 on: February 02, 2014, 06:52:37 pm »
Solved ;)
The OpenAL.dll's for 32 and 64 bit are swapped in SFML downloads.

In the 32-bit version (i tried only Windows) there is the 64-bit OpenAL (454kb, and the 32-bit version is 410kb).
Also in the source file download the dll's are swapped.

Please someone tell Laurent, i also get a crash when i tried the new 32-bit version on GitHub.

The main problem is that when i try to use the 64-bit Libsnd i get a crash, this not happens with OpenAL.
Additionally as i said i have no problem with my main computer, i get this issues with the other one.






« Last Edit: February 02, 2014, 06:58:48 pm by wogoo »

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Sf::Sound for music
« Reply #12 on: February 15, 2014, 08:50:29 pm »
I'm currious as to why sf::Music couldn't be used???

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Sf::Sound for music
« Reply #13 on: February 15, 2014, 09:02:25 pm »
I'm currious as to why sf::Music couldn't be used???
...a reason i can't explain here...
Sounds ominous, doesn't it?  ???
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*