mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
add 'audio.acoustic-effects' setting
This commit is contained in:
parent
cd537cc1cb
commit
d6bd5bd8fa
7 changed files with 42 additions and 8 deletions
|
|
@ -24,6 +24,14 @@ function update_setting(x, id, name, postfix)
|
|||
)
|
||||
end
|
||||
|
||||
function create_checkbox(id, name, tooltip)
|
||||
tooltip = tooltip or ''
|
||||
document.root:add(string.format(
|
||||
"<checkbox consumer='function(x) app.set_setting(\"%s\", x) end' checked='%s' tooltip='%s'>%s</checkbox>",
|
||||
id, app.str_setting(id), gui.str(tooltip, "settings"), gui.str(name, "settings")
|
||||
))
|
||||
end
|
||||
|
||||
local initialized = false
|
||||
|
||||
function on_open()
|
||||
|
|
@ -71,4 +79,6 @@ function on_open()
|
|||
if info then
|
||||
selectbox.value = info.device_specifier
|
||||
end
|
||||
|
||||
create_checkbox("audio.acoustic-effects", "Acoustic effects", "audio.acoustic-effects.tooltip")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ function on_open()
|
|||
create_setting("chunks.load-distance", "Load Distance", 1)
|
||||
create_setting("chunks.load-speed", "Load Speed", 1)
|
||||
create_setting("graphics.fog-curve", "Fog Curve", 0.1)
|
||||
|
||||
|
||||
create_checkbox("graphics.backlight", "Backlight", "graphics.backlight.tooltip")
|
||||
create_checkbox("graphics.soft-lighting", "Soft lighting", "graphics.soft-lighting.tooltip")
|
||||
create_checkbox("graphics.dense-render", "Dense blocks render", "graphics.dense-render.tooltip")
|
||||
|
|
|
|||
|
|
@ -481,8 +481,16 @@ bool ALSpeaker::isManuallyStopped() const {
|
|||
|
||||
static bool alc_enumeration_ext = false;
|
||||
|
||||
ALAudio::ALAudio(ALCdevice* device, ALCcontext* context, bool useEffects)
|
||||
: device(device), context(context), useEffects(useEffects) {
|
||||
ALAudio::ALAudio(
|
||||
ALCdevice* device,
|
||||
ALCcontext* context,
|
||||
bool useEffects,
|
||||
const AudioSettings& settings
|
||||
)
|
||||
: device(device),
|
||||
context(context),
|
||||
settings(settings),
|
||||
useEffects(useEffects) {
|
||||
ALCint size;
|
||||
alcGetIntegerv(device, ALC_ATTRIBUTES_SIZE, 1, &size);
|
||||
std::vector<ALCint> attrs(size);
|
||||
|
|
@ -693,7 +701,7 @@ std::unique_ptr<InputDevice> ALAudio::openInputDevice(
|
|||
);
|
||||
}
|
||||
|
||||
std::unique_ptr<ALAudio> ALAudio::create() {
|
||||
std::unique_ptr<ALAudio> ALAudio::create(const AudioSettings& settings) {
|
||||
alc_enumeration_ext = alcIsExtensionPresent(nullptr, "ALC_ENUMERATION_EXT");
|
||||
|
||||
ALCdevice* device = alcOpenDevice(nullptr);
|
||||
|
|
@ -722,7 +730,7 @@ std::unique_ptr<ALAudio> ALAudio::create() {
|
|||
logger.info() << "device supports " << sends << " aux sends per source";
|
||||
|
||||
logger.info() << "initialized";
|
||||
return std::make_unique<ALAudio>(device, context, effects);
|
||||
return std::make_unique<ALAudio>(device, context, effects, settings);
|
||||
}
|
||||
|
||||
uint ALAudio::getFreeSource() {
|
||||
|
|
@ -787,6 +795,10 @@ void ALAudio::setAcoustics(Acoustics acoustics) {
|
|||
if (!useEffects) {
|
||||
return;
|
||||
}
|
||||
if (!settings.acousticEffects.get()) {
|
||||
alAuxiliaryEffectSloti(effectSlots[0], AL_EFFECTSLOT_EFFECT, 0);
|
||||
return;
|
||||
}
|
||||
int reverbEffect = effects[REVERB_EFFECT];
|
||||
AL_CHECK(alEffectf(
|
||||
reverbEffect,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@
|
|||
#include <AL/alc.h>
|
||||
#include <AL/alext.h>
|
||||
|
||||
struct AudioSettings;
|
||||
|
||||
namespace audio {
|
||||
struct ALBuffer;
|
||||
class ALAudio;
|
||||
|
|
@ -177,6 +179,8 @@ namespace audio {
|
|||
uint maxSources = 256;
|
||||
uint maxEffectSlots = 64;
|
||||
|
||||
const AudioSettings& settings;
|
||||
|
||||
bool initEffects();
|
||||
public:
|
||||
std::vector<uint> effectSlots;
|
||||
|
|
@ -185,7 +189,12 @@ namespace audio {
|
|||
|
||||
bool useEffects;
|
||||
|
||||
ALAudio(ALCdevice* device, ALCcontext* context, bool effects);
|
||||
ALAudio(
|
||||
ALCdevice* device,
|
||||
ALCcontext* context,
|
||||
bool effects,
|
||||
const AudioSettings& settings
|
||||
);
|
||||
~ALAudio();
|
||||
|
||||
uint getFreeSource();
|
||||
|
|
@ -226,6 +235,6 @@ namespace audio {
|
|||
return false;
|
||||
}
|
||||
|
||||
static std::unique_ptr<ALAudio> create();
|
||||
static std::unique_ptr<ALAudio> create(const AudioSettings& settings);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ void audio::initialize(
|
|||
enabled = enabled && settings.enabled.get();
|
||||
if (enabled) {
|
||||
logger.info() << "initializing ALAudio backend";
|
||||
backend = ALAudio::create().release();
|
||||
backend = ALAudio::create(settings).release();
|
||||
}
|
||||
if (backend == nullptr) {
|
||||
if (enabled) {
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ SettingsHandler::SettingsHandler(EngineSettings& settings) {
|
|||
builder.add("volume-ambient", &settings.audio.volumeAmbient);
|
||||
builder.add("volume-music", &settings.audio.volumeMusic);
|
||||
builder.add("input-device", &settings.audio.inputDevice);
|
||||
builder.add("acoustic-effects", &settings.audio.acousticEffects);
|
||||
|
||||
builder.addSection("display");
|
||||
builder.add("width", &settings.display.width);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ struct AudioSettings {
|
|||
NumberSetting volumeMusic {1.0f, 0.0f, 1.0f, setting_format::percent};
|
||||
|
||||
StringSetting inputDevice {"auto"};
|
||||
|
||||
FlagSetting acousticEffects {true};
|
||||
};
|
||||
|
||||
struct DisplaySettings {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue