0
0

getLength returns the wrong length when I create the sound like so:

system->createSound("media/Sin44.mp3", FMOD_ACCURATETIME | FMOD_SOFTWARE | FMOD_CREATECOMPRESSEDSAMPLE | FMOD_2D, 0, &sound2);

unsigned int duration;
result = sound2->getLength(&duration, FMOD_TIMEUNIT_MS);

With FMOD_CREATECOMPRESSEDSAMPLE getLength gives me 114912, which is about half the correct length.
Without, it gives me 229825, which I believe is correct.

  • You must to post comments
0
0

When I play the mp3 it only plays half way through the song.

Lastly, when I specify FMOD_CREATECOMPRESSEDSAMPLE there are some memory leaks. The leaks aren’t there when I leave this flag out.

I detected the leaks by putting
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_CHECK_CRT_DF | _CRTDBG_LEAK_CHECK_DF);

at the beginning of my test program (which is basically your playsound example). You don’t need to play the sound to get the leaks. I’m not very familiar with _CrtSetDbgFlag, so take these results with a grain of salt. But here’s what I get:

Detected memory leaks!
Dumping objects ->
_sftbuf.c(91) : {58} crt block at 0x009055F8, subtype 0, 4096 bytes long.
Data: < ime 00:00:00/00> 0A 69 6D 65 20 30 30 3A 30 30 3A 30 30 2F 30 30
crtlib.c(434) : {53} crt block at 0x00904CB8, subtype 0, 532 bytes long.
Data: < > EC 01 00 00 FF FF FF FF 00 00 00 00 00 00 00 00
mbctype.c(593) : {4} crt block at 0x009032A8, subtype 0, 544 bytes long.
Data: < > 02 00 00 00 E4 04 00 00 00 00 00 00 00 00 00 00
ioinit.c(136) : {2} crt block at 0x00902110, subtype 0, 1280 bytes long.
Data: < g > 03 00 00 00 C1 0A 00 00 01 00 00 00 D8 67 15 00
tidtable.c(384) : {1} crt block at 0x00901EC0, subtype 0, 532 bytes long.
Data: < > 08 0B 00 00 FF FF FF FF 00 00 00 00 00 00 00 00

  • You must to post comments
0
0

I have the same problem. I use FMOD_CREATECOMPRESSEDSAMPLE to create a sound. It only plays about half of the song and suddenly finish. When I use getLength, the programm crashed !
if(sound1!=0){
result=sound1->getLength(length,FMOD_TIMEUNIT_MS);
ERRCHECK(result);
}
The Debugger says a problem occured and it couldn’t read at adress 0xffffff
what did I do wrong

  • You must to post comments
0
0

I have found out it self. I just forgot to allocate memory for the pointer *length.

now corret:
unsigned int *length=new unsigned int;
result=sound->getLength(length,FMOD_TIMEUNIT_MS)

  • You must to post comments
0
0

and that fixes it?

I have

unsigned int duration;
result = sound2-&gt;getLength(&amp;duration, FMOD_TIMEUNIT_MS);
  • You must to post comments
0
0

[quote="lightning.net":pv4ohnpn]I have found out it self. I just forgot to allocate memory for the pointer *length.

now corret:
unsigned int *length=new unsigned int;
result=sound->getLength(length,FMOD_TIMEUNIT_MS)[/quote:pv4ohnpn]

that is incorrect, use unsigned int length, then getLength(&length.. ) otherwisee you are using very inneficent code (ie allocating 4 bytes then leaking it)

  • You must to post comments
0
0

ok thanks for the length /2 thing, i’ve fixed that for the next release.

  • You must to post comments
Showing 6 results
Your Answer

Please first to submit.