X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fcrossfade.cc;h=fd59982f6200fb17745a625c50a9883c54f62e2b;hb=7d96960b162d25da87c388a3083775e8770bba56;hp=d45d5efa9fb621d762e8957ee3137edae567c373;hpb=f7f9d6fdc40248b190ec9c6e1a886261d55777ae;p=ardour.git diff --git a/libs/ardour/crossfade.cc b/libs/ardour/crossfade.cc index d45d5efa9f..fd59982f62 100644 --- a/libs/ardour/crossfade.cc +++ b/libs/ardour/crossfade.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2003-2006 Paul Davis + Copyright (C) 2003-2006 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,18 +17,17 @@ */ -#include -#include +#include "pbd/stacktrace.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include "ardour/types.h" +#include "ardour/crossfade.h" +#include "ardour/crossfade_compare.h" +#include "ardour/audioregion.h" +#include "ardour/playlist.h" +#include "ardour/utils.h" +#include "ardour/session.h" +#include "ardour/source.h" #include "i18n.h" #include @@ -51,15 +50,11 @@ Sample* Crossfade::crossfade_buffer_in = 0; void Crossfade::set_buffer_size (nframes_t sz) { - if (crossfade_buffer_out) { - delete [] crossfade_buffer_out; - crossfade_buffer_out = 0; - } + delete [] crossfade_buffer_out; + crossfade_buffer_out = 0; - if (crossfade_buffer_in) { - delete [] crossfade_buffer_in; - crossfade_buffer_in = 0; - } + delete [] crossfade_buffer_in; + crossfade_buffer_in = 0; if (sz) { crossfade_buffer_out = new Sample[sz]; @@ -73,34 +68,34 @@ Crossfade::operator== (const Crossfade& other) return (_in == other._in) && (_out == other._out); } -Crossfade::Crossfade (boost::shared_ptr in, boost::shared_ptr out, +Crossfade::Crossfade (boost::shared_ptr in, boost::shared_ptr out, nframes_t length, nframes_t position, AnchorPoint ap) - : AudioRegion (in->session(), position, length, "foobar"), - _fade_in (Parameter(FadeInAutomation), 0.0, 2.0, 1.0), // linear (gain coefficient) => -inf..+6dB - _fade_out (Parameter(FadeOutAutomation), 0.0, 2.0, 1.0) // linear (gain coefficient) => -inf..+6dB + : AudioRegion (in->session(), position, length, in->name() + string ("<>") + out->name()), + _fade_in (Evoral::Parameter(FadeInAutomation)), // linear (gain coefficient) => -inf..+6dB + _fade_out (Evoral::Parameter(FadeOutAutomation)) // linear (gain coefficient) => -inf..+6dB { _in = in; _out = out; - _anchor_point = ap; _follow_overlap = false; - _active = Config->get_xfades_active (); + _active = _session.config.get_xfades_active (); _fixed = true; initialize (); } Crossfade::Crossfade (boost::shared_ptr a, boost::shared_ptr b, CrossfadeModel model, bool act) - : AudioRegion (a->session(), 0, 0, "foobar"), - _fade_in (Parameter(FadeInAutomation), 0.0, 2.0, 1.0), // linear (gain coefficient) => -inf..+6dB - _fade_out (Parameter(FadeOutAutomation), 0.0, 2.0, 1.0) // linear (gain coefficient) => -inf..+6dB + : AudioRegion (a->session(), 0, 0, a->name() + string ("<>") + b->name()), + _fade_in (Evoral::Parameter(FadeInAutomation)), // linear (gain coefficient) => -inf..+6dB + _fade_out (Evoral::Parameter(FadeOutAutomation)) // linear (gain coefficient) => -inf..+6dB { _in_update = false; _fixed = false; + _follow_overlap = false; if (compute (a, b, model)) { throw failed_constructor(); @@ -109,14 +104,12 @@ Crossfade::Crossfade (boost::shared_ptr a, boost::shared_ptr -inf..+6dB - _fade_out (Parameter(FadeOutAutomation), 0.0, 2.0, 1.0) // linear (gain coefficient) => -inf..+6dB + : AudioRegion (playlist.session(), 0, 0, "unnamed crossfade"), + _fade_in (Evoral::Parameter(FadeInAutomation)), // linear (gain coefficient) => -inf..+6dB + _fade_out (Evoral::Parameter(FadeOutAutomation)) // linear (gain coefficient) => -inf..+6dB { boost::shared_ptr r; @@ -129,7 +122,7 @@ Crossfade::Crossfade (const Playlist& playlist, XMLNode& node) error << _("Crossfade: no \"in\" region in state") << endmsg; throw failed_constructor(); } - + PBD::ID id (prop->value()); if ((r = playlist.find_region (id)) == 0) { @@ -137,7 +130,7 @@ Crossfade::Crossfade (const Playlist& playlist, XMLNode& node) << endmsg; throw failed_constructor(); } - + if ((_in = boost::dynamic_pointer_cast (r)) == 0) { throw failed_constructor(); } @@ -154,15 +147,16 @@ Crossfade::Crossfade (const Playlist& playlist, XMLNode& node) << endmsg; throw failed_constructor(); } - + if ((_out = boost::dynamic_pointer_cast (r)) == 0) { throw failed_constructor(); } _length = 0; initialize(); - - if (set_state (node)) { + _active = true; + + if (set_state (node, Stateful::loading_state_version)) { throw failed_constructor(); } } @@ -177,13 +171,13 @@ Crossfade::Crossfade (boost::shared_ptr orig, boost::shared_ptr