Opened 13 years ago

Closed 11 years ago

#961 closed enhancement (fixed)

Music Manager

Reported by: historic_bruno Owned by: stwf
Priority: Should Have Milestone: Alpha 14
Component: Core engine Keywords: music sound
Cc: Yves Patch:

Description

Currently the music code is a broken mess, full of hacks, and the GUI scripts are responsible for most of the logic. We need a music manager implemented in the engine, preferably with a worker thread so it's independent of the render loop. Maybe a reasonable level of abstraction is that of a simple media player:

  • Playlist/queue is created with track paths
  • Playlist can be played/stopped/paused
  • Fade when switching tracks
  • Play sequentially or randomly (default)
  • Optional looping
  • Gain setting

This task may require changes to snd_mgr as well, if it doesn't provide the functionality we need.

Change History (13)

comment:1 by Philip Taylor, 12 years ago

An alternative view on the level of abstraction:

The game will usually start by playing the menu music. Once you start a match, it goes to in-game music. Once you end a game, it goes to victory/defeat music, and after a while it probably goes back to the menu music.

The in-game music (and probably the victory/defeat music too) depends on what civ you are (or were) playing as. Some scenarios might want to force a certain type of music (maybe you're Celts invading Persia so it should play Persian music, or maybe it's a mod with some special music for its maps). Some might want to play a specific track at a specific point for a cinematic or some other special event, then go back to the default in-game music afterwards.

The in-game music also has to switch between peace and battle tracks. The simulation code can report e.g. the number of attacks within the past 1 second, and will probably have to detect large-scale battles (say, at least 10 attacks per second for 5 seconds involving troops belonging to you or an ally) for GUI notifications. Something needs to convert that high-frequency data into sensible music choices, e.g. don't switch back and forth every time the battle slows down for ten seconds because that'll irritate the player after a few cycles.

Should all of this logic be handled by GUI scripts explicitly computing playlists themselves? (I think probably not, since the music spans across multiple independent GUI pages so the GUI seems like the wrong place for any long-term music logic). Should it all be handled by the new music manager in C++? (Seems inflexible - generally better to avoid putting game-specific logic in C++). Maybe the music manager should have its own scripts just to implement its music-selection logic? (I don't really know.)

in reply to:  1 comment:2 by historic_bruno, 12 years ago

Replying to Philip:

Maybe the music manager should have its own scripts just to implement its music-selection logic? (I don't really know.)

That makes sense. Basically a music manager that is always running, unless music is disabled, and it simply responds to interesting events (GUI/simulation/whatever)? Sounds like slightly more effort to design, but worth it for the flexibility.

comment:3 by Kieran P, 12 years ago

Priority: Must HaveShould Have

comment:4 by historic_bruno, 12 years ago

Milestone: Alpha 8Alpha 9

comment:5 by Kieran P, 12 years ago

Milestone: Alpha 9Alpha 10

comment:6 by Kieran P, 12 years ago

Milestone: Alpha 10Alpha 11

comment:7 by Kieran P, 12 years ago

Milestone: Alpha 11
Priority: Should HaveMust Have
Resolution: duplicate
Status: newclosed

Merged with #1223

comment:8 by ben, 12 years ago

In 12428:

New sound system implementation by stwf, refs #1223, #961.
Enables audio on OS X, refs #685, #931.
Fixes music not playing after a game, refs #946.

comment:9 by historic_bruno, 12 years ago

Keywords: music,sound → music sound
Milestone: Backlog
Priority: Must HaveShould Have
Resolution: duplicate
Status: closedreopened

Re-opening as a likely extension of the new sound system.

comment:10 by Yves, 11 years ago

Cc: Yves added

comment:11 by stwf, 11 years ago

Owner: set to stwf
Status: reopenednew

comment:12 by stwf, 11 years ago

Milestone: BacklogAlpha 14

comment:13 by stwf, 11 years ago

Resolution: fixed
Status: newclosed

OK, a first draft of playlist functionality is included in r13368. The old code read a list of applicable songs and picked a random one to loop repeatedly. I added functionality to send the whole list and the sound manager will loop through the list repeatedly with a 15 second gap between songs. If people want I can add options to change the gap, add random play, etc.

Note: See TracTickets for help on using tickets.