@@ -68,6 +68,21 @@ namespace lsl {
6868 cf_undefined = 0 // Can not be transmitted.
6969 };
7070
71+ /* *
72+ * Post-processing options for stream inlets.
73+ */
74+ enum processing_options_t {
75+ post_none = 0 , // No automatic post-processing; return the ground-truth time stamps for manual post-processing
76+ // (this is the default behavior of the inlet).
77+ post_clocksync = 1 , // Perform automatic clock synchronization; equivalent to manually adding the time_correction() value
78+ // to the received time stamps.
79+ post_dejitter = 2 , // Remove jitter from time stamps. This will apply a smoothing algorithm to the received time stamps;
80+ // the smoothing needs to see a minimum number of samples (30-120 seconds worst-case) until the remaining
81+ // jitter is consistently below 1ms.
82+ post_monotonize = 4 , // Force the time-stamps to be monotonically ascending (only makes sense if timestamps are dejittered).
83+ post_threadsafe = 8 , // Post-processing is thread-safe (same inlet can be read from by multiple threads); uses somewhat more CPU.
84+ post_ALL = 1 |2 |4 |8 // The combination of all possible post-processing options.
85+ };
7186
7287 /* *
7388 * Protocol version.
@@ -722,7 +737,7 @@ namespace lsl {
722737
723738 /* *
724739 * Retrieve an estimated time correction offset for the given stream.
725- * The first call to this function takes several miliseconds until a reliable first estimate is obtained.
740+ * The first call to this function takes several milliseconds until a reliable first estimate is obtained.
726741 * Subsequent calls are instantaneous (and rely on periodic background updates).
727742 * The precision of these estimates should be below 1 ms (empirically within +/-0.2 ms).
728743 * @timeout Timeout to acquire the first time-correction estimate (default: no timeout).
@@ -732,6 +747,15 @@ namespace lsl {
732747 */
733748 double time_correction (double timeout=FOREVER) { int ec=0 ; double res = lsl_time_correction (obj,timeout,&ec); check_error (ec); return res; }
734749
750+ /* *
751+ * Set post-processing flags to use. By default, the inlet performs NO post-processing and returns the
752+ * ground-truth time stamps, which can then be manually synchronized using time_correction(), and then
753+ * smoothed/dejittered if desired. This function allows automating these two and possibly more operations.
754+ * Warning: when you enable this, you will no longer receive or be able to recover the original time stamps.
755+ * @param flags An integer that is the result of bitwise OR'ing one or more options from processing_options_t
756+ * together (e.g., post_clocksync|post_dejitter); the default is to enable all options.
757+ */
758+ void set_postprocessing (unsigned flags=post_ALL) { check_error (lsl_set_postprocessing (obj,flags)); }
735759
736760 // =======================================
737761 // === Pulling a sample from the inlet ===
@@ -986,6 +1010,16 @@ namespace lsl {
9861010 * hot-swapped or restarted in between two measurements.
9871011 */
9881012 bool was_clock_reset () { return lsl_was_clock_reset (obj) != 0 ; }
1013+
1014+ /* *
1015+ * Override the half-time (forget factor) of the time-stamp smoothing.
1016+ * The default is 90 seconds unless a different value is set in the config file.
1017+ * Using a longer window will yield lower jitter in the time stamps, but longer
1018+ * windows will have trouble tracking changes in the clock rate (usually due to
1019+ * temperature changes); the default is able to track changes up to 10
1020+ * degrees C per minute sufficiently well.
1021+ */
1022+ void smoothing_halftime (float value) { check_error (lsl_smoothing_halftime (obj,value)); }
9891023 private:
9901024 // The inlet is a non-copyable object.
9911025 stream_inlet (const stream_inlet &rhs);
0 commit comments