Play Module From Memory With Mikmod


JyCet

Member
Joined
Feb 23, 2004
Messages
469
Age
118
Location
France
Website
Visit site
Hi all,
I've "played" a little with mikmod library to play a module from the SD ... and now with the solution of Notaz it work !! :D ( http://www.gp32x.de/board/index.php?showtopic=34715 )

But now I suspect mikmod kill my frame skip due to many SD access, to check that i've search a long time on the web how to play a module from the memory with mikmod ... but the only thing i've found is "use MREADER and Player_LoadGeneric" but no example for how to ... :(

My module is already in the gpe file (it's *.h file), does someone know how to use/configure MREADER ?

Thank in advance for any help :)
 
Last edited by a moderator:
Thank for this easy tips to test, unfortunately it's always slow with the module in /tmp/ :(

I've tested some differents mixing configuration:
md_mixfreq = 22100; = increase the speed
md_mode = 0; //8bits & mono -> doesn't work :(
md_mode = DMODE_16BITS | DMODE_SOFT_MUSIC; // mono -> work but slower than in stereo :s strange !

Does the 8bits mixing work for someone ?
Thanks :)
 
I found an example to play a module from memory but I dont know how use it :huh:

CODE
typedef struct
{
MREADER mr;
int offset;
int eof;
SDL_RWops *rw;
} LMM_MREADER;
BOOL LMM_Seek(struct MREADER *mr,long to,int dir)
{
int at;
LMM_MREADER* lmmmr=(LMM_MREADER*)mr;
if(dir==SEEK_SET)
to+=lmmmr->offset;
at=SDL_RWseek(lmmmr->rw, to, dir);
return at<lmmmr->offset;
}
long LMM_Tell(struct MREADER *mr)
{
int at;
LMM_MREADER* lmmmr=(LMM_MREADER*)mr;
at=SDL_RWtell(lmmmr->rw)-lmmmr->offset;
return at;
}
BOOL LMM_Read(struct MREADER *mr,void *buf,size_t sz)
{
int got;
LMM_MREADER* lmmmr=(LMM_MREADER*)mr;
got=SDL_RWread(lmmmr->rw, buf, sz, 1);
return got;
}
int LMM_Get(struct MREADER *mr)
{
unsigned char c;
int i=EOF;
LMM_MREADER* lmmmr=(LMM_MREADER*)mr;
if(SDL_RWread(lmmmr->rw,&c,1,1))
i=c;
return i;
}
BOOL LMM_Eof(struct MREADER *mr)
{
int offset;
LMM_MREADER* lmmmr=(LMM_MREADER*)mr;
offset=LMM_Tell(mr);
return offset>=lmmmr->eof;
}
MODULE *MikMod_LoadSongRW(SDL_RWops *rw, int maxchan)
{
LMM_MREADER lmmmr={
LMM_Seek,
LMM_Tell,
LMM_Read,
LMM_Get,
LMM_Eof,
0,
0,
rw
};
MODULE *m;
lmmmr.offset=SDL_RWtell(rw);
SDL_RWseek(rw,0,SEEK_END);
lmmmr.eof=SDL_RWtell(rw);
SDL_RWseek(rw,lmmmr.offset,SEEK_SET);
m=Player_LoadGeneric((MREADER*)&lmmmr,maxchan,0);
return m;
}



My module is:
CODE
unsigned char music1[19716] = { ... };



Any idea how MikMod_LoadSongRW can play my music1 ?

Thanks a lot
 
Sorry, pb solved ... I really need to sleep :)

solution

CODE

rw = SDL_RWFromMem(music1,sizeof(music1)/sizeof(unsigned char));
module = MikMod_LoadSongRW ( rw , 4);



:)
 
Back
Top