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)
follow-up: 2 comment:1 by , 12 years ago
comment:2 by , 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 , 12 years ago
Priority: | Must Have → Should Have |
---|
comment:4 by , 12 years ago
Milestone: | Alpha 8 → Alpha 9 |
---|
comment:5 by , 12 years ago
Milestone: | Alpha 9 → Alpha 10 |
---|
comment:6 by , 12 years ago
Milestone: | Alpha 10 → Alpha 11 |
---|
comment:7 by , 12 years ago
Milestone: | Alpha 11 |
---|---|
Priority: | Should Have → Must Have |
Resolution: | → duplicate |
Status: | new → closed |
Merged with #1223
comment:9 by , 12 years ago
Keywords: | music,sound → music sound |
---|---|
Milestone: | → Backlog |
Priority: | Must Have → Should Have |
Resolution: | duplicate |
Status: | closed → reopened |
Re-opening as a likely extension of the new sound system.
comment:10 by , 11 years ago
Cc: | added |
---|
comment:11 by , 11 years ago
Owner: | set to |
---|---|
Status: | reopened → new |
comment:12 by , 11 years ago
Milestone: | Backlog → Alpha 14 |
---|
comment:13 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
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.
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.)