From fb630f622df6f65f253800bdd979e89f26123c3b Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 5 Nov 2012 15:54:18 +0000 Subject: LTC generator: filter the signal to reduce ringing. git-svn-id: svn://localhost/ardour2/branches/3.0@13382 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/session_ltc.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'libs/ardour/session_ltc.cc') 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(); } -- cgit v1.2.3