Fix compensation of roll delay with MIDI tracks; data
authorCarl Hetherington <carl@carlh.net>
Mon, 31 Oct 2011 21:17:14 +0000 (21:17 +0000)
committerCarl Hetherington <carl@carlh.net>
Mon, 31 Oct 2011 21:17:14 +0000 (21:17 +0000)
should be obtained from playback_sample, not
transport_frame (should fix #4172).

git-svn-id: svn://localhost/ardour2/branches/3.0@10362 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/midi_diskstream.h
libs/ardour/midi_diskstream.cc
libs/ardour/midi_track.cc

index 1bb9746d6bb9a3cbf469e3136f4027ae77f6495d..65008714123b2f4be47fdcb546a76c7d1f7dd174 100644 (file)
@@ -62,7 +62,7 @@ class MidiDiskstream : public Diskstream
        float playback_buffer_load() const;
        float capture_buffer_load() const;
 
-       void get_playback(MidiBuffer& dst, framepos_t start, framepos_t end);
+       void get_playback (MidiBuffer& dst, framecnt_t);
 
        void set_record_enabled (bool yn);
 
index 79b59eef50d7830c82b20d596309cc4cccd16537..7ab8c46c306297073891a96357f970235d463e1c 100644 (file)
@@ -1409,43 +1409,34 @@ MidiDiskstream::use_pending_capture_data (XMLNode& /*node*/)
        return 0;
 }
 
-/** Writes playback events in the given range to \a dst, translating time stamps
- * so that an event at \a start has time = 0
+/** Writes playback events from playback_sample for nframes to dst, translating time stamps
+ *  so that an event at playback_sample has time = 0
  */
 void
-MidiDiskstream::get_playback (MidiBuffer& dst, framepos_t start, framepos_t end)
+MidiDiskstream::get_playback (MidiBuffer& dst, framecnt_t nframes)
 {
        dst.clear();
        assert(dst.size() == 0);
 
-       // Reverse.  ... We just don't do reverse, ok?  Back off.
-       if (end <= start) {
-               return;
-       }
-
-       // Translate stamps to be relative to start
-
-
 #ifndef NDEBUG
        DEBUG_TRACE (DEBUG::MidiDiskstreamIO, string_compose (
                             "%1 MDS pre-read read %4..%5 from %2 write to %3\n", _name,
-                            _playback_buf->get_read_ptr(), _playback_buf->get_write_ptr(), start, end));
+                            _playback_buf->get_read_ptr(), _playback_buf->get_write_ptr(), playback_sample, playback_sample + nframes));
 //        cerr << "================\n";
 //        _playback_buf->dump (cerr);
 //        cerr << "----------------\n";
 
-       const size_t events_read = _playback_buf->read(dst, start, end);
+       const size_t events_read = _playback_buf->read (dst, playback_sample, playback_sample + nframes);
        DEBUG_TRACE (DEBUG::MidiDiskstreamIO, string_compose (
                             "%1 MDS events read %2 range %3 .. %4 rspace %5 wspace %6 r@%7 w@%8\n",
-                            _name, events_read, start, end,
+                            _name, events_read, playback_sample, playback_sample + nframes,
                             _playback_buf->read_space(), _playback_buf->write_space(),
-                        _playback_buf->get_read_ptr(), _playback_buf->get_write_ptr()));
+                            _playback_buf->get_read_ptr(), _playback_buf->get_write_ptr()));
 #else
-       _playback_buf->read(dst, start, end);
+       _playback_buf->read (dst, playback_sample, playback_sample + nframes);
 #endif
 
-       gint32 frames_read = end - start;
-       g_atomic_int_add(&_frames_read_from_ringbuffer, frames_read);
+       g_atomic_int_add (&_frames_read_from_ringbuffer, nframes);
 }
 
 bool
index 238e616a4f2343e48710314c798fd07f1eef170e..9114311ac9e0b1e24d622c1d5cf95bdf843f7bda 100644 (file)
@@ -358,7 +358,7 @@ MidiTrack::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame
                c.set_midi (1);
                bufs.set_count (c);
 
-               diskstream->get_playback (mbuf, start_frame, end_frame);
+               diskstream->get_playback (mbuf, nframes);
 
                /* append immediate messages to the first MIDI buffer (thus sending it to the first output port) */