Author Topic: How heavy module music is?  (Read 263 times)

Offline RyanBram

  • Active artist
  • *
  • Posts: 27
  • Operating System: Windows
How heavy module music is?
« on: April 08, 2017, 10:37:19 »
Hi, community.
I have plan to use libopenmpt.js for creating web based game. I am using tool that make non programmer like me to fullfilll the task. The only problem is the tool/engine doesn't support module music format and I prefer it over ogg because of filesize. I have 2 questions.
The questions are:
1. How much computer resources are needed to playback format like IT or MPTM compared to MIDI or OGG Vorbis?
2. How fast is libopenmpt.js to playback module music file? Can it be use for real time playback without lag or performance penalty?

Thanks.
« Last Edit: April 11, 2017, 03:30:25 by RyanBram »

Offline manx

  • OpenMPT Developers
  • *****
  • Posts: 100
Re: How heavy module music is?
« Reply #1 on: April 08, 2017, 12:07:59 »
Hi, community.
I have plan to use libopenmpt.js for creating web based game. I am using tool that make non programmer like me to fullfilll the task. The only problem is the tool/engine doesn't support module music format and I prefer it over ogg because of filesize. Before I invest my money for programmer, I have 2 qustions.

libopenmpt.js comes at a size cost itself, thus you probably have to include that also in your calculations (it may very well still be less in size than ogg or mp3 tracks).

1. How much computer resources are needed to playback format like IT or MPTM compared to MIDI or OGG Vorbis?

libopenmpt.js is rather big (about 2.4MB of Javascript code). Additionally, the whole module file has to be loaded by libopenmpt.js, which (temporarily during loading) requires (roughly) twice the amount of memory as the module file consumes on disk. During playback, roughly the module size plus some internal structures (which are not really that big) of memory is required. If the module uses sample compression, all sample data will be uncompressed during loading and be stored uncompressed in memory.

2. How fast is libopenmpt.js to playback module music file? Can it be use for real time playback without lag or performance penalty?

I am not aware of anyone using libopenmpt.js in a Javascript game engine so far. Realtime playback is certainly possible and used by various websites (although for module playback only, without a game engine running additionally). CPU consumption is (depending on the Javascript engine and browser) roughly at worst 2 times the CPU consumption of native playback (so far, noone has done precise benchmarks, afaik).
Rather technical aspect: I am not sure if it would be possible to put libopenmpt.js rendering into a separate WebWorker (I am not a Javascript expert and thus I have never tried that). That would allow libopenmpt.js to run in a separate thread than the game engine, which would allow it to use a separate CPU core concurrently. If that is not possible (or not implemented by your game), libopenmpt.js will have to compete with the rest of your game for CPU time.

Even though we would certainly like to see people experimenting with libopenmpt.js in web-based games, I am not quite sure if I could recommend that usage. You will certainly have less hassle if you are using AAC or Ogg Vorbis playback provided by the browsers and your game engine.

Offline Saga Musix

  • OpenMPT Developers
  • *****
  • Posts: 6,106
  • aka Jojo
    • Download music, samples, VST plugins: Saga Musix Website
  • Operating System: Windows 7 x64
Re: How heavy module music is?
« Reply #2 on: April 08, 2017, 12:47:09 »
As manx says, you would have to experiment and check if libopenmpt can be run in a WebWorker, as running libopenmpt in the main JavaScript thread is really unsuitable for the game. It's one of the reasons why e.g. libopenmpt playback via chiptune2.js often stalls when switching tabs - the browser is ismply busy doing other things in the main thread.
ยป No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

Offline RyanBram

  • Active artist
  • *
  • Posts: 27
  • Operating System: Windows
Re: How heavy module music is?
« Reply #3 on: April 10, 2017, 06:58:22 »
Thank you, Manx and Saga for the detailed explanation and suggestion.
I will take your suggestions and tell my programmer, especially about WebWorker and will inform you about the result, so everyone will get benefit from the information.

Best regards,
RyanBram