From c9582da23371bfd40f3087f5a9112d081ef012da Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 20 Feb 2009 00:30:42 +0000 Subject: Make source length a dynamic thing. Update MIDI region length (actually and visually) when position changes. git-svn-id: svn://localhost/ardour2/branches/3.0@4644 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/midi_source.cc | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'libs/ardour/midi_source.cc') diff --git a/libs/ardour/midi_source.cc b/libs/ardour/midi_source.cc index bb5179d2bb..7cb8cbb83e 100644 --- a/libs/ardour/midi_source.cc +++ b/libs/ardour/midi_source.cc @@ -54,7 +54,9 @@ MidiSource::MidiSource (Session& s, string name, Source::Flag flags) , _read_data_count(0) , _write_data_count(0) , _writing (false) + , _length_beats(0.0) , _last_read_end(0) + , _last_write_end(0) { } @@ -63,7 +65,9 @@ MidiSource::MidiSource (Session& s, const XMLNode& node) , _read_data_count(0) , _write_data_count(0) , _writing (false) + , _length_beats(0.0) , _last_read_end(0) + , _last_write_end(0) { _read_data_count = 0; _write_data_count = 0; @@ -101,6 +105,19 @@ MidiSource::set_state (const XMLNode& node) return 0; } +sframes_t +MidiSource::length (sframes_t pos) const +{ + BeatsFramesConverter converter(_session, pos); + return converter.to(_length_beats); +} + +void +MidiSource::update_length (sframes_t pos, sframes_t cnt) +{ + // You're not the boss of me! +} + void MidiSource::invalidate () { @@ -150,7 +167,9 @@ nframes_t MidiSource::midi_write (MidiRingBuffer& dst, sframes_t position, nframes_t cnt) { Glib::Mutex::Lock lm (_lock); - return write_unlocked (dst, position, cnt); + const nframes_t ret = write_unlocked (dst, position, cnt); + _last_write_end = position + cnt; + return ret; } bool @@ -172,17 +191,21 @@ MidiSource::mark_streaming_midi_write_started (NoteMode mode, sframes_t start_fr _model->set_note_mode(mode); _model->start_write(); } - + + _last_write_end = start_frame; _writing = true; } void MidiSource::mark_streaming_write_started () { + sframes_t start_frame = _session.transport_frame(); + if (_model) { _model->start_write(); } + _last_write_end = start_frame; _writing = true; } @@ -190,7 +213,7 @@ void MidiSource::mark_streaming_write_completed () { if (_model) { - _model->end_write(false); // FIXME: param? + _model->end_write(false); } _writing = false; -- cgit v1.2.3