MikMod for ZGE

Use of external libraries (DLLs) from ZGE.

Moderator: Moderators

User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

MikMod for ZGE

Post by Rado1 »

MikMod is a module player and library supporting many formats, including mod, s3m, it, and xm. After initial compilation of the library for Windows and Android I made some first successful tests. The implementation is still in early phase, but I'm sure MikMod can be a good and free (LGPL licenced) replacement of the Bass library for mod music included in ZGE applications.

See the attached demo working on Windows.

Any comments are welcome.
Attachments
mikmod_demo.zip
MikMod demo project and DLL
(110.32 KiB) Downloaded 631 times
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi Rado1,

Nice job & find! Hadn't heard of MikMod before :)

One small issue. When i try to load another module into the file component, i need to save the project and reload it before i can get it to play. When building a standalone it does always work, so it's not a huge problem .. but perhaps it could be solved somehow.

K
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Kjell wrote:One small issue. When i try to load another module into the file component, i need to save the project and reload it before i can get it to play. When building a standalone it does always work, so it's not a huge problem .. but perhaps it could be solved somehow.
This happens to me as well, but only occasionally - sometimes it works, sometimes not. Maybe Ville could have a look at it.
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

FYI I just obtained a consent from the MikMod authors to use the library for ZGE, even commercial applications (!). It seems to be a good replacement for the Bass library which is applicable freely only for non-commercial projects. In next days I'm going to finalize the ZExternalLibrary component, prepare some demos and build pre-compiled versions of the library for Windows and Android you can download. I'll keep you informed.
fracteed
Posts: 43
Joined: Wed Apr 30, 2014 1:14 am
Location: Sydney

Post by fracteed »

Nice one Rado1....very interested to try this out on Android! Does it support .MIDI files? What about audio formats(mp3/ogg) for Android?
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

The MikMod library supports just MOD-type files (669, amf, asy, dsm, far, gdm, gt2, imf, it, m15, med, mod, mtm, okt, s3m, stm, stx, ult, umx, uni, xm). In addition, it can load raw and wav files to be played as sound effects.

MIDI files can be converted to any of the MOD format very easily. Almost each tracker allows to import MIDI file and to export it to the MOD file. I'm using OpenMPT (http://openmpt.org/) which allows to open MIDI files directly; just do File/Open then File/Compatibility Export and you have IT file playable by MikMod. Reccomendation: because default MIDI playing uses stupid sounds from the OS default sound bank, I usually change the sound of different channels before exporting - the result is much better.

Lossy formats (Vobis, mp3, ...) are not supported by the library. MP3 is usually playable by any OS so there should be find some way to play it on Android in ZGE easily; on Windows just call some system command -> I think Kjell has shown it in some forum post. I'll think about it later. BTW these formats are not the best option for ZGE games/applications. Usually the size of mp3 file highly exceeds the size of compiled ZGE application.
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi fracteed,

Each of these "format families" have distinct characteristics.

- Modules contain the music composition in combination with ( primarily ) wave-based samples for instruments.
- MIDI files contain the music composition and use a standardized collection of instruments.
- Digital audio files such as MP3 and OGG simply contain a ( lossy ) waveform.

Although i'm not much of a MIDI fan either ( just like Rado1 ), i guess it could be a valid choice if you're going for Windows 95 era game music.

Anyway, you can use the exact same technique as demonstrated in the Sunset example .. although the loading time is quite bad, so you might want to consider a alternative library that streams the MIDI file instead of parsing it entirely at once. Attached is a demo.

+ As previously mentioned, MP3 / OGG but also MIDI is natively supported on Android.

K
Attachments
Duke.zip
(75.92 KiB) Downloaded 590 times
fracteed
Posts: 43
Joined: Wed Apr 30, 2014 1:14 am
Location: Sydney

Post by fracteed »

Thanks for the info guys. I do have some familiarity with trackers and the MOD format, as I have played around with Sunvox and Renoise in the past. I come from a more traditional music background and much prefer a standard left to right DAW piano roll for composing.

The vertical scroll of a tracker interface does my head in, but as Rado1 quite rightly says , I could just import my Midi files into a tracker and then export that as a MOD type file. Will have to explore OpenMT, as that looks really nice. I am aware of how crappy General Midi sounds are, and I was only referring to using MIDI as a data format, not for GM sound quality :)

My current game is just using mostly square wave sounds with the inbuilt ZGE synth as I am going for a retro chipsound vibe, so it is perfect. On the next ZGE project I will experiment with the tracker/MOD method.

I am not really concerned with exported file sizes, so ideally I would like the option of just using low sample rate mp3's or ogg for all my music and sfx on a future project. Still not really sure what library I would have to use to get this working with ZGE/Android?
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi fracteed,
fracteed wrote:I come from a more traditional music background and much prefer a standard left to right DAW piano roll for composing.
Funnily enough, even though i've had formal music training and i'm comfortable reading & writing partitures, i've always preferred trackers somehow :) You wouldn't believe how much time i spend with ..

Image
fracteed wrote:Still not really sure what library I would have to use to get this working with ZGE/Android?
Don't have any experience with this personally, but it seems like you should be able to use libOpenSLES.so ( in the same vein of calling OpenGL on Android ) for just that.

K
fracteed
Posts: 43
Joined: Wed Apr 30, 2014 1:14 am
Location: Sydney

Post by fracteed »

Ha, a scary interface indeed. Reminds me of my Amiga days :D
In the end, it is whatever works for you and there can can be a certain beauty in a minimal interface. I have played around with a few trackers over the years but I always end up going back to one of my many DAW's (I had 8 paid ones at last count!)...usually Reaper these days.

I must say that Renoise is incredibly impressive though as a tracker and may draw me back one day.

Also the open source Radium is very interesting and has embedded Pure Data into it on the Linux version.
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Finally, I produced the 1st "official" release of MikMod library for ZGE. The precompiled library for Windows and Android can be downloaded from this link.

Attached you will find the demo ZGE project which includes MikMod ZExternalLibrary component. The demo runs on Windows and also on Android; just copy the libmikmod.dll to the project/exe directory for Windows and/or libmikmod.so to the generated libs/armeabi directory for Android. Ville, if you agree I'll add the MikMod external library to the current ZGE beta sources.

Note: MikMod can run only on Android devices with OpenSL ES; it means Android 2.3 (API level 9) and higher. I recommend also to set it in AndroidManifest.xml as

Code: Select all

<uses-sdk android:minSdkVersion="9" />
FYI I provided the Android building artifacts to the authors/maintainers of MikMod, so hopefully you can compile some next version of the library by yourself.

Remark: Personally, I also prefer DAW which is more intuitive for track editing and mixing. However, I also like the idea of small MOD audio files which can be nicely integrated to applications as a background music or sound effects. Therefore, my preferred way is to export tracks/patterns from a DAW to tracker and finalize the composition by adding sampled sounds there.

For those of you who would like to play mp3 or Vobis files on Android, I can have a look at OpenSL ES... later...
Attachments
demo1.zip
MikMod demo ZGE project
(217.71 KiB) Downloaded 590 times
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi Rado1,

Nice work! Unfortunately MikMod doesn't seem to support adlib / include a adlib emulator. So for instance when trying to play a S3M file that uses adlib instruments, it causes your standalone to crash. But i doubt this will be a problem for most users .. just something to be aware of.

K
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Hi Kjell,

you are right adlib is not supported by MikMod library at the moment. AFAIK the BASS library supports adlib instruments neither. However, I can ask the MikMod authors to make use of e.g. AdPlug library... but is it really necessary?

Rado1.
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi Rado1,
Rado1 wrote:but is it really necessary?
Well, only when you want to use adlib instruments ;) I think MikMod not supporting adlib is perfectly fine though, as there are plenty of other libraries out there that you can use when you do need it. And it's certainly not for everybody anyway .. more difficult to use / learn compared to samples and some people don't like the sound of it.

In case you're curious / just for fun, here's a track made in Adlib Tracker II ( adlib only, no samples supported ) .. which uses OPL3 instead of AdLib / OPL2 / YM3812, but it should give you a decent impression regardless.

http://www.youtube.com/watch?v=oNhazT5HG0E

K
zondarg
Posts: 13
Joined: Fri Jan 01, 2016 12:17 pm

Re: MikMod for ZGE

Post by zondarg »

Hi everyone,
since I had some issues with the "older" version of the libmikmod on windows (no stereo output on my machine and others) I recompiled the actual libmikmod-3.3.10 version with MinGW for windows. The android version did not have this problem.
I thought I should share the updated dll in the hope somebody finds it helpful :D
Z.

(Edit: Added missing LGPL license text to archive - needs to be included)
Attachments
libmikmod3.zip
Updated libmikmod-3.3.10 (with lgpl text)
(118.13 KiB) Downloaded 620 times
Last edited by zondarg on Sat Jun 24, 2017 8:49 am, edited 1 time in total.
Post Reply