Staredit Network > Forums > Modding Discussion > Topic: Music system plugin
Music system plugin
Jun 25 2017, 9:51 pm
By: Pr0nogo  

Jun 25 2017, 9:51 pm Pr0nogo Post #1



I am now actively pursuing a music system plugin. The goals of this project are as follows:

  • Load tracks from the mod file itself;
  • Adhere to a global track list so that all tracks can be played regardless of the map;
  • Read death counter data from maps to control which track is active and when a track fades out;
  • Read volume from the player's music setting (or play through the music channel);
  • Lower volume incrementally over X seconds to simulate fading out (and raise over X seconds to simulate fading in)

This will require the ability to use the plugin to interpret data from a hardcoded set of death counters, which means only maps with the appropriate triggers will work with the system, but that's fine for my purposes. I will post developments as they occur. If you wish to contribute, please let me know!

old OP (defunct goals)


Post has been edited 1 time(s), last time on Aug 30 2017, 12:08 am by Pr0nogo.




Jun 26 2017, 7:00 pm Corbo Post #2

ALL PRAISE YOUR SUPREME LORD CORBO

hmm... Interesting.

I will try some stuff out...



fuck you all

Jun 26 2017, 8:08 pm lifebot Post #3



You could try pre-applying fade in and fade out affects in Audacity to your sound files if you desire those effects to be persistent.

As for using death counters for activating the loops at a specific timing, you could try replacing it with moving units it could make it less of a chore.




Jun 26 2017, 8:12 pm lifebot Post #4



Using moving units instead of death counters can remove the issues of menu pauses screwing up the wav loops.

However, doing this replacement will make the loops to not work properly when #x2 or #x3 speed modes are enabled in game.

This is simply due to the fact that units move faster when #x2 or others are enabled. A simple workaround is to advise players to not enable speed modes during briefing or with in-game warnings.




Jun 26 2017, 8:18 pm Pr0nogo Post #5



Quote from Corbo
hmm... Interesting.

I will try some stuff out...
Alright, let me know how you make out!

Quote from lifebot
You could try pre-applying fade in and fade out affects in Audacity to your sound files if you desire those effects to be persistent.
As for using death counters for activating the loops at a specific timing, you could try replacing it with moving units it could make it less of a chore.
The 'move unit' action still functions even when the game is paused? My understanding was that even if all conditions of a trigger are met, the actions won't run while the game is paused. I am speaking strictly from my knowledge of single-player offline games, so there might be a difference between that and 1.18's online games.




Jun 26 2017, 8:23 pm KYSXD Post #6



Maybe you could customize the music interface created for SC:Burning Ground: CMS: Combast Music System Plugin Test

Here are some links to a source:

Music_Interface.h
Music_Interface.cpp
Game_Hooks.cpp (Example)

I think that you could create custom functions or triggers in the map and link them with GPTP.




Jun 26 2017, 8:28 pm Pr0nogo Post #7



Holy moly. That looks incredibly promising. Thanks for the share KYSXD! This is basically everything I'd need as long as I was able to specify the music files and when to fade them.

Now I just need someone with more coding knowledge than myself to see about implementing them in an appropriate fashion.




Jun 26 2017, 8:29 pm lifebot Post #8



Quote from Pr0nogo
The 'move unit' action still functions even when the game is paused?

Can confirm it still functions when the game is paused.

Since the unit would be ordered to move prior to the pause, the unit should keep moving to the destination even if game is paused.

You just have to find out the exact distance the unit needs to move for each sound file. Kind of pain in the ass but certainly executable




Jun 27 2017, 9:55 am Sand Wraith Post #9

she/her

A plugin can be used in tandem with a directory within which read/write permissions are enabled, a batch script (assuming target is Windows), and FMOD, an audio library, some map triggers, and an auxiliary program (or not).

You will also need a coder.

Look for "FMOD Studio Programmer’s API and Low Level Programmer API". You need the Windows API (probably don't go for W10's API if compatibility is a concern).

Based on my personal experiments in VFSRST, the system can be created easily.

Based on my experience:

The plugin for the mod must launch the aux program on SCBW startup (or match startup).

The aux program will include calls to the FMOD API and the ability to read and write files in the active directory (IIRC the active directory is considered to be the mod's *.exe file's location).

In the map, designate a few death counters to serve a few purposes relevant to basic music player.

examples:
Code
dc 00 for function "play file"
dc 01 for function "stop playback"
dc 02 for function "pause playback"
dc 03 for function "fade in"
dc 04 for function "fade out"
dc 05 for function "exit"

dc 10 for parameter 1
dc 11 for parameter 2
dc 12 for parameter 3

etc.


and designate some function prototypes.
examples:
Code
function play file: takes dc 10 (INT) to describe file to be played (file to be played must be designated in a 1-to-1 relationship with DC-accessible numbers -- namely, positive integers (I think)).

function stop playback: takes nothing.

function fade in: takes dc 10 (INT) to describe a duration.

etc.


Now.

The plugin (whether by A(s,t)'s GPTP or Neiv or Heinermann or so forth) has direct access of course to the map's DCs. The map itself, in run-time, can set (and read) a bunch of values in the designated DCs. That is obvious. The plugin can also access these values.

This means that for any given map the map and the plugin can cross-communicate.

In the map, any time you want to play music, use your designated functions (that are merely a few specific DCs for which you follow some rules).

Then, the plugin shall read the specific DCs, recognize the special numbers as having meanings, and then output a message to a file or other piece of memory (or message box or stream or pipe or whatever (i don't know all the methods available, i used a file)) accessible to the aux program. (And then it will reset the DCs to an empty value so that it doesn't trip/activate itself again on the next game loop.)

The aux program's sole purpose is to read the message output by the plugin and then use the FMOD API to play/stop/fade music -- that is to say, the aux program does exactly as the plugin commands.

(In the past I used an aux program because I found that an #include directive on the FMOD API in the plugin code itself would cause SCBW to reliably crash to desktop on game startup. So the aux program isn't necessarily necessary given that I don't know for certain if it is impossible to incorporate FMOD API calls in the plugin itself.)

Therefore: the map commands the plugin to perform specific functions by way of DCs. The plugin understands what these DCs mean and delegates the actual music playing to a separate aux program.

---

Anyway, I think this method is the method through which one has utmost control over how the music and what music is played. Unfortunately it is a roundabout method due to my lack of knowledge, but when implemented appropriately, effectively bypasses any of SCBW's music playing limitations (though tbh it is probably perfectly possible to simply manipulate SCBW's own music system).




Jun 27 2017, 4:56 pm Pr0nogo Post #10



That seems like a pretty thorough approach and I could get behind it. Would it be playing through the game's music channel or would it have to have its own volume control?

Thanks a lot for sharing, looks promising.




Jun 28 2017, 1:21 am Sand Wraith Post #11

she/her

No problem. Personally, I would be very excited to see someone implement it. This system as I have described it would have its own volume control. The aux program would be responsible for it.

That said, I would think it is very much possible to read the volume level of SCBW's music with the plugin and then send that data to the aux program to adjust appropriately.




Aug 30 2017, 12:08 am Pr0nogo Post #12



Back at this again, this time with the intent to code at least some of it myself, though I'm still very much a greenhorn with regards to C++/GPTP.

The OP has been updated with the goals for this project. You can also find them below.

  • Load tracks from the mod file itself;
  • Adhere to a global track list so that all tracks can be played regardless of the map;
  • Read death counter data from maps to control which track is active and when a track fades out;
  • Read volume from the player's music setting (or play through the music channel);
  • Lower volume incrementally over X seconds to simulate fading out (and raise over X seconds to simulate fading in)





Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[09:24 pm]
Moose -- denis
[05:00 pm]
lil-Inferno -- benis
[10:41 am]
v9bettel -- Nice
[01:39 am]
Ultraviolet -- no u elky skeleton guy, I'll use em better
[10:50 pm]
Vrael -- Ultraviolet
Ultraviolet shouted: How about you all send me your minerals instead of washing them into the gambling void? I'm saving up for a new name color and/or glow
hey cut it out I'm getting all the minerals
[10:11 pm]
Ultraviolet -- :P
[10:11 pm]
Ultraviolet -- How about you all send me your minerals instead of washing them into the gambling void? I'm saving up for a new name color and/or glow
[2024-4-17. : 11:50 pm]
O)FaRTy1billion[MM] -- nice, now i have more than enough
[2024-4-17. : 11:49 pm]
O)FaRTy1billion[MM] -- if i don't gamble them away first
[2024-4-17. : 11:49 pm]
O)FaRTy1billion[MM] -- o, due to a donation i now have enough minerals to send you minerals
Please log in to shout.


Members Online: Sylph-Of-Space, RIVE, Ultraviolet, Roy