diff options
author | David Robillard <d@drobilla.net> | 2008-09-29 22:47:40 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-09-29 22:47:40 +0000 |
commit | b5ec66ae6cb60fa43c343d3d29340b2370d0b9d1 (patch) | |
tree | 217722d96b61288f44477c69ac3bbe5d2e7d43f1 /libs/ardour | |
parent | 03f188cc8b17edc7c727f62b22b4577a2fdbfbe8 (diff) |
Can't call the wrong function when there's only one of them: remove ARDOUR::Parameter and just use Evoral::Parameter (move Ardour specific functionality to EventTypeMap where it belongs).
Less than pretty in places but easily seddable just in case...
git-svn-id: svn://localhost/ardour2/branches/3.0@3838 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour')
31 files changed, 313 insertions, 389 deletions
diff --git a/libs/ardour/SConscript b/libs/ardour/SConscript index 156daf2bc0..f310e7ca0f 100644 --- a/libs/ardour/SConscript +++ b/libs/ardour/SConscript @@ -117,7 +117,6 @@ mtc_slave.cc named_selection.cc onset_detector.cc panner.cc -parameter.cc pcm_utils.cc playlist.cc playlist_factory.cc diff --git a/libs/ardour/ardour/automatable.h b/libs/ardour/ardour/automatable.h index dbce7de0bf..8cfadec638 100644 --- a/libs/ardour/ardour/automatable.h +++ b/libs/ardour/ardour/automatable.h @@ -26,7 +26,6 @@ #include <ardour/session_object.h> #include <ardour/automation_list.h> #include <ardour/automation_control.h> -#include <ardour/parameter.h> #include <ardour/event_type_map.h> #include <evoral/ControlSet.hpp> #include <evoral/Sequence.hpp> @@ -56,20 +55,20 @@ public: virtual void automation_snapshot(nframes_t now, bool force); virtual void transport_stopped(nframes_t now); - virtual string describe_parameter(Parameter param); + virtual string describe_parameter(Evoral::Parameter param); - AutoState get_parameter_automation_state (Parameter param, bool lock = true); - virtual void set_parameter_automation_state (Parameter param, AutoState); + AutoState get_parameter_automation_state (Evoral::Parameter param, bool lock = true); + virtual void set_parameter_automation_state (Evoral::Parameter param, AutoState); - AutoStyle get_parameter_automation_style (Parameter param); - void set_parameter_automation_style (Parameter param, AutoStyle); + AutoStyle get_parameter_automation_style (Evoral::Parameter param); + void set_parameter_automation_style (Evoral::Parameter param, AutoStyle); void protect_automation (); - void what_has_visible_data(std::set<Parameter>&) const; - const std::set<Parameter>& what_can_be_automated() const { return _can_automate_list; } + void what_has_visible_data(std::set<Evoral::Parameter>&) const; + const std::set<Evoral::Parameter>& what_can_be_automated() const { return _can_automate_list; } - void mark_automation_visible(Parameter, bool); + void mark_automation_visible(Evoral::Parameter, bool); inline bool should_snapshot (nframes_t now) { return (_last_automation_snapshot > now @@ -92,18 +91,18 @@ public: protected: Session& _a_session; - void can_automate(Parameter); + void can_automate(Evoral::Parameter); - virtual void auto_state_changed (Parameter which) {} + virtual void auto_state_changed (Evoral::Parameter which) {} - int set_automation_state(const XMLNode&, Parameter default_param); + int set_automation_state(const XMLNode&, Evoral::Parameter default_param); XMLNode& get_automation_state(); int load_automation (const std::string& path); int old_set_automation_state(const XMLNode&); - std::set<Parameter> _visible_controls; - std::set<Parameter> _can_automate_list; + std::set<Evoral::Parameter> _visible_controls; + std::set<Evoral::Parameter> _can_automate_list; nframes_t _last_automation_snapshot; static nframes_t _automation_interval; diff --git a/libs/ardour/ardour/automation_control.h b/libs/ardour/ardour/automation_control.h index 7878077a98..db481b2f99 100644 --- a/libs/ardour/ardour/automation_control.h +++ b/libs/ardour/ardour/automation_control.h @@ -23,7 +23,6 @@ #include <boost/shared_ptr.hpp> #include <pbd/controllable.h> -#include <ardour/parameter.h> #include <evoral/Control.hpp> #include <ardour/automation_list.h> @@ -40,7 +39,7 @@ class AutomationControl : public PBD::Controllable, public Evoral::Control { public: AutomationControl(ARDOUR::Session&, - const Parameter& parameter, + const Evoral::Parameter& parameter, boost::shared_ptr<ARDOUR::AutomationList> l=boost::shared_ptr<ARDOUR::AutomationList>(), const string& name=""); diff --git a/libs/ardour/ardour/automation_list.h b/libs/ardour/ardour/automation_list.h index cae8d3cbba..d5aff74ab9 100644 --- a/libs/ardour/ardour/automation_list.h +++ b/libs/ardour/ardour/automation_list.h @@ -32,19 +32,16 @@ #include <pbd/statefuldestructible.h> #include <ardour/ardour.h> -#include <ardour/parameter.h> #include <evoral/ControlList.hpp> -using Evoral::ControlEvent; - namespace ARDOUR { class AutomationList : public PBD::StatefulDestructible, public Evoral::ControlList { public: - AutomationList (Parameter id); - AutomationList (const XMLNode&, Parameter id); + AutomationList (Evoral::Parameter id); + AutomationList (const XMLNode&, Evoral::Parameter id); ~AutomationList(); virtual boost::shared_ptr<Evoral::ControlList> create(Evoral::Parameter id); diff --git a/libs/ardour/ardour/event_type_map.h b/libs/ardour/ardour/event_type_map.h index 4d7180c028..99911121c5 100644 --- a/libs/ardour/ardour/event_type_map.h +++ b/libs/ardour/ardour/event_type_map.h @@ -21,17 +21,24 @@ #ifndef __ardour_event_type_map_h__ #define __ardour_event_type_map_h__ +#include <string> #include <evoral/TypeMap.hpp> namespace ARDOUR { +/** This is the interface Ardour provides to Evoral about what + * parameter and event types/ranges/names etc. to use. + */ class EventTypeMap : public Evoral::TypeMap { public: bool type_is_midi(uint32_t type) const; uint8_t parameter_midi_type(const Evoral::Parameter& param) const; uint32_t midi_event_type(uint8_t status) const; - bool is_integer(const Evoral::Parameter& param) const; + bool is_integer(const Evoral::Parameter& param) const; + Evoral::Parameter new_parameter(uint32_t type, uint8_t channel=0, uint32_t id=0) const; + Evoral::Parameter new_parameter(const std::string& str) const; + std::string to_symbol(const Evoral::Parameter& param) const; static EventTypeMap& instance() { return event_type_map; } diff --git a/libs/ardour/ardour/io.h b/libs/ardour/ardour/io.h index 521efbafb4..34ffad94ce 100644 --- a/libs/ardour/ardour/io.h +++ b/libs/ardour/ardour/io.h @@ -248,7 +248,7 @@ class IO : public SessionObject, public AutomatableControls, public Latent void clear_automation (); - void set_parameter_automation_state (Parameter, AutoState); + void set_parameter_automation_state (Evoral::Parameter, AutoState); virtual void transport_stopped (nframes_t now); virtual void automation_snapshot (nframes_t now, bool force); diff --git a/libs/ardour/ardour/ladspa_plugin.h b/libs/ardour/ardour/ladspa_plugin.h index b26e4120b1..1e7a53a65a 100644 --- a/libs/ardour/ardour/ladspa_plugin.h +++ b/libs/ardour/ardour/ladspa_plugin.h @@ -58,7 +58,7 @@ class LadspaPlugin : public ARDOUR::Plugin int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const; uint32_t nth_parameter (uint32_t port, bool& ok) const; - std::set<Parameter> automatable() const; + std::set<Evoral::Parameter> automatable() const; void activate () { if (!_was_activated && _descriptor->activate) @@ -85,7 +85,7 @@ class LadspaPlugin : public ARDOUR::Plugin void set_block_size (nframes_t nframes) {} int connect_and_run (BufferSet& bufs, uint32_t& in, uint32_t& out, nframes_t nframes, nframes_t offset); - std::string describe_parameter (Parameter); + std::string describe_parameter (Evoral::Parameter); std::string state_node_name() const { return "ladspa"; } void print_parameter (uint32_t, char*, uint32_t len) const; diff --git a/libs/ardour/ardour/lv2_plugin.h b/libs/ardour/ardour/lv2_plugin.h index b3711c5588..978e52b446 100644 --- a/libs/ardour/ardour/lv2_plugin.h +++ b/libs/ardour/ardour/lv2_plugin.h @@ -68,7 +68,7 @@ class LV2Plugin : public ARDOUR::Plugin const LV2_Feature* const* features() { return _features; } - std::set<Parameter> automatable() const; + std::set<Evoral::Parameter> automatable() const; void activate () { if (!_was_activated) { @@ -94,7 +94,7 @@ class LV2Plugin : public ARDOUR::Plugin void set_block_size (nframes_t nframes) {} int connect_and_run (BufferSet& bufs, uint32_t& in, uint32_t& out, nframes_t nframes, nframes_t offset); - std::string describe_parameter (Parameter); + std::string describe_parameter (Evoral::Parameter); std::string state_node_name() const { return "lv2"; } void print_parameter (uint32_t, char*, uint32_t len) const; diff --git a/libs/ardour/ardour/midi_playlist.h b/libs/ardour/ardour/midi_playlist.h index dcc202bbf4..697d80611b 100644 --- a/libs/ardour/ardour/midi_playlist.h +++ b/libs/ardour/ardour/midi_playlist.h @@ -25,7 +25,7 @@ #include <ardour/ardour.h> #include <ardour/playlist.h> -#include <ardour/parameter.h> +#include <evoral/Parameter.hpp> namespace ARDOUR { @@ -57,7 +57,7 @@ public: void set_note_mode (NoteMode m) { _note_mode = m; } - std::set<Parameter> contained_automation(); + std::set<Evoral::Parameter> contained_automation(); protected: diff --git a/libs/ardour/ardour/midi_track.h b/libs/ardour/ardour/midi_track.h index 02313c7e6e..56f73fbe9d 100644 --- a/libs/ardour/ardour/midi_track.h +++ b/libs/ardour/ardour/midi_track.h @@ -75,7 +75,7 @@ public: /** A control that will send "immediate" events to a MIDI track when twiddled */ struct MidiControl : public AutomationControl { - MidiControl(MidiTrack* route, const Parameter& param, + MidiControl(MidiTrack* route, const Evoral::Parameter& param, boost::shared_ptr<AutomationList> al = boost::shared_ptr<AutomationList>()) : AutomationControl (route->session(), param, al) , _route (route) diff --git a/libs/ardour/ardour/panner.h b/libs/ardour/ardour/panner.h index 6cd3b0755d..7b4f2d1039 100644 --- a/libs/ardour/ardour/panner.h +++ b/libs/ardour/ardour/panner.h @@ -46,7 +46,7 @@ class AudioBuffer; class StreamPanner : public sigc::trackable, public PBD::Stateful { public: - StreamPanner (Panner& p, Parameter param); + StreamPanner (Panner& p, Evoral::Parameter param); ~StreamPanner (); void set_muted (bool yn); @@ -103,7 +103,7 @@ class StreamPanner : public sigc::trackable, public PBD::Stateful bool _muted; struct PanControllable : public AutomationControl { - PanControllable (Session& s, std::string name, StreamPanner& p, Parameter param) + PanControllable (Session& s, std::string name, StreamPanner& p, Evoral::Parameter param) : AutomationControl (s, param, boost::shared_ptr<AutomationList>(new AutomationList(param)), name) , panner (p) @@ -125,7 +125,7 @@ class StreamPanner : public sigc::trackable, public PBD::Stateful class BaseStereoPanner : public StreamPanner { public: - BaseStereoPanner (Panner&, Parameter param); + BaseStereoPanner (Panner&, Evoral::Parameter param); ~BaseStereoPanner (); /* this class just leaves the pan law itself to be defined @@ -152,7 +152,7 @@ class BaseStereoPanner : public StreamPanner class EqualPowerStereoPanner : public BaseStereoPanner { public: - EqualPowerStereoPanner (Panner&, Parameter param); + EqualPowerStereoPanner (Panner&, Evoral::Parameter param); ~EqualPowerStereoPanner (); void distribute_automated (AudioBuffer& src, BufferSet& obufs, @@ -161,7 +161,7 @@ class EqualPowerStereoPanner : public BaseStereoPanner void get_current_coefficients (pan_t*) const; void get_desired_coefficients (pan_t*) const; - static StreamPanner* factory (Panner&, Parameter param); + static StreamPanner* factory (Panner&, Evoral::Parameter param); static string name; XMLNode& state (bool full_state); @@ -175,14 +175,14 @@ class EqualPowerStereoPanner : public BaseStereoPanner class Multi2dPanner : public StreamPanner { public: - Multi2dPanner (Panner& parent, Parameter); + Multi2dPanner (Panner& parent, Evoral::Parameter); ~Multi2dPanner (); void distribute (AudioBuffer& src, BufferSet& obufs, gain_t gain_coeff, nframes_t nframes); void distribute_automated (AudioBuffer& src, BufferSet& obufs, nframes_t start, nframes_t end, nframes_t nframes, pan_t** buffers); - static StreamPanner* factory (Panner&, Parameter); + static StreamPanner* factory (Panner&, Evoral::Parameter); static string name; XMLNode& state (bool full_state); diff --git a/libs/ardour/ardour/parameter.h b/libs/ardour/ardour/parameter.h deleted file mode 100644 index a9aa051924..0000000000 --- a/libs/ardour/ardour/parameter.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - Copyright (C) 2007 Paul Davis - Author: Dave Robillard - - 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_parameter_h__ -#define __ardour_parameter_h__ - -#include <string> -#include <pbd/compose.h> -#include <pbd/error.h> -#include <ardour/types.h> -#include <evoral/Parameter.hpp> -#include <evoral/MIDIParameters.hpp> - -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 unique Parameter ID with respect to it's Automatable parent. - * - * These are fast to compare, but passing a (const) reference around is - * probably more efficient than copying because the Parameter contains - * metadata not used for comparison. - * - * See evoral/Parameter.hpp for precise definition. - */ -class Parameter : public Evoral::Parameter -{ -public: - Parameter(AutomationType type = NullAutomation, uint32_t id=0, uint8_t channel=0) - : Evoral::Parameter((uint32_t)type, channel, id) - { - init_metadata(type); - } - - Parameter(const Evoral::Parameter& copy) - : Evoral::Parameter(copy) - { - } - - static void init_metadata(AutomationType type) { - double min = 0.0f; - double max = 1.0f; - double normal = 0.0f; - switch(type) { - case NullAutomation: - case GainAutomation: - max = 2.0f; - normal = 1.0f; - break; - case PanAutomation: - normal = 0.5f; - break; - case PluginAutomation: - case SoloAutomation: - case MuteAutomation: - case FadeInAutomation: - case FadeOutAutomation: - case EnvelopeAutomation: - max = 2.0f; - normal = 1.0f; - break; - case MidiCCAutomation: - case MidiPgmChangeAutomation: - case MidiChannelPressureAutomation: - Evoral::MIDI::controller_range(min, max, normal); break; - case MidiPitchBenderAutomation: - Evoral::MIDI::bender_range(min, max, normal); break; - } - set_range(type, min, max, normal); - } - - Parameter(const std::string& str); - - inline AutomationType type() const { return (AutomationType)_type; } - - std::string symbol() const; - - inline operator Parameter() { return (Parameter)*this; } -}; - - -} // namespace ARDOUR - -#endif // __ardour_parameter_h__ - diff --git a/libs/ardour/ardour/plugin.h b/libs/ardour/ardour/plugin.h index fec044e885..bb81776d53 100644 --- a/libs/ardour/ardour/plugin.h +++ b/libs/ardour/ardour/plugin.h @@ -32,7 +32,6 @@ #include <ardour/chan_count.h> #include <ardour/cycles.h> #include <ardour/latent.h> -#include <ardour/parameter.h> #include <ardour/plugin_insert.h> #include <vector> @@ -129,8 +128,8 @@ class Plugin : public PBD::StatefulDestructible, public Latent virtual int connect_and_run (BufferSet& bufs, uint32_t& in, uint32_t& out, nframes_t nframes, nframes_t offset) = 0; - virtual std::set<Parameter> automatable() const = 0; - virtual string describe_parameter (Parameter) = 0; + virtual std::set<Evoral::Parameter> automatable() const = 0; + virtual string describe_parameter (Evoral::Parameter) = 0; virtual string state_node_name() const = 0; virtual void print_parameter (uint32_t, char*, uint32_t len) const = 0; diff --git a/libs/ardour/ardour/plugin_insert.h b/libs/ardour/ardour/plugin_insert.h index 28c7718971..25a9e52e88 100644 --- a/libs/ardour/ardour/plugin_insert.h +++ b/libs/ardour/ardour/plugin_insert.h @@ -74,14 +74,14 @@ class PluginInsert : public Processor bool is_generator() const; - void set_parameter (Parameter param, float val); - float get_parameter (Parameter param); + void set_parameter (Evoral::Parameter param, float val); + float get_parameter (Evoral::Parameter param); float default_parameter_value (const Evoral::Parameter& param); struct PluginControl : public AutomationControl { - PluginControl (PluginInsert* p, const Parameter ¶m, + PluginControl (PluginInsert* p, const Evoral::Parameter ¶m, boost::shared_ptr<AutomationList> list = boost::shared_ptr<AutomationList>()); void set_value (float val); @@ -103,13 +103,13 @@ class PluginInsert : public Processor PluginType type (); - string describe_parameter (Parameter param); + string describe_parameter (Evoral::Parameter param); nframes_t signal_latency() const; private: - void parameter_changed (Parameter, float); + void parameter_changed (Evoral::Parameter, float); std::vector<boost::shared_ptr<Plugin> > _plugins; @@ -118,7 +118,7 @@ class PluginInsert : public Processor void init (); void set_automatable (); - void auto_state_changed (Parameter which); + void auto_state_changed (Evoral::Parameter which); int32_t count_for_configuration (ChanCount in, ChanCount out) const; diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index d7bbe369fe..1b9962744d 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -86,20 +86,22 @@ AudioEngine::AudioEngine (string client_name) Port::set_engine (this); - Parameter::init_metadata(NullAutomation); - Parameter::init_metadata(GainAutomation); - Parameter::init_metadata(PanAutomation); - Parameter::init_metadata(PluginAutomation); - Parameter::init_metadata(SoloAutomation); - Parameter::init_metadata(MuteAutomation); - Parameter::init_metadata(MidiCCAutomation); - Parameter::init_metadata(MidiPgmChangeAutomation); - Parameter::init_metadata(MidiPitchBenderAutomation); - Parameter::init_metadata(MidiChannelPressureAutomation); - Parameter::init_metadata(FadeInAutomation); - Parameter::init_metadata(FadeOutAutomation); - Parameter::init_metadata(EnvelopeAutomation); - Parameter::init_metadata(MidiCCAutomation); + // Initialize parameter metadata (e.g. ranges) + Evoral::Parameter p(NullAutomation); + p = EventTypeMap::instance().new_parameter(NullAutomation); + p = EventTypeMap::instance().new_parameter(GainAutomation); + p = EventTypeMap::instance().new_parameter(PanAutomation); + p = EventTypeMap::instance().new_parameter(PluginAutomation); + p = EventTypeMap::instance().new_parameter(SoloAutomation); + p = EventTypeMap::instance().new_parameter(MuteAutomation); + p = EventTypeMap::instance().new_parameter(MidiCCAutomation); + p = EventTypeMap::instance().new_parameter(MidiPgmChangeAutomation); + p = EventTypeMap::instance().new_parameter(MidiPitchBenderAutomation); + p = EventTypeMap::instance().new_parameter(MidiChannelPressureAutomation); + p = EventTypeMap::instance().new_parameter(FadeInAutomation); + p = EventTypeMap::instance().new_parameter(FadeOutAutomation); + p = EventTypeMap::instance().new_parameter(EnvelopeAutomation); + p = EventTypeMap::instance().new_parameter(MidiCCAutomation); } AudioEngine::~AudioEngine () diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index f74fb83735..d7ade04bc4 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -78,9 +78,9 @@ AudioRegion::init () AudioRegion::AudioRegion (Session& s, nframes_t start, nframes_t length, string name) : Region (s, start, length, name, DataType::AUDIO) , _automatable(s) - , _fade_in (new AutomationList(Parameter(FadeInAutomation))) - , _fade_out (new AutomationList(Parameter(FadeOutAutomation))) - , _envelope (new AutomationList(Parameter(EnvelopeAutomation))) + , _fade_in (new AutomationList(Evoral::Parameter(FadeInAutomation))) + , _fade_out (new AutomationList(Evoral::Parameter(FadeOutAutomation))) + , _envelope (new AutomationList(Evoral::Parameter(EnvelopeAutomation))) { init (); } @@ -89,9 +89,9 @@ AudioRegion::AudioRegion (Session& s, nframes_t start, nframes_t length, string AudioRegion::AudioRegion (boost::shared_ptr<AudioSource> src, nframes_t start, nframes_t length) : Region (src, start, length, PBD::basename_nosuffix(src->name()), DataType::AUDIO, 0, Region::Flag(Region::DefaultFlags|Region::External)) , _automatable(src->session()) - , _fade_in (new AutomationList(Parameter(FadeInAutomation))) - , _fade_out (new AutomationList(Parameter(FadeOutAutomation))) - , _envelope (new AutomationList(Parameter(EnvelopeAutomation))) + , _fade_in (new AutomationList(Evoral::Parameter(FadeInAutomation))) + , _fade_out (new AutomationList(Evoral::Parameter(FadeOutAutomation))) + , _envelope (new AutomationList(Evoral::Parameter(EnvelopeAutomation))) { boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> (src); if (afs) { @@ -105,9 +105,9 @@ AudioRegion::AudioRegion (boost::shared_ptr<AudioSource> src, nframes_t start, n AudioRegion::AudioRegion (boost::shared_ptr<AudioSource> src, nframes_t start, nframes_t length, const string& name, layer_t layer, Flag flags) : Region (src, start, length, name, DataType::AUDIO, layer, flags) , _automatable(src->session()) - , _fade_in (new AutomationList(Parameter(FadeInAutomation))) - , _fade_out (new AutomationList(Parameter(FadeOutAutomation))) - , _envelope (new AutomationList(Parameter(EnvelopeAutomation))) + , _fade_in (new AutomationList(Evoral::Parameter(FadeInAutomation))) + , _fade_out (new AutomationList(Evoral::Parameter(FadeOutAutomation))) + , _envelope (new AutomationList(Evoral::Parameter(EnvelopeAutomation))) { boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> (src); if (afs) { @@ -121,9 +121,9 @@ AudioRegion::AudioRegion (boost::shared_ptr<AudioSource> src, nframes_t start, n AudioRegion::AudioRegion (const SourceList& srcs, nframes_t start, nframes_t length, const string& name, layer_t layer, Flag flags) : Region (srcs, start, length, name, DataType::AUDIO, layer, flags) , _automatable(srcs[0]->session()) - , _fade_in (new AutomationList(Parameter(FadeInAutomation))) - , _fade_out (new AutomationList(Parameter(FadeOutAutomation))) - , _envelope (new AutomationList(Parameter(EnvelopeAutomation))) + , _fade_in (new AutomationList(Evoral::Parameter(FadeInAutomation))) + , _fade_out (new AutomationList(Evoral::Parameter(FadeOutAutomation))) + , _envelope (new AutomationList(Evoral::Parameter(EnvelopeAutomation))) { init (); listen_to_my_sources (); @@ -133,9 +133,9 @@ AudioRegion::AudioRegion (const SourceList& srcs, nframes_t start, nframes_t len AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other, nframes_t offset, nframes_t length, const string& name, layer_t layer, Flag flags) : Region (other, offset, length, name, layer, flags) , _automatable(other->session()) - , _fade_in (new AutomationList(Parameter(FadeInAutomation))) - , _fade_out (new AutomationList(Parameter(FadeOutAutomation))) - , _envelope (new AutomationList(Parameter(EnvelopeAutomation))) + , _fade_in (new AutomationList(Evoral::Parameter(FadeInAutomation))) + , _fade_out (new AutomationList(Evoral::Parameter(FadeOutAutomation))) + , _envelope (new AutomationList(Evoral::Parameter(EnvelopeAutomation))) { set<boost::shared_ptr<Source> > unique_srcs; @@ -186,9 +186,9 @@ AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other, nframes_t AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other) : Region (other) , _automatable(other->session()) - , _fade_in (new AutomationList(Parameter(FadeInAutomation))) - , _fade_out (new AutomationList(Parameter(FadeOutAutomation))) - , _envelope (new AutomationList(Parameter(EnvelopeAutomation))) + , _fade_in (new AutomationList(Evoral::Parameter(FadeInAutomation))) + , _fade_out (new AutomationList(Evoral::Parameter(FadeOutAutomation))) + , _envelope (new AutomationList(Evoral::Parameter(EnvelopeAutomation))) { assert(_type == DataType::AUDIO); _scale_amplitude = other->_scale_amplitude; @@ -203,9 +203,9 @@ AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other) AudioRegion::AudioRegion (boost::shared_ptr<AudioSource> src, const XMLNode& node) : Region (src, node) , _automatable(src->session()) - , _fade_in (new AutomationList(Parameter(FadeInAutomation))) - , _fade_out (new AutomationList(Parameter(FadeOutAutomation))) - , _envelope (new AutomationList(Parameter(EnvelopeAutomation))) + , _fade_in (new AutomationList(Evoral::Parameter(FadeInAutomation))) + , _fade_out (new AutomationList(Evoral::Parameter(FadeOutAutomation))) + , _envelope (new AutomationList(Evoral::Parameter(EnvelopeAutomation))) { boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> (src); if (afs) { @@ -225,9 +225,9 @@ AudioRegion::AudioRegion (boost::shared_ptr<AudioSource> src, const XMLNode& nod AudioRegion::AudioRegion (SourceList& srcs, const XMLNode& node) : Region (srcs, node) , _automatable(srcs[0]->session()) - , _fade_in (new AutomationList(Parameter(FadeInAutomation))) - , _fade_out (new AutomationList(Parameter(FadeOutAutomation))) - , _envelope (new AutomationList(Parameter(EnvelopeAutomation))) + , _fade_in (new AutomationList(Evoral::Parameter(FadeInAutomation))) + , _fade_out (new AutomationList(Evoral::Parameter(FadeOutAutomation))) + , _envelope (new AutomationList(Evoral::Parameter(EnvelopeAutomation))) { init (); diff --git a/libs/ardour/automatable.cc b/libs/ardour/automatable.cc index c9f774d441..a4d0de0958 100644 --- a/libs/ardour/automatable.cc +++ b/libs/ardour/automatable.cc @@ -67,7 +67,7 @@ Automatable::old_set_automation_state (const XMLNode& node) if (sstr.fail()) { break; } - mark_automation_visible (Parameter(PluginAutomation, what), true); + mark_automation_visible (Evoral::Parameter(PluginAutomation, what), true); } } @@ -96,7 +96,7 @@ Automatable::load_automation (const string& path) } Glib::Mutex::Lock lm (control_lock()); - set<Parameter> tosave; + set<Evoral::Parameter> tosave; controls().clear (); _last_automation_snapshot = 0; @@ -110,10 +110,11 @@ Automatable::load_automation (const string& path) in >> when; if (!in) goto bad; in >> value; if (!in) goto bad; + Evoral::Parameter param(PluginAutomation, port); /* FIXME: this is legacy and only used for plugin inserts? I think? */ - boost::shared_ptr<Evoral::Control> c = control (Parameter(PluginAutomation, port), true); + boost::shared_ptr<Evoral::Control> c = control (param, true); c->list()->add (when, value); - tosave.insert (Parameter(PluginAutomation, port)); + tosave.insert (param); } return 0; @@ -127,7 +128,7 @@ Automatable::load_automation (const string& path) void Automatable::add_control(boost::shared_ptr<Evoral::Control> ac) { - Parameter param = ac->parameter(); + Evoral::Parameter param = ac->parameter(); ControlSet::add_control(ac); _can_automate_list.insert(param); @@ -135,10 +136,10 @@ Automatable::add_control(boost::shared_ptr<Evoral::Control> ac) } void -Automatable::what_has_visible_data(set<Parameter>& s) const +Automatable::what_has_visible_data(set<Evoral::Parameter>& s) const { Glib::Mutex::Lock lm (control_lock()); - set<Parameter>::const_iterator li; + set<Evoral::Parameter>::const_iterator li; for (li = _visible_controls.begin(); li != _visible_controls.end(); ++li) { s.insert (*li); @@ -146,11 +147,11 @@ Automatable::what_has_visible_data(set<Parameter>& s) const } string -Automatable::describe_parameter (Parameter param) +Automatable::describe_parameter (Evoral::Parameter param) { /* derived classes like PluginInsert should override this */ - if (param == Parameter(GainAutomation)) { + if (param == Evoral::Parameter(GainAutomation)) { return _("Fader"); } else if (param.type() == PanAutomation) { /* ID's are zero-based, present them as 1-based */ @@ -165,23 +166,23 @@ Automatable::describe_parameter (Parameter param) } else if (param.type() == MidiChannelPressureAutomation) { return string_compose("Pressure [%1]", int(param.channel()) + 1); } else { - return param.symbol(); + return EventTypeMap::instance().to_symbol(param); } } void -Automatable::can_automate (Parameter what) +Automatable::can_automate (Evoral::Parameter what) { _can_automate_list.insert (what); } void -Automatable::mark_automation_visible (Parameter what, bool yn) +Automatable::mark_automation_visible (Evoral::Parameter what, bool yn) { if (yn) { _visible_controls.insert (what); } else { - set<Parameter>::iterator i; + set<Evoral::Parameter>::iterator i; if ((i = _visible_controls.find (what)) != _visible_controls.end()) { _visible_controls.erase (i); @@ -194,7 +195,7 @@ Automatable::mark_automation_visible (Parameter what, bool yn) * pass that type and it will be used for the untyped AutomationList found. */ int -Automatable::set_automation_state (const XMLNode& node, Parameter legacy_param) +Automatable::set_automation_state (const XMLNode& node, Evoral::Parameter legacy_param) { Glib::Mutex::Lock lm (control_lock()); @@ -216,7 +217,10 @@ Automatable::set_automation_state (const XMLNode& node, Parameter legacy_param) const XMLProperty* id_prop = (*niter)->property("automation-id"); - Parameter param = (id_prop ? Parameter(id_prop->value()) : legacy_param); + Evoral::Parameter param = (id_prop + ? EventTypeMap::instance().new_parameter(id_prop->value()) + : legacy_param); + if (param.type() == NullAutomation) { warning << "Automation has null type" << endl; continue; @@ -226,7 +230,7 @@ Automatable::set_automation_state (const XMLNode& node, Parameter legacy_param) if (!id_prop) { warning << "AutomationList node without automation-id property, " - << "using default: " << legacy_param.symbol() << endmsg; + << "using default: " << EventTypeMap::instance().to_symbol(legacy_param) << endmsg; } boost::shared_ptr<Evoral::Control> existing = control(param); @@ -265,7 +269,7 @@ Automatable::get_automation_state () } void -Automatable::set_parameter_automation_state (Parameter param, AutoState s) +Automatable::set_parameter_automation_state (Evoral::Parameter param, AutoState s) { Glib::Mutex::Lock lm (control_lock()); @@ -279,7 +283,7 @@ Automatable::set_parameter_automation_state (Parameter param, AutoState s) } AutoState -Automatable::get_parameter_automation_state (Parameter param, bool lock) +Automatable::get_parameter_automation_state (Evoral::Parameter param, bool lock) { AutoState result = Off; @@ -299,7 +303,7 @@ Automatable::get_parameter_automation_state (Parameter param, bool lock) } void -Automatable::set_parameter_automation_style (Parameter param, AutoStyle s) +Automatable::set_parameter_automation_style (Evoral::Parameter param, AutoStyle s) { Glib::Mutex::Lock lm (control_lock()); @@ -313,7 +317,7 @@ Automatable::set_parameter_automation_style (Parameter param, AutoStyle s) } AutoStyle -Automatable::get_parameter_automation_style (Parameter param) +Automatable::get_parameter_automation_style (Evoral::Parameter param) { Glib::Mutex::Lock lm (control_lock()); diff --git a/libs/ardour/automation_control.cc b/libs/ardour/automation_control.cc index 769f111a23..710fe449f8 100644 --- a/libs/ardour/automation_control.cc +++ b/libs/ardour/automation_control.cc @@ -31,10 +31,10 @@ using namespace PBD; AutomationControl::AutomationControl( ARDOUR::Session& session, - const Parameter& parameter, + const Evoral::Parameter& parameter, boost::shared_ptr<ARDOUR::AutomationList> list, const string& name) - : Controllable((name != "") ? name : parameter.symbol()) + : Controllable((name != "") ? name : EventTypeMap::instance().to_symbol(parameter)) , Evoral::Control(parameter, list) , _session(session) { diff --git a/libs/ardour/automation_list.cc b/libs/ardour/automation_list.cc index c8a5ba7a39..6e2d959628 100644 --- a/libs/ardour/automation_list.cc +++ b/libs/ardour/automation_list.cc @@ -24,8 +24,8 @@ #include <sstream> #include <algorithm> #include <sigc++/bind.h> -#include <ardour/parameter.h> #include <ardour/automation_list.h> +#include <ardour/event_type_map.h> #include <evoral/Curve.hpp> #include <pbd/stacktrace.h> #include <pbd/enumwriter.h> @@ -51,7 +51,7 @@ static void dumpit (const AutomationList& al, string prefix = "") #endif /* XXX: min_val max_val redundant? (param.min() param.max()) */ -AutomationList::AutomationList (Parameter id) +AutomationList::AutomationList (Evoral::Parameter id) : ControlList(id) { _state = Off; @@ -86,7 +86,7 @@ AutomationList::AutomationList (const AutomationList& other, double start, doubl /** \a id is used for legacy sessions where the type is not present * in or below the <AutomationList> node. It is used if \a id is non-null. */ -AutomationList::AutomationList (const XMLNode& node, Parameter id) +AutomationList::AutomationList (const XMLNode& node, Evoral::Parameter id) : ControlList(id) { _touching = false; @@ -127,7 +127,7 @@ AutomationList::operator= (const AutomationList& other) _events.clear (); for (const_iterator i = other._events.begin(); i != other._events.end(); ++i) { - _events.push_back (new ControlEvent (**i)); + _events.push_back (new Evoral::ControlEvent (**i)); } _min_yval = other._min_yval; @@ -220,7 +220,7 @@ AutomationList::state (bool full) char buf[64]; LocaleGuard lg (X_("POSIX")); - root->add_property ("automation-id", _parameter.symbol()); + root->add_property ("automation-id", EventTypeMap::instance().to_symbol(_parameter)); root->add_property ("id", _id.to_s()); @@ -388,7 +388,7 @@ AutomationList::set_state (const XMLNode& node) } if ((prop = node.property (X_("automation-id"))) != 0){ - _parameter = Evoral::Parameter(prop->value()); + _parameter = EventTypeMap::instance().new_parameter(prop->value()); } else { warning << "Legacy session: automation list has no automation-id property."; } diff --git a/libs/ardour/crossfade.cc b/libs/ardour/crossfade.cc index b6ca322c73..fb4325865c 100644 --- a/libs/ardour/crossfade.cc +++ b/libs/ardour/crossfade.cc @@ -78,8 +78,8 @@ Crossfade::Crossfade (boost::shared_ptr<AudioRegion> in, boost::shared_ptr<Audio nframes_t position, AnchorPoint ap) : AudioRegion (in->session(), position, length, "foobar"), - _fade_in (Parameter(FadeInAutomation)), // linear (gain coefficient) => -inf..+6dB - _fade_out (Parameter(FadeOutAutomation)) // linear (gain coefficient) => -inf..+6dB + _fade_in (Evoral::Parameter(FadeInAutomation)), // linear (gain coefficient) => -inf..+6dB + _fade_out (Evoral::Parameter(FadeOutAutomation)) // linear (gain coefficient) => -inf..+6dB { _in = in; @@ -95,8 +95,8 @@ Crossfade::Crossfade (boost::shared_ptr<AudioRegion> in, boost::shared_ptr<Audio Crossfade::Crossfade (boost::shared_ptr<AudioRegion> a, boost::shared_ptr<AudioRegion> b, CrossfadeModel model, bool act) : AudioRegion (a->session(), 0, 0, "foobar"), - _fade_in (Parameter(FadeInAutomation)), // linear (gain coefficient) => -inf..+6dB - _fade_out (Parameter(FadeOutAutomation)) // linear (gain coefficient) => -inf..+6dB + _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; @@ -114,8 +114,8 @@ Crossfade::Crossfade (boost::shared_ptr<AudioRegion> a, boost::shared_ptr<AudioR Crossfade::Crossfade (const Playlist& playlist, XMLNode& node) : AudioRegion (playlist.session(), 0, 0, "foobar"), - _fade_in (Parameter(FadeInAutomation)), // linear (gain coefficient) => -inf..+6dB - _fade_out (Parameter(FadeOutAutomation)) // linear (gain coefficient) => -inf..+6dB + _fade_in (Evoral::Parameter(FadeInAutomation)), // linear (gain coefficient) => -inf..+6dB + _fade_out (Evoral::Parameter(FadeOutAutomation)) // linear (gain coefficient) => -inf..+6dB { boost::shared_ptr<Region> r; diff --git a/libs/ardour/event_type_map.cc b/libs/ardour/event_type_map.cc index 2d724a26ef..39c2e3d6eb 100644 --- a/libs/ardour/event_type_map.cc +++ b/libs/ardour/event_type_map.cc @@ -22,6 +22,11 @@ #include <ardour/event_type_map.h> #include <evoral/Parameter.hpp> #include <evoral/midi_events.h> +#include <evoral/MIDIParameters.hpp> +#include <pbd/error.h> +#include <pbd/compose.h> + +using namespace std; namespace ARDOUR { @@ -64,5 +69,142 @@ EventTypeMap::is_integer(const Evoral::Parameter& param) const && param.type() <= MidiChannelPressureAutomation); } +Evoral::Parameter +EventTypeMap::new_parameter(uint32_t type, uint8_t channel, uint32_t id) const +{ + Evoral::Parameter p(type, channel, id); + + double min = 0.0f; + double max = 1.0f; + double normal = 0.0f; + switch((AutomationType)type) { + case NullAutomation: + case GainAutomation: + max = 2.0f; + normal = 1.0f; + break; + case PanAutomation: + normal = 0.5f; + break; + case PluginAutomation: + case SoloAutomation: + case MuteAutomation: + case FadeInAutomation: + case FadeOutAutomation: + case EnvelopeAutomation: + max = 2.0f; + normal = 1.0f; + break; + case MidiCCAutomation: + case MidiPgmChangeAutomation: + case MidiChannelPressureAutomation: + Evoral::MIDI::controller_range(min, max, normal); break; + case MidiPitchBenderAutomation: + Evoral::MIDI::bender_range(min, max, normal); break; + } + + p.set_range(type, min, max, normal); + return p; +} + +Evoral::Parameter +EventTypeMap::new_parameter(const string& str) const +{ + AutomationType p_type = NullAutomation; + uint8_t p_channel = 0; + uint32_t p_id = 0; + + if (str == "gain") { + p_type = GainAutomation; + } else if (str == "solo") { + p_type = SoloAutomation; + } else if (str == "mute") { + p_type = MuteAutomation; + } else if (str == "fadein") { + p_type = FadeInAutomation; + } else if (str == "fadeout") { + p_type = FadeOutAutomation; + } else if (str == "envelope") { + p_type = EnvelopeAutomation; + } else if (str == "pan") { + p_type = PanAutomation; + } else if (str.length() > 4 && str.substr(0, 4) == "pan-") { + p_type = PanAutomation; + p_id = atoi(str.c_str()+4); + } else if (str.length() > 10 && str.substr(0, 10) == "parameter-") { + p_type = PluginAutomation; + p_id = atoi(str.c_str()+10); + } else if (str.length() > 7 && str.substr(0, 7) == "midicc-") { + p_type = MidiCCAutomation; + uint32_t channel = 0; + sscanf(str.c_str(), "midicc-%d-%d", &channel, &p_id); + assert(channel < 16); + p_channel = channel; + } else if (str.length() > 16 && str.substr(0, 16) == "midi-pgm-change-") { + p_type = MidiPgmChangeAutomation; + uint32_t channel = 0; + sscanf(str.c_str(), "midi-pgm-change-%d", &channel); + assert(channel < 16); + p_id = 0; + p_channel = channel; + } else if (str.length() > 18 && str.substr(0, 18) == "midi-pitch-bender-") { + p_type = MidiPitchBenderAutomation; + uint32_t channel = 0; + sscanf(str.c_str(), "midi-pitch-bender-%d", &channel); + assert(channel < 16); + p_id = 0; + p_channel = channel; + } else if (str.length() > 24 && str.substr(0, 24) == "midi-channel-pressure-") { + p_type = MidiChannelPressureAutomation; + uint32_t channel = 0; + sscanf(str.c_str(), "midi-channel-pressure-%d", &channel); + assert(channel < 16); + p_id = 0; + p_channel = channel; + } else { + PBD::warning << "Unknown Parameter '" << str << "'" << endmsg; + } + + return new_parameter(p_type, p_channel, p_id); +} + +/** Unique string representation, suitable as an XML property value. + * e.g. <AutomationList automation-id="whatthisreturns"> + */ +std::string +EventTypeMap::to_symbol(const Evoral::Parameter& param) const +{ + AutomationType t = (AutomationType)param.type(); + + if (t == GainAutomation) { + return "gain"; + } else if (t == PanAutomation) { + return string_compose("pan-%1", param.id()); + } else if (t == SoloAutomation) { + return "solo"; + } else if (t == MuteAutomation) { + return "mute"; + } else if (t == FadeInAutomation) { + return "fadein"; + } else if (t == FadeOutAutomation) { + return "fadeout"; + } else if (t == EnvelopeAutomation) { + return "envelope"; + } else if (t == PluginAutomation) { + return string_compose("parameter-%1", param.id()); + } else if (t == MidiCCAutomation) { + return string_compose("midicc-%1-%2", int(param.channel()), param.id()); + } else if (t == MidiPgmChangeAutomation) { + return string_compose("midi-pgm-change-%1", int(param.channel())); + } else if (t == MidiPitchBenderAutomation) { + return string_compose("midi-pitch-bender-%1", int(param.channel())); + } else if (t == MidiChannelPressureAutomation) { + return string_compose("midi-channel-pressure-%1", int(param.channel())); + } else { + PBD::warning << "Uninitialized Parameter symbol() called." << endmsg; + return ""; + } +} + } // namespace ARDOUR diff --git a/libs/ardour/gain.cc b/libs/ardour/gain.cc index 741ac2b57a..dd385e513c 100644 --- a/libs/ardour/gain.cc +++ b/libs/ardour/gain.cc @@ -22,7 +22,7 @@ using namespace ARDOUR; Gain::Gain () - : AutomationList (Parameter(GainAutomation)) /* XXX yuck; clamps gain to -inf .. +6db */ + : AutomationList (Evoral::Parameter(GainAutomation)) /* XXX yuck; clamps gain to -inf .. +6db */ { } diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc index a06d4118cb..0343545936 100644 --- a/libs/ardour/io.cc +++ b/libs/ardour/io.cc @@ -138,7 +138,7 @@ IO::IO (Session& s, const string& name, deferred_state = 0; boost::shared_ptr<AutomationList> gl( - new AutomationList(Parameter(GainAutomation))); + new AutomationList(Evoral::Parameter(GainAutomation))); _gain_control = boost::shared_ptr<GainControl>( new GainControl(X_("gaincontrol"), *this, gl)); @@ -180,7 +180,7 @@ IO::IO (Session& s, const XMLNode& node, DataType dt) apply_gain_automation = false; boost::shared_ptr<AutomationList> gl( - new AutomationList(Parameter(GainAutomation))); + new AutomationList(Evoral::Parameter(GainAutomation))); _gain_control = boost::shared_ptr<GainControl>( new GainControl(X_("gaincontrol"), *this, gl)); @@ -1411,7 +1411,7 @@ IO::set_state (const XMLNode& node) if ((*iter)->name() == X_("Automation")) { - set_automation_state (*(*iter), Parameter(GainAutomation)); + set_automation_state (*(*iter), Evoral::Parameter(GainAutomation)); } if ((*iter)->name() == X_("controllable")) { @@ -2274,7 +2274,7 @@ IO::clear_automation () } void -IO::set_parameter_automation_state (Parameter param, AutoState state) +IO::set_parameter_automation_state (Evoral::Parameter param, AutoState state) { // XXX: would be nice to get rid of this special hack diff --git a/libs/ardour/ladspa_plugin.cc b/libs/ardour/ladspa_plugin.cc index 29f2d16767..d756bbfcbe 100644 --- a/libs/ardour/ladspa_plugin.cc +++ b/libs/ardour/ladspa_plugin.cc @@ -471,7 +471,7 @@ LadspaPlugin::get_parameter_descriptor (uint32_t which, ParameterDescriptor& des } string -LadspaPlugin::describe_parameter (Parameter which) +LadspaPlugin::describe_parameter (Evoral::Parameter which) { if (which.type() == PluginAutomation && which.id() < parameter_count()) { return port_names()[which.id()]; @@ -494,16 +494,16 @@ LadspaPlugin::signal_latency () const } } -set<Parameter> +set<Evoral::Parameter> LadspaPlugin::automatable () const { - set<Parameter> ret; + set<Evoral::Parameter> ret; for (uint32_t i = 0; i < parameter_count(); ++i){ if (LADSPA_IS_PORT_INPUT(port_descriptor (i)) && LADSPA_IS_PORT_CONTROL(port_descriptor (i))){ - ret.insert (ret.end(), Parameter(PluginAutomation, i)); + ret.insert (ret.end(), Evoral::Parameter(PluginAutomation, i)); } } diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index f6bb2ec4dd..231d267468 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -360,7 +360,7 @@ LV2Plugin::get_parameter_descriptor (uint32_t which, ParameterDescriptor& desc) string -LV2Plugin::describe_parameter (Parameter which) +LV2Plugin::describe_parameter (Evoral::Parameter which) { if (which.type() == PluginAutomation && which.id() < parameter_count()) { SLV2Value name = slv2_port_get_name(_plugin, @@ -383,14 +383,14 @@ LV2Plugin::signal_latency () const } } -set<Parameter> +set<Evoral::Parameter> LV2Plugin::automatable () const { - set<Parameter> ret; + set<Evoral::Parameter> ret; for (uint32_t i = 0; i < parameter_count(); ++i){ if (parameter_is_input(i) && parameter_is_control(i)) { - ret.insert (ret.end(), Parameter(PluginAutomation, i)); + ret.insert (ret.end(), Evoral::Parameter(PluginAutomation, i)); } } diff --git a/libs/ardour/midi_playlist.cc b/libs/ardour/midi_playlist.cc index 9ac1d41994..7403438483 100644 --- a/libs/ardour/midi_playlist.cc +++ b/libs/ardour/midi_playlist.cc @@ -265,7 +265,7 @@ MidiPlaylist::destroy_region (boost::shared_ptr<Region> region) return changed; } -set<Parameter> +set<Evoral::Parameter> MidiPlaylist::contained_automation() { /* this function is never called from a realtime thread, so @@ -274,7 +274,7 @@ MidiPlaylist::contained_automation() Glib::Mutex::Lock rm (region_lock); - set<Parameter> ret; + set<Evoral::Parameter> ret; for (RegionList::const_iterator r = regions.begin(); r != regions.end(); ++r) { boost::shared_ptr<MidiRegion> mr = boost::dynamic_pointer_cast<MidiRegion>(*r); diff --git a/libs/ardour/panner.cc b/libs/ardour/panner.cc index a0c85d35f6..3ff4caf4f3 100644 --- a/libs/ardour/panner.cc +++ b/libs/ardour/panner.cc @@ -69,7 +69,7 @@ static double direct_pan_to_control (pan_t val) { return val; } -StreamPanner::StreamPanner (Panner& p, Parameter param) +StreamPanner::StreamPanner (Panner& p, Evoral::Parameter param) : parent (p) , _control (new PanControllable(p.session(), X_("panner"), *this, param)) { @@ -179,7 +179,7 @@ StreamPanner::add_state (XMLNode& node) /*---------------------------------------------------------------------- */ -BaseStereoPanner::BaseStereoPanner (Panner& p, Parameter param) +BaseStereoPanner::BaseStereoPanner (Panner& p, Evoral::Parameter param) : StreamPanner (p, param) { } @@ -336,7 +336,7 @@ BaseStereoPanner::distribute (AudioBuffer& srcbuf, BufferSet& obufs, gain_t gain /*---------------------------------------------------------------------- */ -EqualPowerStereoPanner::EqualPowerStereoPanner (Panner& p, Parameter param) +EqualPowerStereoPanner::EqualPowerStereoPanner (Panner& p, Evoral::Parameter param) : BaseStereoPanner (p, param) { update (); @@ -451,7 +451,7 @@ EqualPowerStereoPanner::distribute_automated (AudioBuffer& srcbuf, BufferSet& ob } StreamPanner* -EqualPowerStereoPanner::factory (Panner& parent, Parameter param) +EqualPowerStereoPanner::factory (Panner& parent, Evoral::Parameter param) { return new EqualPowerStereoPanner (parent, param); } @@ -520,7 +520,7 @@ EqualPowerStereoPanner::set_state (const XMLNode& node) /*----------------------------------------------------------------------*/ -Multi2dPanner::Multi2dPanner (Panner& p, Parameter param) +Multi2dPanner::Multi2dPanner (Panner& p, Evoral::Parameter param) : StreamPanner (p, param) { update (); @@ -638,7 +638,7 @@ Multi2dPanner::distribute_automated (AudioBuffer& src, BufferSet& obufs, } StreamPanner* -Multi2dPanner::factory (Panner& p, Parameter param) +Multi2dPanner::factory (Panner& p, Evoral::Parameter param) { return new Multi2dPanner (p, param); } @@ -788,7 +788,7 @@ Panner::reset (uint32_t nouts, uint32_t npans) outputs.push_back (Output (1.0, 0)); for (n = 0; n < npans; ++n) { - push_back (new EqualPowerStereoPanner (*this, Parameter(PanAutomation, n))); + push_back (new EqualPowerStereoPanner (*this, Evoral::Parameter(PanAutomation, n))); } break; @@ -798,7 +798,7 @@ Panner::reset (uint32_t nouts, uint32_t npans) outputs.push_back (Output (1.0, 1.0)); for (n = 0; n < npans; ++n) { - push_back (new Multi2dPanner (*this, Parameter(PanAutomation, n))); + push_back (new Multi2dPanner (*this, Evoral::Parameter(PanAutomation, n))); } break; @@ -810,7 +810,7 @@ Panner::reset (uint32_t nouts, uint32_t npans) outputs.push_back (Output (0, 1.0)); for (n = 0; n < npans; ++n) { - push_back (new Multi2dPanner (*this, Parameter(PanAutomation, n))); + push_back (new Multi2dPanner (*this, Evoral::Parameter(PanAutomation, n))); } break; @@ -823,7 +823,7 @@ Panner::reset (uint32_t nouts, uint32_t npans) outputs.push_back (Output (0.5, 0.75)); for (n = 0; n < npans; ++n) { - push_back (new Multi2dPanner (*this, Parameter(PanAutomation, n))); + push_back (new Multi2dPanner (*this, Evoral::Parameter(PanAutomation, n))); } break; @@ -835,7 +835,7 @@ Panner::reset (uint32_t nouts, uint32_t npans) } for (n = 0; n < npans; ++n) { - push_back (new Multi2dPanner (*this, Parameter(PanAutomation, n))); + push_back (new Multi2dPanner (*this, Evoral::Parameter(PanAutomation, n))); } break; @@ -969,7 +969,7 @@ Panner::clear_automation () struct PanPlugins { string name; uint32_t nouts; - StreamPanner* (*factory)(Panner&, Parameter); + StreamPanner* (*factory)(Panner&, Evoral::Parameter); }; PanPlugins pan_plugins[] = { @@ -1071,7 +1071,7 @@ Panner::set_state (const XMLNode& node) assumption, but its still an assumption. */ - sp = pan_plugins[i].factory (*this, Parameter(PanAutomation, 0)); + sp = pan_plugins[i].factory (*this, Evoral::Parameter(PanAutomation, 0)); if (sp->set_state (**niter) == 0) { push_back (sp); diff --git a/libs/ardour/parameter.cc b/libs/ardour/parameter.cc deleted file mode 100644 index d6e9d16db5..0000000000 --- a/libs/ardour/parameter.cc +++ /dev/null @@ -1,121 +0,0 @@ -/* - Copyright (C) 2008 Paul Davis - Written by Dave Robillard - - 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. -*/ - -#include <ardour/parameter.h> - -using namespace ARDOUR; - - -/** Construct an Parameter from a string returned from Parameter::to_string - * (AutomationList automation-id property) - */ -Parameter::Parameter(const std::string& str) - : Evoral::Parameter (NullAutomation, 0) -{ - if (str == "gain") { - _type = GainAutomation; - } 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 == "pan") { - _type = PanAutomation; - } else if (str.length() > 4 && str.substr(0, 4) == "pan-") { - _type = PanAutomation; - _id = atoi(str.c_str()+4); - } else if (str.length() > 10 && str.substr(0, 10) == "parameter-") { - _type = PluginAutomation; - _id = atoi(str.c_str()+10); - } else if (str.length() > 7 && str.substr(0, 7) == "midicc-") { - _type = MidiCCAutomation; - uint32_t channel = 0; - sscanf(str.c_str(), "midicc-%d-%d", &channel, &_id); - assert(channel < 16); - _channel = channel; - } else if (str.length() > 16 && str.substr(0, 16) == "midi-pgm-change-") { - _type = MidiPgmChangeAutomation; - uint32_t channel = 0; - sscanf(str.c_str(), "midi-pgm-change-%d", &channel); - assert(channel < 16); - _id = 0; - _channel = channel; - } else if (str.length() > 18 && str.substr(0, 18) == "midi-pitch-bender-") { - _type = MidiPitchBenderAutomation; - uint32_t channel = 0; - sscanf(str.c_str(), "midi-pitch-bender-%d", &channel); - assert(channel < 16); - _id = 0; - _channel = channel; - } else if (str.length() > 24 && str.substr(0, 24) == "midi-channel-pressure-") { - _type = MidiChannelPressureAutomation; - uint32_t channel = 0; - sscanf(str.c_str(), "midi-channel-pressure-%d", &channel); - assert(channel < 16); - _id = 0; - _channel = channel; - } else { - PBD::warning << "Unknown Parameter '" << str << "'" << endmsg; - } - - init_metadata((AutomationType)_type); // set min/max/normal -} - - -/** Unique string representation, suitable as an XML property value. - * e.g. <AutomationList automation-id="whatthisreturns"> - */ -std::string -Parameter::symbol() const -{ - if (_type == GainAutomation) { - return "gain"; - } else if (_type == PanAutomation) { - return string_compose("pan-%1", _id); - } 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-%2", int(_channel), _id); - } else if (_type == MidiPgmChangeAutomation) { - return string_compose("midi-pgm-change-%1", int(_channel)); - } else if (_type == MidiPitchBenderAutomation) { - return string_compose("midi-pitch-bender-%1", int(_channel)); - } else if (_type == MidiChannelPressureAutomation) { - return string_compose("midi-channel-pressure-%1", int(_channel)); - } else { - PBD::warning << "Uninitialized Parameter symbol() called." << endmsg; - return ""; - } -} - diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index bd1323b0f1..97ce2d7c01 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -147,7 +147,7 @@ PluginInsert::~PluginInsert () } void -PluginInsert::auto_state_changed (Parameter which) +PluginInsert::auto_state_changed (Evoral::Parameter which) { if (which.type() != PluginAutomation) return; @@ -218,15 +218,15 @@ PluginInsert::is_generator() const void PluginInsert::set_automatable () { - set<Parameter> a = _plugins.front()->automatable (); + set<Evoral::Parameter> a = _plugins.front()->automatable (); Plugin::ParameterDescriptor desc; - for (set<Parameter>::iterator i = a.begin(); i != a.end(); ++i) { + for (set<Evoral::Parameter>::iterator i = a.begin(); i != a.end(); ++i) { if (i->type() == PluginAutomation) { can_automate (*i); _plugins.front()->get_parameter_descriptor(i->id(), desc); - Parameter param(*i); + Evoral::Parameter param(*i); param.set_range(desc.lower, desc.upper, _plugins.front()->default_value(i->id())); boost::shared_ptr<AutomationList> list(new AutomationList(param)); add_control(boost::shared_ptr<AutomationControl>(new PluginControl(this, *i, list))); @@ -235,7 +235,7 @@ PluginInsert::set_automatable () } void -PluginInsert::parameter_changed (Parameter which, float val) +PluginInsert::parameter_changed (Evoral::Parameter which, float val) { if (which.type() != PluginAutomation) return; @@ -359,7 +359,7 @@ PluginInsert::run_in_place (BufferSet& bufs, nframes_t start_frame, nframes_t en } void -PluginInsert::set_parameter (Parameter param, float val) +PluginInsert::set_parameter (Evoral::Parameter param, float val) { if (param.type() != PluginAutomation) return; @@ -375,14 +375,14 @@ PluginInsert::set_parameter (Parameter param, float val) ac->set_value(val); } else { warning << "set_parameter called for nonexistant parameter " - << param.symbol() << endmsg; + << EventTypeMap::instance().to_symbol(param) << endmsg; } _session.set_dirty(); } float -PluginInsert::get_parameter (Parameter param) +PluginInsert::get_parameter (Evoral::Parameter param) { if (param.type() != PluginAutomation) return 0.0; @@ -394,7 +394,7 @@ PluginInsert::get_parameter (Parameter param) void PluginInsert::automation_run (BufferSet& bufs, nframes_t nframes, nframes_t offset) { - ControlEvent next_event (0, 0.0f); + Evoral::ControlEvent next_event (0, 0.0f); nframes_t now = _session.transport_frame (); nframes_t end = now + nframes; @@ -631,9 +631,9 @@ PluginInsert::state (bool full) /* add port automation state */ XMLNode *autonode = new XMLNode(port_automation_node_name); - set<Parameter> automatable = _plugins[0]->automatable(); + set<Evoral::Parameter> automatable = _plugins[0]->automatable(); - for (set<Parameter>::iterator x = automatable.begin(); x != automatable.end(); ++x) { + for (set<Evoral::Parameter>::iterator x = automatable.begin(); x != automatable.end(); ++x) { /*XMLNode* child = new XMLNode("port"); snprintf(buf, sizeof(buf), "%" PRIu32, *x); @@ -766,7 +766,7 @@ PluginInsert::set_state(const XMLNode& node) } boost::shared_ptr<AutomationControl> c = boost::dynamic_pointer_cast<AutomationControl>( - data().control(Parameter(PluginAutomation, port_id), true)); + data().control(Evoral::Parameter(PluginAutomation, port_id), true)); if (!child->children().empty()) { c->alist()->set_state (*child->children().front()); @@ -805,7 +805,7 @@ PluginInsert::set_state(const XMLNode& node) } string -PluginInsert::describe_parameter (Parameter param) +PluginInsert::describe_parameter (Evoral::Parameter param) { if (param.type() != PluginAutomation) return Automatable::describe_parameter(param); @@ -852,7 +852,7 @@ PluginInsert::type () } } -PluginInsert::PluginControl::PluginControl (PluginInsert* p, const Parameter ¶m, boost::shared_ptr<AutomationList> list) +PluginInsert::PluginControl::PluginControl (PluginInsert* p, const Evoral::Parameter ¶m, boost::shared_ptr<AutomationList> list) : AutomationControl (p->session(), param, list, p->describe_parameter(param)) , _plugin (p) { diff --git a/libs/ardour/processor.cc b/libs/ardour/processor.cc index 82591effa4..5fbb30810d 100644 --- a/libs/ardour/processor.cc +++ b/libs/ardour/processor.cc @@ -158,7 +158,7 @@ Processor::state (bool full_state) XMLNode& automation = Automatable::get_automation_state(); - for (set<Parameter>::iterator x = _visible_controls.begin(); x != _visible_controls.end(); ++x) { + for (set<Evoral::Parameter>::iterator x = _visible_controls.begin(); x != _visible_controls.end(); ++x) { if (x != _visible_controls.begin()) { sstr << ' '; } @@ -198,7 +198,7 @@ Processor::set_state (const XMLNode& node) if ((prop = (*niter)->property ("path")) != 0) { old_set_automation_state (*(*niter)); } else { - set_automation_state (*(*niter), Parameter(PluginAutomation)); + set_automation_state (*(*niter), Evoral::Parameter(PluginAutomation)); } if ((prop = (*niter)->property ("visible")) != 0) { @@ -214,7 +214,7 @@ Processor::set_state (const XMLNode& node) break; } // FIXME: other automation types? - mark_automation_visible (Parameter(PluginAutomation, what), true); + mark_automation_visible (Evoral::Parameter(PluginAutomation, what), true); } } diff --git a/libs/ardour/send.cc b/libs/ardour/send.cc index a80e99a1ee..034bed77c3 100644 --- a/libs/ardour/send.cc +++ b/libs/ardour/send.cc @@ -103,7 +103,7 @@ Send::set_state(const XMLNode& node) if ((*niter)->name() == "IOProcessor") { insert_node = *niter; } else if ((*niter)->name() == X_("Automation")) { - _io->set_automation_state (*(*niter), Parameter(GainAutomation)); + _io->set_automation_state (*(*niter), Evoral::Parameter(GainAutomation)); } } |