diff options
Diffstat (limited to 'libs/ardour/ardour')
-rw-r--r-- | libs/ardour/ardour/audioregion.h | 22 | ||||
-rw-r--r-- | libs/ardour/ardour/automatable.h | 48 | ||||
-rw-r--r-- | libs/ardour/ardour/automation_event.h | 170 | ||||
-rw-r--r-- | libs/ardour/ardour/crossfade.h | 8 | ||||
-rw-r--r-- | libs/ardour/ardour/curve.h | 36 | ||||
-rw-r--r-- | libs/ardour/ardour/gain.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/io.h | 34 | ||||
-rw-r--r-- | libs/ardour/ardour/ladspa_plugin.h | 4 | ||||
-rw-r--r-- | libs/ardour/ardour/panner.h | 14 | ||||
-rw-r--r-- | libs/ardour/ardour/param_id.h | 137 | ||||
-rw-r--r-- | libs/ardour/ardour/plugin.h | 7 | ||||
-rw-r--r-- | libs/ardour/ardour/plugin_insert.h | 16 | ||||
-rw-r--r-- | libs/ardour/ardour/types.h | 10 |
13 files changed, 324 insertions, 184 deletions
diff --git a/libs/ardour/ardour/audioregion.h b/libs/ardour/ardour/audioregion.h index f844d45ef1..db763876b0 100644 --- a/libs/ardour/ardour/audioregion.h +++ b/libs/ardour/ardour/audioregion.h @@ -67,9 +67,9 @@ class AudioRegion : public Region bool fade_in_active () const { return _flags & Region::FadeIn; } bool fade_out_active () const { return _flags & Region::FadeOut; } - Curve& fade_in() { return _fade_in; } - Curve& fade_out() { return _fade_out; } - Curve& envelope() { return _envelope; } + AutomationList& fade_in() { return _fade_in; } + AutomationList& fade_out() { return _fade_out; } + AutomationList& envelope() { return _envelope; } virtual nframes_t read_peaks (PeakData *buf, nframes_t npeaks, nframes_t offset, nframes_t cnt, @@ -162,14 +162,14 @@ class AudioRegion : public Region void source_offset_changed (); void listen_to_my_curves (); - mutable Curve _fade_in; - FadeShape _fade_in_shape; - mutable Curve _fade_out; - FadeShape _fade_out_shape; - mutable Curve _envelope; - gain_t _scale_amplitude; - uint32_t _fade_in_disabled; - uint32_t _fade_out_disabled; + mutable AutomationList _fade_in; + FadeShape _fade_in_shape; + mutable AutomationList _fade_out; + FadeShape _fade_out_shape; + mutable AutomationList _envelope; + gain_t _scale_amplitude; + uint32_t _fade_in_disabled; + uint32_t _fade_out_disabled; protected: /* default constructor for derived (compound) types */ diff --git a/libs/ardour/ardour/automatable.h b/libs/ardour/ardour/automatable.h index c6621b9780..f6d6d86ed0 100644 --- a/libs/ardour/ardour/automatable.h +++ b/libs/ardour/ardour/automatable.h @@ -24,6 +24,7 @@ #include <map> #include <ardour/session_object.h> #include <ardour/automation_event.h> +#include <ardour/param_id.h> namespace ARDOUR { @@ -36,28 +37,46 @@ public: virtual ~Automatable() {} - virtual AutomationList& automation_list(uint32_t n); + // shorthand for gain, pan, etc + inline AutomationList* automation_list(AutomationType type, bool create_if_missing=false) { + return automation_list(ParamID(type), create_if_missing); + } - virtual void automation_snapshot (nframes_t now) {}; + virtual AutomationList* automation_list(ParamID id, bool create_if_missing=false); + virtual const AutomationList* automation_list(ParamID id) const; + + virtual void add_automation_parameter(AutomationList* al); + + virtual void automation_snapshot(nframes_t now) {}; virtual bool find_next_event(nframes_t start, nframes_t end, ControlEvent& ev) const; - virtual string describe_parameter(uint32_t which); - virtual float default_parameter_value(uint32_t which) { return 1.0f; } + virtual string describe_parameter(ParamID param); + virtual float default_parameter_value(ParamID param) { return 1.0f; } + + virtual void clear_automation(); + + AutoState get_parameter_automation_state (ParamID param); + virtual void set_parameter_automation_state (ParamID param, AutoState); + + AutoStyle get_parameter_automation_style (ParamID param); + void set_parameter_automation_style (ParamID param, AutoStyle); + + void protect_automation (); - void what_has_automation(std::set<uint32_t>&) const; - void what_has_visible_automation(std::set<uint32_t>&) const; - const std::set<uint32_t>& what_can_be_automated() const { return _can_automate_list; } + void what_has_automation(std::set<ParamID>&) const; + void what_has_visible_automation(std::set<ParamID>&) const; + const std::set<ParamID>& what_can_be_automated() const { return _can_automate_list; } - void mark_automation_visible(uint32_t, bool); + void mark_automation_visible(ParamID, bool); protected: - void can_automate(uint32_t); + void can_automate(ParamID); - virtual void automation_list_creation_callback(uint32_t, AutomationList&) {} + virtual void automation_list_creation_callback(ParamID, AutomationList&) {} - int set_automation_state(const XMLNode&); + int set_automation_state(const XMLNode&, ParamID default_param); XMLNode& get_automation_state(); int load_automation (const std::string& path); @@ -65,10 +84,9 @@ protected: mutable Glib::Mutex _automation_lock; - // FIXME: map with int keys is a bit silly. this could be O(1) - std::map<uint32_t,AutomationList*> _parameter_automation; - std::set<uint32_t> _visible_parameter_automation; - std::set<uint32_t> _can_automate_list; + std::map<ParamID,AutomationList*> _parameter_automation; + std::set<ParamID> _visible_parameter_automation; + std::set<ParamID> _can_automate_list; nframes_t _last_automation_snapshot; }; diff --git a/libs/ardour/ardour/automation_event.h b/libs/ardour/ardour/automation_event.h index f04dcdc112..af1a3cb704 100644 --- a/libs/ardour/ardour/automation_event.h +++ b/libs/ardour/ardour/automation_event.h @@ -32,35 +32,39 @@ #include <pbd/statefuldestructible.h> #include <ardour/ardour.h> +#include <ardour/param_id.h> namespace ARDOUR { - + +class Curve; + struct ControlEvent { - double when; - double value; - + ControlEvent (double w, double v) - : when (w), value (v) { } - ControlEvent (const ControlEvent& other) - : when (other.when), value (other.value) {} + : when (w), value (v) { + coeff[0] = coeff[1] = coeff[2] = coeff[3] = 0.0; + } - virtual ~ControlEvent() {} + ControlEvent (const ControlEvent& other) + : when (other.when), value (other.value) { + coeff[0] = coeff[1] = coeff[2] = coeff[3] = 0.0; + } -// bool operator==(const ControlEvent& other) { -// return value == other.value && when == other.when; -// } - + double when; + double value; + double coeff[4]; ///< Used by Curve }; + class AutomationList : public PBD::StatefulDestructible { public: - typedef std::list<ControlEvent*> AutomationEventList; - typedef AutomationEventList::iterator iterator; - typedef AutomationEventList::const_iterator const_iterator; + typedef std::list<ControlEvent*> EventList; + typedef EventList::iterator iterator; + typedef EventList::const_iterator const_iterator; - AutomationList (double default_value); - AutomationList (const XMLNode&); + AutomationList (ParamID id, double min_val, double max_val, double default_val); + AutomationList (const XMLNode&, ParamID id); ~AutomationList(); AutomationList (const AutomationList&); @@ -68,14 +72,17 @@ class AutomationList : public PBD::StatefulDestructible AutomationList& operator= (const AutomationList&); bool operator== (const AutomationList&); + ParamID param_id() const { return _param_id; } + void set_param_id(ParamID id) { _param_id = id; } + void freeze(); void thaw (); - AutomationEventList::size_type size() const { return events.size(); } - bool empty() const { return events.empty(); } + EventList::size_type size() const { return _events.size(); } + bool empty() const { return _events.empty(); } void reset_default (double val) { - default_value = val; + _default_value = val; } void clear (); @@ -111,7 +118,7 @@ class AutomationList : public PBD::StatefulDestructible sigc::signal<void> automation_style_changed; void set_automation_style (AutoStyle m); - AutoStyle automation_style() const { return _style; } + AutoStyle automation_style() const { return _style; } sigc::signal<void> automation_state_changed; bool automation_playback() const { @@ -126,29 +133,29 @@ class AutomationList : public PBD::StatefulDestructible bool touching() const { return _touching; } void set_yrange (double min, double max) { - min_yval = min; - max_yval = max; + _min_yval = min; + _max_yval = max; } - double get_max_y() const { return max_yval; } - double get_min_y() const { return min_yval; } + double get_max_y() const { return _max_yval; } + double get_min_y() const { return _min_yval; } void truncate_end (double length); void truncate_start (double length); - iterator begin() { return events.begin(); } - iterator end() { return events.end(); } + iterator begin() { return _events.begin(); } + iterator end() { return _events.end(); } - ControlEvent* back() { return events.back(); } - ControlEvent* front() { return events.front(); } + ControlEvent* back() { return _events.back(); } + ControlEvent* front() { return _events.front(); } - const_iterator const_begin() const { return events.begin(); } - const_iterator const_end() const { return events.end(); } + const_iterator const_begin() const { return _events.begin(); } + const_iterator const_end() const { return _events.end(); } std::pair<AutomationList::iterator,AutomationList::iterator> control_points_adjacent (double when); template<class T> void apply_to_points (T& obj, void (T::*method)(const AutomationList&)) { - Glib::Mutex::Lock lm (lock); + Glib::Mutex::Lock lm (_lock); (obj.*method)(*this); } @@ -160,16 +167,16 @@ class AutomationList : public PBD::StatefulDestructible XMLNode& serialize_events (); void set_max_xval (double); - double get_max_xval() const { return max_xval; } + double get_max_xval() const { return _max_xval; } double eval (double where) { - Glib::Mutex::Lock lm (lock); + Glib::Mutex::Lock lm (_lock); return unlocked_eval (where); } double rt_safe_eval (double where, bool& ok) { - Glib::Mutex::Lock lm (lock, Glib::TRY_LOCK); + Glib::Mutex::Lock lm (_lock, Glib::TRY_LOCK); if ((ok = lm.locked())) { return unlocked_eval (where); @@ -183,65 +190,66 @@ class AutomationList : public PBD::StatefulDestructible return a->when < b->when; } }; - - static sigc::signal<void, AutomationList*> AutomationListCreated; - - protected: - - AutomationEventList events; - mutable Glib::Mutex lock; - int8_t _frozen; - bool changed_when_thawed; - bool _dirty; - + struct LookupCache { double left; /* leftmost x coordinate used when finding "range" */ - std::pair<AutomationList::iterator,AutomationList::iterator> range; + std::pair<AutomationList::const_iterator,AutomationList::const_iterator> range; }; - mutable LookupCache lookup_cache; - - AutoState _state; - AutoStyle _style; - bool _touching; - bool _new_touch; - double max_xval; - double min_yval; - double max_yval; - double default_value; - bool sort_pending; - - iterator rt_insertion_point; - double rt_pos; - - void maybe_signal_changed (); - void mark_dirty (); - void _x_scale (double factor); - - /* called by type-specific unlocked_eval() to handle - common case of 0, 1 or 2 control points. - */ + static sigc::signal<void, AutomationList*> AutomationListCreated; - double shared_eval (double x); + const EventList& events() const { return _events; } + double default_value() const { return _default_value; } - /* called by shared_eval() to handle any case of - 3 or more control points. - */ - - virtual double multipoint_eval (double x); + // teeny const violations for Curve + mutable sigc::signal<void> Dirty; + Glib::Mutex& lock() const { return _lock; } + LookupCache& lookup_cache() const { return _lookup_cache; } + + /** Called by locked entry point and various private + * locations where we already hold the lock. + * + * FIXME: Should this be private? Curve needs it.. + */ + double unlocked_eval (double x) const; - /* called by locked entry point and various private - locations where we already hold the lock. - */ + Curve& curve() { return *_curve; } + const Curve& curve() const { return *_curve; } - virtual double unlocked_eval (double where); + protected: - virtual ControlEvent* point_factory (double,double) const; - virtual ControlEvent* point_factory (const ControlEvent&) const; + /** Called by unlocked_eval() to handle cases of 3 or more control points. + */ + virtual double multipoint_eval (double x) const; AutomationList* cut_copy_clear (double, double, int op); int deserialize_events (const XMLNode&); + + void maybe_signal_changed (); + void mark_dirty (); + void _x_scale (double factor); + + mutable LookupCache _lookup_cache; + + ParamID _param_id; + EventList _events; + mutable Glib::Mutex _lock; + int8_t _frozen; + bool _changed_when_thawed; + AutoState _state; + AutoStyle _style; + bool _touching; + bool _new_touch; + double _max_xval; + double _min_yval; + double _max_yval; + double _default_value; + bool _sort_pending; + iterator _rt_insertion_point; + double _rt_pos; + + Curve* _curve; }; } // namespace diff --git a/libs/ardour/ardour/crossfade.h b/libs/ardour/ardour/crossfade.h index 61a30f1c0f..78a137bde3 100644 --- a/libs/ardour/ardour/crossfade.h +++ b/libs/ardour/ardour/crossfade.h @@ -124,8 +124,8 @@ class Crossfade : public ARDOUR::AudioRegion bool can_follow_overlap() const; void set_follow_overlap (bool yn); - Curve& fade_in() { return _fade_in; } - Curve& fade_out() { return _fade_out; } + AutomationList& fade_in() { return _fade_in; } + AutomationList& fade_out() { return _fade_out; } nframes_t set_length (nframes_t); @@ -157,8 +157,8 @@ class Crossfade : public ARDOUR::AudioRegion int32_t layer_relation; - mutable Curve _fade_in; - mutable Curve _fade_out; + mutable AutomationList _fade_in; + mutable AutomationList _fade_out; static Sample* crossfade_buffer_out; static Sample* crossfade_buffer_in; diff --git a/libs/ardour/ardour/curve.h b/libs/ardour/ardour/curve.h index 605eda2e4b..b96bb5c78e 100644 --- a/libs/ardour/ardour/curve.h +++ b/libs/ardour/ardour/curve.h @@ -30,50 +30,30 @@ namespace ARDOUR { -struct CurvePoint : public ControlEvent -{ - double coeff[4]; - - CurvePoint (double w, double v) - : ControlEvent (w, v) { - - coeff[0] = coeff[1] = coeff[2] = coeff[3] = 0.0; - } - - ~CurvePoint() {} -}; - -class Curve : public AutomationList +class Curve { public: - Curve (double min_yval, double max_yval, double defaultvalue, bool nostate = false); + Curve (const AutomationList& al); ~Curve (); Curve (const Curve& other); - Curve (const Curve& other, double start, double end); - Curve (const XMLNode&); + //Curve (const Curve& other, double start, double end); + /*Curve (const XMLNode&, ParamID id);*/ bool rt_safe_get_vector (double x0, double x1, float *arg, int32_t veclen); void get_vector (double x0, double x1, float *arg, int32_t veclen); - AutomationEventList::iterator closest_control_point_before (double xval); - AutomationEventList::iterator closest_control_point_after (double xval); - void solve (); - static sigc::signal<void, Curve*> CurveCreated; - - protected: - ControlEvent* point_factory (double,double) const; - ControlEvent* point_factory (const ControlEvent&) const; - private: - AutomationList::iterator last_bound; - double unlocked_eval (double where); double multipoint_eval (double x); void _get_vector (double x0, double x1, float *arg, int32_t veclen); + const AutomationList& _list; + + void on_list_dirty() { _dirty = true; } + bool _dirty; }; } // namespace ARDOUR diff --git a/libs/ardour/ardour/gain.h b/libs/ardour/ardour/gain.h index 5832f71101..e57cfdc0d7 100644 --- a/libs/ardour/ardour/gain.h +++ b/libs/ardour/ardour/gain.h @@ -25,7 +25,7 @@ namespace ARDOUR { -struct Gain : public Curve { +struct Gain : public AutomationList { Gain(); Gain (const Gain&); diff --git a/libs/ardour/ardour/io.h b/libs/ardour/ardour/io.h index 3952d14c0e..1592ac7cac 100644 --- a/libs/ardour/ardour/io.h +++ b/libs/ardour/ardour/io.h @@ -34,7 +34,7 @@ #include <pbd/controllable.h> #include <ardour/ardour.h> -#include <ardour/session_object.h> +#include <ardour/automatable.h> #include <ardour/utils.h> #include <ardour/curve.h> #include <ardour/types.h> @@ -64,9 +64,8 @@ class BufferSet; * An IO can contain ports of varying types, making routes/inserts/etc with * varied combinations of types (eg MIDI and audio) possible. */ -class IO : public SessionObject +class IO : public Automatable { - public: static const string state_node_name; @@ -227,22 +226,15 @@ class IO : public SessionObject } void clear_automation (); - - virtual void set_gain_automation_state (AutoState); - AutoState gain_automation_state() const { return _gain_automation_curve.automation_state(); } - //sigc::signal<void> gain_automation_state_changed; - - virtual void set_gain_automation_style (AutoStyle); - AutoStyle gain_automation_style () const { return _gain_automation_curve.automation_style(); } - //sigc::signal<void> gain_automation_style_changed; + + void set_parameter_automation_state (ParamID, AutoState); virtual void transport_stopped (nframes_t now); // interface: matches Insert void automation_snapshot (nframes_t now); // interface: matches Automatable - ARDOUR::Curve& gain_automation_curve () { return _gain_automation_curve; } - - void start_gain_touch (); - void end_gain_touch (); + // FIXME: these will probably become unsafe in the near future + ARDOUR::AutomationList& gain_automation() { return *automation_list(GainAutomation); } + const ARDOUR::AutomationList& gain_automation() const { return *automation_list(GainAutomation); } void start_pan_touch (uint32_t which); void end_pan_touch (uint32_t which); @@ -299,16 +291,12 @@ class IO : public SessionObject nframes_t last_automation_snapshot; static nframes_t _automation_interval; - AutoState _gain_automation_state; - AutoStyle _gain_automation_style; + /*AutoState _gain_automation_state; + AutoStyle _gain_automation_style;*/ - bool apply_gain_automation; - Curve _gain_automation_curve; + bool apply_gain_automation; + //Curve _gain_automation_curve; - Glib::Mutex automation_lock; - - virtual int set_automation_state (const XMLNode&); - virtual XMLNode& get_automation_state (); virtual int load_automation (std::string path); /* AudioTrack::deprecated_use_diskstream_connections() needs these */ diff --git a/libs/ardour/ardour/ladspa_plugin.h b/libs/ardour/ardour/ladspa_plugin.h index f1f1bb8811..5c15632391 100644 --- a/libs/ardour/ardour/ladspa_plugin.h +++ b/libs/ardour/ardour/ladspa_plugin.h @@ -63,7 +63,7 @@ class LadspaPlugin : public ARDOUR::Plugin void set_parameter (uint32_t port, float val); float get_parameter (uint32_t port) const; int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const; - std::set<uint32_t> automatable() const; + std::set<ParamID> automatable() const; uint32_t nth_parameter (uint32_t port, bool& ok) const; void activate () { if (descriptor->activate) { @@ -85,7 +85,7 @@ class LadspaPlugin : public ARDOUR::Plugin int connect_and_run (BufferSet& bufs, uint32_t& in, uint32_t& out, nframes_t nframes, nframes_t offset); void store_state (ARDOUR::PluginState&); void restore_state (ARDOUR::PluginState&); - string describe_parameter (uint32_t); + string describe_parameter (ParamID); string state_node_name() const { return "ladspa"; } void print_parameter (uint32_t, char*, uint32_t len) const; diff --git a/libs/ardour/ardour/panner.h b/libs/ardour/ardour/panner.h index 0e5ab68525..af3cda94e2 100644 --- a/libs/ardour/ardour/panner.h +++ b/libs/ardour/ardour/panner.h @@ -81,8 +81,9 @@ class StreamPanner : public sigc::trackable, public PBD::Stateful /* XXX this is wrong. for multi-dimensional panners, there must surely be more than 1 automation curve. */ + /* TODO: Panner is-a Automation solves this */ - virtual Curve& automation() = 0; + virtual AutomationList& automation() = 0; sigc::signal<void> Changed; /* for position */ sigc::signal<void> StateChanged; /* for mute */ @@ -149,7 +150,8 @@ class BaseStereoPanner : public StreamPanner void set_automation_state (AutoState); void set_automation_style (AutoStyle); - Curve& automation() { return _automation; } + /* TODO: StreamPanner is-a Automatable? */ + AutomationList& automation() { return _automation; } /* old school automation loading */ @@ -163,7 +165,7 @@ class BaseStereoPanner : public StreamPanner float left_interp; float right_interp; - Curve _automation; + AutomationList _automation; }; class EqualPowerStereoPanner : public BaseStereoPanner @@ -203,8 +205,10 @@ class Multi2dPanner : public StreamPanner /* XXX this is wrong. for multi-dimensional panners, there must surely be more than 1 automation curve. */ + + /* TODO: StreamPanner is-a Automatable? */ - Curve& automation() { return _automation; } + AutomationList& automation() { return _automation; } void distribute (AudioBuffer& src, BufferSet& obufs, gain_t gain_coeff, nframes_t nframes); void distribute_automated (AudioBuffer& src, BufferSet& obufs, @@ -222,7 +226,7 @@ class Multi2dPanner : public StreamPanner int load (istream&, string path, uint32_t&); private: - Curve _automation; + AutomationList _automation; void update (); }; diff --git a/libs/ardour/ardour/param_id.h b/libs/ardour/ardour/param_id.h new file mode 100644 index 0000000000..eb5563b06d --- /dev/null +++ b/libs/ardour/ardour/param_id.h @@ -0,0 +1,137 @@ +/* + Copyright (C) 2007 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 the Free + Software Foundation; either version 2 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef __ardour_param_id_h__ +#define __ardour_param_id_h__ + +#include <string> +#include <pbd/compose.h> +#include <pbd/error.h> +#include <ardour/types.h> + +namespace ARDOUR { + + +/** ID of an automatable parameter. + * + * A given automatable object has a number of automatable parameters. This is + * the unique ID for those parameters. Anything automatable (AutomationList, + * Curve) must have an ID unique with respect to it's Automatable parent. + * + * A parameter ID has two parts, a type and an int (only used by some types). + * + * This is a bit more ugly than it could be, due to using the existing/legacy + * ARDOUR::AutomationType: GainAutomation, PanAutomation, SoloAutomation, + * and MuteAutomation use only the type(), but PluginAutomation and + * MidiCCAutomation use the id() as port number and CC number, respectively. + * + * Future types may use a string or URI or whatever, as long as these are + * comparable anything may be added. ints are best as these should be fast to + * copy and compare with one another. + */ +class ParamID +{ +public: + inline ParamID(AutomationType type = NullAutomation, uint32_t id=0) : _type(type), _id(id) {} + + /** Construct an ParamID from a string returned from ParamID::to_string + * (AutomationList automation-id property) + */ + ParamID(const std::string& str) : _type(NullAutomation), _id(0) { + if (str == "gain") { + _type = GainAutomation; + } else if (str == "pan") { + _type = PanAutomation; + } else if (str == "solo") { + _type = SoloAutomation; + } else if (str == "mute") { + _type = MuteAutomation; + } else if (str == "fadein") { + _type = FadeInAutomation; + } else if (str == "fadeout") { + _type = FadeOutAutomation; + } else if (str == "envelope") { + _type = EnvelopeAutomation; + } else if (str.length() > 10 && str.substr(0, 10) == "parameter-") { + _type = PluginAutomation; + _id = atoi(str.c_str()+10); + PBD::info << "Parameter: " << str << " -> " << _id << endl; + } else if (str.length() > 7 && str.substr(0, 7) == "midicc-") { + _type = MidiCCAutomation; + _id = atoi(str.c_str()+7); + PBD::info << "MIDI CC: " << str << " -> " << _id << endl; + } else { + PBD::warning << "Unknown ParamID '" << str << "'" << endmsg; + } + } + + inline AutomationType type() const { return _type; } + inline uint32_t id() const { return _id; } + + inline bool operator==(const ParamID& id) const + { return (_type == id._type && _id == id._id); } + + /** Arbitrary but fixed ordering, so we're comparable (usable in std::map) */ + inline bool operator<(const ParamID& id) const { + // FIXME: branch a performance problem? #ifdef DEBUG? + if (_type == NullAutomation) + PBD::warning << "Uninitialized ParamID compared." << endmsg; + return (_type < id._type || _id < id._id); + } + + inline operator bool() const { return (_type != 0); } + + /** Unique string representation, suitable as an XML property value. + * e.g. <AutomationList automation-id="whatthisreturns"> + */ + inline std::string to_string() const { + if (_type == GainAutomation) { + return "gain"; + } else if (_type == PanAutomation) { + return "pan"; + } else if (_type == SoloAutomation) { + return "solo"; + } else if (_type == MuteAutomation) { + return "mute"; + } else if (_type == FadeInAutomation) { + return "fadein"; + } else if (_type == FadeOutAutomation) { + return "fadeout"; + } else if (_type == EnvelopeAutomation) { + return "envelope"; + } else if (_type == PluginAutomation) { + return string_compose("parameter-%1", _id); + } else if (_type == MidiCCAutomation) { + return string_compose("midicc-%1", _id); + } else { + PBD::warning << "Uninitialized ParamID to_string() called." << endmsg; + return ""; + } + } + +private: + // default copy constructor is ok + AutomationType _type; + uint32_t _id; +}; + + +} // namespace ARDOUR + +#endif // __ardour_param_id_h__ + diff --git a/libs/ardour/ardour/plugin.h b/libs/ardour/ardour/plugin.h index b1a2823b33..22c0862202 100644 --- a/libs/ardour/ardour/plugin.h +++ b/libs/ardour/ardour/plugin.h @@ -31,6 +31,7 @@ #include <ardour/chan_count.h> #include <ardour/plugin_state.h> #include <ardour/cycles.h> +#include <ardour/param_id.h> #include <vector> #include <set> @@ -121,10 +122,10 @@ class Plugin : public PBD::StatefulDestructible virtual int connect_and_run (BufferSet& bufs, uint32_t& in, uint32_t& out, nframes_t nframes, nframes_t offset) = 0; - virtual std::set<uint32_t> automatable() const = 0; + virtual std::set<ParamID> automatable() const = 0; virtual void store_state (ARDOUR::PluginState&) = 0; virtual void restore_state (ARDOUR::PluginState&) = 0; - virtual string describe_parameter (uint32_t) = 0; + virtual string describe_parameter (ParamID) = 0; virtual string state_node_name() const = 0; virtual void print_parameter (uint32_t, char*, uint32_t len) const = 0; @@ -139,7 +140,7 @@ class Plugin : public PBD::StatefulDestructible virtual bool has_editor() const = 0; - sigc::signal<void,uint32_t,float> ParameterChanged; + sigc::signal<void,ParamID,float> ParameterChanged; PBD::Controllable *get_nth_control (uint32_t); diff --git a/libs/ardour/ardour/plugin_insert.h b/libs/ardour/ardour/plugin_insert.h index 4acacae7f5..df0460af84 100644 --- a/libs/ardour/ardour/plugin_insert.h +++ b/libs/ardour/ardour/plugin_insert.h @@ -76,13 +76,9 @@ class PluginInsert : public Insert bool is_generator() const; - void set_parameter (uint32_t port, float val); + void set_parameter (ParamID param, float val); - AutoState get_port_automation_state (uint32_t port); - void set_port_automation_state (uint32_t port, AutoState); - void protect_automation (); - - float default_parameter_value (uint32_t which); + float default_parameter_value (ParamID param); boost::shared_ptr<Plugin> plugin(uint32_t num=0) const { if (num < _plugins.size()) { @@ -94,7 +90,7 @@ class PluginInsert : public Insert PluginType type (); - string describe_parameter (uint32_t); + string describe_parameter (ParamID param); nframes_t latency(); @@ -103,7 +99,7 @@ class PluginInsert : public Insert private: - void parameter_changed (uint32_t, float); + void parameter_changed (ParamID, float); std::vector<boost::shared_ptr<Plugin> > _plugins; @@ -112,8 +108,8 @@ class PluginInsert : public Insert void init (); void set_automatable (); - void auto_state_changed (uint32_t which); - void automation_list_creation_callback (uint32_t, AutomationList&); + void auto_state_changed (ParamID which); + void automation_list_creation_callback (ParamID, AutomationList&); int32_t count_for_configuration (ChanCount in, ChanCount out) const; diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h index d5f10410db..b2f13def81 100644 --- a/libs/ardour/ardour/types.h +++ b/libs/ardour/ardour/types.h @@ -93,12 +93,20 @@ namespace ARDOUR { OverlapType coverage (nframes_t start_a, nframes_t end_a, nframes_t start_b, nframes_t end_b); + /** See param_id.h + * XXX: I don't think/hope these hex values matter anymore. + */ enum AutomationType { + NullAutomation = 0x0, GainAutomation = 0x1, PanAutomation = 0x2, PluginAutomation = 0x4, SoloAutomation = 0x8, - MuteAutomation = 0x10 + MuteAutomation = 0x10, + MidiCCAutomation = 0x20, + FadeInAutomation = 0x40, + FadeOutAutomation = 0x80, + EnvelopeAutomation = 0x100 }; enum AutoState { |