Community > Project / Coder's Corner

Any good Unity asset for playing Modules?

<< < (2/2)

Saga Musix:
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?

CDKML:
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?

Saga Musix:

--- Quote from: CDKML on October 08, 2017, 13:48:23 ---But openmpt is in C/C++ and Unity uses C#.
--- End quote ---
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.


--- Quote from: CDKML on October 08, 2017, 13:48:23 ---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?
--- End quote ---
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: ---// 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);


--- End code ---

Navigation

[0] Message Index

[*] Previous page

Go to full version