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;
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 */
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;
#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> ()))
{
}
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
*/
+#include "pbd/convert.h"
+#include "pbd/replace_all.h"
+
#include "ardour/vca.h"
#include "ardour/vca_manager.h"
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;
}
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>();
+}