modplay - MOD music player for Android and iOS

Monkey Programming Forums/User Modules/modplay - MOD music player for Android and iOS

sygem(Posted 2014) [#1]
I have created a module that wraps the excellent 'libmodplug' library for Android and iOS - if anyone fancies tackling other targets they are welcome to!

The Android version is largely based on the AndModPlug library from Peculiar Games, who are kind enough to provide their sources. I have slightly modified the original libmodplug to enable looping of files.

GitHub repo: https://github.com/sygem/modplay

I have included a sample project in the repo, but basic usage looks like this:

format_code('Local player := New ModPlayer()
player.SetLoopCount(-1) ' enables continuous looping

Local file := New ModFile("mymodfile.mod")
player.Play(file)
')

I used this in my last game, which is live on both the iOS and Google Play stores.


Sammy(Posted 2014) [#2]
Nice, I'm a big fan of retro computer music. Thank you!


Nobuyuki(Posted 2014) [#3]
hot cheese, this is a great thing. I'm glad someone finally tackled it.

I see glfw natives. Does it work on glfw?


sygem(Posted 2014) [#4]
I see glfw natives. Does it work on glfw?


It doesn't work on glfw yet, but I was starting to work on it. I haven't made much progress, and I'm not sure when I'll be working on it again. Of course, if someone wants to take it on...


Snader(Posted 2014) [#5]
Very nice work. Thanks for sharing!


Supertino(Posted 2014) [#6]
Great stuff this will be very handy Thanks sygem


Nobuyuki(Posted 2014) [#7]
Heya, bumping this because I have a question.

Does your library have a way to unload mods from memory? Are they unloaded automatically at any point? Or are they streamed from the source?

I was starting to try to work on some of the GLFW portions of the code, but I didn't get very far because I was 1. Considering using libopenmpt instead of libmodplug (because it's more updated), and 2. Researching how to best pipe the data to OpenAL. I noticed you used Audio Units on ios, but I haven't checked the Java code to see what's used there, yet.


sygem(Posted 2014) [#8]
Does your library have a way to unload mods from memory? Are they unloaded automatically at any point? Or are they streamed from the source?


Looking through the Android code, there is an UnLoadMod() method - it just isn't exposed to the Monkey side at the moment. This is called each time a new Mod is played, but could be called at any time to unload the mod from ModPlug.

The Mod file data is stored in byte array, so it should be garbage collected if there are no more references to the ModFile?


Nobuyuki(Posted 2014) [#9]
so libmodplug wouldn't hold onto a databuffer reference it was passed to by the wrapper function? When you're dealing with externs there's no guarantees I think, but I wanna make sure I'm understanding things clearly.

Also, was there a specific thing that was keeping you from implementing glfw? Was OpenAL going to be a headache? Cross-platform issues? Just curious :)