summaryrefslogtreecommitdiff
path: root/libs/ardour/session_ltc.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2012-11-05 22:55:04 +0000
committerRobin Gareus <robin@gareus.org>2012-11-05 22:55:04 +0000
commit3f1b758491b59c3d06ef1b4c3577fb2eba8d16f0 (patch)
tree76f1f6df1ae25368edc0c281e57240490951f766 /libs/ardour/session_ltc.cc
parent0a4f4026a9e98ad2466d7f3e7de41dac8f22a136 (diff)
LTC generator: adaptive signal filter
git-svn-id: svn://localhost/ardour2/branches/3.0@13386 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/session_ltc.cc')
-rw-r--r--libs/ardour/session_ltc.cc21
1 files changed, 10 insertions, 11 deletions
diff --git a/libs/ardour/session_ltc.cc b/libs/ardour/session_ltc.cc
index 8d976ea4da..516daea76d 100644
--- a/libs/ardour/session_ltc.cc
+++ b/libs/ardour/session_ltc.cc
@@ -48,15 +48,15 @@ using namespace Timecode;
/* 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.
+ * 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.
*
- * TODO: this should become an adaptive value, when
- * the playback speed is increases so that 1 bit < 3-4
- * audio samples, we should fall back to 25 us.
+ * This filter is adaptive so that fast vari-speed signals
+ * will not be affected by it.
*/
-#define LTC_RISE_TIME MIN (100, MAX(25, (2000000 / engine().frame_rate())))
+#define LTC_RISE_TIME(speed) MIN (100, MAX(25, (4000000 / ((speed==0)?1:speed) / engine().frame_rate())))
void
Session::ltc_tx_initialize()
@@ -69,7 +69,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);
+ ltc_encoder_set_filter(ltc_encoder, LTC_RISE_TIME(1.0));
/* buffersize for 1 LTC frame: (1 + sample-rate / fps) bytes
* usually returned by ltc_encoder_get_buffersize(encoder)
@@ -198,9 +198,7 @@ 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_encoder_set_filter(ltc_encoder, LTC_RISE_TIME(ltc_speed));
ltc_enc_tcformat = cur_timecode;
ltc_tx_reset();
}
@@ -246,6 +244,7 @@ Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end
*/
DEBUG_TRACE (DEBUG::LTC, string_compose("LTC TX2: speed change old: %1 cur: %2 tgt: %3 ctd: %4\n", ltc_speed, current_speed, target_speed, fabs(current_speed) - target_speed));
speed_changed = true;
+ ltc_encoder_set_filter(ltc_encoder, LTC_RISE_TIME(new_ltc_speed));
}
if (end_frame == start_frame || fabs(current_speed) < 0.1 ) {