PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Problems with sound

Hi! I'm getting far too many problems with Hekkus (Windows Desktop, not testing with ppc yet), it is most likely because of my ignorance, so I have few questions:
Firstly, is it true that I can play 4-5 or more wav files at the same time simply by calling PlaySound(bla bla); for each one of them?
Hi Ryumaster,

Can you tell me which version of EDGELIB and Hekkus you're using? Also, are you using the DLL?

When using ClassESound, you are able to play 8 sound effects and 2 music files simultaneously.
Hi! I'm using Edgelib 3.20 and latest Hekkus 0.9.6.2 with static libs.
Is it logic, when I'm using, for example,
global->ecd->snd->FreeSoundEffect(7);
global->ecd->snd->FreeSoundEffect(6);
in a row, and on second try to free memory (on freeing effect 6) I sudennly get break with error in dbgheap.c
Code:
}
__finally {
/* unlock the heap
*/
error on this line ->>>>>>>>> munlock(_HEAP_LOCK);
}


I can continue further, thought, but if I get same error 2-3 more times, everything crashes.

And when I'm trying to play 3 or 4 sounds at the same time, dynamically loading 2 of them, while one sound is looping as background music, I always get total crash.
Do You get analogical errors, or this has to do something with my own code?
Hi Ryumaster,

In our own games we have no problems using the Hekkus Sound library. Please check the following:
- When using the static library, define HSS_STATICLIB before defining ESOUND_HEKKUS
- Preload all sound effects and see if you can play multiple sounds (while playing a music file) without incorrect breakpoints or crashes
- Try to stop all sounds before freeing a sound effect, does this help?
- Is your global pointer set up correctly, also is ecd linked correctly?
Thank You a lot for answering! Now I'll focus on game audio and try to fix everything. By the way, what is the difference between Free(); and DeAlloc ? Do the both free memory that surface uses?
Can you tell me if any of the solutions mentioned above fixed your audio problem? Also, can you tell me more about your question about Free() and DeAlloc(), for which class/object are you using these?
Hi!
The only problem with sound left is when I call FreeSoundEffect(). It works fine only once, and later I always get breakpoint as I mentioned above. (too bad stopping all sounds helps not)
Anyway, it works for everyone, and I'll make it work for me :) I just haven't got enough time for more testings. Probably.

About Free(). The point why I've asked it's because I've tried to free surfaces from memory Using Free();, but because Free takes no parameters, and surfacename.free do not work for me either, I thought maybe it is good idea to free using DeAlloc(surfacename) because DeAlloc has something to do with memory. Unfortunately, there was more to it, because my surfaces are still always stays in memory.
Hi Ryumaster,

If you're using the hekkus DLL, please make sure to remove all HSS_STATICLIB definitions in the esound_hekkus wrapper and in your own source code. If you're using the static library, define HSS_STATICLIB just before defining ESOUND_HEKKUS and including edgemain.h.

Regarding your surfaces. If you're using E2DSurface pointers we recommend the following:
Code:

//For surface creation
E2DSurface *surf;
surf = new E2DSurface;
if (surf)
{
ERESULT result = display->CreateSurface(surf, "image.png");
//check result and other things
}

//For surface cleanup
if (surf)
{
surf->Free();//This is not required, as deleting the surface will call the destructor to clean up surface memory
delete surf;
}


If you're not using surface pointers you can just add an E2DSurface object to your framework class. Here is a code example:

Code:

//surface creation, surf is an E2DSurface object defined as a class member
ERESULT result = display->CreateSurface(&surf;, "image.png");
//check result and do other things

//surface cleanup
surf.Free();//This one is also not required, when the class is destroyed, the object is automatically freed


I hope this clears it all up :)
Hi! Thank You for large reply, it is all clear with surfaces now.
About sound. Looks like this ugly heap corruption has something to do with how Windows works with dll files, there are many similar threads Google gives out, anyway, I'm still working on it.
If I choose to use Static Libs (everything set fine, I've checked many times), I get this error we all had before (breakpoint on delete). I have got only one question for now - if I use static libs, I have to use hss.dll anyway? When I delete if from folder, I get an error. This is normal? Cause I'm just thinking, maybe I messed up somewhere in VS2005 configs.
Hi Ryumaster,

You can check if you're really using the static library by just removing the DLL. If it runs without any errors, then everything went well.

Because you get the error message, you probably link the wrong library. Please make sure it links /Hekkus/lib_static/xp instead of Hekkus/lib/xp.
OMG, that is the case. I could never figure out, that static libs was not in archives of Hekkus. In fact, they are only available to donors. Well, I know what to do next... And once again, Edge saves the day :) Thank You!
Ryumaster · 20 Nov 2007, 16:04 UTC — Hmmm
Hi! Maybe I'm doing something wrong, but mod files can not be played from EdgePack.
(even if compression off)

Here is modified sample of Yours:

if (ecd.snd->Open() == E_OK)
Code:
{
ecd.snd->LoadSoundEffect(0, "sound.wav");
ClassEFile ef;
unsigned char *filedata;
unsigned long filedatasize;
if (ef.Open("1.epk", EFOF_READ))
{
if (!ef.PackAuthorize(0))
Quit();
}
if (ef.PackGetFileData(filedata, filedatasize, "music.mod") == E_OK)
{
ecd.snd->PlayMusic(0, true);
}


Sound Effects is OK (maybe), but music is silent. Is it bug or is it normal?
I'm still using DLL, not static libs. Please let me know if You can reproduce this.
Hi Ryumaster,

In your code you don't call snd->LoadMusic before calling snd->PlayMusic. After calling PackGetFileData, use filedata and filedatasize as parameters to ClassESound :: LoadMusic.