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
This commit is contained in:
Paul Davis 2006-10-20 16:09:42 +00:00
parent 2592a320d4
commit 3e8be2ca62
9 changed files with 88 additions and 57 deletions

View file

@ -21,6 +21,9 @@
<Option name="stop-recording-on-xrun" value="no"/> <Option name="stop-recording-on-xrun" value="no"/>
<Option name="stop-at-session-end" value="no"/> <Option name="stop-at-session-end" value="no"/>
<Option name="auto-xfade" value="yes"/> <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="no-new-session-dialog" value="yes"/>
<Option name="timecode-source-is-synced" value="yes"/> <Option name="timecode-source-is-synced" value="yes"/>
<Option name="auditioner-left-out" value="%JACK_INPUT%1"/> <Option name="auditioner-left-out" value="%JACK_INPUT%1"/>

View file

@ -288,7 +288,7 @@ AudioStreamView::add_crossfade (Crossfade *crossfade)
crossfade->Invalidated.connect (mem_fun (*this, &AudioStreamView::remove_crossfade)); crossfade->Invalidated.connect (mem_fun (*this, &AudioStreamView::remove_crossfade));
crossfade_views.push_back (cv); crossfade_views.push_back (cv);
if (!crossfades_visible) { if (!Config->get_crossfades_visible() || !crossfades_visible) {
cv->hide (); cv->hide ();
} }
} }

View file

@ -127,6 +127,10 @@ CrossfadeView::crossfade_changed (Change what_changed)
set_duration (crossfade.overlap_length(), this); set_duration (crossfade.overlap_length(), this);
need_redraw_curves = true; need_redraw_curves = true;
} }
if (what_changed & Crossfade::FollowOverlapChanged) {
need_redraw_curves = true;
}
if (what_changed & Crossfade::ActiveChanged) { if (what_changed & Crossfade::ActiveChanged) {
/* calls redraw_curves */ /* calls redraw_curves */
@ -142,9 +146,15 @@ CrossfadeView::redraw_curves ()
Points* points; Points* points;
int32_t npoints; int32_t npoints;
float* vec; float* vec;
double h; 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 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. track is either Small or Smaller.

View file

@ -45,7 +45,7 @@ class AudioPlaylist : public ARDOUR::Playlist
AudioPlaylist (const AudioPlaylist&, string name, bool hidden = false); AudioPlaylist (const AudioPlaylist&, string name, bool hidden = false);
AudioPlaylist (const AudioPlaylist&, nframes_t start, nframes_t cnt, 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); nframes_t read (Sample *dst, Sample *mixdown, float *gain_buffer, nframes_t start, nframes_t cnt, uint32_t chan_n=0);

View file

@ -108,6 +108,8 @@ class Crossfade : public PBD::StatefulDestructible
nframes_t overlap_length() const; nframes_t overlap_length() const;
nframes_t position() const { return _position; } nframes_t position() const { return _position; }
void invalidate();
sigc::signal<void,Crossfade*> Invalidated; sigc::signal<void,Crossfade*> Invalidated;
sigc::signal<void,Change> StateChanged; sigc::signal<void,Change> StateChanged;
@ -135,6 +137,7 @@ class Crossfade : public PBD::StatefulDestructible
static void set_short_xfade_length (nframes_t n); static void set_short_xfade_length (nframes_t n);
static Change ActiveChanged; static Change ActiveChanged;
static Change FollowOverlapChanged;
private: private:
friend struct CrossfadeComparePtr; friend struct CrossfadeComparePtr;

View file

@ -55,7 +55,7 @@ class Playlist : public PBD::StatefulDestructible {
Playlist (const Playlist&, string name, bool hidden = false); Playlist (const Playlist&, string name, bool hidden = false);
Playlist (const Playlist&, nframes_t start, nframes_t cnt, 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; virtual void dump () const;
void ref(); void ref();
@ -171,6 +171,8 @@ class Playlist : public PBD::StatefulDestructible {
mutable gint block_notifications; mutable gint block_notifications;
mutable gint ignore_state_changes; mutable gint ignore_state_changes;
mutable Glib::Mutex region_lock; mutable Glib::Mutex region_lock;
std::set<boost::shared_ptr<Region> > pending_adds;
std::set<boost::shared_ptr<Region> > pending_removes;
RegionList pending_bounds; RegionList pending_bounds;
bool pending_modified; bool pending_modified;
bool pending_length; bool pending_length;

View file

@ -237,9 +237,9 @@ AudioPlaylist::remove_dependents (boost::shared_ptr<Region> region)
tmp = i; tmp = i;
tmp++; tmp++;
if ((*i)->involves (r)) { if ((*i)->involves (r)) {
/* do not delete crossfades */ delete *i;
_crossfades.erase (i);
} }
i = tmp; i = tmp;
@ -488,9 +488,7 @@ AudioPlaylist::set_state (const XMLNode& node)
XMLNodeList nlist; XMLNodeList nlist;
XMLNodeConstIterator niter; XMLNodeConstIterator niter;
if (!in_set_state) { Playlist::set_state (node);
Playlist::set_state (node);
}
nlist = node.children(); nlist = node.children();
@ -502,10 +500,12 @@ AudioPlaylist::set_state (const XMLNode& node)
continue; continue;
} }
Crossfade *xfade;
try { 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) { catch (failed_constructor& err) {
@ -514,44 +514,28 @@ AudioPlaylist::set_state (const XMLNode& node)
// << endl; // << endl;
continue; 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; return 0;
} }
void 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; delete *i;
i = tmp;
} }
_crossfades.clear (); _crossfades.clear ();
Playlist::clear (); Playlist::clear (with_signals);
} }
XMLNode& XMLNode&

View file

@ -37,6 +37,7 @@ using namespace PBD;
nframes_t Crossfade::_short_xfade_length = 0; nframes_t Crossfade::_short_xfade_length = 0;
Change Crossfade::ActiveChanged = new_change(); Change Crossfade::ActiveChanged = new_change();
Change Crossfade::FollowOverlapChanged = new_change();
/* XXX if and when we ever implement parallel processing of the process() /* XXX if and when we ever implement parallel processing of the process()
callback, these will need to be handled on a per-thread basis. 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; _length = length;
_position = position; _position = position;
_anchor_point = ap; _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; _fixed = true;
initialize (); initialize ();
@ -188,6 +197,7 @@ Crossfade::Crossfade (const Crossfade &orig, boost::shared_ptr<AudioRegion> newi
Crossfade::~Crossfade () Crossfade::~Crossfade ()
{ {
Invalidated (this);
} }
void void
@ -795,6 +805,8 @@ Crossfade::set_follow_overlap (bool yn)
} else { } else {
set_length (_out->first_frame() + _out->length() - _in->first_frame()); set_length (_out->first_frame() + _out->length() - _in->first_frame());
} }
StateChanged (FollowOverlapChanged);
} }
nframes_t nframes_t
@ -847,3 +859,9 @@ Crossfade::set_short_xfade_length (nframes_t n)
{ {
_short_xfade_length = n; _short_xfade_length = n;
} }
void
Crossfade::invalidate ()
{
Invalidated (this); /* EMIT SIGNAL */
}

View file

@ -331,6 +331,7 @@ void
Playlist::notify_region_removed (boost::shared_ptr<Region> r) Playlist::notify_region_removed (boost::shared_ptr<Region> r)
{ {
if (holding_state ()) { if (holding_state ()) {
pending_removes.insert (r);
pending_modified = true; pending_modified = true;
pending_length = true; pending_length = true;
} else { } else {
@ -350,6 +351,7 @@ Playlist::notify_region_added (boost::shared_ptr<Region> r)
*/ */
if (holding_state()) { if (holding_state()) {
pending_adds.insert (r);
pending_modified = true; pending_modified = true;
pending_length = true; pending_length = true;
} else { } else {
@ -372,9 +374,8 @@ Playlist::notify_length_changed ()
void void
Playlist::flush_notifications () Playlist::flush_notifications ()
{ {
RegionList::iterator r;
RegionList::iterator a;
set<boost::shared_ptr<Region> > dependent_checks_needed; set<boost::shared_ptr<Region> > dependent_checks_needed;
set<boost::shared_ptr<Region> >::iterator s;
uint32_t n = 0; uint32_t n = 0;
if (in_flush) { if (in_flush) {
@ -405,8 +406,18 @@ Playlist::flush_notifications ()
/* don't increment n again - its the same list */ /* 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) { for (s = pending_adds.begin(); s != pending_adds.end(); ++s) {
check_dependents (*x, false); 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) { if ((freeze_length != _get_maximum_extent()) || pending_length) {
@ -424,6 +435,8 @@ Playlist::flush_notifications ()
Modified (); /* EMIT SIGNAL */ Modified (); /* EMIT SIGNAL */
} }
pending_adds.clear ();
pending_removes.clear ();
pending_bounds.clear (); pending_bounds.clear ();
in_flush = false; in_flush = false;
@ -543,7 +556,7 @@ Playlist::remove_region_internal (boost::shared_ptr<Region>region, bool delay_so
RegionList::iterator i; RegionList::iterator i;
nframes_t old_length = 0; nframes_t old_length = 0;
// cerr << "removing region " << region->name() << endl; cerr << "removing region " << region->name() << " holding = " << holding_state() << endl;
if (!holding_state()) { if (!holding_state()) {
old_length = _get_maximum_extent(); old_length = _get_maximum_extent();
@ -1155,20 +1168,21 @@ Playlist::region_changed (Change what_changed, boost::shared_ptr<Region> region)
} }
void void
Playlist::clear () Playlist::clear (bool with_signals)
{ {
RegionList::iterator i;
RegionList tmp;
{ {
RegionLock rl (this); RegionLock rl (this);
tmp = regions; for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
pending_removes.insert (*i);
}
regions.clear (); regions.clear ();
} }
for (i = tmp.begin(); i != tmp.end(); ++i) { if (with_signals) {
notify_region_removed (*i); LengthChanged ();
Modified ();
} }
} }
/*********************************************************************** /***********************************************************************
@ -1331,10 +1345,7 @@ Playlist::set_state (const XMLNode& node)
} }
} }
{ clear (false);
RegionLock rl (this);
regions.clear ();
}
nlist = node.children(); nlist = node.children();