mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 03:21: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
|
|
@ -190,18 +190,34 @@ void audio::initialize(
|
|||
audio::get_channel(channel.name)->setVolume(value * value);
|
||||
}, true));
|
||||
}
|
||||
objects_keeper.keepAlive(settings.acousticEffects.observe([=](auto value) {
|
||||
objects_keeper.keepAlive(settings.acousticEffects.observe([=](bool value) {
|
||||
if (value) return;
|
||||
backend->setAcoustics(audio::Acoustics {});
|
||||
}, true));
|
||||
|
||||
if (inputEnabled) {
|
||||
::input_device = backend->openInputDevice("", 44100, 1, 16);
|
||||
::input_enabled = true;
|
||||
}
|
||||
if (::input_device) {
|
||||
::input_device->startCapture();
|
||||
}
|
||||
::input_enabled = inputEnabled;
|
||||
|
||||
objects_keeper.keepAlive(settings.recordingEnabled.observe([&settings](bool enabled) {
|
||||
if (!::input_enabled) {
|
||||
return;
|
||||
}
|
||||
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() {
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ void Engine::initialize(CoreParameters coreParameters) {
|
|||
|
||||
keepAlive(settings.audio.inputDevice.observe([](auto name) {
|
||||
audio::set_input_device(name == "auto" ? "" : name);
|
||||
}, true));
|
||||
}));
|
||||
|
||||
project->loadProjectStartScript();
|
||||
if (!params.headless) {
|
||||
|
|
|
|||
|
|
@ -57,6 +57,10 @@ FullCheckBox::FullCheckBox(
|
|||
|
||||
add(checkbox);
|
||||
|
||||
auto& checkboxActions = actions;
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ SettingsHandler::SettingsHandler(EngineSettings& settings) {
|
|||
|
||||
builder.addSection("audio");
|
||||
builder.add("enabled", &settings.audio.enabled, false);
|
||||
builder.add("recording-enabled", &settings.audio.recordingEnabled);
|
||||
builder.add("volume-master", &settings.audio.volumeMaster);
|
||||
builder.add("volume-regular", &settings.audio.volumeRegular);
|
||||
builder.add("volume-ui", &settings.audio.volumeUI);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
struct AudioSettings {
|
||||
/// @brief try to initialize AL backend
|
||||
FlagSetting enabled {true};
|
||||
FlagSetting recordingEnabled {false};
|
||||
|
||||
NumberSetting volumeMaster {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