summaryrefslogtreecommitdiff
path: root/src/latencyfilter.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2018-06-14 22:32:23 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2018-06-14 22:32:23 +0200
commit7dd8cab92e5e3300834d39b7f5f9f5547681cdc1 (patch)
treeb0dda2acb0525f53d2d2b00ca421c6f879279bef /src/latencyfilter.cc
parent464aa94c70de2467797acb38b785e4cd2321655c (diff)
Set latency_max in milliseconds instead of samples.
Diffstat (limited to 'src/latencyfilter.cc')
-rw-r--r--src/latencyfilter.cc15
1 files changed, 12 insertions, 3 deletions
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<typename T1, typename T2>
+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;