Utilizing libopenmpt in Games for Dynamic/Interactive Music?

Started by rchrdcrg, August 16, 2019, 13:00:30

Previous topic - Next topic

rchrdcrg

Hello folks! So I've got a bit of a question!

I see there's a library that can be used for playback, but I'm no programmer, and lately I've been curious just what is libopenmpt capable of? Is it merely for playback, or could it be tied into variables in a game that would allow for more precise control such as:
-Volume/mute of channels
-Jumping to different patterns on cue
-Changing volume/effect/vst commands based on data from the game

If any of that is possible, let's just say I can dream up some truly amazing things you could do with that!

Saga Musix

Most of that is possible with the library, except for manipulating pattern data (which I guess your third point refers to). libopenmpt does not handle plugins and that would certainly not be a very useful feature for games anyway, as redistributing VST plugins is often not trivial (and more importantly you typically don't have the permission to do so with many plugins).
If you're seriously interested in what is possible and how it can be done, the documentation for each API function can be found at https://lib.openmpt.org/doc/
» 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.

rchrdcrg

Awesome, thanks! Yeah, I didn't even really think about VST in depth before blurting it out... makes sense! I'm interested in exploring dynamic soundtracks for games in more detail than what most games do. Usually a dynamic soundtrack is just different prerecorded tracks that are faded in and out based on something simple like location/action, or maybe certain notes and effects are tied to actions and correspond to a beat, such as Rez, but I wanted to take it a step further and basically hand over some of the "composition" to the game itself with the objective that the music would be unique to every playthrough. Perhaps the game design could even be worked around this so that better skill equals better music, as if the player feels like a musician but by playing something unrelated like a Geometry Wars clone or something.

LPChip

If you are interested in procedural generated music (music that interacts with what happens in game), you should check out an indie game developer called Nifflas.

He uses Unity nowadays, and he created his own synthesizer in Unity, so he can have the music interact with what happens in-game. For example, in his latest game Knytt Underground, there is a section that is rhythm based, where you hear and see the music interact with the game very clearly.

Here's one of the examples of his earlier implementations: https://youtu.be/HLA3AekhB3U?t=98 The character is forced to transform every beat. In later puzzles, the puzzles themselves transform their state based on the beat or musical events.

Here is an example of the synth he build for his upcoming project Ondskan: https://www.youtube.com/watch?v=bU8HEQm0zX0. Everything you hear is generated by his synth and as you can see that he presses some buttons, those button presses could be an event in a game just as easily. For example, entering a room could add a synth section or change a parameter. For example, entering a cave could add a delay section to simulate reverb.
"Heh, maybe I should've joined the compo only because it would've meant I wouldn't have had to worry about a damn EQ or compressor for a change. " - Atlantis
"yes.. I think in this case it was wishful thinking: MPT is makng my life hard so it must be wrong" - Rewbs

violgamba

Sorry for necroposting, but for the record, and the sake of others interested in this: interaction options are currently limited.
- You can not interactively manipulate channels (mute/volume/etc).
- You can not interactively jump to patterns.

You CAN set the tempo, pitch and volume of the song, but that's about it, for now.

I'm also interested in this kind of interaction.  I read a similar post to this one and got libopenmpt working before realizing that it isn't actually interactive.

If I'm mistaken about this, then I apologize.  I'd love to be wrong, but I haven't seen anything in the documentation about channels or patterns except for getter functions.

Saga Musix

That's not quite right.

Quote from: violgamba on January 09, 2023, 08:19:19- You can not interactively manipulate channels (mute/volume/etc).
set_channel_volume and set_channel_mute_status from the interactive interface.

Quote from: violgamba on January 09, 2023, 08:19:19- You can not interactively jump to patterns.
There is both set_position_seconds and set_position_order_row for jumping to a specific position.
» 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.

violgamba

Oooh boy, that's exciting.  But, how did I miss these?  I guess I wasn't as thorough as I thought.

Thanks for setting the record straight.

lucckasmarciel

You can use extreme sample converter to convert your vst sounds into wav files.