OpenXcom Forum

OpenXcom => Suggestions => Topic started by: Mr. Quiet on February 06, 2014, 03:13:26 am

Title: Setting music to specific maps?
Post by: Mr. Quiet on February 06, 2014, 03:13:26 am
I just found this: https://archive.org/details/Sounds_of_Nature_Collection (https://archive.org/details/Sounds_of_Nature_Collection)

and now I'm excited to add these environmental sounds into my game(after I edit them with tense ambient music of course), but I have to choose certain nature tracks so they blend in with every battlescape map. I hope this adds immersion to my game.

Here's my question. Is it possible for OXC to be able to play, for example "Jungle track 1" only when you enter a jungle map? I also want a City in Distress track for Terror-Sites too, if I could ever find one or find time to make one. I don't have time for anything these days :(

Can this be done by messing with the rulesets or something? I dunno anything about modding X-COM, so I'm at your mercy ;_;.

I apologize if this has already been posted before.

Thanks everyone!

Edit: If this can't be done through the game, I guess I can do it manually, but it'll be a pain. As soon as I land and know which map type it is, I save and exit, switch .ogg file to the map type track and get back on. I'll do it when I know I'm going to be in for at least an hour.
Title: Re: Setting music to specific maps?
Post by: Solarius Scorch on February 07, 2014, 10:06:10 am
If this can't be done through the game, I guess I can do it manually, but it'll be a pain. As soon as I land and know which map type it is, I save and exit, switch .ogg file to the map type track and get back on. I'll do it when I know I'm going to be in for at least an hour.

I think using Winamp or Windows Media Player would be easier. :P

I really like the idea though.
Title: Re: Setting music to specific maps?
Post by: hszp on February 07, 2014, 10:54:18 am
https://github.com/SupSuper/OpenXcom/blob/master/src/Battlescape/BattlescapeState.cpp#L485
Code: [Select]
_game->getResourcePack()->getRandomMusic("GMTACTIC")->play();

It is not currently possible. One would need to change the source to allow rulesets to change this.
If you have a tune or two that catches some guru's attention, it could get implemented quickly I think. Like, in v1.1.
Title: Re: Setting music to specific maps?
Post by: B1ackwolf on February 07, 2014, 07:15:03 pm
so right now its impossible? thats sad i was really interesed on this feature,by now i just tab and hear the music track on my aimp3 and then tab again to the game  :'(...a pretty lame solution xDDD
Title: Re: Setting music to specific maps?
Post by: Gifty on February 07, 2014, 09:13:30 pm
TFTD had this; how was it handled in that game?
Title: Re: Setting music to specific maps?
Post by: SupSuper on February 07, 2014, 11:30:24 pm
TFTD had this; how was it handled in that game?
TFTD had two tracks, one for underwater and one for surface missions. We will consider expanding this flexibility to any mission type in the 1.0+ mod overhaul.
Title: Re: Setting music to specific maps?
Post by: Mr. Quiet on February 08, 2014, 12:23:04 am
Thanks I'll do just that with VLC :)

If I ever have time, I'm gonna attempt to make a decent track using Audacity ;)

I just thought of something neat, adding military radio voice overs as well every couple minutes, but we'll see how that turns out.

Maybe this won't be answered, but I'll ask anyway.

How long or how big in size does a track have to be so that it'll begin to lag the game in anyway? Because if I do anything creative, I'm gonna think big and make a long track, with maybe the same music repeating, but different ambient sounds will appear, so it doesn't feel repetitive in one mission. Would an hour long track be okay? Size being under 100MB.
Title: Re: Setting music to specific maps?
Post by: Warboy1982 on February 08, 2014, 06:37:19 am
i don't THINK any track length would cause it any significant lag, it loads all the music into memory at startup, so you'd be looking at a longer initial load time, and a larger memory footprint. the engine itself needs about 5 meg of ram, so go nuts, but don't expect it to work too well with mobile devices.
Title: Re: Setting music to specific maps?
Post by: hszp on February 11, 2014, 01:51:48 am
Do you guys have ideas what rules could be defined, what would be the parameters for specifying music tracks?
The initial suggestion was battlescape, based on terrain type.
Mission type could be an additional parameter or the approximate number of live enemies.
On the geoscape, I could imagine starting a specific track if there are UFOs on the radar or having a different music in the early stage of the game.

Although, realistically, I doubt anyone would use all these features if they were available.
Title: Re: Setting music to specific maps?
Post by: moriarty on February 11, 2014, 12:23:46 pm
I think you might be on to something, hszp.

If we define certain "flags", maybe they could later be used to change the ambient music in certain ways? This wouldn't have to be used at first, but there appear to be people here who are interested in creating additional music tracks... also, maybe it could be possible to change the music's pitch and/or tempo according to certain flags?

think about this: geoscape music changes to a slightly dramatic "alert"-type music when a UFO appears. you send an interceptor, and the music changes to a more "dramatic/battle" type of music. as your interceptor closes in on the UFO, its radar detects a second UFO - the music increases slightly in tempo (doesn't even have to be a noticeable difference... it will have a subliminal effect). if you happen to detect even more UFOs, each new one will increase the tempo even further... in heated air battles, this would probably increse the player's adrenaline levels without him/her ever noticing :)

the same would happen in the battlescape.

I would think of flags for these "situations":

geoscape:
- UFO detected (wait, does the music already change for that? I'm not sure and can't check right now)
- UFO shot down
- number of UFOs visible on the geoscape
- number of interceptors in the air
in dogfight:
- number of shots fired (?)
- amount of damage to participating interceptors
- amount of damage to UFO

battlescape:
- number of aliens visible in the battlescape
- number of soldiers wounded
- number of soldiers killed in this battle
- number of aliens killed in this battle
- number of soldiers with morale below certain threshold
- number of shots fired during turn (?)


I'm sure there's many more things that could influence the music... but do you think this could be possible at all, Warboy? How difficult would it be to include more music tracks? And would it be possible at all to change pitch and tempo according to "situations" as above?
Title: Re: Setting music to specific maps?
Post by: hszp on February 11, 2014, 12:55:54 pm
Changing the tempo may sound like a good idea, however the SDL library which is used by OpenXcom does not let you mix the music to this extent.
Title: Re: Setting music to specific maps?
Post by: hszp on February 12, 2014, 11:37:55 am
I intend to make a patch to support the feature in the subject of this topic and a little more: choosing music depending on mission type + terrain type
An example of the ruleset I'm aiming at:
Code: [Select]
- type: GMTACTIC_CRASHSITE_COLD.ogg
  overrides: CRASHSITE
  terrain:
    0: POLAR
    1: MOUNT
- type: GMGEO_REPLACEMENT.ogg
  overrides: GMGEO1
- type: GMGEO_ADDITIONAL.ogg
  extends: GMGEO

This would
1. define a specific music file for arctic and mountain missions.
2. override one of the geoscape tracks
3. add an additional geoscape tracks

I may decide to simplify it further. I would not want to make it any more complex as this will be my first shot at contributing code to OpenXcom.
Title: Re: Setting music to specific maps?
Post by: Mr. Quiet on February 12, 2014, 09:52:28 pm
Thank you so much hszp! I have another suggestion that will be more specific, but I'm asking for too much. I'm happy with this ;)

Thank you!
Title: Re: Setting music to specific maps?
Post by: hszp on February 14, 2014, 05:19:37 pm
I've managed to compile and do some modifications, overriding the built-in tracks 1:1 is possible in this branch, but not depending on terrain type:
https://github.com/szabopeter/OpenXcom/tree/MusicRuleset
Title: Re: Setting music to specific maps?
Post by: hszp on March 04, 2014, 10:01:19 am
I had some second thoughts on this topic. Now I want to move the basic music definitions to the rulesets not just hack in the additional music files.
So a part of Xcom1Ruleset.rul will look something like
Code: [Select]
music:
  - type: GMDEFEND
    midipack: 3
  - type: GMENBASE
    midipack: 6
  - type: GMGEO
    files:
      GMGEO1: 0
      GMGEO2: 18
      GMGEO3
      GMGEO4
  - type: GMINTER
    midipack: 2
  - type: GMINTRO1
    midipack: 19
  - type: GMINTRO2
    midipack: 20
  - type: GMINTRO3
    midipack: 21
  - type: GMLOSE
    midipack: 10
  - type: GMMARS
    midipack: 9
  - type: GMNEWMAR
    midipack: 8
  - type: GMSTORY
    midipack: 12
  - type: GMTACTIC
    terrain: [CULTA, DESERT, FOREST, JUNGLE, MOUNT, POLAR]
    files:
      - GMTACTIC: 17
      - GMTACTIC2
  - type: GMWIN
    midipack: 11

And a mod could have something like this in its ruleset:
Code: [Select]
music:
  - type: GMTACTIC
    mode: replace
    terrain: [FOREST, JUNGLE]
    files:
      - WILDFIRE
  - type: GMTACTIC
    mode: extend
    terrain: [DESERT]
    files:
      - DUSTBITE

This way you could either replace or just extend the list from which the engine randomly chooses a track.
Title: Re: Setting music to specific maps?
Post by: Solarius Scorch on March 04, 2014, 03:57:30 pm
I would absolutely love this. :)
Title: Re: Setting music to specific maps?
Post by: hszp on March 09, 2014, 09:30:44 am
Well, there have been a few minor changes in the end as to how the ruleset looks like, but the idea has been 'materialized' into code in the end: https://github.com/szabopeter/OpenXcom/tree/MusicRules
What I plan to do before submitting the pull request:
Title: Re: Setting music to specific maps?
Post by: hszp on March 09, 2014, 06:17:30 pm
Test data (Music files from https://lorcan.freelanzer.com/)
Code: [Select]
# Lorcán - Cydonia's Fall OST
music:
  - type: GMDEFEND
    files: [ UFOCF-OST/Defend Base - Lorcan ]
  - type: GMENBASE
    files: [ UFOCF-OST/Lightning War - Lorcan ]
  - type: GMGEO1
    files: [ UFOCF-OST/Geoscape (Part I) - Lorcan ]
  - type: GMGEO
    files:
      - UFOCF-OST/Geoscape (Part I) - Lorcan
      - UFOCF-OST/Geoscape (Part II) - Lorcan
      - UFOCF-OST/UFOpedia - Lorcan
      - UFOCF-OST/Waiting - Lorcan
  - type: GMINTER
    files: [ UFOCF-OST/Interception - Lorcan ]
  - type: GMINTRO1
    files: [ UFOCF-OST/Intro (Part I) - Lorcan ]
  - type: GMINTRO2
    files: [ UFOCF-OST/Intro (Part II) - Lorcan ]
  - type: GMINTRO3
    files: [ UFOCF-OST/Intro (Part III) - Lorcan ]
  - type: GMLOSE
    files: [ UFOCF-OST/Lose Game - Lorcan ]
  - type: GMMARS
    files: [ UFOCF-OST/Debriefing - Lorcan ]
  - type: GMNEWMAR
    files: [ UFOCF-OST/Mars Briefing - Lorcan ]
  - type: GMSTORY
    files: [ UFOCF-OST/The Story - Lorcan ]
  - type: GMTACTIC
    terrain: [CULTA, DESERT, FOREST, JUNGLE, MOUNT, POLAR, UBASE, URBAN]
    files: [ UFOCF-OST/Tactical Battle - Lorcan ]
  - type: GMTACTIC
    terrain: [MARS, XBASE]
    files: [ UFOCF-OST/Far From Earth - Lorcan ]
  - type: GMWIN
    files: [ UFOCF-OST/Win Game - Lorcan ]
  - type: GMGRAVES
    files: [ UFOCF-OST/Nightbird Theme - Lorcan ]
Title: Re: Setting music to specific maps?
Post by: hszp on March 10, 2014, 03:36:18 pm
Here is the windows binary: https://bit.ly/1i0iOb8 (3.54MB)
Title: Re: Setting music to specific maps?
Post by: Fenyő on March 10, 2014, 09:33:52 pm
Nice job! :)

I assume all the file-items in the "files" part (in the ruleset file) are required to be exist in the file-system...
Title: Re: Setting music to specific maps?
Post by: hszp on March 10, 2014, 10:30:06 pm
Thanks, Fenyő!
Yes, the specified files are absolutely mandatory. If any of them are missing, you get a nice error message right after loading the rules. But if you override the standard rules, the original music files are not needed and not loaded.
Title: Re: Setting music to specific maps?
Post by: Solarius Scorch on April 27, 2014, 02:29:18 pm
Well, is there any chance that this feature is actually implemented?

I have so many ideas on what to do with this... :)
Title: Re: Setting music to specific maps?
Post by: hszp on April 28, 2014, 02:37:56 pm
It is implemented, there has also been a pull request (which I will have to update sometime), but it will probably not be merged any time soon.
Title: Re: Setting music to specific maps?
Post by: Solarius Scorch on April 28, 2014, 02:48:14 pm
It is implemented, there has also been a pull request (which I will have to update sometime), but it will probably not be merged any time soon.

Right of course, I meant merged. ;)

Seeing as the nightly build is updated several times a day, and that the new versions are actually useful, I don't really feel like experimenting with external exes. Especially if I have to compile them myself.