diff options
author | David Robillard <d@drobilla.net> | 2009-02-20 00:30:42 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-02-20 00:30:42 +0000 |
commit | c9582da23371bfd40f3087f5a9112d081ef012da (patch) | |
tree | d039fc76d262918d0335941ad5933bf7ccebfd05 /libs/ardour/midi_source.cc | |
parent | bed0d89337b0775e669439ef4e0759feb7ddc74e (diff) |
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
Diffstat (limited to 'libs/ardour/midi_source.cc')
-rw-r--r-- | libs/ardour/midi_source.cc | 29 |
1 files changed, 26 insertions, 3 deletions
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<nframes_t>& 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; |