mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-09 04:50:14 +02:00
Allow changing the event loop tick rate
This also changes the refresh rate for most plugins. You can now lower this setting if your computer is struggling to keep up with rendering a certain heavy plugin.
This commit is contained in:
@@ -96,6 +96,12 @@ Configuration::Configuration(const fs::path& config_path,
|
||||
} else {
|
||||
invalid_options.push_back(key);
|
||||
}
|
||||
} else if (key == "frame_rate") {
|
||||
if (const auto parsed_value = value.as_floating_point()) {
|
||||
frame_rate = parsed_value->get();
|
||||
} else {
|
||||
invalid_options.push_back(key);
|
||||
}
|
||||
} else if (key == "group") {
|
||||
if (const auto parsed_value = value.as_string()) {
|
||||
group = parsed_value->get();
|
||||
@@ -110,3 +116,8 @@ Configuration::Configuration(const fs::path& config_path,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::chrono::steady_clock::duration Configuration::event_loop_interval() const {
|
||||
return std::chrono::duration_cast<std::chrono::steady_clock::duration>(
|
||||
std::chrono::milliseconds(1000) / frame_rate.value_or(60.0));
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <bitsery/ext/std_optional.h>
|
||||
#include <chrono>
|
||||
#include <optional>
|
||||
|
||||
#include "bitsery/ext/boost-path.h"
|
||||
@@ -109,6 +110,18 @@ class Configuration {
|
||||
*/
|
||||
bool editor_xembed = false;
|
||||
|
||||
/**
|
||||
* The number of times per second we'll handle the event loop. In most
|
||||
* plugins this also controls the plugin editor GUI's refresh rate.
|
||||
*
|
||||
* This defaults to 60 fps, but we'll store it in an optional as we only
|
||||
* want to show it in the startup message if this setting has explicitly
|
||||
* been set.
|
||||
*
|
||||
* @relates event_loop_interval
|
||||
*/
|
||||
std::optional<float> frame_rate;
|
||||
|
||||
/**
|
||||
* The name of the plugin group that should be used for the plugin this
|
||||
* configuration object was created for. If not set, then the plugin should
|
||||
@@ -139,13 +152,22 @@ class Configuration {
|
||||
*/
|
||||
std::vector<std::string> unknown_options;
|
||||
|
||||
/**
|
||||
* The delay in milliseconds between calls to the event loop and to
|
||||
* `effEditIdle` for VST2 plugins. This is based on `frame_rate`.
|
||||
*/
|
||||
std::chrono::steady_clock::duration event_loop_interval() const;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value1b(cache_time_info);
|
||||
s.value1b(editor_double_embed);
|
||||
s.value1b(editor_xembed);
|
||||
s.ext(frame_rate, bitsery::ext::StdOptional(),
|
||||
[](S& s, auto& v) { s.value4b(v); });
|
||||
s.ext(group, bitsery::ext::StdOptional(),
|
||||
[](S& s, auto& v) { s.text1b(v, 4096); });
|
||||
|
||||
s.ext(matched_file, bitsery::ext::StdOptional(),
|
||||
[](S& s, auto& v) { s.ext(v, bitsery::ext::BoostPath{}); });
|
||||
s.ext(matched_pattern, bitsery::ext::StdOptional(),
|
||||
|
||||
Reference in New Issue
Block a user