mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-11 14:01:49 +00:00
add audio.recording-enabled setting
This commit is contained in:
parent
c4bddba6b7
commit
eb453d8170
9 changed files with 71 additions and 37 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
function create_setting(id, name, step, postfix)
|
function create_trackbar_setting(id, name, step, postfix)
|
||||||
local info = app.get_setting_info(id)
|
local info = app.get_setting_info(id)
|
||||||
postfix = postfix or ""
|
postfix = postfix or ""
|
||||||
document.root:add(gui.template("track_setting", {
|
document.root:add(gui.template("track_setting", {
|
||||||
|
|
@ -10,10 +10,10 @@ function create_setting(id, name, step, postfix)
|
||||||
step=step,
|
step=step,
|
||||||
postfix=postfix
|
postfix=postfix
|
||||||
}))
|
}))
|
||||||
update_setting(app.get_setting(id), id, name, postfix)
|
update_trackbar_label(app.get_setting(id), id, name, postfix)
|
||||||
end
|
end
|
||||||
|
|
||||||
function update_setting(x, id, name, postfix)
|
function update_trackbar_label(x, id, name, postfix)
|
||||||
app.set_setting(id, x)
|
app.set_setting(id, x)
|
||||||
-- updating label
|
-- updating label
|
||||||
document[id..".L"].text = string.format(
|
document[id..".L"].text = string.format(
|
||||||
|
|
@ -24,12 +24,22 @@ function update_setting(x, id, name, postfix)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function update_checkbox_setting(id, value)
|
||||||
|
app.set_setting(id, value)
|
||||||
|
|
||||||
|
local recording_enabled = app.get_setting("audio.recording-enabled")
|
||||||
|
document.input_device_select.enabled = recording_enabled
|
||||||
|
document.input_volume_inner.enabled = recording_enabled
|
||||||
|
document.input_volume_outer.enabled = recording_enabled
|
||||||
|
end
|
||||||
|
|
||||||
function create_checkbox(id, name, tooltip)
|
function create_checkbox(id, name, tooltip)
|
||||||
tooltip = tooltip or ''
|
tooltip = tooltip or ''
|
||||||
document.root:add(string.format(
|
document.root:add(string.format(
|
||||||
"<checkbox consumer='function(x) app.set_setting(\"%s\", x) end' checked='%s' tooltip='%s'>%s</checkbox>",
|
"<checkbox consumer='function(x) update_checkbox_setting(\"%s\", x) end' checked='%s' tooltip='%s'>%s</checkbox>",
|
||||||
id, app.str_setting(id), gui.str(tooltip, "settings"), gui.str(name, "settings")
|
id, app.str_setting(id), gui.str(tooltip, "settings"), gui.str(name, "settings")
|
||||||
))
|
))
|
||||||
|
update_checkbox_setting(id, app.get_setting(id))
|
||||||
end
|
end
|
||||||
|
|
||||||
local initialized = false
|
local initialized = false
|
||||||
|
|
@ -55,11 +65,12 @@ function on_open()
|
||||||
prev_amplitude = amplitude
|
prev_amplitude = amplitude
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
create_setting("audio.volume-master", "Master Volume", 0.01)
|
create_trackbar_setting("audio.volume-master", "Master Volume", 0.01)
|
||||||
create_setting("audio.volume-regular", "Regular Sounds", 0.01)
|
create_trackbar_setting("audio.volume-regular", "Regular Sounds", 0.01)
|
||||||
create_setting("audio.volume-ui", "UI Sounds", 0.01)
|
create_trackbar_setting("audio.volume-ui", "UI Sounds", 0.01)
|
||||||
create_setting("audio.volume-ambient", "Ambient", 0.01)
|
create_trackbar_setting("audio.volume-ambient", "Ambient", 0.01)
|
||||||
create_setting("audio.volume-music", "Music", 0.01)
|
create_trackbar_setting("audio.volume-music", "Music", 0.01)
|
||||||
|
|
||||||
document.root:add("<label context='settings'>@Microphone</label>")
|
document.root:add("<label context='settings'>@Microphone</label>")
|
||||||
document.root:add("<select id='input_device_select' "..
|
document.root:add("<select id='input_device_select' "..
|
||||||
"onselect='function(opt) app.set_setting(\"audio.input-device\", opt) end'/>")
|
"onselect='function(opt) app.set_setting(\"audio.input-device\", opt) end'/>")
|
||||||
|
|
@ -67,9 +78,7 @@ function on_open()
|
||||||
.."<container id='input_volume_inner' color='#00FF00FF' pos='1' size='2'/>"
|
.."<container id='input_volume_inner' color='#00FF00FF' pos='1' size='2'/>"
|
||||||
.."</container>")
|
.."</container>")
|
||||||
local selectbox = document.input_device_select
|
local selectbox = document.input_device_select
|
||||||
local devices = {
|
local devices = {}
|
||||||
{value="none", text=gui.str("None", "settings.microphone")},
|
|
||||||
}
|
|
||||||
local names = audio.__get_input_devices_names()
|
local names = audio.__get_input_devices_names()
|
||||||
for i, name in ipairs(names) do
|
for i, name in ipairs(names) do
|
||||||
table.insert(devices, {value=name, text=name})
|
table.insert(devices, {value=name, text=name})
|
||||||
|
|
@ -78,7 +87,10 @@ function on_open()
|
||||||
local info = audio.input.get_input_info()
|
local info = audio.input.get_input_info()
|
||||||
if info then
|
if info then
|
||||||
selectbox.value = info.device_specifier
|
selectbox.value = info.device_specifier
|
||||||
|
else
|
||||||
|
selectbox.value = app.get_setting("audio.input-device")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_checkbox("audio.recording-enabled", "Enable microphone", "audio.recording-enabled.tooltip")
|
||||||
create_checkbox("audio.acoustic-effects", "Acoustic effects", "audio.acoustic-effects.tooltip")
|
create_checkbox("audio.acoustic-effects", "Acoustic effects", "audio.acoustic-effects.tooltip")
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ tostring_overrides["display.framerate"] = function(x)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function create_setting(id, name, step, postfix, tooltip, changeonrelease)
|
function create_trackbar_setting(id, name, step, postfix, tooltip, changeonrelease)
|
||||||
local info = app.get_setting_info(id)
|
local info = app.get_setting_info(id)
|
||||||
postfix = postfix or ""
|
postfix = postfix or ""
|
||||||
tooltip = tooltip or ""
|
tooltip = tooltip or ""
|
||||||
|
|
@ -25,10 +25,10 @@ function create_setting(id, name, step, postfix, tooltip, changeonrelease)
|
||||||
tooltip=tooltip,
|
tooltip=tooltip,
|
||||||
changeonrelease=changeonrelease
|
changeonrelease=changeonrelease
|
||||||
}))
|
}))
|
||||||
update_setting(app.get_setting(id), id, name, postfix)
|
update_trackbar_label(app.get_setting(id), id, name, postfix)
|
||||||
end
|
end
|
||||||
|
|
||||||
function update_setting(x, id, name, postfix)
|
function update_trackbar_label(x, id, name, postfix)
|
||||||
local str
|
local str
|
||||||
local func = tostring_overrides[id]
|
local func = tostring_overrides[id]
|
||||||
if func then
|
if func then
|
||||||
|
|
@ -55,8 +55,8 @@ end
|
||||||
|
|
||||||
|
|
||||||
function on_open()
|
function on_open()
|
||||||
create_setting("camera.fov", "FOV", 1, "°")
|
create_trackbar_setting("camera.fov", "FOV", 1, "°")
|
||||||
create_setting("display.framerate", "Framerate", 1, "", "", true)
|
create_trackbar_setting("display.framerate", "Framerate", 1, "", "", true)
|
||||||
|
|
||||||
document.root:add(string.format(
|
document.root:add(string.format(
|
||||||
"<select context='settings' onselect='function(opt) app.set_setting(\"display.window-mode\", tonumber(opt)) end' selected='%s'>"..
|
"<select context='settings' onselect='function(opt) app.set_setting(\"display.window-mode\", tonumber(opt)) end' selected='%s'>"..
|
||||||
|
|
@ -70,5 +70,5 @@ function on_open()
|
||||||
create_checkbox("camera.inertia", "Camera Inertia")
|
create_checkbox("camera.inertia", "Camera Inertia")
|
||||||
create_checkbox("camera.fov-effects", "Camera FOV Effects")
|
create_checkbox("camera.fov-effects", "Camera FOV Effects")
|
||||||
create_checkbox("display.limit-fps-iconified", "Limit Background FPS")
|
create_checkbox("display.limit-fps-iconified", "Limit Background FPS")
|
||||||
create_setting("graphics.gamma", "Gamma", 0.05, "", "graphics.gamma.tooltip")
|
create_trackbar_setting("graphics.gamma", "Gamma", 0.05, "", "graphics.gamma.tooltip")
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
function create_setting(id, name, step, postfix, tooltip, changeonrelease)
|
function create_trackbar_setting(id, name, step, postfix, tooltip, changeonrelease)
|
||||||
local info = app.get_setting_info(id)
|
local info = app.get_setting_info(id)
|
||||||
postfix = postfix or ""
|
postfix = postfix or ""
|
||||||
tooltip = tooltip or ""
|
tooltip = tooltip or ""
|
||||||
|
|
@ -14,10 +14,10 @@ function create_setting(id, name, step, postfix, tooltip, changeonrelease)
|
||||||
tooltip=tooltip,
|
tooltip=tooltip,
|
||||||
changeonrelease=changeonrelease
|
changeonrelease=changeonrelease
|
||||||
}))
|
}))
|
||||||
update_setting(app.get_setting(id), id, name, postfix)
|
update_trackbar_label(app.get_setting(id), id, name, postfix)
|
||||||
end
|
end
|
||||||
|
|
||||||
function update_setting(x, id, name, postfix)
|
function update_trackbar_label(x, id, name, postfix)
|
||||||
-- updating label
|
-- updating label
|
||||||
document[id..".L"].text = string.format(
|
document[id..".L"].text = string.format(
|
||||||
"%s: %s%s",
|
"%s: %s%s",
|
||||||
|
|
@ -36,15 +36,15 @@ function create_checkbox(id, name, tooltip)
|
||||||
end
|
end
|
||||||
|
|
||||||
function on_open()
|
function on_open()
|
||||||
create_setting("chunks.load-distance", "Load Distance", 1)
|
create_trackbar_setting("chunks.load-distance", "Load Distance", 1)
|
||||||
create_setting("chunks.load-speed", "Load Speed", 1)
|
create_trackbar_setting("chunks.load-speed", "Load Speed", 1)
|
||||||
create_setting("graphics.fog-curve", "Fog Curve", 0.1)
|
create_trackbar_setting("graphics.fog-curve", "Fog Curve", 0.1)
|
||||||
|
|
||||||
create_checkbox("graphics.backlight", "Backlight", "graphics.backlight.tooltip")
|
create_checkbox("graphics.backlight", "Backlight", "graphics.backlight.tooltip")
|
||||||
create_checkbox("graphics.soft-lighting", "Soft lighting", "graphics.soft-lighting.tooltip")
|
create_checkbox("graphics.soft-lighting", "Soft lighting", "graphics.soft-lighting.tooltip")
|
||||||
create_checkbox("graphics.dense-render", "Dense blocks render", "graphics.dense-render.tooltip")
|
create_checkbox("graphics.dense-render", "Dense blocks render", "graphics.dense-render.tooltip")
|
||||||
create_checkbox("graphics.advanced-render", "Advanced render", "graphics.advanced-render.tooltip")
|
create_checkbox("graphics.advanced-render", "Advanced render", "graphics.advanced-render.tooltip")
|
||||||
create_setting("graphics.ssao", "SSAO", 1, "", "graphics.ssao.tooltip")
|
create_trackbar_setting("graphics.ssao", "SSAO", 1, "", "graphics.ssao.tooltip")
|
||||||
create_setting("graphics.shadows-quality", "Shadows quality", 1)
|
create_trackbar_setting("graphics.shadows-quality", "Shadows quality", 1)
|
||||||
create_setting("graphics.clouds-quality", "Clouds quality", 1)
|
create_trackbar_setting("graphics.clouds-quality", "Clouds quality", 1)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,5 @@
|
||||||
<trackbar
|
<trackbar
|
||||||
value='%{value}' min='%{min}' max='%{max}' step='%{step}' tooltip='%{tooltip}'
|
value='%{value}' min='%{min}' max='%{max}' step='%{step}' tooltip='%{tooltip}'
|
||||||
consumer='function(x) app.set_setting("%{id}", x) end' change-on-release='%{changeonrelease}'
|
consumer='function(x) app.set_setting("%{id}", x) end' change-on-release='%{changeonrelease}'
|
||||||
sub-consumer='function(x) update_setting(x, "%{id}", "%{name}", "%{postfix}") end'/>
|
sub-consumer='function(x) update_trackbar_label(x, "%{id}", "%{name}", "%{postfix}") end'/>
|
||||||
</panel>
|
</panel>
|
||||||
|
|
|
||||||
|
|
@ -190,18 +190,34 @@ void audio::initialize(
|
||||||
audio::get_channel(channel.name)->setVolume(value * value);
|
audio::get_channel(channel.name)->setVolume(value * value);
|
||||||
}, true));
|
}, true));
|
||||||
}
|
}
|
||||||
objects_keeper.keepAlive(settings.acousticEffects.observe([=](auto value) {
|
objects_keeper.keepAlive(settings.acousticEffects.observe([=](bool value) {
|
||||||
if (value) return;
|
if (value) return;
|
||||||
backend->setAcoustics(audio::Acoustics {});
|
backend->setAcoustics(audio::Acoustics {});
|
||||||
}, true));
|
}, true));
|
||||||
|
|
||||||
if (inputEnabled) {
|
::input_enabled = inputEnabled;
|
||||||
::input_device = backend->openInputDevice("", 44100, 1, 16);
|
|
||||||
::input_enabled = true;
|
objects_keeper.keepAlive(settings.recordingEnabled.observe([&settings](bool enabled) {
|
||||||
}
|
if (!::input_enabled) {
|
||||||
if (::input_device) {
|
return;
|
||||||
::input_device->startCapture();
|
}
|
||||||
}
|
if (!enabled && ::input_device == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (enabled) {
|
||||||
|
logger.info() << "recording enabled; input device is "
|
||||||
|
<< settings.inputDevice.get();
|
||||||
|
::input_device = backend->openInputDevice(
|
||||||
|
settings.inputDevice.get(), 44100, 1, 16
|
||||||
|
);
|
||||||
|
::input_device->startCapture();
|
||||||
|
} else {
|
||||||
|
if (::input_device) {
|
||||||
|
::input_device->stopCapture();
|
||||||
|
}
|
||||||
|
::input_device = nullptr;
|
||||||
|
}
|
||||||
|
}, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
InputDevice* audio::get_input_device() {
|
InputDevice* audio::get_input_device() {
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ void Engine::initialize(CoreParameters coreParameters) {
|
||||||
|
|
||||||
keepAlive(settings.audio.inputDevice.observe([](auto name) {
|
keepAlive(settings.audio.inputDevice.observe([](auto name) {
|
||||||
audio::set_input_device(name == "auto" ? "" : name);
|
audio::set_input_device(name == "auto" ? "" : name);
|
||||||
}, true));
|
}));
|
||||||
|
|
||||||
project->loadProjectStartScript();
|
project->loadProjectStartScript();
|
||||||
if (!params.headless) {
|
if (!params.headless) {
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,10 @@ FullCheckBox::FullCheckBox(
|
||||||
|
|
||||||
add(checkbox);
|
add(checkbox);
|
||||||
|
|
||||||
|
auto& checkboxActions = actions;
|
||||||
label->setMargin(glm::vec4(5.f, 5.f, 0.f, 0.f));
|
label->setMargin(glm::vec4(5.f, 5.f, 0.f, 0.f));
|
||||||
|
label->listenAction(UIAction::CLICK, [&checkboxActions](auto& gui) {
|
||||||
|
checkboxActions.notify(UIAction::CLICK, gui);
|
||||||
|
});
|
||||||
add(label);
|
add(label);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ SettingsHandler::SettingsHandler(EngineSettings& settings) {
|
||||||
|
|
||||||
builder.addSection("audio");
|
builder.addSection("audio");
|
||||||
builder.add("enabled", &settings.audio.enabled, false);
|
builder.add("enabled", &settings.audio.enabled, false);
|
||||||
|
builder.add("recording-enabled", &settings.audio.recordingEnabled);
|
||||||
builder.add("volume-master", &settings.audio.volumeMaster);
|
builder.add("volume-master", &settings.audio.volumeMaster);
|
||||||
builder.add("volume-regular", &settings.audio.volumeRegular);
|
builder.add("volume-regular", &settings.audio.volumeRegular);
|
||||||
builder.add("volume-ui", &settings.audio.volumeUI);
|
builder.add("volume-ui", &settings.audio.volumeUI);
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
struct AudioSettings {
|
struct AudioSettings {
|
||||||
/// @brief try to initialize AL backend
|
/// @brief try to initialize AL backend
|
||||||
FlagSetting enabled {true};
|
FlagSetting enabled {true};
|
||||||
|
FlagSetting recordingEnabled {false};
|
||||||
|
|
||||||
NumberSetting volumeMaster {1.0f, 0.0f, 1.0f, setting_format::percent};
|
NumberSetting volumeMaster {1.0f, 0.0f, 1.0f, setting_format::percent};
|
||||||
NumberSetting volumeRegular {1.0f, 0.0f, 1.0f, setting_format::percent};
|
NumberSetting volumeRegular {1.0f, 0.0f, 1.0f, setting_format::percent};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue