summaryrefslogtreecommitdiff
path: root/libs/ardour/smf_source.cc
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-10-07 07:20:09 +0000
committerDavid Robillard <d@drobilla.net>2007-10-07 07:20:09 +0000
commit49763a55c9bcbff2cb7844f36df777bbfadab172 (patch)
tree6751da6e2c8c24207fd197ef4fca7c5bb8f467d1 /libs/ardour/smf_source.cc
parent7d2efe25ac9ab876c91684591a7bbf02337f9476 (diff)
Fix several MIDI timestamp related problems:
Fix recording MIDI regions that start at t != 0. Fix display of MIDI events in regions that start at t != 0. Fix recording after relocating an already rec-armed MIDI track. git-svn-id: svn://localhost/ardour2/trunk@2528 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/smf_source.cc')
-rw-r--r--libs/ardour/smf_source.cc17
1 files changed, 12 insertions, 5 deletions
diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc
index 4ad8f80b4b..3bc53cb538 100644
--- a/libs/ardour/smf_source.cc
+++ b/libs/ardour/smf_source.cc
@@ -159,7 +159,6 @@ SMFSource::open()
_track_size = 4;
// Write a tentative header just to pad things out so writing happens in the right spot
- set_timeline_position(0);
flush_header();
write_footer();
seek_to_end();
@@ -403,7 +402,7 @@ SMFSource::write_unlocked (MidiRingBuffer& src, nframes_t cnt)
while (true) {
bool ret = src.full_peek(sizeof(double), (Byte*)&time);
- if (!ret || time > _length + cnt)
+ if (!ret || time - _timeline_position > _length + cnt)
break;
ret = src.read_prefix(&time, &size);
@@ -423,10 +422,9 @@ SMFSource::write_unlocked (MidiRingBuffer& src, nframes_t cnt)
assert(time >= _timeline_position);
time -= _timeline_position;
- assert(time >= _last_ev_time);
const MidiEvent ev(time, size, buf);
- append_event_unlocked(MidiEvent(ev));
+ append_event_unlocked(ev);
if (_model)
_model->append(ev);
@@ -438,7 +436,7 @@ SMFSource::write_unlocked (MidiRingBuffer& src, nframes_t cnt)
const nframes_t oldlen = _length;
update_length(oldlen, cnt);
- ViewDataRangeReady (oldlen, cnt); /* EMIT SIGNAL */
+ ViewDataRangeReady (_timeline_position + oldlen, cnt); /* EMIT SIGNAL */
return cnt;
}
@@ -453,6 +451,8 @@ SMFSource::append_event_unlocked(const MidiEvent& ev)
}
printf("\n");*/
+ assert(ev.time() >= 0);
+
assert(ev.time() >= _last_ev_time);
// FIXME: assumes tempo never changes after start
@@ -517,6 +517,13 @@ SMFSource::mark_for_remove ()
}
void
+SMFSource::mark_streaming_midi_write_started (NoteMode mode, nframes_t start_frame)
+{
+ MidiSource::mark_streaming_midi_write_started (mode, start_frame);
+ _last_ev_time = 0;
+}
+
+void
SMFSource::mark_streaming_write_completed ()
{
MidiSource::mark_streaming_write_completed();