+#ifndef MAX
+#define MAX(a,b) ( (a) > (b) ? (a) : (b) )
+#endif
+#ifndef MIN
+#define MIN(a,b) ( (a) < (b) ? (a) : (b) )
+#endif
+
+/* LTC signal should have a rise time of 25 us +/- 5 us.
+ * yet with most sound-cards a square-wave of 1-2 sample
+ * introduces ringing and small oscillations.
+ * https://en.wikipedia.org/wiki/Gibbs_phenomenon
+ * A low-pass filter in libltc can reduce this at
+ * the cost of being slightly out of spec WRT to rise-time.
+ *
+ * This filter is adaptive so that fast vari-speed signals
+ * will not be affected by it.
+ */
+#define LTC_RISE_TIME(speed) MIN (100, MAX(40, (4000000 / ((speed==0)?1:speed) / engine().sample_rate())))
+
+#define TV_STANDARD(tcf) \
+ (timecode_to_frames_per_second(tcf)==25.0 ? LTC_TV_625_50 : \
+ timecode_has_drop_frames(tcf)? LTC_TV_525_60 : LTC_TV_FILM_24)
+