openrw icon indicating copy to clipboard operation
openrw copied to clipboard

EFX environment and reverb effect. Closes #697.

Open ArtemPopof opened this issue 6 years ago • 7 comments

Some classes to support EFX and realisation of a reverb. Closes https://github.com/rwengine/openrw/issues/697

ArtemPopof avatar Feb 16 '19 11:02 ArtemPopof

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.

ArtemPopof avatar Feb 16 '19 11:02 ArtemPopof

Codecov Report

Merging #702 into master will increase coverage by 0.10%. The diff coverage is 36.64%.

Impacted file tree graph

@@            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 data Powered by Codecov. Last update 9b4ebc1...960d1a1. Read the comment docs.

codecov[bot] avatar Feb 16 '19 11:02 codecov[bot]

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. ;)

ghost avatar Feb 16 '19 22:02 ghost

Suggested improvements look good to me.

ArtemPopof avatar Feb 18 '19 21:02 ArtemPopof

Do you need some help with changes? You can catch me on IRC. ;)

ghost avatar Feb 27 '19 20:02 ghost

Do you plan to continue work on this pull?

ghost avatar Mar 17 '19 23:03 ghost

Bump?

ghost avatar May 25 '19 12:05 ghost