summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/latencyfilter.cc19
-rw-r--r--src/latencyfilter.h2
-rw-r--r--src/settings.h14
3 files changed, 14 insertions, 21 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)
diff --git a/src/latencyfilter.h b/src/latencyfilter.h
index a49dd47..8191276 100644
--- a/src/latencyfilter.h
+++ b/src/latencyfilter.h
@@ -44,6 +44,6 @@ public:
private:
Settings& settings;
Random& random;
- double latency_offset{0.0};
+ float latency_offset{0.0};
std::size_t latency_last_pos{0};
};
diff --git a/src/settings.h b/src/settings.h
index 6b4048c..f37a810 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -111,13 +111,13 @@ struct Settings
static float constexpr latency_laid_back_ms_default = 0.0f;
Atomic<float> latency_laid_back_ms{latency_laid_back_ms_default};
- //! 0 := Robot
- //! 100 := Good drummer
- //! 200 := Decent drummer
- //! 300 := Decent drummer on a bad day
- //! 400 := Bad drummer
- //! 500 := Bad and drunk drummer
- static float constexpr latency_stddev_default = 100.0f;
+ //! 0.0 := Robot
+ //! 2.0 := Good drummer
+ //! 4.0 := Decent drummer
+ //! 6.0 := Decent drummer on a bad day
+ //! 8.0 := Bad drummer
+ //! 10.0 := Bad and drunk drummer
+ static float constexpr latency_stddev_default = 2.0f;
Atomic<float> latency_stddev{latency_stddev_default};
//! Regain on-beat position.