Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "indoor" and "night" fields for sound effects #55633

Merged
merged 3 commits into from
Mar 10, 2022

Conversation

dseguin
Copy link
Member

@dseguin dseguin commented Feb 24, 2022

Summary

None

Purpose of change

Fixes #55095.
Sort of a follow up to #52308.

Describe the solution

Adds the JSON fields "is_indoors" and "is_night" to sound_effect type objects:

{
  "type": "sound_effect",
  "id": "smash_success",
  "variant": "t_gates_mech_control_lab",
  "season": "winter",
  "is_indoors": true,
  "is_night": false,
  "volume": 50,
  "files": [
    "terrain/metal/smash_metal_1.ogg",
    "terrain/metal/smash_metal_2.ogg",
    "terrain/metal/smash_metal_3.ogg"
  ]
}

Using the field "is_indoors" will make it so that the sound only plays if the player is indoors (true) or outdoors (false). If the field is omitted, the sound plays whether the player is indoors or not.

Likewise for "is_night", except for nighttime (true) and daytime (false).


SFX search pattern optimization

Previously, each individual combination of sound parameters was queried individually. This meant that adding a new parameter effectively doubled the search space, growing exponentially. With just variant and season, the search space was ("the # of sound effects" x 4) + 1. Now that is_indoors and is_night are added, the search space would grow to x 16.

I refactored the search pattern to grow linearly with the number of parameters, which improves the worst case from O(2^n) to O(n). A benefit of the new pattern is that the search order no longer matters (ex: season can be queried before variant without changing the results).


Describe alternatives you've considered

I could have kept the original search pattern, but as explained above it just wasn't scalable.

Testing

Tested using the soundpack from Fris0uman's repository: https://github.com/Fris0uman/CDDA-Soundpacks

Additional context

TODO:

  • Add fields and integrate them with sound functions
  • Optimize search pattern
  • Testing
  • Documentation

@github-actions github-actions bot added json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Feb 24, 2022
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Feb 24, 2022
@Maleclypse Maleclypse added <Bugfix> This is a fix for a bug (or closes open issue) SDL: Tiles / Sound Tiles visual interface and sounds. Sound Events Sound events handling in the game labels Feb 24, 2022
@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` and removed SDL: Tiles / Sound Tiles visual interface and sounds. labels Mar 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` <Documentation> Design documents, internal info, guides and help. json-styled JSON lint passed, label assigned by github actions Sound Events Sound events handling in the game
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move Inside/outside and daytime/nighttime to a property of a sound instead of a dedicated sound
3 participants