GP32 Libmikmod


No problem,

I'll alter that unit though because I use Mr. Mirkos SDK and need to change it to compile. I might make a few versions and remove some of the loaders too and see if that makes any size difference to the compiled version.
 
Hi!
Last days i was trying to compile libMikMod also, and it was an impossible task for me :-(
We had a thread about this in gp32spain forums also.
Pea, have you managed to compile a libMidMod.a? I'm really interested in that, beacause i need to play other module formats than mods in my progs.
cheers :D
 
Hi guys,

Yes I have a libmikmod.a compiled, but it hasn't been tested, and I haven't had time to do this yet. I think maybe this weekend :) It uses Mr. Mirkos SDK, but the functions it uses are so few, that changing it for the official SDK should be no probs (in fact, the gp32 version was originally written for the offical SDK)...
 
Heres the latest:

It compiles and starts to run. Then when it inits the drivers, it has the 'driver not supported' error on the GP32 driver.

I then found that the GP32 driver also needs to be changed to Mr. Mirkos SDK. The following functions are missing counterparts in the Mirko SDK:

GpPcmInit
GpPcmPlay
GpPcmLock
GpPcmStop

Any ideas? I might start a new thread with this :)
 
UPDATE:
I integrated MrMirkos ringbuffer functions into the GP32 sound driver, and updated the IO routines with the fileio functions from the MirkoSDK.

When I tested it, it seemed to hang on loading, but adding some debug routines I found out that it was just loading extremely slowly (about 1 hour 45 minutes for a 400kb XM - I kid you not!!) and I actually ran out of batteries before the XM finished loading. However, I chekced back at the code and put the file caching routines back that I had removed (!!) and it works at a proper speed now!

Currently it still doesn't work yet. It seems to be a problem within libmikmod itself, but I assume it is due to something I do - probably that the IO routines aren't loading the sound data properly.

Does anyone know anything about libmikmod? If so, it hangs in the following function:
sloader.c, SL_RegisterSample

The function is:
Code:
/* Registers a sample for loading when SL_LoadSamples() is called. */
SAMPLOAD* SL_RegisterSample(SAMPLE* s,int type,MREADER* reader )
{
	SAMPLOAD *news,**samplist,*cruise;

	if(type==MD_MUSIC) {
  samplist = &musiclist;
  cruise = musiclist;
	} else
   if (type==MD_SNDFX) {
  samplist = &sndfxlist;
  cruise = sndfxlist;
	} else
  return NULL;

	/* Allocate and add structure to the END of the list */
	if(!(news=(SAMPLOAD*)_mm_malloc(sizeof(SAMPLOAD)))) return NULL;
	
	if(cruise) {
  while(cruise->next) cruise=cruise->next;
  cruise->next = news;
	} else
  *samplist = news;

	news->infmt     = s->flags & SF_FORMATMASK;
	news->outfmt    = news->infmt;
	news->reader    = reader;
	news->sample    = s;
	news->length    = s->length;
	news->loopstart = s->loopstart;
	news->loopend   = s->loopend;

	return news;
}

The exact place it hangs is:
Code:
while(cruise->next) cruise=cruise->next;

Seems to do an infinite loop or something. It does it on an arbitrary sample, but the same sample each time (e.g. the third out of eighteen).

Cheers,
Pea
 
Fixed that bug... now onwards I go.

Who would have thought - a bug in libmikmod itself! I added the following line (in bold):

news->infmt = s->flags & SF_FORMATMASK;
news->outfmt = news->infmt;
news->reader = reader;
news->sample = s;
news->length = s->length;
news->loopstart = s->loopstart;
news->loopend = s->loopend;
news->next = NULL;

Maybe I am using a hacked version that has been unfortunately edited? Or maybe other compilers automatically set pointers to NULL on creation? Whatever - it definately wasn't in the new code, but in existing mikmod code!
 
Just a quick question, with libmikmod, can you jump to an order position?

The song I intend to use this for has multiple looping songs in one module.

You probably could, but I wouldn't know the function name to call.
 
I really hope you get Libmikmod sorted out, because I'm getting better and better at coding every day and have some ideas for using it that would be cool. :)
 
Newest development - cuts out when trying to decompress an 'IT compressed' sample with an 'invalid data' error ... maybe the song is corrupt, am trying with others...
 
Does LibMikMod make any form of semi-recognizable sound/noise/garbage output, audible by making the speaker vibrate at such an amplitude that sound waves are emitted?

:)

Personally, I use modplug tracker for making IT files, so maybe the error is that libmikmod is expecting IT's compression, but we're not sure if mpt compresses it the same way.
 
Yes, it does make sound. The process is (read comments below):

Code:
	MikMod_RegisterDriver(&drv_gp32);
	md_device = 1; // Force use of only this one driver

	MikMod_RegisterLoader(&load_xm);

	md_mode |= DMODE_SOFT_MUSIC;
	if (MikMod_Init("")) {
  gp_debug( "ERROR: During init" );
	}

	// Starts making noise - clicks like a cicada while the song loads. I presume that
	// this means that the ringbuffer has random noise in it and hasn't been cleared
  	
	gp_debug( "LOAD MODULE" );
	module = Player_Load("dev0:\\GPMM\\skidmark.xm", 8, 0 );
	gp_debug( "FINISHED LOADING" );

	// Gets to here ok. This means it doesn't crash at least. Exits cleanly, but with errors.
	
	if (module) {
  // This bit never happens :(

  gp_debug( "START MODULE" );
  Player_Start(module);

  gp_debug( "PLAY MODULE" );
  while (Player_Active()) {
  	for(i=0; i<10000; i++ ){ j=i; }
  	MikMod_Update();
  }
  gp_debug( "FINISHED PLAYING" );
  Player_Stop();
  Player_Free(module);
	}else{
  // This is where we end up. Error loading XM. Further debugging within
  // the code has (slowly) led me to the 16bit IT unpacking code, but
  // I have little knowledge of IT packed samples and can't tell if the
  // Data is being read incorrectly

  gp_debug( "ERROR LOADING XM" );
	}

	MikMod_Exit();
 
hehe, just tried it with an IT song, and same result, except it punts out on unpacking an 8 bit IT sample :( so its basically its the unpacking of samples it doesn't like in all cases.
 
Hey Pea, MikPlay32 (the program whose source I pointed to you) doesn't play IT files right.

This isn't a problem with MikPlay32, but a problem with MikMod.

MikMod has been updated since MikPlay32, so there are loaders that have been fixed, and maybe the player was updated too.

I don't know the possibly difficulty to do this, but if you can use the loaders and such of the updated mikmod for the libmikmod that you're compiling, that'd be great. :)

MikMod 3.2.0-beta2

(MikPlay32 uses 3.1.10)

Edit: I think the problem is an outdated mikmod version because I have the winamp plugin that uses mikmod to play mods, and it sounds correct with that, so I have to suspect the problem is an outdated mikmod.
 
Preliminary version here:
http://www.pea.co.nz/gp32/downloads.php

PLEASE NOTE: This is a preliminary version. Currently it will slow down your application because when you call MikMod_Update to update the sound, it will wait until there is a free buffer and then update the sound. I will release a new version in the next couple of days that will not wait like this (it will only update if the buffer is nearly empty).

Cheers
 
You rock, you're awesome! :)

Thanks a million!

Does it use the updated mikmod loaders/player? :)

If not, that's ok, just make sure you look into it. :)
 
yeah, I spent some time yesterday applying all the changes to the latest (3.2.0 beta2) source that you gave me the link to. I also removed all the redundunt code from the lib (specific to platforms other than the GP32) and reduced its size by about 150kb.

When you compile a program using libmikmod, it only includes the functions that you actually need, so even though the lib is ~360kb, my app is about 100kb.

EDIT: The source on my site has all the irrelevent code removed, and contains a gp32 subfolder with the updated code and a makefile/batch to compile the lib.
 
Back
Top