diff options
author | André Nusser <andre.nusser@googlemail.com> | 2018-07-21 15:44:46 +0200 |
---|---|---|
committer | André Nusser <andre.nusser@googlemail.com> | 2018-07-21 15:44:46 +0200 |
commit | a7e14b2065b6f1ee07aac3c6b936d968abfbd42c (patch) | |
tree | 1d4e84c106878b75d082cb1d1ceb345a09adb725 /src/latencyfilter.cc | |
parent | 6ba96e9a60428676fdf5cf6060e5d981ba1f3976 (diff) |
Fix visualization to be samplerate independent.
Diffstat (limited to 'src/latencyfilter.cc')
-rw-r--r-- | src/latencyfilter.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/latencyfilter.cc b/src/latencyfilter.cc index 9410b50..0f3259b 100644 --- a/src/latencyfilter.cc +++ b/src/latencyfilter.cc @@ -44,6 +44,12 @@ static T1 getLatencySamples(T1 latency_ms, T2 samplerate) return latency_ms * samplerate / 1000.; } +template<typename T1, typename T2> +static T1 getLatencyMs(T1 latency_samples, T2 samplerate) +{ + return 1000. * latency_samples / samplerate; +} + bool LatencyFilter::filter(event_t& event, std::size_t pos) { auto enabled = settings.enable_latency_modifier.load(); @@ -86,7 +92,8 @@ bool LatencyFilter::filter(event_t& event, std::size_t pos) event.offset += latency_laid_back; // laid back offset (user controlled) event.offset += latency_offset; // current drift - settings.latency_current.store(latency_offset + latency_laid_back); + auto latency_current_ms = getLatencyMs(latency_offset + latency_laid_back, samplerate); + settings.latency_current.store(latency_current_ms); return true; } |