diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2016-02-29 14:44:25 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2016-05-31 15:30:38 -0400 |
commit | f44cac5cc60c0ad93da3a44db2517f09cc82f345 (patch) | |
tree | 1035815b0f93b2ae39fef15402f9a9e4ea87fb1e /libs/ardour | |
parent | 089549acb67e9f11039853eb5af48b00d206b7a5 (diff) |
expand and improve VCA API
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/vca.h | 8 | ||||
-rw-r--r-- | libs/ardour/ardour/vca_manager.h | 4 | ||||
-rw-r--r-- | libs/ardour/vca.cc | 23 | ||||
-rw-r--r-- | libs/ardour/vca_manager.cc | 45 |
4 files changed, 68 insertions, 12 deletions
diff --git a/libs/ardour/ardour/vca.h b/libs/ardour/ardour/vca.h index 9a4ff0f602..a4e2e9f4df 100644 --- a/libs/ardour/ardour/vca.h +++ b/libs/ardour/ardour/vca.h @@ -33,9 +33,10 @@ class Route; class LIBARDOUR_API VCA : public SessionHandleRef { public: - VCA (Session& session, const std::string& name); + VCA (Session& session, const std::string& name, uint32_t num); std::string name() const { return _name; } + uint32_t number () const { return _number; } void set_value (double val, PBD::Controllable::GroupControlDisposition group_override); double get_value () const; @@ -45,9 +46,14 @@ class LIBARDOUR_API VCA : public SessionHandleRef { void add (boost::shared_ptr<Route>); void remove (boost::shared_ptr<Route>); + static std::string default_name_template (); + static int next_vca_number (); private: + uint32_t _number; std::string _name; boost::shared_ptr<GainControl> _control; + + static gint next_number; }; } /* namespace */ diff --git a/libs/ardour/ardour/vca_manager.h b/libs/ardour/ardour/vca_manager.h index 54cc14b572..764b966941 100644 --- a/libs/ardour/ardour/vca_manager.h +++ b/libs/ardour/ardour/vca_manager.h @@ -42,9 +42,11 @@ class VCAManager : public SessionHandleRef VCAManager (ARDOUR::Session&); ~VCAManager (); - boost::shared_ptr<VCA> create_vca (std::string const & name = std::string()); + int create_vca (uint32_t n, std::string const & name = std::string()); void remove_vca (boost::shared_ptr<VCA>); + boost::shared_ptr<VCA> vca_by_number(uint32_t) const; + typedef std::list<boost::shared_ptr<VCA> > VCAS; VCAS vcas() const; diff --git a/libs/ardour/vca.cc b/libs/ardour/vca.cc index b49489dfe7..67ca4733cb 100644 --- a/libs/ardour/vca.cc +++ b/libs/ardour/vca.cc @@ -21,13 +21,31 @@ #include "ardour/route.h" #include "ardour/vca.h" +#include "i18n.h" + using namespace ARDOUR; using namespace PBD; using std::string; -VCA::VCA (Session& s, const string& n) +gint VCA::next_number = 0; + +string +VCA::default_name_template () +{ + return _("VCA %n"); +} + +int +VCA::next_vca_number () +{ + /* recall that atomic_int_add() returns the value before the add */ + return g_atomic_int_add (&next_number, 1) + 1; +} + +VCA::VCA (Session& s, const string& name, uint32_t num) : SessionHandleRef (s) - , _name (n) + , _number (num) + , _name (name) , _control (new GainControl (s, Evoral::Parameter (GainAutomation), boost::shared_ptr<AutomationList> ())) { } @@ -48,6 +66,7 @@ void VCA::add (boost::shared_ptr<Route> r) { boost::dynamic_pointer_cast<GainControl>(r->gain_control())->add_master (_control); + std::cerr << name() << " now controlling " << r->name() << std::endl; } void diff --git a/libs/ardour/vca_manager.cc b/libs/ardour/vca_manager.cc index c5164982c3..476cd02bda 100644 --- a/libs/ardour/vca_manager.cc +++ b/libs/ardour/vca_manager.cc @@ -17,6 +17,9 @@ */ +#include "pbd/convert.h" +#include "pbd/replace_all.h" + #include "ardour/vca.h" #include "ardour/vca_manager.h" @@ -41,21 +44,34 @@ VCAManager::vcas () const return _vcas; } -boost::shared_ptr<VCA> -VCAManager::create_vca (std::string const & name) +int +VCAManager::create_vca (uint32_t howmany, std::string const & name_template) { - boost::shared_ptr<VCA> vca = boost::shared_ptr<VCA> (new VCA (_session, name)); + VCAList vcal; + { Mutex::Lock lm (lock); - _vcas.push_back (vca); - } - VCAList vcal; - vcal.push_back (vca); + for (uint32_t n = 0; n < howmany; ++n) { + + int num = VCA::next_vca_number (); + string name = name_template; + + if (name.find ("%n")) { + string sn = PBD::to_string (n, std::dec); + replace_all (name, "%n", sn); + } + + boost::shared_ptr<VCA> vca = boost::shared_ptr<VCA> (new VCA (_session, name, num)); + + _vcas.push_back (vca); + vcal.push_back (vca); + } + } VCAAdded (vcal); /* EMIT SIGNAL */ - return vca; + return 0; } @@ -73,3 +89,16 @@ VCAManager::remove_vca (boost::shared_ptr<VCA> vca) VCARemoved (vcal); /* EMIT SIGNAL */ } +boost::shared_ptr<VCA> +VCAManager::vca_by_number (uint32_t n) const +{ + Mutex::Lock lm (lock); + + for (VCAS::const_iterator i = _vcas.begin(); i != _vcas.end(); ++i) { + if ((*i)->number() == n) { + return *i; + } + } + + return boost::shared_ptr<VCA>(); +} |