Author Topic: Computer generated music for FS2SCP  (Read 4746 times)

0 Members and 1 Guest are viewing this topic.

Offline z64555

  • 210
  • Self-proclaimed controls expert
    • Steam
Re: Computer generated music for FS2SCP
Sounds a lot like what we've got with LUA already...
Secure the Source, Contain the Code, Protect the Project
chief1983

------------
funtapaz: Hunchon University biologists prove mankind is evolving to new, higher form of life, known as Homopithecus Juche.
z64555: s/J/Do
BotenAlfred: <funtapaz> Hunchon University biologists prove mankind is evolving to new, higher form of life, known as Homopithecus Douche.

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: Computer generated music for FS2SCP
Indeed. If there is a lua module that can be imported into the scipting environment, then you're already most of the way there.

As for making allowances for other interfaces, it's not something we (as the SCP) have a lot of interest in. We like to keep code complexity to a minimum; adding dedicated hooks for external, optional libraries is only warranted when there's a clear benefit to doing so (as, for example, demonstrated by the TrackIR plugin). In this case, I think the preferred way to do it would be to prototype such an interface using the lua API, and turn it into a built-in interface if (and only if) there's a lot of demand for it and clear performance benefits to be achieved by it.

In other words, if you want it so much, why don't you start working on a lua-based interface solution to show this off?
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

  
Re: Computer generated music for FS2SCP
How can i try the LUA interface ?

Wich version holds it ?

I am still mastering SoundHelix because the thing has like 10000 variable to setup a music...

Edit:

I believe i found a good solution :

All logic is handled by the LUA script.

LUA script needs to be able to communicate to soundhelix jar.

It can be done two ways (simple)

1 - Allowing LUA to call external applications (Something that is not permitted under most circunstances due to secutiry risk). LUA would talk to a custom soundhelix jar using the standard input/output of the spawned process
2 - Allowing LUA to communicate with another application via TCP/IP (Basically UDP packets via 127.0.0.1). This is preferred cause its much less risky. I prefer this way.

On the custom JAR side there will be 3 simple functions :

1 - Start a music XML with random seed. Each music XML will be premade with parameters corresponding to certain situations (Danger, Idleness etc).
2 - Fade out the current music (allowing transition from one state to the other).
3 - Stop current music.

LUA can then send commands to start, fade out, stop and start another music upon game state change. Thats not all that hard.

Later i will try to find a way to allow on-the-fly music transitions without the need to fade out.

From the SoundHelix page, this is a very simple SoundHelix player :

Code: [Select]
import java.net.URL;
import com.soundhelix.player.Player;
import com.soundhelix.util.SongUtils;

public class SoundHelixTest {
    public static void main(String[] args) {
        try {
            Player player = SongUtils.generateSong(new URL("http://www.soundhelix.com/applet/examples/SoundHelix-Piano.xml"),
                                                   System.nanoTime());

            player.open();
            player.play();
            player.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Not complicate in any way. All i need is to add capability to talk via UDP and find a simple way to change music volume as a fading measure from inside the JAR. Maybe its dependent on the MIDI device being used ? Do FS2 use MIDI ? If not, just fade out the MIDI volume slider would be pretty simple and would not interfere with anything else.

On the LUA side i need a way to scan current mission to detect enemy presence and a metric to weight enemy aggregate firepower vs friendly aggregate firepower. I think this is a good parameter to decide the music speed. At least would be a good easy start.

Sounds reasonable ?
« Last Edit: July 12, 2012, 02:01:24 pm by jorgealdo »

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: Computer generated music for FS2SCP
Quote
On the LUA side i need a way to scan current mission to detect enemy presence and a metric to weight enemy aggregate firepower vs friendly aggregate firepower.

All information needed to do this is already provided in the lua API (the mn.Ships table holds a list of all ships in the mission).
Network access in lua can be handled by a lua library like this one: http://w3.impa.br/~diego/software/luasocket/

For general info on how to use lua scripts in FSO, read this page on the wiki: http://www.hard-light.net/wiki/index.php/Scripting.tbl
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Computer generated music for FS2SCP
the other day i was reading about alien, a module which apparently lets you can talk to any dll you want if you have the function prototypes. it handles the type conversions for you. the other option is to build a lua module proper that provides the neccisary api interfaces.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN