Any information about JS library that use OpenMPT WASM?

Started by RyanBram, June 18, 2019, 12:19:04

Previous topic - Next topic

RyanBram

Hi.
It seems that I haven't been in this forum for quite a long time.

I have questions related with WebAssembly version of OpenMPT. I never see it in performance because if I remember correctly Chiptune2.js hasn't been updated when OpenMPT starts to support WebAssembly.

Can you tell me, where I can find opensource library that use OpenMPT WASM for its backend, hopefully with sample code for web or index.html so I can see how it works offline?

I am also curious when saw libopenmpt.wasm is so small in size compared with libopenmpt.js which is a really nice thing.

Saga Musix

There are only few modifications required to chiptune2.js to make it work with the WASM version; you can see those modifications in action e.g. on modarchive.org and s3m.it.
» 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.

RyanBram

Do websites you mentioned above support playing module from local folder like https://deskjet.github.io/chiptune2.js/ ?
I have visited both, but cannot find the feature.

Or maybe, it is just maybe. There will be official index.html that will be bundled with libopenmpt.js or libopenmpt.wasm to see them in action, just like openmpt123 for seeing libopenmpt in action. Something like one from modarchive is really good. I used to download https://github.com/deskjet/chiptune2.js/tree/old-master to see libopenmpt.js playing music locally, but unfortunately it doesn't have latest feature from newer libopenmpt.js nor supporting webassembly either.

Please don't be upset. It is just a suggestion.

Saga Musix

Quote from: RyanBram on June 19, 2019, 17:39:25
Do websites you mentioned above support playing module from local folder
No, as it should be easily guessably the online players are there to play the tunes on those sites. The site you posted is just a simple demonstration of how to use chiptune2.js, not intended as a full-fledged player.
What exactly is it that you want to achieve? Do you need code that demonstrates you how to use libopenmpt.js? Then look at modarchive.org or s3m.it. Do you need a portable libopenmpt-based module player? There are many, see e.g. here: http://wiki.openmpt.org/Libopenmpt#Players Some of them are written in JavaScript.
» 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.

RyanBram

Hi Saga Musix,

You may remember that I ever told you that I want to use OpenMPT for my game project. And I am really happy when I know OpenMPT will available as Javascript library, which mean it can potentially become cross platform solution for Module playback without recompiling the library, because HTML5 is supported everywhere. Just pick suitable rendering engine like NW.js for desktop, Cordova for Android, and Chrome/Firefox for Web, then I basically can make game once and run everywhere.

The problem is, although I can search many Javascript programmer on internet to make me RPG Maker MV plugin, but only few of them who know or interested about how module music works, and fewer than that who know about how to use libopenmpt.js for web audio playback support, and even fewer than that who know about how to integrate it as RPG Maker MV plugin. Fortunately there are chiptune2.js, therefore I don't have to introduce my programmer from beginning about module music. Just point him to chiptune2.js GitHub repository and its web example, then ask him to integrate it in RPG Maker MV.

It works!

I have planned to share my commissioned code to public, so every indie gamer like me can get benefit from it. I can proudly said  that it is based on libopenmpt that make my plugin works. And of course OpenMPT wiki can be updated to tell that it is used in gaming world just like it is used in XMPlay, Foobar, etc. But in fact I am too shy to share it to public because it doesn't performed as intended. There are too much latency in audio playback, so I am not continuing the project  although I understand that the latency may not caused by libopempt, maybe the plugin is what caused the latency.  I am almost desperate to continue my project until I know AudioStreaming.js  that incorporating stbvorbis compiled with emscripten to support iOS or web browser who may don't have native support for OGG. Then I wonder how emscripten based js can perform so well in supporting ogg playback for web. Now OpenMPT has evolved. It can be compiled into web assembly, which mean there are potential upgrade to make it run better on web. Unfortunately, chiptune2.js is not updated to support this new feature, which mean I cannot just  download and overwrite the old chiptune.js and libopempt.js to make my plugin magically support web assembly as well.

I am attached my code and project in case you want to look at it (I don't want to bother you, just leave it if you don't interested). It can be opened in RPG Maker MV or you may playtest it using browser or nw.js.
https://drive.google.com/file/d/1iUUUtOqpIQD0O5_pHdRkVG5wI7yV4cLX/view?usp=sharing

And then for your questions
Quote from: Saga Musix on June 20, 2019, 11:48:29
what exactly is it that you want to achieve?
I want to integrate OpenMPT into RPG Maker MV game engine so the engine can support module music.

Quote from: Saga Musix on June 20, 2019, 11:48:29
Do you need code that demonstrates you how to use libopenmpt.js?
Yes, so I can point to my programmer about what I want to achive or they can study it to make plugin.

Quote from: Saga Musix on June 20, 2019, 11:48:29
Do you need a portable libopenmpt-based module player?
Yes. I need them to test how well libopenmpt.js perform in web should be.

Thank you for reading this post.

Saga Musix

Quotethen I basically can make game once and run everywhere
We have mentioned this several times before but here is another warning: The way browsers and libopenmpt work is not really suitable for background music for web games. JavaScript and WASM are both single-threaded, so the audio updates will be fighting with any other code (in particular graphics) to be delivered in time. When this fails, there will be audible dropouts. Even on my beefy work machine which is probably better than what 90% of casual browser game players have available, this happens when running the wasm version of libopenmpt alongside some random browser games. You might be missing your target audience by a mile if you do this.

Quotebut only few of them who know or interested about how module music works, and fewer than that who know about how to use libopenmpt.js
They don't need to know any of this. They just need to be able to either
1) read other people's code (which they really should be capable of if you pay them money) or
2) read the emscripten documentation / examples how to load a piece of wasm code. Everything else (interacting with libopenmpt) will stay the same as it currently is in chiptune2.js.
» 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.

RyanBram

Thank you Saga for your patience in answering my questions. Actually I want to reply you after the commission was successfully finished, but please let me ask some more questions while the commission still on progress.

Quote from: Saga Musix on June 26, 2019, 15:47:04
JavaScript and WASM are both single-threaded, so the audio updates will be fighting with any other code (in particular graphics) to be delivered in time. When this fails, there will be audible dropouts.
I am really sure you and Manx are the most knowledgeable about OpenMPT, please let me know why OpenMPT cannot achieve similar performance like emscripten of stbvorbis.js and opus.js? I'll give you both examples:


  • One of RPG Maker MV Core Scripts developer created AudioStreaming.js plugin to be used in RPG Maker which replace builtin browser codec with emscripten of stbvorbis.js and when I tried it, it can achieve similar performance like native code and even faster. This is one of the very reason I back to this forum to ask about possibility of integrating libopenmpt.js for games despite you warned me several times. Maybe times changes everything since the last time I asked you before
  • Construct 3 Game Editor use emscripten of Opus.js or Opus.wasm to ensure cross platform and cross browser audio formats support, which simplify user for not preparing two internet supported formats: vorbis and aac.

Above stories inspires me to do same with libopenmpt and always make me curious, why old formats like modules which are designed since old slow computer era, cannot gain similar performance like modern format, such as vorbis and opus in modern web browser in modern computer.

Quote from: Saga Musix on June 26, 2019, 15:47:04
They don't need to know any of this. They just need to be able to either
1) read other people's code (which they really should be capable of if you pay them money) or
2) read the emscripten documentation / examples how to load a piece of wasm code. Everything else (interacting with libopenmpt) will stay the same as it currently is in chiptune2.js.

Actually based on recent conditions, I and my programmer decided to use AudioStreaming.js as base for adding libopenmpt.js support into RPG Maker MV, as the library already designed to support the engine in mind. He said to me that chiptune2.js wasn't needed anymore because libopenmpt.js can directly connected to AudioStreaming.js unlike our previous attempt for adding libopenmpt.js support in our game.

Thank you very much for everything, and really sorry for always taking your time answering my questions.