From 7dd8cab92e5e3300834d39b7f5f9f5547681cdc1 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 14 Jun 2018 22:32:23 +0200 Subject: Set latency_max in milliseconds instead of samples. --- src/latencyfilter.cc | 15 ++++++++++++--- src/settings.h | 6 +++--- 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'src') 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 +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 master_bleed{1.0f}; Atomic has_bleed_control{false}; - Atomic enable_latency_modifier{true}; + Atomic enable_latency_modifier{false}; - //! Maximum "early hits" introduces latency. In no. samples. - Atomic latency_max{10000u}; + //! Maximum "early hits" introduces latency in milliseconds. + Atomic latency_max{250u}; //! 0 := on-beat //! positive := laid back -- cgit v1.2.3