Hi,
I am having trouble getting any sound with your tutorial code to work. I am using code::blocks 10.05, sfml 1.6 on win7-64. Its the first time I have used the audio library. But I have got another tutorial too work playing sound and music. Kaboom.wav is actually from that tutorial and plays in windows media player fine.
http://www.gamefromscratch.com/page/Game-From-Scratch-CPP-Edition-Part-9.aspx (http://www.gamefromscratch.com/page/Game-From-Scratch-CPP-Edition-Part-9.aspx)
#include <SFML/Audio.hpp>
#include <iomanip>
#include <iostream>
int main()
{
// Load a sound buffer from a wav file
sf::SoundBuffer Buffer;
if (!Buffer.LoadFromFile("kaboom.wav"))
{
std::cout << "unable to load file\n";
return EXIT_FAILURE;
}
// Display sound informations
std::cout << "sound.wav :" << std::endl;
std::cout << " " << Buffer.GetDuration() << " sec" << std::endl;
std::cout << " " << Buffer.GetSampleRate() << " samples / sec" << std::endl;
std::cout << " " << Buffer.GetChannelsCount() << " channels" << std::endl;
// Create a sound instance and play it
sf::Sound sound(Buffer);
sound.Play();
output
sound.wav :
4.97952 sec
48000 samples / sec
2 channels
Process returned 0 (0x0) execution time : 0.454 s
Press any key to continue.
No sound played. No errors when compiling or at runtime.
I have placed these files with my executable and with my .cpp code.
audio-sound.exe (my executable).
libgcc_s_dw2-1.dll
libsndfile-1.dll
sfml-audio.dll
sfml-graphics.dll
sfml-network.dll
sfml-system.dll
sfml-window.dll
I have these files in order in my build options -> linker options -> other options.
-lsfml-audio
-lsfml-graphics
-lsfml-window
-lsfml-system
any ideas?
Phew, You have saved me from spending any more time with Dependency Watcher and messing up my DLL's <sigh of relief>.
in regards to missing code, I commented it out as it was originally hanging like this (I have changed .wav file now).
sound.wav :
0.370068 sec
11025 samples / sec
1 channels
Playing... 0.00 sec
But after reading your reply I put it back in. It failed, like above. But then worked when running it a second time. After some playing around, trying to break it again so I could find the problem. It was my Comodo Firewall sand boxing it.
Not sure why this stops it from working, as my other SFML graphics library projects work fine sand boxed.
Oh well, Comodo Firewall users beware.
p.s.
:-[ with that said, I didn't realize I needed the extra code. I will have to go back to the tutorials to see how I missed that.
Thank you for your time.