diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index c74b91596a..249c198bfd 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -1101,8 +1101,6 @@ MidiRegionView::apply_diff (bool as_subcommand, bool was_copy) if (commit) { trackview.editor().commit_reversible_command (); - /* XXX the GUI should NOT be responsible for causing this call tree */ - midi_view()->midi_track()->region_edited (_region); } } diff --git a/libs/ardour/ardour/disk_reader.h b/libs/ardour/ardour/disk_reader.h index c9e4c0b6d4..80343a2029 100644 --- a/libs/ardour/ardour/disk_reader.h +++ b/libs/ardour/ardour/disk_reader.h @@ -128,7 +128,6 @@ protected: void resolve_tracker (Evoral::EventSink& buffer, samplepos_t time); - void playlist_changed (const PBD::PropertyChange&); int use_playlist (DataType, boost::shared_ptr); void playlist_ranges_moved (std::list< Evoral::RangeMove > const &, bool); diff --git a/libs/ardour/ardour/midi_region.h b/libs/ardour/ardour/midi_region.h index 500c483827..6ae1375899 100644 --- a/libs/ardour/ardour/midi_region.h +++ b/libs/ardour/ardour/midi_region.h @@ -162,6 +162,7 @@ class LIBARDOUR_API MidiRegion : public Region void update_length_beats (const int32_t sub_num); void model_changed (); + void model_contents_changed (); void model_shifted (double qn_distance); void model_automation_state_changed (Evoral::Parameter const &); @@ -171,6 +172,7 @@ class LIBARDOUR_API MidiRegion : public Region std::set _filtered_parameters; ///< parameters that we ask our source not to return when reading PBD::ScopedConnection _model_connection; PBD::ScopedConnection _model_shift_connection; + PBD::ScopedConnection _model_changed_connection; PBD::ScopedConnection _source_connection; PBD::ScopedConnection _model_contents_connection; bool _ignore_shift; diff --git a/libs/ardour/ardour/midi_track.h b/libs/ardour/ardour/midi_track.h index ebe4e9bd56..556ab890ff 100644 --- a/libs/ardour/ardour/midi_track.h +++ b/libs/ardour/ardour/midi_track.h @@ -139,6 +139,8 @@ public: void realtime_handle_transport_stopped (); void region_edited (boost::shared_ptr); + int use_playlist (DataType, boost::shared_ptr); + protected: XMLNode& state (bool save_template); @@ -174,6 +176,9 @@ private: /** Update automation controls to reflect any changes in buffers. */ void update_controls (BufferSet const& bufs); void restore_controls (); + + void playlist_contents_changed (); + PBD::ScopedConnection playlist_content_change_connection; }; } /* namespace ARDOUR*/ diff --git a/libs/ardour/disk_reader.cc b/libs/ardour/disk_reader.cc index 6ee8b6585d..dcf783bcfc 100644 --- a/libs/ardour/disk_reader.cc +++ b/libs/ardour/disk_reader.cc @@ -204,12 +204,6 @@ DiskReader::adjust_buffering () } } -void -DiskReader::playlist_changed (const PropertyChange&) -{ - playlist_modified (); -} - void DiskReader::playlist_modified () { @@ -237,6 +231,8 @@ DiskReader::use_playlist (DataType dt, boost::shared_ptr playlist) take care of the buffer refill. */ + cerr << "DR " << _track->name() << " using playlist, loading ? " << _session.loading() << endl; + if (!overwrite_queued && (prior_playlist || _session.loading())) { _session.request_overwrite_buffer (_track); overwrite_queued = true; @@ -258,7 +254,6 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp if (run_must_resolve) { boost::shared_ptr mt = boost::dynamic_pointer_cast (_track); if (mt) { - cerr << _track->name() << " resolving " << _tracker.on() << " notes @ " << start_sample << endl; resolve_tracker (mt->immediate_events(), start_sample); } run_must_resolve = false; @@ -532,8 +527,8 @@ DiskReader::overwrite_existing_buffers () midi_playlist()->render (0); minsert.update(); assert (midi_playlist()->rendered()); - //cerr << "Reading " << name() << " took " << minsert.elapsed() << " microseconds, final size = " << midi_playlist()->rendered()->size() << endl; - //midi_playlist()->rendered()->dump (100); + // cerr << "Reading " << name() << " took " << minsert.elapsed() << " microseconds, final size = " << midi_playlist()->rendered()->size() << endl; + // midi_playlist()->rendered()->dump (100); } g_atomic_int_set (&_pending_overwrite, 0); diff --git a/libs/ardour/midi_playlist.cc b/libs/ardour/midi_playlist.cc index a7092c45ba..00d1f5badd 100644 --- a/libs/ardour/midi_playlist.cc +++ b/libs/ardour/midi_playlist.cc @@ -416,7 +416,7 @@ MidiPlaylist::render (MidiChannelFilter* filter) Playlist::RegionReadLock rl (this); - DEBUG_TRACE (DEBUG::MidiPlaylistIO, "---- MidiPlaylist::dump-----\n"); + DEBUG_TRACE (DEBUG::MidiPlaylistIO, string_compose ("---- MidiPlaylist::render (regions: %1)-----\n", regions.size())); std::vector< boost::shared_ptr > regs; @@ -458,7 +458,7 @@ MidiPlaylist::render (MidiChannelFilter* filter) continue; } - DEBUG_TRACE (DEBUG::MidiPlaylistIO, string_compose ("dump from %1 at %2\n", mr->name())); + DEBUG_TRACE (DEBUG::MidiPlaylistIO, string_compose ("render from %1\n", mr->name())); mr->render (*tgt, 0, _note_mode, filter); } diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index d1a1f672d7..ee5d6e86df 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -541,7 +541,7 @@ MidiRegion::render (Evoral::EventSink& dst, dst, // destination buffer _position - _start, // start position of the source in session samples _start + internal_offset, // where to start reading in the source - max_samplecnt, + _start + internal_offset + _length, 0, cursor, 0, @@ -670,7 +670,16 @@ MidiRegion::model_changed () ); model()->ContentsShifted.connect_same_thread (_model_shift_connection, boost::bind (&MidiRegion::model_shifted, this, _1)); + model()->ContentsChanged.connect_same_thread (_model_changed_connection, boost::bind (&MidiRegion::model_contents_changed, this)); } + +void +MidiRegion::model_contents_changed () +{ + std::cerr << "MIDI Region " << name() << " contents changed\n"; + send_change (Properties::contents); +} + void MidiRegion::model_shifted (double qn_distance) { @@ -685,6 +694,7 @@ MidiRegion::model_shifted (double qn_distance) _start = new_start; what_changed.add (Properties::start); what_changed.add (Properties::start_beats); + what_changed.add (Properties::contents); send_change (what_changed); } else { _ignore_shift = false; diff --git a/libs/ardour/midi_track.cc b/libs/ardour/midi_track.cc index 16d97a984c..53a3ed3366 100644 --- a/libs/ardour/midi_track.cc +++ b/libs/ardour/midi_track.cc @@ -873,9 +873,7 @@ MidiTrack::realtime_handle_transport_stopped () } void -MidiTrack::region_edited(boost::shared_ptr region) +MidiTrack::playlist_contents_changed () { - cerr << "MIDI region " << region->name() << " edited, queue reload\n"; - _session.request_overwrite_buffer (boost::dynamic_pointer_cast (shared_from_this())); } diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index 417157f411..3cab0ef4aa 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -1772,14 +1772,18 @@ Playlist::region_changed (const PropertyChange& what_changed, boost::shared_ptr< our_interests.add (Properties::muted); our_interests.add (Properties::layer); our_interests.add (Properties::opaque); + our_interests.add (Properties::contents); bounds.add (Properties::start); bounds.add (Properties::position); bounds.add (Properties::length); + bool send_contents = false; + if (what_changed.contains (bounds)) { region_bounds_changed (what_changed, region); save = !(_splicing || _nudging); + send_contents = true; } if (what_changed.contains (Properties::position) && !what_changed.contains (Properties::length)) { @@ -1788,8 +1792,6 @@ Playlist::region_changed (const PropertyChange& what_changed, boost::shared_ptr< notify_region_end_trimmed (region); } else if (what_changed.contains (Properties::position) && what_changed.contains (Properties::length)) { notify_region_start_trimmed (region); - } else if (what_changed.contains (Properties::start)) { - notify_contents_changed (); } /* don't notify about layer changes, since we are the only object that can initiate @@ -1800,6 +1802,10 @@ Playlist::region_changed (const PropertyChange& what_changed, boost::shared_ptr< save = true; } + if (send_contents || save) { + notify_contents_changed (); + } + mark_session_dirty (); return save;