From 6ba96e9a60428676fdf5cf6060e5d981ba1f3976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Nusser?= Date: Sat, 21 Jul 2018 14:35:36 +0200 Subject: Switch latency_stddev to be samplerate independent (and thus in ms). Visualization seems correct but I didn't verify the math. --- src/latencyfilter.cc | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'src/latencyfilter.cc') diff --git a/src/latencyfilter.cc b/src/latencyfilter.cc index abb67cd..9410b50 100644 --- a/src/latencyfilter.cc +++ b/src/latencyfilter.cc @@ -73,21 +73,14 @@ bool LatencyFilter::filter(event_t& event, std::size_t pos) latency_last_pos = pos; - float offset_min = latency * -1.0f; - float offset_max = latency * 1.0f; - - float mean = 0.0f;//latency_laid_back; - float stddev = latency_stddev; - - float offset = random.normalDistribution(mean, stddev); - - latency_offset += offset; - - if(latency_offset > offset_max) latency_offset = offset_max; - if(latency_offset < offset_min) latency_offset = offset_min; + float offset_min = -latency; + float offset_max = latency; + float offset_ms = random.normalDistribution(0.0f, latency_stddev); + latency_offset += getLatencySamples(offset_ms, samplerate); + latency_offset = std::max(offset_min, std::min(offset_max, latency_offset)); DEBUG(offset, "latency: %d, offset: %f, drift: %f", - (int)latency, offset, latency_offset); + (int)latency, offset_ms, latency_offset); event.offset += latency; // fixed latency offset event.offset += latency_laid_back; // laid back offset (user controlled) -- cgit v1.2.3