summaryrefslogtreecommitdiff
path: root/libs/ardour/session_ltc.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2012-11-05 19:13:10 +0000
committerRobin Gareus <robin@gareus.org>2012-11-05 19:13:10 +0000
commit0a4f4026a9e98ad2466d7f3e7de41dac8f22a136 (patch)
tree2fe207cc0628359494c7bae8cda67a721390709d /libs/ardour/session_ltc.cc
parentfb630f622df6f65f253800bdd979e89f26123c3b (diff)
experimental LTC sub-frame drift compensation for scope testing
git-svn-id: svn://localhost/ardour2/branches/3.0@13384 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/session_ltc.cc')
-rw-r--r--libs/ardour/session_ltc.cc32
1 files changed, 30 insertions, 2 deletions
diff --git a/libs/ardour/session_ltc.cc b/libs/ardour/session_ltc.cc
index e24a233b7b..8d976ea4da 100644
--- a/libs/ardour/session_ltc.cc
+++ b/libs/ardour/session_ltc.cc
@@ -50,9 +50,13 @@ using namespace Timecode;
* 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
+ * on the sample-rate.
+ *
+ * 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.
*/
-#define LTC_RISE_TIME MIN (150, MAX(25, (4000000 / engine().frame_rate())))
+#define LTC_RISE_TIME MIN (100, MAX(25, (2000000 / engine().frame_rate())))
void
Session::ltc_tx_initialize()
@@ -465,6 +469,24 @@ Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end
DEBUG_TRACE (DEBUG::LTC, string_compose("LTC TX5 restart @ %1 + %2 - %3 | byte %4\n",
ltc_enc_pos, ltc_enc_cnt, cyc_off, ltc_enc_byte));
}
+#if 1 /* experimental sample bit alignment */
+ else if (ltc_speed != 0 && (fptcf / ltc_speed / 80) > 3 ) {
+ /* We may get away without a DLL if speed-changes are uniform enough and
+ * no oscillation takes place, the linear approx here should reduce the
+ * jitter sufficiently when generating LTC from another LTC source or
+ * JACK-transport or ardour internal clock.
+ *
+ * Note that the granularity of the LTC encoder speed is 1 byte =
+ * (frames-per-timecode-frame / 10) audio-samples.
+ *
+ * Thus, tiny speed changes won't have any effect and larger ones
+ * may lead to oscillations.
+ * To be better than that, resampling (or a rewrite of the encoder) is
+ * required.
+ */
+ ltc_speed -= ((ltc_enc_pos + ltc_enc_cnt - poff) - cycle_start_frame) / engine().frame_rate();
+ }
+#endif
// (6) encode and output
@@ -529,6 +551,12 @@ Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end
ltc_enc_byte = (ltc_enc_byte + 1)%10;
if (ltc_enc_byte == 0 && ltc_speed != 0) {
ltc_encoder_inc_timecode(ltc_encoder);
+#if 0 /* force fixed parity -- scope debug */
+ LTCFrame f;
+ ltc_encoder_get_frame(ltc_encoder, &f);
+ f.biphase_mark_phase_correction=0;
+ ltc_encoder_set_frame(ltc_encoder, &f);
+#endif
ltc_tx_recalculate_position();
ltc_enc_cnt = 0;
} else if (ltc_enc_byte == 0) {