mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-08 07:45:00 +01:00
expand and improve VCA API
This commit is contained in:
parent
089549acb6
commit
f44cac5cc6
4 changed files with 68 additions and 12 deletions
|
|
@ -33,9 +33,10 @@ class Route;
|
||||||
|
|
||||||
class LIBARDOUR_API VCA : public SessionHandleRef {
|
class LIBARDOUR_API VCA : public SessionHandleRef {
|
||||||
public:
|
public:
|
||||||
VCA (Session& session, const std::string& name);
|
VCA (Session& session, const std::string& name, uint32_t num);
|
||||||
|
|
||||||
std::string name() const { return _name; }
|
std::string name() const { return _name; }
|
||||||
|
uint32_t number () const { return _number; }
|
||||||
|
|
||||||
void set_value (double val, PBD::Controllable::GroupControlDisposition group_override);
|
void set_value (double val, PBD::Controllable::GroupControlDisposition group_override);
|
||||||
double get_value () const;
|
double get_value () const;
|
||||||
|
|
@ -45,9 +46,14 @@ class LIBARDOUR_API VCA : public SessionHandleRef {
|
||||||
void add (boost::shared_ptr<Route>);
|
void add (boost::shared_ptr<Route>);
|
||||||
void remove (boost::shared_ptr<Route>);
|
void remove (boost::shared_ptr<Route>);
|
||||||
|
|
||||||
|
static std::string default_name_template ();
|
||||||
|
static int next_vca_number ();
|
||||||
private:
|
private:
|
||||||
|
uint32_t _number;
|
||||||
std::string _name;
|
std::string _name;
|
||||||
boost::shared_ptr<GainControl> _control;
|
boost::shared_ptr<GainControl> _control;
|
||||||
|
|
||||||
|
static gint next_number;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace */
|
} /* namespace */
|
||||||
|
|
|
||||||
|
|
@ -42,9 +42,11 @@ class VCAManager : public SessionHandleRef
|
||||||
VCAManager (ARDOUR::Session&);
|
VCAManager (ARDOUR::Session&);
|
||||||
~VCAManager ();
|
~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>);
|
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;
|
typedef std::list<boost::shared_ptr<VCA> > VCAS;
|
||||||
VCAS vcas() const;
|
VCAS vcas() const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,31 @@
|
||||||
#include "ardour/route.h"
|
#include "ardour/route.h"
|
||||||
#include "ardour/vca.h"
|
#include "ardour/vca.h"
|
||||||
|
|
||||||
|
#include "i18n.h"
|
||||||
|
|
||||||
using namespace ARDOUR;
|
using namespace ARDOUR;
|
||||||
using namespace PBD;
|
using namespace PBD;
|
||||||
using std::string;
|
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)
|
: SessionHandleRef (s)
|
||||||
, _name (n)
|
, _number (num)
|
||||||
|
, _name (name)
|
||||||
, _control (new GainControl (s, Evoral::Parameter (GainAutomation), boost::shared_ptr<AutomationList> ()))
|
, _control (new GainControl (s, Evoral::Parameter (GainAutomation), boost::shared_ptr<AutomationList> ()))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -48,6 +66,7 @@ void
|
||||||
VCA::add (boost::shared_ptr<Route> r)
|
VCA::add (boost::shared_ptr<Route> r)
|
||||||
{
|
{
|
||||||
boost::dynamic_pointer_cast<GainControl>(r->gain_control())->add_master (_control);
|
boost::dynamic_pointer_cast<GainControl>(r->gain_control())->add_master (_control);
|
||||||
|
std::cerr << name() << " now controlling " << r->name() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,9 @@
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "pbd/convert.h"
|
||||||
|
#include "pbd/replace_all.h"
|
||||||
|
|
||||||
#include "ardour/vca.h"
|
#include "ardour/vca.h"
|
||||||
#include "ardour/vca_manager.h"
|
#include "ardour/vca_manager.h"
|
||||||
|
|
||||||
|
|
@ -41,21 +44,34 @@ VCAManager::vcas () const
|
||||||
return _vcas;
|
return _vcas;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<VCA>
|
int
|
||||||
VCAManager::create_vca (std::string const & name)
|
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);
|
Mutex::Lock lm (lock);
|
||||||
_vcas.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);
|
||||||
}
|
}
|
||||||
|
|
||||||
VCAList vcal;
|
boost::shared_ptr<VCA> vca = boost::shared_ptr<VCA> (new VCA (_session, name, num));
|
||||||
|
|
||||||
|
_vcas.push_back (vca);
|
||||||
vcal.push_back (vca);
|
vcal.push_back (vca);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
VCAAdded (vcal); /* EMIT SIGNAL */
|
VCAAdded (vcal); /* EMIT SIGNAL */
|
||||||
return vca;
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -73,3 +89,16 @@ VCAManager::remove_vca (boost::shared_ptr<VCA> vca)
|
||||||
VCARemoved (vcal); /* EMIT SIGNAL */
|
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>();
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue