diff options
author | David Robillard <d@drobilla.net> | 2009-02-19 19:42:25 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-02-19 19:42:25 +0000 |
commit | 75c15679bf1551dcb93d4fa62075517c66d3b222 (patch) | |
tree | 8a101d994120ee09c3560aebe99b7e565a137d1f | |
parent | c006ff176250a01621437907652ef012789dba2f (diff) |
Only create a Curve for an AutomationList if we need it.
Fix crash on crossfade editor show (ticket 2442).
git-svn-id: svn://localhost/ardour2/branches/3.0@4641 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | gtk2_ardour/audio_region_view.cc | 2 | ||||
-rw-r--r-- | gtk2_ardour/crossfade_edit.cc | 11 | ||||
-rw-r--r-- | gtk2_ardour/crossfade_edit.h | 3 | ||||
-rw-r--r-- | libs/ardour/ardour/automation_list.h | 1 | ||||
-rw-r--r-- | libs/ardour/ardour/session.h | 1 | ||||
-rw-r--r-- | libs/ardour/audio_track.cc | 2 | ||||
-rw-r--r-- | libs/ardour/audioregion.cc | 2 | ||||
-rw-r--r-- | libs/ardour/automation_list.cc | 28 | ||||
-rw-r--r-- | libs/ardour/panner.cc | 2 | ||||
-rw-r--r-- | libs/ardour/route.cc | 2 | ||||
-rw-r--r-- | libs/ardour/session_command.cc | 1 | ||||
-rw-r--r-- | libs/evoral/evoral/ControlList.hpp | 9 | ||||
-rw-r--r-- | libs/evoral/src/ControlList.cpp | 24 |
13 files changed, 69 insertions, 19 deletions
diff --git a/gtk2_ardour/audio_region_view.cc b/gtk2_ardour/audio_region_view.cc index 4ec3531000..6af8496e9b 100644 --- a/gtk2_ardour/audio_region_view.cc +++ b/gtk2_ardour/audio_region_view.cc @@ -33,6 +33,8 @@ #include <pbd/memento_command.h> #include <pbd/stacktrace.h> +#include <evoral/Curve.hpp> + #include "streamview.h" #include "audio_region_view.h" #include "audio_time_axis.h" diff --git a/gtk2_ardour/crossfade_edit.cc b/gtk2_ardour/crossfade_edit.cc index eb5cb2fba9..f6a0d7e1f7 100644 --- a/gtk2_ardour/crossfade_edit.cc +++ b/gtk2_ardour/crossfade_edit.cc @@ -66,10 +66,9 @@ CrossfadeEditor::Presets* CrossfadeEditor::fade_in_presets = 0; CrossfadeEditor::Presets* CrossfadeEditor::fade_out_presets = 0; CrossfadeEditor::Half::Half () - : line (0), - //normative_curve (Evoral::Parameter(GainAutomation, 0.0, 1.0, 1.0)), // FIXME: GainAutomation? - normative_curve (Evoral::Parameter(GainAutomation)), - gain_curve (Evoral::Parameter(GainAutomation)) + : line (0) + , normative_curve (Evoral::Parameter(GainAutomation)) + , gain_curve (Evoral::Parameter(GainAutomation)) { } @@ -726,7 +725,7 @@ CrossfadeEditor::redraw () fade[current].shading->property_points() = spts; for (vector<ArdourCanvas::WaveView*>::iterator i = fade[current].waves.begin(); i != fade[current].waves.end(); ++i) { - (*i)->property_gain_src() = &fade[current].gain_curve; + (*i)->property_gain_src() = static_cast<Evoral::Curve*>(&fade[current].gain_curve.curve()); } } @@ -1124,7 +1123,7 @@ CrossfadeEditor::make_waves (boost::shared_ptr<AudioRegion> region, WhichFade wh waveview->property_sourcefile_length_function() = (void*) sourcefile_length_from_c; waveview->property_peak_function() = (void*) region_read_peaks_from_c; waveview->property_gain_function() = (void*) curve_get_vector_from_c; - waveview->property_gain_src() = &fade[which].gain_curve; + waveview->property_gain_src() = static_cast<Evoral::Curve*>(&fade[which].gain_curve.curve()); waveview->property_x() = canvas_border; waveview->property_y() = yoff; waveview->property_height() = ht; diff --git a/gtk2_ardour/crossfade_edit.h b/gtk2_ardour/crossfade_edit.h index f7f607393f..685dc43772 100644 --- a/gtk2_ardour/crossfade_edit.h +++ b/gtk2_ardour/crossfade_edit.h @@ -96,8 +96,7 @@ class CrossfadeEditor : public ArdourDialog void move_to (double x, double y, double xfract, double yfract); }; - struct PointSorter - { + struct PointSorter { bool operator() (const CrossfadeEditor::Point* a, const CrossfadeEditor::Point *b) { return a->x < b->x; } diff --git a/libs/ardour/ardour/automation_list.h b/libs/ardour/ardour/automation_list.h index 923967448c..7ede9f019a 100644 --- a/libs/ardour/ardour/automation_list.h +++ b/libs/ardour/ardour/automation_list.h @@ -85,6 +85,7 @@ class AutomationList : public PBD::StatefulDestructible, public Evoral::ControlL XMLNode& serialize_events (); private: + void create_curve_if_necessary (); int deserialize_events (const XMLNode&); void maybe_signal_changed (); diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 23155c7ab1..b42699d964 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -703,7 +703,6 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable sigc::signal<void> NamedSelectionRemoved; /* Curves and AutomationLists (TODO when they go away) */ - void add_curve(Evoral::Curve*); void add_automation_list(AutomationList*); /* fade curves */ diff --git a/libs/ardour/audio_track.cc b/libs/ardour/audio_track.cc index 104815b9dc..df648bc055 100644 --- a/libs/ardour/audio_track.cc +++ b/libs/ardour/audio_track.cc @@ -24,6 +24,8 @@ #include <pbd/error.h> #include <pbd/enumwriter.h> +#include <evoral/Curve.hpp> + #include <ardour/audio_track.h> #include <ardour/audio_diskstream.h> #include <ardour/session.h> diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index 1559827b42..e48f2ae586 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -35,6 +35,8 @@ #include <pbd/enumwriter.h> #include <pbd/convert.h> +#include <evoral/Curve.hpp> + #include <ardour/audioregion.h> #include <ardour/session.h> #include <ardour/gain.h> diff --git a/libs/ardour/automation_list.cc b/libs/ardour/automation_list.cc index 0066e71c3c..7493df26ac 100644 --- a/libs/ardour/automation_list.cc +++ b/libs/ardour/automation_list.cc @@ -50,7 +50,6 @@ static void dumpit (const AutomationList& al, string prefix = "") } #endif -/* XXX: min_val max_val redundant? (param.min() param.max()) */ AutomationList::AutomationList (Evoral::Parameter id) : ControlList(id) { @@ -58,6 +57,8 @@ AutomationList::AutomationList (Evoral::Parameter id) _style = Absolute; _touching = false; + create_curve_if_necessary(); + assert(_parameter.type() != NullAutomation); AutomationListCreated(this); } @@ -69,6 +70,8 @@ AutomationList::AutomationList (const AutomationList& other) _state = other._state; _touching = other._touching; + create_curve_if_necessary(); + assert(_parameter.type() != NullAutomation); AutomationListCreated(this); } @@ -79,6 +82,8 @@ AutomationList::AutomationList (const AutomationList& other, double start, doubl _style = other._style; _state = other._state; _touching = other._touching; + + create_curve_if_necessary(); assert(_parameter.type() != NullAutomation); AutomationListCreated(this); @@ -96,8 +101,11 @@ AutomationList::AutomationList (const XMLNode& node, Evoral::Parameter id) set_state (node); - if (id) + if (id) { _parameter = id; + } + + create_curve_if_necessary(); assert(_parameter.type() != NullAutomation); AutomationListCreated(this); @@ -114,6 +122,22 @@ AutomationList::create(Evoral::Parameter id) return boost::shared_ptr<Evoral::ControlList>(new AutomationList(id)); } +void +AutomationList::create_curve_if_necessary() +{ + switch (_parameter.type()) { + case GainAutomation: + case PanAutomation: + case FadeInAutomation: + case FadeOutAutomation: + case EnvelopeAutomation: + create_curve(); + break; + default: + break; + } +} + bool AutomationList::operator== (const AutomationList& other) { diff --git a/libs/ardour/panner.cc b/libs/ardour/panner.cc index b7dfd79068..0bd40d9e45 100644 --- a/libs/ardour/panner.cc +++ b/libs/ardour/panner.cc @@ -37,6 +37,8 @@ #include <pbd/xml++.h> #include <pbd/enumwriter.h> +#include <evoral/Curve.hpp> + #include <ardour/session.h> #include <ardour/panner.h> #include <ardour/utils.h> diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index ea2a472495..a80ceb70ef 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -27,6 +27,8 @@ #include <pbd/stacktrace.h> #include <pbd/memento_command.h> +#include <evoral/Curve.hpp> + #include <ardour/timestamps.h> #include <ardour/audioengine.h> #include <ardour/route.h> diff --git a/libs/ardour/session_command.cc b/libs/ardour/session_command.cc index bb51d51c43..bedbe7211f 100644 --- a/libs/ardour/session_command.cc +++ b/libs/ardour/session_command.cc @@ -35,6 +35,7 @@ #include <pbd/id.h> #include <pbd/statefuldestructible.h> #include <pbd/failed_constructor.h> +#include <evoral/Curve.hpp> using namespace PBD; using namespace ARDOUR; diff --git a/libs/evoral/evoral/ControlList.hpp b/libs/evoral/evoral/ControlList.hpp index 70488b60be..c9f791ec17 100644 --- a/libs/evoral/evoral/ControlList.hpp +++ b/libs/evoral/evoral/ControlList.hpp @@ -25,10 +25,10 @@ #include <glibmm/thread.h> #include "evoral/types.hpp" #include "evoral/Parameter.hpp" -#include "evoral/Curve.hpp" namespace Evoral { +class Curve; /** A single event (time-stamped value) for a control */ @@ -216,8 +216,11 @@ public: bool rt_safe_earliest_event (double start, double end, double& x, double& y, bool start_inclusive=false) const; bool rt_safe_earliest_event_unlocked (double start, double end, double& x, double& y, bool start_inclusive=false) const; - Curve& curve() { return *_curve; } - const Curve& curve() const { return *_curve; } + void create_curve(); + void destroy_curve(); + + Curve& curve() { assert(_curve); return *_curve; } + const Curve& curve() const { assert(_curve); return *_curve; } virtual void mark_dirty () const; diff --git a/libs/evoral/src/ControlList.cpp b/libs/evoral/src/ControlList.cpp index 0677c622ee..dee0242143 100644 --- a/libs/evoral/src/ControlList.cpp +++ b/libs/evoral/src/ControlList.cpp @@ -21,6 +21,7 @@ #include <utility> #include <iostream> #include "evoral/ControlList.hpp" +#include "evoral/Curve.hpp" using namespace std; @@ -36,7 +37,7 @@ inline bool event_time_less_than (ControlEvent* a, ControlEvent* b) ControlList::ControlList (const Parameter& id) : _parameter(id) , _interpolation(Linear) - , _curve(new Curve(*this)) + , _curve(0) { _frozen = 0; _changed_when_thawed = false; @@ -54,7 +55,7 @@ ControlList::ControlList (const Parameter& id) ControlList::ControlList (const ControlList& other) : _parameter(other._parameter) , _interpolation(Linear) - , _curve(new Curve(*this)) + , _curve(0) { _frozen = 0; _changed_when_thawed = false; @@ -70,14 +71,14 @@ ControlList::ControlList (const ControlList& other) for (const_iterator i = other._events.begin(); i != other._events.end(); ++i) { _events.push_back (new ControlEvent (**i)); } - + mark_dirty (); } ControlList::ControlList (const ControlList& other, double start, double end) : _parameter(other._parameter) , _interpolation(Linear) - , _curve(new Curve(*this)) + , _curve(0) { _frozen = 0; _changed_when_thawed = false; @@ -99,7 +100,7 @@ ControlList::ControlList (const ControlList& other, double start, double end) _events.push_back (new ControlEvent ((*i)->when, (*i)->value)); } } - + mark_dirty (); } @@ -148,6 +149,19 @@ ControlList::operator= (const ControlList& other) } void +ControlList::create_curve() +{ + _curve = new Curve(*this); +} + +void +ControlList::destroy_curve() +{ + delete _curve; + _curve = NULL; +} + +void ControlList::maybe_signal_changed () { mark_dirty (); |