rethink how to load legacy crossfades as new-style xfades
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 30 May 2012 19:30:38 +0000 (19:30 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 30 May 2012 19:30:38 +0000 (19:30 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@12496 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/audio_playlist.cc
libs/ardour/audioregion.cc
libs/ardour/region_factory.cc

index b157d68545eecac3cbdceb406607b9876bf2f97b..0054b6a1777c5430ce43f5b8fcc4d41d6fef4ef0 100644 (file)
@@ -669,46 +669,46 @@ AudioPlaylist::set_state (const XMLNode& node, int version)
 
                        XMLProperty* p = (*i)->property (X_("active"));
                        assert (p);
+
                        if (!string_is_affirmative (p->value())) {
                                continue;
                        }
+                       
+                       if ((p = (*i)->property (X_("in"))) == 0) {
+                               continue;
+                       }
 
-                       p = (*i)->property (X_("in"));
-                       assert (p);
                        boost::shared_ptr<Region> in = region_by_id (PBD::ID (p->value ()));
+
                        if (!in) {
                                warning << string_compose (_("Legacy crossfade involved an incoming region not present in playlist \"%1\" - crossfade discarded"),
                                                           name()) 
                                        << endmsg;
                                continue;
                        }
+
                        boost::shared_ptr<AudioRegion> in_a = boost::dynamic_pointer_cast<AudioRegion> (in);
                        assert (in_a);
+                       
+                       const XMLNodeList c = (*i)->children ();
 
-                       p = (*i)->property (X_("out"));
-                       assert (p);
-                       boost::shared_ptr<Region> out = region_by_id (PBD::ID (p->value ()));
-                       if (!in) {
-                               warning << string_compose (_("Legacy crossfade involved an outgoing region not present in playlist \"%1\" - crossfade discarded"),
-                                                          name()) 
-                                       << endmsg;
-                               continue;
-                       }
-                       boost::shared_ptr<AudioRegion> out_a = boost::dynamic_pointer_cast<AudioRegion> (out);
-                       assert (out_a);
-
-                       XMLNodeList c = (*i)->children ();
                        for (XMLNodeConstIterator j = c.begin(); j != c.end(); ++j) {
                                if ((*j)->name() == X_("FadeIn")) {
                                        in_a->fade_in()->set_state (**j, version);
-                                       in_a->set_fade_in_active (true);
-                                       in_a->set_fade_in_is_xfade (true);
                                } else if ((*j)->name() == X_("FadeOut")) {
-                                       out_a->fade_out()->set_state (**j, version);
-                                       out_a->set_fade_out_active (true);
-                                       out_a->set_fade_out_is_xfade (true);
+                                       in_a->inverse_fade_in()->set_state (**j, version);
                                }
                        }
+
+                       if ((p = (*i)->property ("follow-overlap")) != 0) {
+                               in_a->set_fade_in_is_short (!string_is_affirmative (p->value()));
+                       } else {
+                               in_a->set_fade_in_is_short (false);
+                       }
+
+                       in_a->set_fade_in_is_xfade (true);
+                       in_a->set_fade_in_active (true);
+                       cerr << in_a->name() << " from playlist fade in  = xfade false\n";
                }
        }
 
index 66b978131dab0ec908ed09127fe2888dbdcfbac6..248da959367a24ddbecf7bdde47429e0a29203c6 100644 (file)
@@ -78,14 +78,14 @@ reverse_curve (boost::shared_ptr<Evoral::ControlList> dst, boost::shared_ptr<con
        size_t len = src->back()->when;
        
        for (Evoral::ControlList::const_iterator it = src->begin(); it!=src->end(); it++) {
-               dst->add ( len - (*it)->when, (*it)->value );
+               dst->add (len - (*it)->when, (*it)->value);
        }
 }
 
 static void
 generate_inverse_power_curve (boost::shared_ptr<Evoral::ControlList> dst, boost::shared_ptr<const Evoral::ControlList> src)
 {
-       //calc inverse curve using sum of squares
+       // calc inverse curve using sum of squares
        for (Evoral::ControlList::const_iterator it = src->begin(); it!=src->end(); ++it ) {
                float value = (*it)->value;
                value = 1 - powf(value,2);
@@ -94,18 +94,6 @@ generate_inverse_power_curve (boost::shared_ptr<Evoral::ControlList> dst, boost:
        }
 }
 
-/*
-static void
-generate_inverse_coefficient_curve (boost::shared_ptr<Evoral::ControlList> dst, boost::shared_ptr<const Evoral::ControlList> src)
-{
-       //calc inverse gain coefficient curve
-       for (Evoral::ControlList::const_iterator it = src->begin(); it!=src->end(); ++it ) {
-               float value = 1.0 - (*it)->value;
-               dst->fast_simple_add ( (*it)->when, value );
-       }
-}
-*/
-
 static void
 generate_db_fade (boost::shared_ptr<Evoral::ControlList> dst, double len, int num_steps, float dB_drop)
 {
@@ -921,8 +909,6 @@ AudioRegion::_set_state (const XMLNode& node, int version, PropertyChange& what_
 
                        if ((prop = child->property ("is-xfade")) != 0) {
                                _fade_in_is_xfade = string_is_affirmative (prop->value());
-                       } else {
-                               _fade_in_is_xfade = false;
                        }
 
                } else if (child->name() == "FadeOut") {
@@ -950,8 +936,6 @@ AudioRegion::_set_state (const XMLNode& node, int version, PropertyChange& what_
 
                        if ((prop = child->property ("is-xfade")) != 0) {
                                _fade_out_is_xfade = string_is_affirmative (prop->value());
-                       } else {
-                               _fade_out_is_xfade = false;
                        }
                        
                } else if (child->name() == "InvFadeIn") {
index 2bc84f8988be23221a46f127d90ff5cd851f7054..fa948844abcf2adc224127a03b1115fc5f8eb555 100644 (file)
@@ -284,9 +284,7 @@ RegionFactory::create (SourceList& srcs, const XMLNode& node)
        if (ret) {
                if (ret->set_state (node, Stateful::loading_state_version)) {
                        ret.reset ();
-                       cerr << "set state on region failed\n";
                } else {
-                       cerr << "add region " << ret->id() << " to region map\n";
                        map_add (ret);
 
                        /* Don't fiddle with position_lock_style here as the region