EFX environment and reverb effect. Closes #697.
Some classes to support EFX and realisation of a reverb. Closes https://github.com/rwengine/openrw/issues/697
It can be used like this:
// load random sound
size_t index = game->getWorld()->sound.createSfxInstance(555);
auto reverb = std::shared_ptr<SoundEffect>(new ReverbEffect);
auto slot = std::shared_ptr<EffectSlot>(new EffectSlot());
Sound& sound = game->getWorld()->sound.getSoundRef(index);
slot->attachEffect(reverb);
sound.attachToEffectSlot(slot);
game->getWorld()->sound.playSfx(index, {0.0f, 0.0f, 0.0f});
Multiple Sound instances can be attached to one effect slot. Effect slot can be binded to one effect.
Codecov Report
Merging #702 into master will increase coverage by
0.10%. The diff coverage is36.64%.
@@ Coverage Diff @@
## master #702 +/- ##
==========================================
+ Coverage 18.11% 18.22% +0.10%
==========================================
Files 247 253 +6
Lines 22633 22765 +132
Branches 5808 5824 +16
==========================================
+ Hits 4101 4149 +48
- Misses 17395 17478 +83
- Partials 1137 1138 +1
| Impacted Files | Coverage Δ | |
|---|---|---|
| rwengine/src/audio/EffectSlot.cpp | 0.00% <0.00%> (ø) |
|
| rwengine/src/audio/Sound.hpp | 0.00% <ø> (-25.00%) |
:arrow_down: |
| rwengine/src/audio/SoundBuffer.cpp | 44.61% <0.00%> (-4.54%) |
:arrow_down: |
| rwengine/src/audio/SoundEffect.hpp | 0.00% <0.00%> (ø) |
|
| rwengine/src/render/ObjectRenderer.cpp | 11.29% <0.00%> (ø) |
|
| rwgame/states/IngameState.cpp | 0.00% <ø> (ø) |
|
| rwengine/src/audio/ReverbEffect.cpp | 6.89% <6.89%> (ø) |
|
| rwengine/src/audio/Sound.cpp | 46.34% <44.44%> (-0.54%) |
:arrow_down: |
| rwengine/src/audio/SoundManager.cpp | 29.08% <57.89%> (+2.04%) |
:arrow_up: |
| rwengine/src/audio/SoundEffect.cpp | 73.33% <71.42%> (ø) |
|
| ... and 10 more |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 9b4ebc1...960d1a1. Read the comment docs.
I've kept possibility to manually operate on basic blocks Sound, SoundSource, SoundBuffer. It's useful to create simple tidy tests. But engine should use neat interface of SoundManager.
It (should) make usage of Sounds simpler and prevent code duplication.
So I think SoundEffect, EffectSlot should be squashed together. Instances of that class stored in vector (which is member of SoundManager).
So code would become something:
// Somewhere in header defined
enum class SoundEffectType {
None,
Reverb
};
// load random sound
size_t index = game->getWorld()->sound.createSfxInstance(555);
game->getWorld()->sound.playSfx(index, SoundEffectType::None, {0.0f, 0.0f, 0.0f}); // All logic are done behind
I look forward to your opinion about this idea. ;)
Suggested improvements look good to me.
Do you need some help with changes? You can catch me on IRC. ;)
Do you plan to continue work on this pull?
Bump?