test acoustics

This commit is contained in:
MihailRis 2026-01-05 23:46:00 +03:00
parent 3523816378
commit 72aba4d31d
8 changed files with 80 additions and 18 deletions

View file

@ -780,15 +780,18 @@ void ALAudio::setListener(
AL_CHECK(alListenerf(AL_GAIN, get_channel(0)->getVolume()));
}
void ALAudio::update(double delta) {
void ALAudio::update(double) {
}
void ALAudio::setAcoustics(Acoustics acoustics) {
if (!useEffects) {
return;
}
int reverbEffect = effects[REVERB_EFFECT];
AL_CHECK(alEffectf(reverbEffect, AL_REVERB_DECAY_TIME, 1.0f));
AL_CHECK(alEffectf(reverbEffect, AL_REVERB_ROOM_ROLLOFF_FACTOR, 0.07f));
AL_CHECK(alEffectf(reverbEffect, AL_REVERB_GAIN, 0.0f));
AL_CHECK(alEffectf(reverbEffect, AL_REVERB_GAINHF, 0.0f));
AL_CHECK(alEffectf(reverbEffect, AL_REVERB_REFLECTIONS_GAIN, 0.0f));
AL_CHECK(alEffectf(reverbEffect, AL_REVERB_DECAY_TIME, std::max<float>(0.1f, acoustics.reverbDecayTime)));
AL_CHECK(alEffectf(reverbEffect, AL_REVERB_ROOM_ROLLOFF_FACTOR, 0.14f));
// AL_CHECK(alEffectf(reverbEffect, AL_REVERB_GAIN, 0.0f));
// AL_CHECK(alEffectf(reverbEffect, AL_REVERB_GAINHF, 0.0f));
AL_CHECK(alEffectf(reverbEffect, AL_REVERB_REFLECTIONS_GAIN, 0.5f));
alAuxiliaryEffectSloti(effectSlots[0], AL_EFFECTSLOT_EFFECT, reverbEffect);
}

View file

@ -226,6 +226,8 @@ namespace audio {
void update(double delta) override;
void setAcoustics(Acoustics acoustics) override;
bool isDummy() const override {
return false;
}

View file

@ -104,6 +104,9 @@ namespace audio {
void update(double delta) override {
}
void setAcoustics(Acoustics) override {
}
bool isDummy() const override {
return true;
}

View file

@ -496,6 +496,10 @@ void audio::update(double delta) {
}
}
void audio::set_acoustics(Acoustics acoustics) {
backend->setAcoustics(std::move(acoustics));
}
void audio::reset_channel(int index) {
auto channel = get_channel(index);
if (channel == nullptr) {

View file

@ -7,6 +7,7 @@
#include "typedefs.hpp"
#include "settings.hpp"
#include "io/fwd.hpp"
#include "effects.hpp"
namespace audio {
/// @brief playing speaker uid
@ -394,6 +395,7 @@ namespace audio {
virtual std::vector<std::string> getInputDeviceNames() = 0;
virtual std::vector<std::string> getOutputDeviceNames() = 0;
virtual void update(double delta) = 0;
virtual void setAcoustics(Acoustics acoustics) = 0;
/// @brief Check if backend is an abstraction that does not internally
/// work with actual audio data or play anything
@ -580,6 +582,8 @@ namespace audio {
/// @param delta time elapsed since the last update (seconds)
void update(double delta);
void set_acoustics(Acoustics acoustics);
/// @brief Stop all playing audio in channel, reset channel state
void reset_channel(int channel);

View file

@ -26,4 +26,8 @@ namespace audio {
protected:
const Effect* effect = nullptr;
};
struct Acoustics {
float reverbDecayTime;
};
}