0
0

I want to know how to play *.XM from resource with minifmod, not use Bin2c to build it in my app. Any one can give me some adv or a part of code?? Thanks a lot!

  • You must to post comments
0
0

yeap listen to Brett, i found it a long time ago :roll:

  • You must to post comments
0
0

[quote="brett":3feme14w]im sure there is a some resource loading code in minifmod that is #ifdef’ed out.. did you look at it?[/quote:3feme14w]

I’ve done that,but still faild,I don’t know why.So,I want to know all steps,
please give me more details. Thanks.

  • You must to post comments
0
0

Note1 : “XM” is the directory name of ressource of the module
Note2 : it was for an old project, using fmod 3.64 or so …

[code:2xkzlrpd]
/*
[API]
[
[DESCRIPTION]
Load a module from a memory location

[PARAMETERS]
name - the module to load

[RETURN_VALUE]
a handle to the memory

[REMARKS]
this function must be efficient an bug free ! (take care of pointers)

[SEE_ALSO]
memclose

]
*/
unsigned int memopen(char *name)
{
MEMFILE *memfile;

memfile = (MEMFILE *)calloc(sizeof(MEMFILE),1);

{  // hey look some load from resource code!
    HRSRC       rec;
    HGLOBAL     handle;

    rec = FindResource(NULL, MAKEINTRESOURCE(IDR_SONG1), name);

    handle = LoadResource(NULL, rec);

    memfile->data = LockResource(handle);
    memfile->length = SizeofResource(NULL, rec);
    memfile->pos = 0;
}


return (unsigned int)memfile;

}

/*
[API]
[
[DESCRIPTION]
Free a memory location

[PARAMETERS]
handle - the handle to deallocate (allocated by memopen)

[RETURN_VALUE]

[REMARKS]
handle must be valid

[SEE_ALSO]

]
*/
void memclose(unsigned int handle)
{
MEMFILE *memfile = (MEMFILE *)handle;

free(memfile);

}

int memread(void *buffer, int size, unsigned int handle)
{
MEMFILE *memfile = (MEMFILE *)handle;

if (memfile->pos + size >= memfile->length)
    size = memfile->length - memfile->pos;

memcpy(buffer, (char *)memfile->data+memfile->pos, size);
memfile->pos += size;

return size;

}

void memseek(unsigned int handle, int pos, signed char mode)
{
MEMFILE *memfile = (MEMFILE *)handle;

if (mode == SEEK_SET) 
    memfile->pos = pos;
else if (mode == SEEK_CUR) 
    memfile->pos += pos;
else if (mode == SEEK_END)
    memfile->pos = memfile->length + pos;

if (memfile->pos > memfile->length)
    memfile->pos = memfile->length;

}

int memtell(unsigned int handle)
{
MEMFILE *memfile = (MEMFILE *)handle;

return memfile->pos;

}

void Load()
{

FSOUND_File_SetCallbacks(memopen, memclose, memread, memseek, memtell);

// ==========================================================================================
// INITIALIZE
// ==========================================================================================
if (!FSOUND_Init(44100, 0))
{
    MessageBox( NULL, "Error upon initialization", "Error", MB_ICONHAND|MB_OK|MB_SYSTEMMODAL);
    return;
}

// ==========================================================================================
// LOAD SONG
// ==========================================================================================
mod = FMUSIC_LoadSong("XM", NULL); //sampleloadcallback);
if (mod == NULL)
{
    MessageBox( NULL, "Error loading song", "Error", MB_ICONHAND|MB_OK|MB_SYSTEMMODAL);
    return;

}

}

void Play()
{
// ==========================================================================================
// PLAY SONG
// ==========================================================================================
if (mod) FMUSIC_PlaySong(mod);
}

void Stop()
{
// ==========================================================================================
// STOP SONG
// ==========================================================================================
if (mod)
{
FMUSIC_StopSong(mod);
FMUSIC_FreeSong(mod);
mod = NULL;
}
}
[/code:2xkzlrpd]

  • You must to post comments
0
0

[quote="KarLKoX":1n0nf73r]Note2 : it was for an old project, using fmod 3.64 or so …
[/quote:1n0nf73r]

3.64 is old? Wow. I’m really behind the times. :)

  • You must to post comments
0
0

lol !!! i realized that drinking when coding is not adviced :)
Shame on me … 😳

  • You must to post comments
0
0

could someone post a win32 asm template to achieve the subject of this thread ?

thanks in advance

  • You must to post comments
Showing 6 results
Your Answer

Please first to submit.