summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2018-07-18 16:46:13 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2018-07-18 16:46:13 +0200
commit04fc8205dc1cc471af9473162fdab48d0f39847b (patch)
tree9e8cd5c67928ae595d0c09e4f889d106626e18fa /src
parenta0484778a9953dfd1948bf4dac71c51deab18cab (diff)
Store and use laidback setting in milliseconds.
Diffstat (limited to 'src')
-rw-r--r--src/latencyfilter.cc7
-rw-r--r--src/settings.h23
2 files changed, 16 insertions, 14 deletions
diff --git a/src/latencyfilter.cc b/src/latencyfilter.cc
index 5cb6db2..abb67cd 100644
--- a/src/latencyfilter.cc
+++ b/src/latencyfilter.cc
@@ -47,9 +47,9 @@ static T1 getLatencySamples(T1 latency_ms, T2 samplerate)
bool LatencyFilter::filter(event_t& event, std::size_t pos)
{
auto enabled = settings.enable_latency_modifier.load();
- auto latency_ms = settings.latency_max.load();
+ auto latency_ms = settings.latency_max_ms.load();
auto samplerate = settings.samplerate.load();
- auto latency_laid_back = settings.latency_laid_back.load();
+ auto latency_laid_back_ms = settings.latency_laid_back_ms.load();
auto latency_stddev = settings.latency_stddev.load();
auto latency_regain = settings.latency_regain.load();
@@ -59,6 +59,7 @@ bool LatencyFilter::filter(event_t& event, std::size_t pos)
}
auto latency = getLatencySamples(latency_ms, samplerate);
+ auto latency_laid_back = getLatencySamples(latency_laid_back_ms, samplerate);
// Assert latency_regain is within range [0; 1].
assert(latency_regain >= 0.0f && latency_regain <= 1.0f);
@@ -102,7 +103,7 @@ std::size_t LatencyFilter::getLatency() const
bool enabled = settings.enable_latency_modifier.load();
if(enabled)
{
- auto latency_ms = settings.latency_max.load();
+ auto latency_ms = settings.latency_max_ms.load();
auto samplerate = settings.samplerate.load();
return getLatencySamples(latency_ms, samplerate);
}
diff --git a/src/settings.h b/src/settings.h
index b9d627a..6b4048c 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -102,13 +102,14 @@ struct Settings
Atomic<bool> enable_latency_modifier{false};
//! Maximum "early hits" introduces latency in milliseconds.
- Atomic<std::size_t> latency_max{100u};
+ Atomic<float> latency_max_ms{150.0f};
//! 0 := on-beat
//! positive := laid back
//! negative := up-beat
- static int constexpr latency_laid_back_default = 0;
- Atomic<int> latency_laid_back{latency_laid_back_default};
+ //! Same range is [-100; 100] ms
+ static float constexpr latency_laid_back_ms_default = 0.0f;
+ Atomic<float> latency_laid_back_ms{latency_laid_back_ms_default};
//! 0 := Robot
//! 100 := Good drummer
@@ -172,8 +173,8 @@ struct SettingsGetter
SettingRef<bool> has_bleed_control;
SettingRef<bool> enable_latency_modifier;
- SettingRef<std::size_t> latency_max;
- SettingRef<int> latency_laid_back;
+ SettingRef<float> latency_max_ms;
+ SettingRef<float> latency_laid_back_ms;
SettingRef<float> latency_stddev;
SettingRef<float> latency_regain;
SettingRef<int> latency_current;
@@ -210,8 +211,8 @@ struct SettingsGetter
, master_bleed{settings.master_bleed}
, has_bleed_control{settings.has_bleed_control}
, enable_latency_modifier{settings.enable_latency_modifier}
- , latency_max{settings.latency_max}
- , latency_laid_back{settings.latency_laid_back}
+ , latency_max_ms{settings.latency_max_ms}
+ , latency_laid_back_ms{settings.latency_laid_back_ms}
, latency_stddev{settings.latency_stddev}
, latency_regain{settings.latency_regain}
, latency_current{settings.latency_current}
@@ -263,8 +264,8 @@ public:
Notifier<bool> has_bleed_control;
Notifier<bool> enable_latency_modifier;
- Notifier<std::size_t> latency_max;
- Notifier<int> latency_laid_back;
+ Notifier<float> latency_max_ms;
+ Notifier<float> latency_laid_back_ms;
Notifier<float> latency_stddev;
Notifier<float> latency_regain;
Notifier<int> latency_current;
@@ -313,8 +314,8 @@ public:
EVAL(has_bleed_control);
EVAL(enable_latency_modifier);
- EVAL(latency_max);
- EVAL(latency_laid_back);
+ EVAL(latency_max_ms);
+ EVAL(latency_laid_back_ms);
EVAL(latency_stddev);
EVAL(latency_regain);
EVAL(latency_current);