diff options
author | André Nusser <andre.nusser@googlemail.com> | 2018-07-21 14:35:36 +0200 |
---|---|---|
committer | André Nusser <andre.nusser@googlemail.com> | 2018-07-21 14:35:36 +0200 |
commit | 6ba96e9a60428676fdf5cf6060e5d981ba1f3976 (patch) | |
tree | adade5a7befd072b42c9d1738bcfb1a702f7954f /src/latencyfilter.cc | |
parent | 94e8431f321a359743d0663f50d5e9a53155dd9d (diff) |
Switch latency_stddev to be samplerate independent (and thus in ms).
Visualization seems correct but I didn't verify the math.
Diffstat (limited to 'src/latencyfilter.cc')
-rw-r--r-- | src/latencyfilter.cc | 19 |
1 files changed, 6 insertions, 13 deletions
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) |