aliens

Author Topic: Setting music to specific maps?  (Read 12461 times)

Offline Mr. Quiet

  • Commander
  • *****
  • Posts: 523
  • Likes: Quiet things. Dislikes: Loud things.
    • View Profile
    • =Open_X_Com= Mods
Setting music to specific maps?
« on: February 06, 2014, 03:13:26 am »
I just found this: 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.
« Last Edit: February 06, 2014, 11:31:38 pm by Mr. Quiet »

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11408
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: Setting music to specific maps?
« Reply #1 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.

Offline hszp

  • Captain
  • ***
  • Posts: 64
    • View Profile
    • szabopeter@github
Re: Setting music to specific maps?
« Reply #2 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.

Offline blackwolf

  • Colonel
  • ****
  • Posts: 156
  • im back...i guess
    • View Profile
Re: Setting music to specific maps?
« Reply #3 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

Offline Gifty

  • Colonel
  • ****
  • Posts: 138
    • View Profile
Re: Setting music to specific maps?
« Reply #4 on: February 07, 2014, 09:13:30 pm »
TFTD had this; how was it handled in that game?

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2159
    • View Profile
Re: Setting music to specific maps?
« Reply #5 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.

Offline Mr. Quiet

  • Commander
  • *****
  • Posts: 523
  • Likes: Quiet things. Dislikes: Loud things.
    • View Profile
    • =Open_X_Com= Mods
Re: Setting music to specific maps?
« Reply #6 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.

Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: Setting music to specific maps?
« Reply #7 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.

Offline hszp

  • Captain
  • ***
  • Posts: 64
    • View Profile
    • szabopeter@github
Re: Setting music to specific maps?
« Reply #8 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.

Offline moriarty

  • Commander
  • *****
  • Posts: 1421
    • View Profile
    • Luke's OX mod site
Re: Setting music to specific maps?
« Reply #9 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?

Offline hszp

  • Captain
  • ***
  • Posts: 64
    • View Profile
    • szabopeter@github
Re: Setting music to specific maps?
« Reply #10 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.

Offline hszp

  • Captain
  • ***
  • Posts: 64
    • View Profile
    • szabopeter@github
Re: Setting music to specific maps?
« Reply #11 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.

Offline Mr. Quiet

  • Commander
  • *****
  • Posts: 523
  • Likes: Quiet things. Dislikes: Loud things.
    • View Profile
    • =Open_X_Com= Mods
Re: Setting music to specific maps?
« Reply #12 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!

Offline hszp

  • Captain
  • ***
  • Posts: 64
    • View Profile
    • szabopeter@github
Re: Setting music to specific maps?
« Reply #13 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

Offline hszp

  • Captain
  • ***
  • Posts: 64
    • View Profile
    • szabopeter@github
Re: Setting music to specific maps?
« Reply #14 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.