summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2018-06-14 22:32:23 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2018-06-14 22:32:23 +0200
commit7dd8cab92e5e3300834d39b7f5f9f5547681cdc1 (patch)
treeb0dda2acb0525f53d2d2b00ca421c6f879279bef /src
parent464aa94c70de2467797acb38b785e4cd2321655c (diff)
Set latency_max in milliseconds instead of samples.
Diffstat (limited to 'src')
-rw-r--r--src/latencyfilter.cc15
-rw-r--r--src/settings.h6
2 files changed, 15 insertions, 6 deletions
diff --git a/src/latencyfilter.cc b/src/latencyfilter.cc
index e2a4965..3bfa866 100644
--- a/src/latencyfilter.cc
+++ b/src/latencyfilter.cc
@@ -38,10 +38,16 @@ LatencyFilter::LatencyFilter(Settings& settings, Random& random)
{
}
+template<typename T1, typename T2>
+static T1 getLatencySamples(T1 latency_ms, T2 samplerate)
+{
+ return latency_ms * samplerate / 1000;
+}
+
bool LatencyFilter::filter(event_t& event, std::size_t pos)
{
auto enabled = settings.enable_latency_modifier.load();
- auto latency = settings.latency_max.load();
+ auto latency_ms = settings.latency_max.load();
auto samplerate = settings.samplerate.load();
auto latency_laid_back = settings.latency_laid_back.load();
auto latency_stddev = settings.latency_stddev.load();
@@ -52,6 +58,8 @@ bool LatencyFilter::filter(event_t& event, std::size_t pos)
return true;
}
+ auto latency = getLatencySamples(latency_ms, samplerate);
+
// Assert latency_regain is within range [0; 1].
assert(latency_regain >= 0.0f && latency_regain <= 1.0f);
@@ -90,10 +98,11 @@ bool LatencyFilter::filter(event_t& event, std::size_t pos)
std::size_t LatencyFilter::getLatency() const
{
bool enabled = settings.enable_latency_modifier.load();
- std::size_t max_latency = settings.latency_max.load();
if(enabled)
{
- return max_latency;
+ auto latency_ms = settings.latency_max.load();
+ auto samplerate = settings.samplerate.load();
+ return getLatencySamples(latency_ms, samplerate);
}
return 0u;
diff --git a/src/settings.h b/src/settings.h
index 65dbad3..f044bae 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -96,10 +96,10 @@ struct Settings
Atomic<float> master_bleed{1.0f};
Atomic<bool> has_bleed_control{false};
- Atomic<bool> enable_latency_modifier{true};
+ Atomic<bool> enable_latency_modifier{false};
- //! Maximum "early hits" introduces latency. In no. samples.
- Atomic<std::size_t> latency_max{10000u};
+ //! Maximum "early hits" introduces latency in milliseconds.
+ Atomic<std::size_t> latency_max{250u};
//! 0 := on-beat
//! positive := laid back