Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > irrKlang
I need some advises and answers

s_i
Registered User
Quote
2013-10-30 19:23:44

I make game for Windows with VisualStudio C++. I have up to 100 different ships in most worse moment. I have 40 sound files of different shots and explosions. Every ship can do 2 shots. 100 ships * (2 shots + 2 explosions) = 400 sounds. So I need to be ready to play theoretically up to 400 3D-sounds playing in most worse moment.

My decision (framerate in game is priority):
D1 -- in global scope: start engine with WinMM soft driver.
D2 -- in global scope: irrklang::ISound* snd[400];
D3 -- preload in memory 40 ISoundSource. (framerate in game is priority)
D4 -- every time, when ship shoots or explodes, make ISound from proper ISoundSource
snd[n] = engine->play3D(sourceSound[m], pos, false, false, true, false);
D5 -- every time, after snd[n] finishes playing, stop() it (for memory deallocating) and drop() it.
D6 -- in the end of game, do removeAllSoundSources() for memory deallocating.

Please, give me advise: is this a good Decision? maybe I need to do something more correctly?

And also answer this questions, please :
Q1 -- in D5: do I need every time stop() for memory deallocating, or in my case memory deallocates automatically (after sound finish its playing) ?
Q2 -- can I use hardware DirectSound8 instead of software WinMM, or in my case WinMM is the best choice for any PC of my purchasers? (maybe 440 is too many buffers for not modern soundcards?)
Q3 -- does DirectSound8 much faster than WinMM, or has better quality of the 3D-sound? (except sound fx)
Q4 -- if I buy irrKlang v1.4, updates (1.5, 2.0, etc) will be free for me?
Q5 -- in D3: shootSound = irrKEngine->addSoundSourceFromFile("sounds/testSound.wav", ESM_NO_STREAMING, true);
I use this for preloading file (I want to use this sound later). Loading and playing then are OK , but . . . File is 52 Mb wav, but "Windows 7 Resource monitor" shows growing of using memory only few hundreds Kb. 8 Mb ogg file similarly. Is preloading broken?


niko
Moderator
Quote
2013-10-31 07:57:00

Basically, it sounds ok for me, but you don't need to store the ISounds and stop() and drop() them manually at all. If you just call play() without telling irrKlang to return an ISound pointer, it will stop and drop it automatically. Also, if you need the ISound pointer, calling stop() isn't necessary anyway. Just drop() it as soon as you don't need it anymore, that's it.

Same for removeAllSoundSources(), this is also called automatically, no need to do this manually. If you need to free some memory in between levels or similar, then this is useful.

About Q2: You have to try this out yourself. But it should work, IMO.
Q3: It totally depends on the audio driver the user has installed. But WinMM usually behaves the same on every system.
Q4: Yes.
Q5: Huge files are streamed by irrklang, regardless if you are telling it to use NO_STREAMING. If you really want to load a full 52MB file into memory and then play it (it is not a good idea), you can use setForcedStreamingThreshold(-1) of the ISoundSource to disable this behavior. So that's why your memory only shows an 8KB increase.


s_i
Guest
Quote
2013-10-31 11:44:06

Oops! . . Some of my sounds (only few) have tremor in WinMM, but with DirectSound all OK. I tested this (in Windows 7) in my game with irrKlang audio, and also in Audacity. (Nikolaus, if it interests you, give me email address, and I'll send you some of them for test.) So I need answers on next three questions. Please :)

Q1 -- What will be if I'll use DirectSound, but refuse to support Windows XP, and I'll support only Windows Vista, 7, 8? DirectSound works there only via WASAPI in soft mode. So in this case what will be the minimal guaranteed number of stored ISoundSources (not less than)? and minimal guaranteed number of played ISounds (not less than)? (for example, not less then 128 ISoundSources and 256 ISounds)
Q2 -- As I understand, WinMM can store in memory many hundreds (but < 2 Gb) of ISoundSources, and play in one moment many hundreds of ISounds?
Q3 -- Wikipedia says, WinMM in Vista has bug -- distortion of some sounds when they are interpolates. Microsoft give patch for downloading only for Windows 7. Does this bug affect us?


niko
Moderator
Quote
2013-10-31 14:27:22

Sure just send them. Sound strange.

Q1: There is no minimal guaranteed sound numbers in irrKlang. It usually just works. If you want to be on the safe side, use WinMM. There, everything is in software and should work the same, always.
Q2: Yes. But keep in mind that you don't really have them all in memory at the same time. For most games, it is enough to just load them when they are played the first time. Which irrKlang does automatically.
Q3: never heard of any problems like that.


s_i
Guest
Quote
2013-11-09 21:54:59

I stress-tested my irrKlang in game with 1024 looped 3D-ISounds (from 1 ISoundSource) playing simultaneously, with DirectSound8 and WinMM. All work good even with my old soundcard Creative Audigy. But I have 1 issue (not bug) in this stress-test :

in the end of battle I have this 3 lines of code:
1 line) stop() and drop() for every sound having pointer
2 line) removeAllSoundSources()
3 line) engine->drop()

Sometimes game crashes after 3nd line. I found two good solutions (tested with DirectSound8 and WinMM) :
1) all work good if only few from this 1024 ISounds return pointer and can be tracked. Others from them do not return pointer, and not looped.
2) all work good if I inserte Sleep(300) somewhere between 1st and 3nd lines.

So I think irrKlang needs at least 0.3 second for drop() 1024 ISounds with pointers (for memory deallocation, etc) befor engine->drop().


niko
Moderator
Quote
2013-11-10 20:41:40

Hm, strange. Did you try removing the 'removeAllSoundSources()' call? It's not necessary at all. Maybe it even helps.


s_i
Guest
Quote
2013-11-10 23:15:53

Tested. That did not help.

If 1024 ISounds return pointers, game needs more time before engine->drop(), (250+ ms).
If less from 1024 ISounds return pointers, game needs less time before engine->drop(). (and crashes rarely)
If 0 sounds from 1024 ISounds return pointers, game needs no time before engine->drop(). (game does not crash)

Do not worry much. 1024 looped ISounds is unreal big number, only for tests. One time from 25 times my game crashed with 31 played looped ISounds (ie between 1st and 3nd lines without any Sleep() ). But 31 is also big number.

Update. Halleluja! I found next solution for this problem. Instead of Sleep(250) I inserted some functions for deleting few non-sound game resources (memory deallocation commands) between 1st and 3nd lines. They do not last 250 ms, work almost instantly -- I do not know why, but the game does not crash. Tested many-many times with DirectSound and WinMM.

Strange, because these resources are not associated with sound. May be the cause in a way that the Windows manages memory?


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "In?ernational" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact