From 260511a8a5f68e83c3bdfd7b28f5f235353da9cd Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 21 Oct 2017 18:27:18 +0200 Subject: Make latency controls more intuitive. --- src/latencyfilter.cc | 13 +++++++++---- src/settings.h | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/latencyfilter.cc b/src/latencyfilter.cc index 2f4bfe5..e1e9776 100644 --- a/src/latencyfilter.cc +++ b/src/latencyfilter.cc @@ -55,6 +55,10 @@ bool LatencyFilter::filter(event_t& event, std::size_t pos) // Assert latency_regain is within range [0; 1]. assert(latency_regain >= 0.0f && latency_regain <= 1.0f); + // User inputs 0 as no regain and 1 as instant - pow() is the other way around + latency_regain *= -1.0f; + latency_regain += 1.0f; + float duration = (pos - latency_last_pos) / samplerate; latency_offset *= pow(latency_regain, duration); @@ -63,8 +67,8 @@ bool LatencyFilter::filter(event_t& event, std::size_t pos) float offset_min = latency * -1.0f; float offset_max = latency * 1.0f; - float mean = latency_laid_back; - float stddev = latency_stddev; + float mean = 0.0f;//latency_laid_back; + float stddev = latency_stddev / 2.0f; float offset = random.normalDistribution(mean, stddev); @@ -76,8 +80,9 @@ bool LatencyFilter::filter(event_t& event, std::size_t pos) DEBUG(offset, "latency: %d, offset: %f, drift: %f", (int)latency, offset, latency_offset); - event.offset += latency; - event.offset += latency_offset;//(int)std::round(offset); + event.offset += latency; // fixed latency offset + event.offset += latency_laid_back; // laid back offset (user controlled) + event.offset += latency_offset; // current drift return true; } diff --git a/src/settings.h b/src/settings.h index b2fe3bb..2f3569f 100644 --- a/src/settings.h +++ b/src/settings.h @@ -94,7 +94,7 @@ struct Settings Atomic enable_latency_modifier{true}; //! Maximum "early hits" introduces latency. In no. samples. - Atomic latency_max{5000u}; + Atomic latency_max{10000u}; //! 0 := on-beat //! positive := laid back -- cgit v1.2.3