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

Author Topic: a few questions from a newbie  (Read 3487 times)

0 Members and 1 Guest are viewing this topic.

s_i

  • Newbie
  • *
  • Posts: 1
    • View Profile
a few questions from a newbie
« on: October 27, 2013, 11:06:39 pm »
Hello!  I write game with DarkGDK, and now I need better audio engine, then DarkGDK internal engine. I tested some freeware engines and found SFML-audio comfortable and easy. But I need answers on some questions. Please, answer on every.  (I use Windows 7 Pro x64 and VS2008 Express, computer with modern i5 CPU and old Creative soundcard, OpenAL drivers in Windows are installed.)

1) I wrote a small test program with DarkGDK (for graphics) and SFML-audio (for audio), based on the example from SFML SDK. In the configuration "Release" with libraries "sfml-audio.lib sfml-system.lib" everything (playing sound and music) works perfectly. But in the configuration "Debag" with libraries "sfml-audio-d.lib sfml-system-d.lib" program returns into Windows on 16 line:

14  // Load a sound buffer from a .wav file
15  sf::SoundBuffer buffer;
16  if (!buffer.loadFromFile("sounds/canary.wav")) {return;}

i.e. it can not load sound, and returns. Why? All paths to folders (with .h and .lib) spelled correctly. VS does not give me error, just a program quietly terminates. So now I use "sfml-audio.lib sfml-system.lib" in Debug mode and it works perfectlyEDIT So can I continue using libraries without "-d" in Debug mode?

2) I can not get rid of extra DLL by using "-s" libs.  I do not think this is the problem of DarkGDK. Can anybody help me?  EDIT Yes, I use SFML_STATIC.

With "sfml-audio-s.lib sfml-system-s.lib" in Release mode VS gives me 58 errors "sfml-audio-s.lib(ALCheck.cpp.obj) : error LNK2001", "sfml-audio-s.lib(SoundStream.cpp.obj) : error LNK2019" etc. (unresolved external symbol),  and 57 warnings "sfml-audio-s.lib(SoundFile.cpp.obj) : warning LNK4217", "sfml-audio-s.lib(ALCheck.cpp.obj) : warning LNK4049" etc. (imported locally defined symbol).

With "sfml-audio-s-d.lib sfml-system-s-d.lib" in Debug mode VS gives me many errors "msvcprtd.lib(MSVCP90D.dll) : error LNK2005:" (... already defined in ...), "sfml-system-s-d.lib(ThreadImpl.cpp.obj) : error LNK2019" etc., and many warnings "sfml-audio-s-d.lib(Music.cpp.obj) : warning LNK4217", "sfml-audio-s-d.lib(SoundBuffer.cpp.obj) : warning LNK4049" and other.

3) ... EDIT Thanks, already answered.
4) Does SFML-audio use SSE, SSE2, SSE3 ?  (I do not know, laptop processors have SSE3?  They will be able to use my game with SFML-audio?)
5) Does SFML-audio work in Windows XP,Vista,7,8 only with 256 sounds?  Can you give me exact number of buffers and exact number of sounds and musics for Windows machines?  (I need this for specify an array of sounds, buffers.)  EDIT I'm afraid that the game will load into memory more sound files, than player's hardware driver can create buffers on player's PC.
6.1) Do I need to distribute driver with my game? (oalinst.exe from Creative)  I think: does SFML-audio self-sufficient, or users need to install in Windows external driver oalinst.exe?  I remember this example from forum: http://en.sfml-dev.org/forums/index.php?topic=13346.0  Or with Windows Vista,7,8 situation is better then with XP?
6.2) My game loads OpenAL32.dll from Windows/SysWOW64. When I delete this file, game loads OpenAL32.dll from "working directory" where Main.cpp lies. In both cases, everything is working correctly.  I.e. OpenAL32.dll from SFML-audio is needed only on computers where no drivers (oalinst.exe) installed?
7) Memory deallocation happens automatically when the variable (sf::Sound sound) goes out of scope, or should we stop the sound, and then destroy it?  The same question applies to the sf::SoundBuffer buffer.

Thank you very much for your answers!
« Last Edit: October 28, 2013, 12:48:43 am by s_i »

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: a few questions from a newbie
« Reply #1 on: October 27, 2013, 11:20:47 pm »
1) loadFromFile just returns false to indicate failure, so that's what's supposed to happen.  To get at the actual error message, try redirecting sf::err().

2) This sounds like a typical setup error that can be solved by reading the tutorials more carefully.  For instance, did you define SFML_STATIC?  If you need more help with this you'll have to provide a lot more details so we can figure out exactly what step you did wrong or if you're experiencing a genuine problem.

FYI, the number of errors/warnings is not useful information.

3-5) SFML audio is implemented with OpenAL and libsndfile, so those questions are probably best answered by looking up information on those libraries.

However, SFML does not support .mp3 at all, because that format is licensed, so (to vastly oversimplify it) it might be illegal to support it without paying money to certain people.

3) I'm not very familiar with this stuff, but my impression is that decoding speed has more to do with the codec/format than anything else, ie the definition of ogg vorbis itself, so library speed is a non-issue.  In any event, OpenAL and libsndfile are so widely used that I can't imagine you'd ever run into speed problems with SFML audio.

4) Again, I don't know this stuff, but googling so far implies that it depends on whether the audio libraries were compiled with SSE optimizations or not.  I'm not sure how to check whether SFML's versions were or not.  Though I certainly wouldn't worry about SFML audio breaking on laptops; if that was a problem it would've been caught ages ago.

5) I don't believe there is a hard limit for anything but OpenAL buffers.  The other objects I think just take up some memory and maybe a buffer.  As for how many OpenAL buffers there are, the best answer I've found is: http://stackoverflow.com/questions/2871905/openal-determine-maximum-sources  Again, don't quote me on this.

6) Simply distributing the openal dll with your game should be fine on all systems.  If the end user has broken drivers, then that's a problem with their system.  Besides, drivers are tied to hardware, and it makes no sense for you to try and provide drivers for every possible audio hardware.  Just like with graphics drivers, that responsibility falls on the vendors producing that hardware.  I believe the dll contains a software driver that will work on any system that doesn't have a hardware driver.  As you pointed out, if a hardware-specific OpenAL driver does exist, the OS will choose it for you, which is a good thing because it makes this simple for you: just distribute the dll and you never have to think about it.

7) Yes.  That's the RAII idiom, and all SFML classes follow it (to my knowledge), so you never have to worry about cleaning things up yourself unless the tutorials/documentation say otherwise.  Stopping the sound before it gets destroyed should be completely unnecessary.  The only problem of this sort you can have is that if the SoundBuffer goes out of scope (and gets destroyed) while Sounds are still using it, bad things happen (and the tutorials warn about this).  But that should be easy to avoid.
« Last Edit: October 27, 2013, 11:54:11 pm by Ixrec »