AndreGarzia.Com all we do is code

RevMikMod

MacOS X RevMikMod External for Runtime Revolution


Game developers rejoice! Now we're able to play mod and mod-like files (like s3m, it...). Mod files are cool because they are very small and they be worked so that they can loop and make wonderful environment music for your games.

RevMikMod is an external for MacOS X Runtime Revolution. It is built upon on MikMod library which is licensed with LGPL, so this is freeware with source. This external uses Carbon Thread API, the music will play on another thread so there's no performance issue. You can play only one music at a time but you can change speed, tempo and volume.

RevMikModInit - initialize library.
RevMikModClose - closes library.
RevMikModPlay
- plays the given file path.
RevMikModStop - stops playing.
RevMikModPause - pauses playing.
RevMikModResume - resumes playing.
RevMikModGetData() - returns some data based on the key given.
Keys:
songname: name of the song
modtype: string type of module loaded
comment: module comments
numchn: number of module channels
numvoices: max # voices used for full NNA playback
numpos: number of positions in this song
numpat: number of patterns in this song
numins: number of instruments
numsmp: number of samples
realchn: real number of channels used
totalchn: total number of channels used (incl NNAs)
initspeed: initial song speed
inittempo: initial song tempo
initvolume: initial global volume (0 - 128)
bpm; current beats-per-minute speed
sngspd: current song speed
volume: song volume (0-128) (or user volume)
patpos: current row number
sngpos: current song position
sngtime: current song time in 2^-10 seconds

RevMikModSetVolume <0-128> - sets the volume.
RevMikModSetTempo <1-32> - sets the tempo.
RevMikModSetSpeed <1-255> - sets the speed.

OBS: These keys are the same as the members of the MODULE structure from the C code.

How it works


It uses Carbon Thread API to update the music playing status (MikMod update function needs to be called in a periodic interval to keep playing the song, this is done automatically in another thread). It builds around the MikMod library which is a very good mod playing library.

Download with source code here. (You need both XCode 2.4 and ExternalEnvironmentV1 for building this)

To download ExternalEnvironmentV1 and/or learn more about Externals check Revolution Newsletter #13. I've changed some stuff on this project, this is not the same one that is built by ExternalEnvironmentV1, I've changed the SDKs not to use 10.2.8 ppc but always use 10.4 universal because thats the only SDK (along with 10.3.9) that I have here. Anyway building universal is the way to go.

Hope this helps everyone, if you use this external and feels like contributing, my paypal account is under agarzia@mac.com or you can use the PayPal donation button on the sidebar, its secure and accepts all major credit cards.