libopenmpt, game dev and effects question

Started by mbbmbbmm, December 02, 2020, 21:08:56

Previous topic - Next topic

mbbmbbmm

Hello everybody!

I would like to use IT- or XM- module playback in game development. But I am a little confused.

From what I've read a big advantage of using mod files for game music is that they are kind of interactive, channels can be muted and unmuted etc.

I played around with SharpMik in Unity3D a bit - and muting/unmuting and setting the song position is working fine :)

But I also read that there is this concept of "subsongs", parts of the module that use Bxx Jump-to-order commands. From what I understand the sections are told to loop until further notice and then can jump to a different subsong on demand. This would allow having reactive music via modules in the game which would be super cool!

The looping via Bxx is working fine - but how can I jump to another subsong right on time? Setting the song position from the game code works but is not very tight, since the exact time of the command depends on the current framerate of the game loop. I think the best way would be to set a new jump command on the last beat and leave the timing to the player - if that is possible at all :D

So I am a bit confused: is it possible to change the effects of a module after it has been loaded by the player? With a library like libopenmpt can I set the Bxx-effect on the last step of a subsong to jump to a different order while it is already playing the module?

Maybe I am misunderstanding the concept. Any help or hints are very appreciated!

Saga Musix

Quote from: mbbmbbmm on December 02, 2020, 21:08:56
The looping via Bxx is working fine - but how can I jump to another subsong right on time? Setting the song position from the game code works but is not very tight, since the exact time of the command depends on the current framerate of the game loop. I think the best way would be to set a new jump command on the last beat and leave the timing to the player - if that is possible at all :D
Sadly there is no easy way to do this right now but it's planned for the future to make this easier: https://bugs.openmpt.org/view.php?id=1017

If you have complete control over the music being played in your game, you can maybe look at this workaround for now, by computing the expected duration of a row: https://forum.openmpt.org/index.php?topic=6516.0
Let me know if you need any help with the formulas .

Quote from: mbbmbbmm on December 02, 2020, 21:08:56So I am a bit confused: is it possible to change the effects of a module after it has been loaded by the player? With a library like libopenmpt can I set the Bxx-effect on the last step of a subsong to jump to a different order while it is already playing the module?
You cannot "edit" the pattern data in the sense you can place Bxx commands after the file has been loaded, but by calculating when a row or pattern is finished playing (see above), you can create smooth transitions between songs. Do note that this is not required if your subsongs are just always supposed to loop back to the same position; this is something the library should already do on its own.
» 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.

mbbmbbmm

Ok, cool that makes sense. I am going to try this later tonight. Thank you!