mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 14:31:50 +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
|
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
|
local initialized = false
|
||||||
|
|
||||||
function on_open()
|
function on_open()
|
||||||
|
|
@ -71,4 +79,6 @@ function on_open()
|
||||||
if info then
|
if info then
|
||||||
selectbox.value = info.device_specifier
|
selectbox.value = info.device_specifier
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_checkbox("audio.acoustic-effects", "Acoustic effects", "audio.acoustic-effects.tooltip")
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -481,8 +481,16 @@ bool ALSpeaker::isManuallyStopped() const {
|
||||||
|
|
||||||
static bool alc_enumeration_ext = false;
|
static bool alc_enumeration_ext = false;
|
||||||
|
|
||||||
ALAudio::ALAudio(ALCdevice* device, ALCcontext* context, bool useEffects)
|
ALAudio::ALAudio(
|
||||||
: device(device), context(context), useEffects(useEffects) {
|
ALCdevice* device,
|
||||||
|
ALCcontext* context,
|
||||||
|
bool useEffects,
|
||||||
|
const AudioSettings& settings
|
||||||
|
)
|
||||||
|
: device(device),
|
||||||
|
context(context),
|
||||||
|
settings(settings),
|
||||||
|
useEffects(useEffects) {
|
||||||
ALCint size;
|
ALCint size;
|
||||||
alcGetIntegerv(device, ALC_ATTRIBUTES_SIZE, 1, &size);
|
alcGetIntegerv(device, ALC_ATTRIBUTES_SIZE, 1, &size);
|
||||||
std::vector<ALCint> attrs(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");
|
alc_enumeration_ext = alcIsExtensionPresent(nullptr, "ALC_ENUMERATION_EXT");
|
||||||
|
|
||||||
ALCdevice* device = alcOpenDevice(nullptr);
|
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() << "device supports " << sends << " aux sends per source";
|
||||||
|
|
||||||
logger.info() << "initialized";
|
logger.info() << "initialized";
|
||||||
return std::make_unique<ALAudio>(device, context, effects);
|
return std::make_unique<ALAudio>(device, context, effects, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint ALAudio::getFreeSource() {
|
uint ALAudio::getFreeSource() {
|
||||||
|
|
@ -787,6 +795,10 @@ void ALAudio::setAcoustics(Acoustics acoustics) {
|
||||||
if (!useEffects) {
|
if (!useEffects) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!settings.acousticEffects.get()) {
|
||||||
|
alAuxiliaryEffectSloti(effectSlots[0], AL_EFFECTSLOT_EFFECT, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
int reverbEffect = effects[REVERB_EFFECT];
|
int reverbEffect = effects[REVERB_EFFECT];
|
||||||
AL_CHECK(alEffectf(
|
AL_CHECK(alEffectf(
|
||||||
reverbEffect,
|
reverbEffect,
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@
|
||||||
#include <AL/alc.h>
|
#include <AL/alc.h>
|
||||||
#include <AL/alext.h>
|
#include <AL/alext.h>
|
||||||
|
|
||||||
|
struct AudioSettings;
|
||||||
|
|
||||||
namespace audio {
|
namespace audio {
|
||||||
struct ALBuffer;
|
struct ALBuffer;
|
||||||
class ALAudio;
|
class ALAudio;
|
||||||
|
|
@ -177,6 +179,8 @@ namespace audio {
|
||||||
uint maxSources = 256;
|
uint maxSources = 256;
|
||||||
uint maxEffectSlots = 64;
|
uint maxEffectSlots = 64;
|
||||||
|
|
||||||
|
const AudioSettings& settings;
|
||||||
|
|
||||||
bool initEffects();
|
bool initEffects();
|
||||||
public:
|
public:
|
||||||
std::vector<uint> effectSlots;
|
std::vector<uint> effectSlots;
|
||||||
|
|
@ -185,7 +189,12 @@ namespace audio {
|
||||||
|
|
||||||
bool useEffects;
|
bool useEffects;
|
||||||
|
|
||||||
ALAudio(ALCdevice* device, ALCcontext* context, bool effects);
|
ALAudio(
|
||||||
|
ALCdevice* device,
|
||||||
|
ALCcontext* context,
|
||||||
|
bool effects,
|
||||||
|
const AudioSettings& settings
|
||||||
|
);
|
||||||
~ALAudio();
|
~ALAudio();
|
||||||
|
|
||||||
uint getFreeSource();
|
uint getFreeSource();
|
||||||
|
|
@ -226,6 +235,6 @@ namespace audio {
|
||||||
return false;
|
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();
|
enabled = enabled && settings.enabled.get();
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
logger.info() << "initializing ALAudio backend";
|
logger.info() << "initializing ALAudio backend";
|
||||||
backend = ALAudio::create().release();
|
backend = ALAudio::create(settings).release();
|
||||||
}
|
}
|
||||||
if (backend == nullptr) {
|
if (backend == nullptr) {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ SettingsHandler::SettingsHandler(EngineSettings& settings) {
|
||||||
builder.add("volume-ambient", &settings.audio.volumeAmbient);
|
builder.add("volume-ambient", &settings.audio.volumeAmbient);
|
||||||
builder.add("volume-music", &settings.audio.volumeMusic);
|
builder.add("volume-music", &settings.audio.volumeMusic);
|
||||||
builder.add("input-device", &settings.audio.inputDevice);
|
builder.add("input-device", &settings.audio.inputDevice);
|
||||||
|
builder.add("acoustic-effects", &settings.audio.acousticEffects);
|
||||||
|
|
||||||
builder.addSection("display");
|
builder.addSection("display");
|
||||||
builder.add("width", &settings.display.width);
|
builder.add("width", &settings.display.width);
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ struct AudioSettings {
|
||||||
NumberSetting volumeMusic {1.0f, 0.0f, 1.0f, setting_format::percent};
|
NumberSetting volumeMusic {1.0f, 0.0f, 1.0f, setting_format::percent};
|
||||||
|
|
||||||
StringSetting inputDevice {"auto"};
|
StringSetting inputDevice {"auto"};
|
||||||
|
|
||||||
|
FlagSetting acousticEffects {true};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DisplaySettings {
|
struct DisplaySettings {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue