I think this is a quite weird error since I haven't seen anything about it in the forum, but this is what I get... ^^'
I get an error when creating a new Song or Sample. No matter the file is .mp3 or .wav it crashes.
I uploaded an image so you can see the error clearly.
As you can see in the code, the file exists and crashes when trying Gosu::Song(f).
So... does anybody know anything about it?
There are many variations of WAV files. Can you try to save it again with e.g. Audacity as a 22kHz PCM WAV file? Those seem to be the most common.
Tried! And didn't work either.
I also tried with mp3, but nothing works...
May I include any library besides gosu libs?
Oh right, you need libsndfile.dll to be next to your EXE file. It ships with Gosu. That may just be it. :)
MP3 is not supported, by the way. (http://mp3licensing.com/
Did you go here, jlnr? http://mp3licensing.com/royalty/games.html
I don't know if it changes anything as far as adding support to libgosu, I just thought the "no royalties for less than 5000 units sold" thing was interesting...
Yeah, it is still annoying to have to think about it, just like FMOD before. :/
AAC seems to be a more relaxed choice if you want a format that works across all four platforms (iOS included):http://www.scirra.com/blog/44/on-html5-audio-formats-aac-and-ogg
Otherwise, OGG is good enough even for OGG haters like me. :) (Contributions are still welcome.)
I was thinking about using ogg in the proyect, I will consider aac too.
Anyway, I was using a .wav for testing the code...
After adding the library the song loads, but it doesn't play.
but I can't hear anything, and the Windows 7 volume mixer doesn't show anything either about my app using sound.
One more thing: if I try to stop the song:
And yes, playing() returns true...
Hmmm, can you show some more code? Or upload the music file?
I uploaded the wav file.
About the code, there's no much to show, but I tested a little more:
if(boost::filesystem::exists(absolutePath() + L"data/bgm/m.wav"))
cout << "a";
Gosu::Song s(absolutePath() + L"data/bgm/m.wav");
cout << "b";
cout << "c";
cout << "-done" << endl;
The output was... "abc" but not "-done".
But this cannot work because it will play the song only while the computer is printing "c", so, about 2ms? :) What if you add
Gosu::sleep(100) after the s.play() call?
Does it means that a song can't play in the background?
Or how it works?
Anyway, adding a sleep(100) after the play() call doesn't change anything :(
It can, but not if you destroy it right after calling play(). :) If you use a Window, then you can use a
scoped_ptr (or the new
unique_ptr or anything else) to load and play it. Gosu::Window internally continues feeding the Song with new data.
yeah, it's true!
But anyway, I tested it before using a pointer and I got the problem of the stop() and it dosn't sound.
Here's the fixed code:
In the Window constructor:
song = new Gosu::Song(absolutePath() + L"data/bgm/m.wav"); // this is ok
In the Window update()
if(input().down(Gosu::kbA) && !song->playing())
cout << "play" << endl; // prints "play" ok
song->play(); // but doesn't sound anything
if(input().down(Gosu::kbZ) && song)
cout << "stop" << endl; // prints "stop" ok
cout << "delete" << endl; // this line is never reached
song = NULL;
If this line is never reached, then what happens? Do you get any exception or error message?
it just hang on
song->stop()... no error displayed.
EDIT: Now it displayed "delete", but it hangs on
delete song; ... kinda weird...
Does any of this change when you use boost::shared_ptr<Gosu::Song> song instead?
No, nothing changes. Actually, the 1st test where I saw the error was using shared_ptr...
For some reason, I cannot load the file on OS X either. (Constructor fails) Saving it as AAC/M4A from Audacity works for me. Is the same true on Windows?
I used to have a table for supported audio formats in the wiki (automated) but I hoped sndfile & AudioToolkit could digest everything by now :S
I saved it as AAC/M4A too with audacity and didn't work.
Could you upload your working file? I'll try it. Maybe it's problem of Audacity format saving.
Actually, it's no wonder that it didn't work. AAC is probably only supported on OS X.
So here's what I'm doing. On all platforms, I use my own code with libogg & libvorbis to play OGG files. On OS X, I use the system's AudioToolKit to play everything else. On Linux and Windows, I use libsndfile.
If the AAC doesn't work, it just means libsndfile doesn't support AAC, no big surprise. If the OGG file doesn't work, then things are really weird because we should be having the same results. :S I have attached both.
m4a give me an error loading the file (unhandled exception: std::runtime_error).
ogg loads but don't play (no error but no sound) and still hangs on stop().
So, it's no my Audacity... maybe something on Windows 7?
I haven't had a problem playing music on Windows 7.
Do you have the right DLLs located in the folder too? They could be mis-matched and out-dated...
Uhm... I had the right Dlls in the right folder, but anyway I copied them again (and replaced) and now it works...
probably it was what you said: outdated libraries.
Aaaahg, I hate this stupid-errors with easy solutions but hard to find!
By the way, on "Release" compilation there's no problem, but on "Debug" one, the program hangs freeing the Gosu::Song object.
I think this was already posted, but I want to be sure it's a known bug ;)
So in Debug, it hangs even with the updated DLLs? So far, I have only heard about Gosu using the wrong DLL on Windows 7, and I still have to read the article about how Windows 7 chooses DLL files.
I'll try it in Windows Vista tomorrow and tell you then.
BTW, I got another error, loading a Song with loop = true (only in Debug, in Release is ok).
When the song finished and is going to be played again from the beginning I got this:
Assertion failed: section == 0, file C: \Documents and Settings\Julian Raschke\Desktop\gosu\GosuImpl/Audio/OggFile.hpp, line 94
Agh, I thought I'd removed that assertion already. I'll try to sneak it into the next release. I was being overly cautious there.
well, don't worry, it's not a big fault ;)
And I think nobody will release games in Debug mode :P
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill