0
0

Hi everybody!!!

I got a problem when I want to play sound from a resource file.
I use Dev-cpp 4.9.9.2.
Here is my code :
[code:28dzonq1]

//main.c

include "fmod.h"

FSOUND_STREAM *musique_ptr = NULL;
HRSRC hResLoad; // handle to loaded resource
HRSRC hRes; // handle/ptr to res
void *lpResLock; // pointer to resource data
int lenght;

...

// Locate the sound resource in the .EXE file.
hRes = FindResource(NULL, "CHRONO", RT_RCDATA);
if (hRes == NULL)
{
MessageBox( hwnd, "Impossible de localiser la musique.", "Erreur", MB_OK );
}

// Load the sound into global memory.
hResLoad = LoadResource(NULL, hRes);
if (hResLoad == NULL)
{
MessageBox( hwnd, "Impossible de charger la musique.", "Erreur", MB_OK );
}

// Lock the sound into global memory.
lpResLock = LockResource(hResLoad);
if (lpResLock == NULL)
{
MessageBox( hwnd, "Impossible de vérouiller la musique dans la mémoire.", "Erreur", MB_OK );
}

// Return the lenght of the resource.
lenght = SizeofResource(NULL, hRes);
if (lenght = 0)
{
MessageBox( hwnd, "La resource n’ a pu etre chargee correctement.", "Erreur", MB_OK );
}

FSOUND_Init(44100, 32, 0);

musique_ptr = FSOUND_Stream_Open(lpResLock, FSOUND_LOADMEMORY, 0, lenght);


  if( musique_ptr == NULL )
  {
      MessageBox( hwnd, "Erreur", "Erreur", MB_OK );
      PostQuitMessage(0);
  }


  FSOUND_Stream_Play(FSOUND_FREE, musique_ptr); 

//test.rc

CHRONO RCDATA "ct32.mid"

  [/code:28dzonq1]

The problem is musique_ptr always returns NULL.
I tryed many things to solve my problem ( MSDN, fmodforum, … ), but as you can see that’ s not enough. So, please, HELP ME before I lose my nerves… ^_^
If you think my english is awful, that’s probably because I’m french…

  • You must to post comments
0
0

I used VC++ and there is the same problem : no errors, no warnings but musique_ptr still return NULL.
I tryed FMUSIC_LoadSongEx too… you know what?
musique_ptr = NULL… arrghhh
Can somebody help me? If I made a big mistake in my source, please tell me where. Thanks.
^_^

  • You must to post comments
0
0

Ahhhh…
Shame on me…
I change :
[code:1ediie4f]
if (lenght = 0)
{
MessageBox( hwnd, "La resource n’ a pu etre chargee correctement.", "Erreur", MB_OK );
}
[/code:1ediie4f]
by
[code:1ediie4f]
if (lenght == 0)
{
MessageBox( hwnd, "La resource n’ a pu etre chargee correctement.", "Erreur", MB_OK );
}
[/code:1ediie4f]
I’ m too bad…
Sorry guys.

  • You must to post comments
0
0

ah of course i didnt even see that :)

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.