Opened 12 years ago

Last modified 12 years ago

#1223 closed enhancement

New Sound System — at Version 1

Reported by: Kieran P Owned by:
Priority: Must Have Milestone: Alpha 11
Component: Core engine Keywords: patch
Cc: Patch:

Description (last modified by Kieran P)

We need a new sound system, that works on Windows, Linux and Mac. Optionally also works on Android systems, so design with cross-device in mind (wrappers, apis etc), but focus on the operating systems first before mobile platforms.

The new sound system needs support for music and sound clips, and should work on both the main menu and ingame. The same system should handle things like background music, button clicks, ambient noise etc.

The implementation should be 100% C++ object oriented, but should have JS interfaces so that GUI events can trigger sounds (like button presses).

Details

Terminology: 'stack' (collection of 'tracks' on a 'queue'), 'track' (object linked to the 'target' sound to be played)

The sound system should support multiple named stacks. A new track can be added to any named stack. Stacks are worked through concurrently (multi-threaded?), playing through their tracks in order of first priority, then the order the track was added to the queue.

A stack can be unlimited in size, or can have a limit. If a limit is set, when a new track is added and the limit of the stack is reached, the stack simply discards the track that was added. This prevent many async sounds piling up and running all at once (like 100 soldiers moving, which should not create a giant "KA-THUNK" when they move).

If a track has 'async' set to false, the stack waits until the tracks target finishes playing before popping the track off the queue and initiating the next track. If the track has 'async' set to true, the target starts playing, the stack pops the track right away, and moves onto the next track, without waiting for the previous one to finish.

TODO: Describe stack clearing, Describe fade between tracks, Describe gain adjustment on zooming, Describe gain adjustment on distance from center screen

Basic JSON representation

{
  "unit_actions": {
    "limit": 10,
    "tracks": [
      { "target": "chop.wav", "async": true },
      { "target": "mine.wav", "async": true },
      { "target": "chop.wav", "async": true },
      { "target": "chop.wav", "async": true },
      { "target": "mine.wav", "async": true }
    ]
  },
  "ambient_noise": {
    "limit": 20,
    "tracks": [
      { "target": "tree_falls.wav", "async": true },
      { "target": "fish_splash.wav", "async": true }
      { "target": "tree_falls.wav", "async": true },
      { "target": "tree_falls.wav", "async": true }
    ]
  },
  "music": {
    "limit": null,
    "tracks": [
      { "target": "peace1.wav", "async": false, "priority": 2 },  # this would play second
      { "target": "peace2.wav", "async": false, "priority": 2 },  # this would play third
      { "target": "war1.wav", "async": false, "priority": 1 }      # this would play first
    ]
  }
}

Change History (1)

comment:1 by Kieran P, 12 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.