diff options
author | David Robillard <drobilla@leibniz.local> | 2014-12-19 18:09:36 -0500 |
---|---|---|
committer | David Robillard <drobilla@leibniz.local> | 2014-12-20 01:13:25 -0500 |
commit | 5d8021bf44c066ad9b5ee4e8ab824267824be738 (patch) | |
tree | b2ebd105b0057f23fb5d59e7504c2fbd8e026621 /libs/ardour/midi_diskstream.cc | |
parent | db92d62c95773d78282e752df7589cc6b8b721c3 (diff) |
Maintain correct tracker state on MIDI overwrite.
This is a little hard-edged in that edits while rolling will prematurely chop
off any playing notes, but at least the state of things actually reflects
reality. More sophisticated solution hopefully to come...
Diffstat (limited to 'libs/ardour/midi_diskstream.cc')
-rw-r--r-- | libs/ardour/midi_diskstream.cc | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc index e2fd6d1681..e52a7c3ad7 100644 --- a/libs/ardour/midi_diskstream.cc +++ b/libs/ardour/midi_diskstream.cc @@ -606,12 +606,20 @@ MidiDiskstream::set_pending_overwrite (bool yn) int MidiDiskstream::overwrite_existing_buffers () { - /* This is safe as long as the butler thread is suspended, which it should be */ + /* Clear the playback buffer contents. This is safe as long as the butler + thread is suspended, which it should be. */ _playback_buf->reset (); + _playback_buf->reset_tracker (); g_atomic_int_set (&_frames_read_from_ringbuffer, 0); g_atomic_int_set (&_frames_written_to_ringbuffer, 0); + /* Resolve all currently active notes in the playlist. This is more + aggressive than it needs to be: ideally we would only resolve what is + absolutely necessary, but this seems difficult and/or impossible without + having the old data or knowing what change caused the overwrite. */ + midi_playlist()->resolve_note_trackers (*_playback_buf, overwrite_frame); + read (overwrite_frame, disk_io_chunk_frames, false); file_frame = overwrite_frame; // it was adjusted by ::read() overwrite_queued = false; @@ -1398,7 +1406,7 @@ MidiDiskstream::get_playback (MidiBuffer& dst, framecnt_t nframes) beyond the loop end. */ - _playback_buf->loop_resolve (dst, 0); + _playback_buf->resolve_tracker (dst, 0); } if (loc->end() >= effective_start && loc->end() < effective_start + nframes) { @@ -1489,7 +1497,7 @@ MidiDiskstream::reset_tracker () boost::shared_ptr<MidiPlaylist> mp (midi_playlist()); if (mp) { - mp->clear_note_trackers (); + mp->reset_note_trackers (); } } |