diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2006-10-20 16:09:42 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2006-10-20 16:09:42 +0000 |
commit | 3e8be2ca624575d7578c405e6df1bfffd4b34fae (patch) | |
tree | 887c7bec241f091ff6f7454be66d691a3eea5191 | |
parent | 2592a320d42dd4a157ee16101c042d875d3142be (diff) |
fixes for crossfade views, crossfades and undo/redo. added default crossfade settings to ardour.rc.in
git-svn-id: svn://localhost/ardour2/trunk@994 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | ardour.rc.in | 3 | ||||
-rw-r--r-- | gtk2_ardour/audio_streamview.cc | 2 | ||||
-rw-r--r-- | gtk2_ardour/crossfade_view.cc | 12 | ||||
-rw-r--r-- | libs/ardour/ardour/audioplaylist.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/crossfade.h | 3 | ||||
-rw-r--r-- | libs/ardour/ardour/playlist.h | 4 | ||||
-rw-r--r-- | libs/ardour/audio_playlist.cc | 52 | ||||
-rw-r--r-- | libs/ardour/crossfade.cc | 22 | ||||
-rw-r--r-- | libs/ardour/playlist.cc | 45 |
9 files changed, 88 insertions, 57 deletions
diff --git a/ardour.rc.in b/ardour.rc.in index 6488d0ed82..735b19c233 100644 --- a/ardour.rc.in +++ b/ardour.rc.in @@ -21,6 +21,9 @@ <Option name="stop-recording-on-xrun" value="no"/> <Option name="stop-at-session-end" value="no"/> <Option name="auto-xfade" value="yes"/> + <Option name="crossfades-active" value="1"/> + <Option name="crossfades-visible" value="1"/> + <Option name="xfade-model" value="0"/> <Option name="no-new-session-dialog" value="yes"/> <Option name="timecode-source-is-synced" value="yes"/> <Option name="auditioner-left-out" value="%JACK_INPUT%1"/> diff --git a/gtk2_ardour/audio_streamview.cc b/gtk2_ardour/audio_streamview.cc index 3cca792523..0e6997b59c 100644 --- a/gtk2_ardour/audio_streamview.cc +++ b/gtk2_ardour/audio_streamview.cc @@ -288,7 +288,7 @@ AudioStreamView::add_crossfade (Crossfade *crossfade) crossfade->Invalidated.connect (mem_fun (*this, &AudioStreamView::remove_crossfade)); crossfade_views.push_back (cv); - if (!crossfades_visible) { + if (!Config->get_crossfades_visible() || !crossfades_visible) { cv->hide (); } } diff --git a/gtk2_ardour/crossfade_view.cc b/gtk2_ardour/crossfade_view.cc index baf0f2a346..42a1a47227 100644 --- a/gtk2_ardour/crossfade_view.cc +++ b/gtk2_ardour/crossfade_view.cc @@ -127,6 +127,10 @@ CrossfadeView::crossfade_changed (Change what_changed) set_duration (crossfade.overlap_length(), this); need_redraw_curves = true; } + + if (what_changed & Crossfade::FollowOverlapChanged) { + need_redraw_curves = true; + } if (what_changed & Crossfade::ActiveChanged) { /* calls redraw_curves */ @@ -142,9 +146,15 @@ CrossfadeView::redraw_curves () Points* points; int32_t npoints; float* vec; - double h; + if (!crossfade.following_overlap()) { + /* curves should not be visible */ + fade_in->hide (); + fade_out->hide (); + return; + } + /* At "height - 3.0" the bottom of the crossfade touches the name highlight or the bottom of the track (if the track is either Small or Smaller. diff --git a/libs/ardour/ardour/audioplaylist.h b/libs/ardour/ardour/audioplaylist.h index 6d67e0f793..383ec73531 100644 --- a/libs/ardour/ardour/audioplaylist.h +++ b/libs/ardour/ardour/audioplaylist.h @@ -45,7 +45,7 @@ class AudioPlaylist : public ARDOUR::Playlist AudioPlaylist (const AudioPlaylist&, string name, bool hidden = false); AudioPlaylist (const AudioPlaylist&, nframes_t start, nframes_t cnt, string name, bool hidden = false); - void clear (); + void clear (bool with_signals=true); nframes_t read (Sample *dst, Sample *mixdown, float *gain_buffer, nframes_t start, nframes_t cnt, uint32_t chan_n=0); diff --git a/libs/ardour/ardour/crossfade.h b/libs/ardour/ardour/crossfade.h index d1b2e8f1e1..d29ba47056 100644 --- a/libs/ardour/ardour/crossfade.h +++ b/libs/ardour/ardour/crossfade.h @@ -108,6 +108,8 @@ class Crossfade : public PBD::StatefulDestructible nframes_t overlap_length() const; nframes_t position() const { return _position; } + void invalidate(); + sigc::signal<void,Crossfade*> Invalidated; sigc::signal<void,Change> StateChanged; @@ -135,6 +137,7 @@ class Crossfade : public PBD::StatefulDestructible static void set_short_xfade_length (nframes_t n); static Change ActiveChanged; + static Change FollowOverlapChanged; private: friend struct CrossfadeComparePtr; diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h index 8f08c58466..2d19f661c4 100644 --- a/libs/ardour/ardour/playlist.h +++ b/libs/ardour/ardour/playlist.h @@ -55,7 +55,7 @@ class Playlist : public PBD::StatefulDestructible { Playlist (const Playlist&, string name, bool hidden = false); Playlist (const Playlist&, nframes_t start, nframes_t cnt, string name, bool hidden = false); - virtual void clear (); + virtual void clear (bool with_signals=true); virtual void dump () const; void ref(); @@ -171,6 +171,8 @@ class Playlist : public PBD::StatefulDestructible { mutable gint block_notifications; mutable gint ignore_state_changes; mutable Glib::Mutex region_lock; + std::set<boost::shared_ptr<Region> > pending_adds; + std::set<boost::shared_ptr<Region> > pending_removes; RegionList pending_bounds; bool pending_modified; bool pending_length; diff --git a/libs/ardour/audio_playlist.cc b/libs/ardour/audio_playlist.cc index e39be5d402..00c3038d25 100644 --- a/libs/ardour/audio_playlist.cc +++ b/libs/ardour/audio_playlist.cc @@ -237,9 +237,9 @@ AudioPlaylist::remove_dependents (boost::shared_ptr<Region> region) tmp = i; tmp++; + if ((*i)->involves (r)) { - /* do not delete crossfades */ - _crossfades.erase (i); + delete *i; } i = tmp; @@ -488,9 +488,7 @@ AudioPlaylist::set_state (const XMLNode& node) XMLNodeList nlist; XMLNodeConstIterator niter; - if (!in_set_state) { - Playlist::set_state (node); - } + Playlist::set_state (node); nlist = node.children(); @@ -502,10 +500,12 @@ AudioPlaylist::set_state (const XMLNode& node) continue; } - Crossfade *xfade; - try { - xfade = new Crossfade (*((const Playlist *)this), *child); + Crossfade* xfade = new Crossfade (*((const Playlist *)this), *child); + _crossfades.push_back (xfade); + xfade->Invalidated.connect (mem_fun (*this, &AudioPlaylist::crossfade_invalidated)); + xfade->StateChanged.connect (mem_fun (*this, &AudioPlaylist::crossfade_changed)); + NewCrossfade(xfade); } catch (failed_constructor& err) { @@ -514,44 +514,28 @@ AudioPlaylist::set_state (const XMLNode& node) // << endl; continue; } - - Crossfades::iterator ci; - - for (ci = _crossfades.begin(); ci != _crossfades.end(); ++ci) { - if (*(*ci) == *xfade) { - break; - } - } - - if (ci == _crossfades.end()) { - _crossfades.push_back (xfade); - xfade->Invalidated.connect (mem_fun (*this, &AudioPlaylist::crossfade_invalidated)); - xfade->StateChanged.connect (mem_fun (*this, &AudioPlaylist::crossfade_changed)); - NewCrossfade(xfade); - } else { - - /* adjust the current state of the existing crossfade */ - - (*ci)->set_state (*child); - - /* drop the new one */ - delete xfade; - } } return 0; } void -AudioPlaylist::clear () +AudioPlaylist::clear (bool with_signals) { - for (Crossfades::iterator i = _crossfades.begin(); i != _crossfades.end(); ++i) { + for (Crossfades::iterator i = _crossfades.begin(); i != _crossfades.end(); ) { + + Crossfades::iterator tmp; + tmp = i; + ++tmp; + delete *i; + + i = tmp; } _crossfades.clear (); - Playlist::clear (); + Playlist::clear (with_signals); } XMLNode& diff --git a/libs/ardour/crossfade.cc b/libs/ardour/crossfade.cc index a197459971..1c4bdb6cad 100644 --- a/libs/ardour/crossfade.cc +++ b/libs/ardour/crossfade.cc @@ -37,6 +37,7 @@ using namespace PBD; nframes_t Crossfade::_short_xfade_length = 0; Change Crossfade::ActiveChanged = new_change(); +Change Crossfade::FollowOverlapChanged = new_change(); /* XXX if and when we ever implement parallel processing of the process() callback, these will need to be handled on a per-thread basis. @@ -82,8 +83,16 @@ Crossfade::Crossfade (boost::shared_ptr<AudioRegion> in, boost::shared_ptr<Audio _length = length; _position = position; _anchor_point = ap; - _follow_overlap = false; - _active = true; + + switch (Config->get_xfade_model()) { + case ShortCrossfade: + _follow_overlap = false; + break; + default: + _follow_overlap = true; + } + + _active = Config->get_crossfades_active (); _fixed = true; initialize (); @@ -188,6 +197,7 @@ Crossfade::Crossfade (const Crossfade &orig, boost::shared_ptr<AudioRegion> newi Crossfade::~Crossfade () { + Invalidated (this); } void @@ -795,6 +805,8 @@ Crossfade::set_follow_overlap (bool yn) } else { set_length (_out->first_frame() + _out->length() - _in->first_frame()); } + + StateChanged (FollowOverlapChanged); } nframes_t @@ -847,3 +859,9 @@ Crossfade::set_short_xfade_length (nframes_t n) { _short_xfade_length = n; } + +void +Crossfade::invalidate () +{ + Invalidated (this); /* EMIT SIGNAL */ +} diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index f87a30c931..056789d4e9 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -331,6 +331,7 @@ void Playlist::notify_region_removed (boost::shared_ptr<Region> r) { if (holding_state ()) { + pending_removes.insert (r); pending_modified = true; pending_length = true; } else { @@ -350,6 +351,7 @@ Playlist::notify_region_added (boost::shared_ptr<Region> r) */ if (holding_state()) { + pending_adds.insert (r); pending_modified = true; pending_length = true; } else { @@ -372,9 +374,8 @@ Playlist::notify_length_changed () void Playlist::flush_notifications () { - RegionList::iterator r; - RegionList::iterator a; set<boost::shared_ptr<Region> > dependent_checks_needed; + set<boost::shared_ptr<Region> >::iterator s; uint32_t n = 0; if (in_flush) { @@ -405,8 +406,18 @@ Playlist::flush_notifications () /* don't increment n again - its the same list */ } - for (set<boost::shared_ptr<Region> >::iterator x = dependent_checks_needed.begin(); x != dependent_checks_needed.end(); ++x) { - check_dependents (*x, false); + for (s = pending_adds.begin(); s != pending_adds.end(); ++s) { + dependent_checks_needed.insert (*s); + n++; + } + + for (s = dependent_checks_needed.begin(); s != dependent_checks_needed.end(); ++s) { + check_dependents (*s, false); + } + + for (s = pending_removes.begin(); s != pending_removes.end(); ++s) { + remove_dependents (*s); + n++; } if ((freeze_length != _get_maximum_extent()) || pending_length) { @@ -424,6 +435,8 @@ Playlist::flush_notifications () Modified (); /* EMIT SIGNAL */ } + pending_adds.clear (); + pending_removes.clear (); pending_bounds.clear (); in_flush = false; @@ -543,7 +556,7 @@ Playlist::remove_region_internal (boost::shared_ptr<Region>region, bool delay_so RegionList::iterator i; nframes_t old_length = 0; - // cerr << "removing region " << region->name() << endl; + cerr << "removing region " << region->name() << " holding = " << holding_state() << endl; if (!holding_state()) { old_length = _get_maximum_extent(); @@ -1155,20 +1168,21 @@ Playlist::region_changed (Change what_changed, boost::shared_ptr<Region> region) } void -Playlist::clear () +Playlist::clear (bool with_signals) { - RegionList::iterator i; - RegionList tmp; - { RegionLock rl (this); - tmp = regions; + for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) { + pending_removes.insert (*i); + } regions.clear (); } - - for (i = tmp.begin(); i != tmp.end(); ++i) { - notify_region_removed (*i); + + if (with_signals) { + LengthChanged (); + Modified (); } + } /*********************************************************************** @@ -1331,10 +1345,7 @@ Playlist::set_state (const XMLNode& node) } } - { - RegionLock rl (this); - regions.clear (); - } + clear (false); nlist = node.children(); |