SFML community forums
Help => Audio => Topic started by: OniLinkPlus on August 14, 2009, 06:12:19 am
-
I have tried everything, including resetting the buffer when I load a sound. The Console isn't telling me anything that could be causing the problem, either. Currently I am using:
Sound.LoadFromFile("Resources/SFX/Jump.wav");
SFX.SetBuffer(Sound);
SFX.Play();
Yes, I have confirmed that the file exists. SFX was initialized as sf::Sound SFX(Sound), and Sound IS a SoundBuffer. Could it be a problem with the file itself?
-
Can you provide a complete / minimal code that reproduces the problem? It would be helpful to have the sound file, too.
-
#include <SFML/Audio.hpp>
sf::SoundBuffer Sound;
sf::Sound SFX(Sound);
int main()
{
Sound.OpenFromFile("Resources/SFX/Jump.wav");
SFX.Play();
while(SFX.Playing)
{
}
return EXIT_SUCCESS;
}
Sound inside the folders: http://www.mediafire.com/?owkkttdztzn
Link with Audio and System.
BTW, I tried the latest SVN Repository version and tried to statically link: Now my OGG files are being called "malformed". They worked before in SFML 1.5, so I dunno what's wrong. The WAV still doesn't work in the SVN sfml2 Version either.
-
Well, a code that you actually tried would be more useful (this one doesn't even compile, and throws lots of messages when you fix the syntax errors).
This one works perfectly:
#include <SFML/Audio.hpp>
int main()
{
sf::SoundBuffer Sound;
Sound.LoadFromFile("jump.wav");
sf::Sound SFX(Sound);
SFX.Play();
while(SFX.GetStatus() == sf::Sound::Playing)
{
}
return EXIT_SUCCESS;
}
-> Don't do anything outside main()
-> Don't pass the buffer to the sound before loading the sound file
-
Well, a code that you actually tried would be more useful (this one doesn't even compile, and throws lots of messages when you fix the syntax errors).
This one works perfectly:
#include <SFML/Audio.hpp>
int main()
{
sf::SoundBuffer Sound;
Sound.LoadFromFile("jump.wav");
sf::Sound SFX(Sound);
SFX.Play();
while(SFX.GetStatus() == sf::Sound::Playing)
{
}
return EXIT_SUCCESS;
}
-> Don't do anything outside main()
-> Don't pass the buffer to the sound before loading the sound file
Wait, what syntax errors? That's a stripped down version of the code I'm using.
Anyways, I did what you said and it works now, but there's still the problem of Audio thinking my OGG Vorbis Audio files are corrupt.
-
Wait, what syntax errors? That's a stripped down version of the code I'm using.
OpenFromFile is a member of sf::Music, not sf::SoundBuffer.
SFX.Playing is a constant, so you get an endless loop (ok, this is not really a syntax error).
there's still the problem of Audio thinking my OGG Vorbis Audio files are corrupt.
So I guess they are. SFML 2.0 uses the official ogg/vorbis libraries, whereas in 1.5 it was an implementation written from scratch (not by me).
-
Wait, what syntax errors? That's a stripped down version of the code I'm using.
OpenFromFile is a member of sf::Music, not sf::SoundBuffer.
SFX.Playing is a constant, so you get an endless loop (ok, this is not really a syntax error).
there's still the problem of Audio thinking my OGG Vorbis Audio files are corrupt.
So I guess they are. SFML 2.0 uses the official ogg/vorbis libraries, whereas in 1.5 it was an implementation written from scratch (not by me).
Ack, why do I make so many mistakes?!
I guess Audacity 1.3.8 doesn't correctly support OGGs, cause that's what I'm using to create them. :\ I wonder if there are any fixes.
-
I found the problem. libsndfile-1.dll was outdated by 2 years. :|
-
Hehe, you should always use the DLLs provided in the SFML/extlibs folder :)