summaryrefslogtreecommitdiff
path: root/libs/ardour/session_ltc.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2012-11-05 15:54:18 +0000
committerRobin Gareus <robin@gareus.org>2012-11-05 15:54:18 +0000
commitfb630f622df6f65f253800bdd979e89f26123c3b (patch)
treed0ae81af08e637dc6354489eed50215c4c6f6b5f /libs/ardour/session_ltc.cc
parent18474a66c6c91fa86e85f8df9f3a1ec880ed23ea (diff)
LTC generator: filter the signal to reduce ringing.
git-svn-id: svn://localhost/ardour2/branches/3.0@13382 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/session_ltc.cc')
-rw-r--r--libs/ardour/session_ltc.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/libs/ardour/session_ltc.cc b/libs/ardour/session_ltc.cc
index c0d98948fb..e24a233b7b 100644
--- a/libs/ardour/session_ltc.cc
+++ b/libs/ardour/session_ltc.cc
@@ -39,6 +39,21 @@ using namespace Timecode;
//#define LTC_GEN_FRAMEDBUG
//#define LTC_GEN_TXDBUG
+#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 rather some ringing and small oscillations.
+ * so we low-pass filter the signal a bit, depending
+ * on the sample-rate
+ */
+#define LTC_RISE_TIME MIN (150, MAX(25, (4000000 / engine().frame_rate())))
+
void
Session::ltc_tx_initialize()
{
@@ -50,6 +65,7 @@ Session::ltc_tx_initialize()
0);
ltc_encoder_set_bufsize(ltc_encoder, nominal_frame_rate(), 23.0);
+ ltc_encoder_set_filter(ltc_encoder, LTC_RISE_TIME);
/* buffersize for 1 LTC frame: (1 + sample-rate / fps) bytes
* usually returned by ltc_encoder_get_buffersize(encoder)
@@ -178,6 +194,9 @@ Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end
ltc_tx_cleanup();
return;
}
+ if (nominal_frame_rate() <= 48000) {
+ ltc_encoder_set_filter(ltc_encoder, LTC_RISE_TIME);
+ }
ltc_enc_tcformat = cur_timecode;
ltc_tx_reset();
}