Mod Archive Forums Mod Archive Forums
Advanced search  

News:

Please note: Your main modarchive.org account will not work here, you must create a forum account to post on the forums.

Pages: [1]   Go Down

Author Topic: Any good Unity asset for playing Modules?  (Read 15093 times)

0 Members and 1 Guest are viewing this topic.

Rave669

  • New User
  • Offline Offline
  • Posts: 13
  • I'm gettin' too old...
    • View Profile
Any good Unity asset for playing Modules?
« on: February 16, 2017, 21:18:34 »

Hi all,

I'm working on a google VR/cardboard project in unity. For the time being, I have been exporting my tracks to MP3 format for use in the project, which works.

But I was curious if there are any decent Unity assets for module playback. I can convert to several formats obviously, but .IT support would probably work best, or .MPTM.

Also, would I be best off using an MP3 for music? How big of a resource hit would I take by playing modules directly? bear in mind, it's a VR game for android, so resources are scarce to begin with.

Anyone with experience in this matter chiming in would be appreciated.
TIA.

EDIT: I just read another post by the Unity Devs on here that mentioned native module support; I looked into it and I did find out that, yes, it supports ImpulseTracker modules natively. my bad.

Still, if anyone knows of an asset for Unity that supports OpenMPT modules, that's be great. and my other question regarding resources is still valid. Gotta keep that framerate high!.
« Last Edit: February 16, 2017, 22:04:48 by Rave669 »
Logged
Been doin' this for decades... Great to be back!

Rave669

  • New User
  • Offline Offline
  • Posts: 13
  • I'm gettin' too old...
    • View Profile
Re: Any good Unity asset for playing Modules?
« Reply #1 on: February 16, 2017, 22:51:02 »

Quick update on this topic:

Okay, I've tried it out; Converted an .mptm song to .IT format; dropped it into my project and there are some issues. If you're interested on my findings regarding modules in unity, read on...

Unity apparently supports .MOD .XM .S3M and .IT formats... Here's why:

Firstly the Unity engine uses FMOD for module support; needless to say, the module used didn't quite sound right in-game. Some samples, volumes and effects were a bit "off" but it would be passable if I worked around it with my composition. Seems to run good on the PC, I still have to compile and test on actual hardware to find out about the performance hit.

Next is file size. Unity's Module support would go a long way if you were using formats that would save space, such as old school MODs or other formats where you use fewer tracks, or if you are using only a handful of short, simple samples but in my example, My Module was almost 26MB, way larger than if I were to convert it to an MP3, which would probably be less than 3MB (almost 10x smaller)

However, if you keep your modules small, you can use scripting in the game to do things like change track volume, or enable/disable  tracks, etc. although I'm still looking at the docs to find out how to use these features. This could make for some interesting in-game features.

However, Seeing as to how playback is not accurate to how I intended it to sound, and the smaller size of an MP3; it looks like that's the route I'll be going. At least if I mix it to an MP3 in OpenMPT, it will preserve all the VST effects and playback will be accurate, not to mention make the final APK smaller.

Maybe I'll try to make some tiny modules for certain parts of the game where the track loops and such, while other parts use MP3 files instead.

Just thought I'd share my experience with this so far. Feel free to share ideas and input on this; I'm all ears!  ;D
« Last Edit: February 16, 2017, 22:54:31 by Rave669 »
Logged
Been doin' this for decades... Great to be back!

Saga Musix

  • TMA Moderator
  • Top Poster
  • ****
  • Offline Offline
  • Posts: 2571
  • I love OpenMPT! And Modules! And TMA! And Pie! :>
    • View Profile
    • Saga Musix - free module music and more!
Re: Any good Unity asset for playing Modules?
« Reply #2 on: February 17, 2017, 00:41:19 »

I think I have seen other module players used with Unity as well (libmodplug/mikmod maybe?). If you are okay with doing a bit of coding yourself, you can try out OpenMPT's own rendering engine, libopenmpt. It can emulate most of the basic DirectX effects that are usable in OpenMPT also on other platforms, and while they are not as high-quality as many VST effects, they can still boost the quality of small files tremendously. You could even use the MO3 format which is a compressed variant of several popular module formats, including IT and MPTM.
And  even without using MO3 or libopenmpt, you can still shrink your IT files in OpenMPT: https://forum.openmpt.org/index.php?topic=4961.0
Logged
» My TMA artist profile
» Visit my music site: https://sagamusix.de/ [de, en]
» Visit my programming website: https://sagagames.de/ [de]
» Open ModPlug Tracker

Rave669

  • New User
  • Offline Offline
  • Posts: 13
  • I'm gettin' too old...
    • View Profile
Re: Any good Unity asset for playing Modules?
« Reply #3 on: February 17, 2017, 03:13:53 »

Thanks for the info; I checked out the link re: compressing modules. I had already run the module through a cleanup which brought it down to half the original size; It's now at 11MB. If I strip the stereo samples down to mono, and maybe lower the sample rate a little I can probably get it smaller.

I'm not adverse to trying to write code to get another player to work with Unity; but I've been writing a LOT of code lately in regards to the game I'm developing. I may have to revisit that in the future; I could always put the end result up on the Unity asset store for others to use If I come up with another solution.

I'll be doing some more testing in hardware; I'll see how good I can get my app to perform with unity's module engine. Worst case scenario, I stick with MP3's as there isn't too much of a performance hit on Android.

Thanks for the input  ;D
Logged
Been doin' this for decades... Great to be back!

CDKML

  • New User
  • Offline Offline
  • Posts: 2
    • View Profile
Re: Any good Unity asset for playing Modules?
« Reply #4 on: September 29, 2017, 18:34:02 »

Hi,
I'm actually working on a final degree project on Unity, AR oriented. My intention is to play a tracker song (.mod, .xm, .s3m, .it and also .mid songs) to visualize a live concert with virtual artists who'd play the instruments with the right notes extracted from the tracker files somehow. The problem here is that i don't know if it's possible to get that kind of information (number and type of instruments, played notes, ...) directly from tracker music in Unity. After this time have you got into any interesting result or improvement on your work?
Logged

Saga Musix

  • TMA Moderator
  • Top Poster
  • ****
  • Offline Offline
  • Posts: 2571
  • I love OpenMPT! And Modules! And TMA! And Pie! :>
    • View Profile
    • Saga Musix - free module music and more!
Re: Any good Unity asset for playing Modules?
« Reply #5 on: September 30, 2017, 19:10:16 »

You can retrieve that kind of information e.g. with libopenmpt as mentioned above. If you need to write custom code anyway, it shouldn't be a problem to work with an external library?
Logged
» My TMA artist profile
» Visit my music site: https://sagamusix.de/ [de, en]
» Visit my programming website: https://sagagames.de/ [de]
» Open ModPlug Tracker

CDKML

  • New User
  • Offline Offline
  • Posts: 2
    • View Profile
Re: Any good Unity asset for playing Modules?
« Reply #6 on: October 08, 2017, 13:48:23 »

But openmpt is in C/C++ and Unity uses C#.
Still, if i figure out how to implement the openmpt library in Unity and hope it works well on phone, what's the extact way to get the single notes from each instrument?
Logged

Saga Musix

  • TMA Moderator
  • Top Poster
  • ****
  • Offline Offline
  • Posts: 2571
  • I love OpenMPT! And Modules! And TMA! And Pie! :>
    • View Profile
    • Saga Musix - free module music and more!
Re: Any good Unity asset for playing Modules?
« Reply #7 on: October 09, 2017, 15:03:35 »

But openmpt is in C/C++ and Unity uses C#.
You can use any C libraries (and I think also C++ libraries) in C# as well. A friend was working on a C# wrapper for libopenmpt a while ago to make it even easier but I don't know if that project was ever finished.

Still, if i figure out how to implement the openmpt library in Unity and hope it works well on phone, what's the extact way to get the single notes from each instrument?
That depends on what kind of information you need, and how you need it. You can retrieve the pattern data from libopenmpt at any pattern position, so you can extract notes and instruments, so if you render the module in small increments, you can obtain the current playback position (pattern + row) and then retrieve the pattern data from there. Something like this (pseudo code):

Code: [Select]
// Render small amount of data (512 samples)
openmpt_module_read_interleaved_float_stereo(mod, samplerate, 512, rendered_data);

// Get current position after this has been rendered
pattern = openmpt_module_get_current_pattern(mod);
row = openmpt_module_get_current_row(mod);

// get note in the first channel of current playback position
note = openmpt_module_get_pattern_row_channel_command(mod, pattern, row, 0,OPENMPT_MODULE_COMMAND_NOTE);

// get instrument in the first channel of current playback position
note = openmpt_module_get_pattern_row_channel_command(mod, pattern, row, 0,OPENMPT_MODULE_COMMAND_INSTRUMENT);

Logged
» My TMA artist profile
» Visit my music site: https://sagamusix.de/ [de, en]
» Visit my programming website: https://sagagames.de/ [de]
» Open ModPlug Tracker
Pages: [1]   Go Up