I've been searching for and trying out many solutions for the whole day, but haven't been able to do anything about the problem so far. There seems to be a problem with the SoundBuffer, because when running this program, the consolole always is showing the same error:
"An internal OpenAL call failed in SoundBuffer.cpp (253) : AL_INVALID_VALVE, a numeric argument is out of range"
Chaning to static lib didnt help here and even putting the audio and libsndfile dlls didnt work either, but if I want to play the same file as "music", than in magically works. (see commented out code below ) I've even tried to replace the ole32.dll (inside Windows\SysWow64) with a newer one, but then visual studio did not start at all (instant crash). I'm using SMFL 2.1 (32 bit) with Visual Studio 2010 on a 64 bit Win 7 Machine. Any help appreciated!
main.cpp:
#include <iostream>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
int main()
{
sf::RenderWindow mMainWindow(sf::VideoMode(300,400,32), "Exitsoundcrash", sf::Style::Titlebar);
sf::Event mMainEvent;
sf::SoundBuffer soundBuffer; // <-----sound doesn't play (error in console window)
sf::Sound sound;
sound.setBuffer(soundBuffer);
if (!soundBuffer.loadFromFile("car.wav"))
return -1;
sound.play();
// sf::Music music; <----- this works
// if (!music.openFromFile("car.wav"))
// return -1;
// music.play();
while(mMainWindow.isOpen())
{
while(mMainWindow.pollEvent(mMainEvent))
{
if(mMainEvent.key.code == sf::Keyboard::Escape)
mMainWindow.close();
}
mMainWindow.clear();
mMainWindow.setFramerateLimit(30);
mMainWindow.display();
}
return 0;
}