summaryrefslogtreecommitdiff
path: root/libs/ardour/session_midi.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2013-03-02 22:52:39 +0000
committerRobin Gareus <robin@gareus.org>2013-03-02 22:52:39 +0000
commitea29eb0d7dcc334b87f6ac3a8f884a5edb7d2ed4 (patch)
tree59f6c8ddbefe5b22dec7e151af7bba91ca9b743b /libs/ardour/session_midi.cc
parent97abc198035163e202415fbb9ccb375ea8f90dc8 (diff)
fix MTC slave+generator for non integer quarter_frame_duration
e.g. 44.1k [SPS] / 30 [fps] / 4 [MTC-frames per timecode-frame] = 367.5 [samples per MTC-frame] git-svn-id: svn://localhost/ardour2/branches/3.0@14115 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/session_midi.cc')
-rw-r--r--libs/ardour/session_midi.cc18
1 files changed, 10 insertions, 8 deletions
diff --git a/libs/ardour/session_midi.cc b/libs/ardour/session_midi.cc
index 69de04de72..50a7178f1b 100644
--- a/libs/ardour/session_midi.cc
+++ b/libs/ardour/session_midi.cc
@@ -369,12 +369,14 @@ Session::send_full_time_code (framepos_t const t)
sample_to_timecode (t, timecode, true /* use_offset */, false /* no subframes */);
// sample-align outbound to rounded (no subframes) timecode
- timecode_to_sample(timecode, outbound_mtc_timecode_frame, true, false);
+ framepos_t mtc_tc;
+ timecode_to_sample(timecode, mtc_tc, true, false);
+ outbound_mtc_timecode_frame = mtc_tc;
transmitting_timecode_time = timecode;
- framecnt_t const quarter_frame_duration = ((framecnt_t) _frames_per_timecode_frame) >> 2;
- if (ceil((t - outbound_mtc_timecode_frame) / quarter_frame_duration) > 0) {
+ double const quarter_frame_duration = ((framecnt_t) _frames_per_timecode_frame) / 4.0;
+ if (ceil((t - mtc_tc) / quarter_frame_duration) > 0) {
Timecode::increment (transmitting_timecode_time, config.get_subframes_per_frame());
outbound_mtc_timecode_frame += _frames_per_timecode_frame;
}
@@ -460,19 +462,19 @@ Session::send_midi_time_code_for_cycle (framepos_t start_frame, framepos_t end_f
assert (next_quarter_frame_to_send <= 7);
/* Duration of one quarter frame */
- framecnt_t const quarter_frame_duration = ((framecnt_t) _frames_per_timecode_frame) >> 2;
+ double const quarter_frame_duration = _frames_per_timecode_frame / 4.0;
DEBUG_TRACE (DEBUG::MTC, string_compose ("TF %1 SF %2 MT %3 QF %4 QD %5\n",
_transport_frame, start_frame, outbound_mtc_timecode_frame,
next_quarter_frame_to_send, quarter_frame_duration));
- if ((outbound_mtc_timecode_frame + (next_quarter_frame_to_send * quarter_frame_duration)) < _transport_frame) {
+ if (rint(outbound_mtc_timecode_frame + (next_quarter_frame_to_send * quarter_frame_duration)) < _transport_frame) {
send_full_time_code (_transport_frame);
return 0;
}
/* Send quarter frames for this cycle */
- while (end_frame > (outbound_mtc_timecode_frame + (next_quarter_frame_to_send * quarter_frame_duration))) {
+ while (end_frame > rint(outbound_mtc_timecode_frame + (next_quarter_frame_to_send * quarter_frame_duration))) {
DEBUG_TRACE (DEBUG::MTC, string_compose ("next frame to send: %1\n", next_quarter_frame_to_send));
@@ -503,7 +505,7 @@ Session::send_midi_time_code_for_cycle (framepos_t start_frame, framepos_t end_f
break;
}
- const framepos_t msg_time = outbound_mtc_timecode_frame + (quarter_frame_duration * next_quarter_frame_to_send);
+ const framepos_t msg_time = rint(outbound_mtc_timecode_frame + (quarter_frame_duration * next_quarter_frame_to_send));
// This message must fall within this block or something is broken
assert (msg_time >= start_frame);
@@ -538,7 +540,7 @@ Session::send_midi_time_code_for_cycle (framepos_t start_frame, framepos_t end_f
Timecode::increment (transmitting_timecode_time, config.get_subframes_per_frame());
// Re-calculate timing of first quarter frame
//timecode_to_sample( transmitting_timecode_time, outbound_mtc_timecode_frame, true /* use_offset */, false );
- outbound_mtc_timecode_frame += 8 * quarter_frame_duration;
+ outbound_mtc_timecode_frame += 2.0 * _frames_per_timecode_frame;
}
}