mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-04 20:55:48 +01:00
Replace C++11 lambdas with functors
This commit is contained in:
parent
6e499e2cc5
commit
d8d70adab8
6 changed files with 97 additions and 41 deletions
|
|
@ -187,8 +187,7 @@ WebsocketsDispatcher::strip_plugin_param_value_handler (Client client, const Nod
|
|||
}
|
||||
|
||||
void
|
||||
WebsocketsDispatcher::update (Client client, std::string node, std::vector<uint32_t> addr,
|
||||
std::vector<TypedValue> val)
|
||||
WebsocketsDispatcher::update (Client client, std::string node, AddressVector addr, ValueVector val)
|
||||
{
|
||||
server ().update_client (client, { node, addr, val }, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class WebsocketsDispatcher : public SurfaceComponent
|
|||
void strip_plugin_enable_handler (Client, const NodeStateMessage&);
|
||||
void strip_plugin_param_value_handler (Client, const NodeStateMessage&);
|
||||
|
||||
void update (Client, std::string, std::vector<uint32_t>, std::vector<TypedValue>);
|
||||
void update (Client, std::string, AddressVector, ValueVector);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@
|
|||
|
||||
using namespace ARDOUR;
|
||||
|
||||
#define ADDR_NONE UINT_MAX
|
||||
|
||||
typedef boost::function<void ()> SignalObserver;
|
||||
|
||||
int
|
||||
|
|
@ -62,7 +64,7 @@ ArdourFeedback::poll () const
|
|||
boost::shared_ptr<Stripable> strip = strips ().nth_strip (strip_n);
|
||||
boost::shared_ptr<PeakMeter> meter = strip->peak_meter ();
|
||||
float db = meter ? meter->meter_level (0, MeterMCP) : -193;
|
||||
update_all (Node::strip_meter, { strip_n }, static_cast<double>(db));
|
||||
update_all (Node::strip_meter, strip_n, static_cast<double>(db));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -72,12 +74,14 @@ void
|
|||
ArdourFeedback::observe_globals ()
|
||||
{
|
||||
// tempo
|
||||
SignalObserver observer = [this] () {
|
||||
update_all (Node::tempo, {}, globals ().tempo ());
|
||||
struct TempoObserver {
|
||||
void operator() (ArdourFeedback* p) {
|
||||
p->update_all (Node::tempo, p->globals ().tempo ());
|
||||
}
|
||||
};
|
||||
|
||||
session ().tempo_map ().PropertyChanged.connect (_signal_connections, MISSING_INVALIDATOR,
|
||||
boost::bind<void> (observer), event_loop ());
|
||||
boost::bind<void> (TempoObserver (), this), event_loop ());
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -86,27 +90,30 @@ ArdourFeedback::observe_strips ()
|
|||
for (uint32_t strip_n = 0; strip_n < strips ().strip_count (); ++strip_n) {
|
||||
boost::shared_ptr<Stripable> strip = strips ().nth_strip (strip_n);
|
||||
|
||||
// gain
|
||||
SignalObserver observer = [this, strip_n] () {
|
||||
// fires multiple times (4x as of ardour 6.0)
|
||||
update_all (Node::strip_gain, { strip_n }, strips ().strip_gain (strip_n));
|
||||
struct StripGainObserver {
|
||||
void operator() (ArdourFeedback* p, uint32_t strip_n) {
|
||||
// fires multiple times (4x as of ardour 6.0)
|
||||
p->update_all (Node::strip_gain, strip_n, p->strips ().strip_gain (strip_n));
|
||||
}
|
||||
};
|
||||
strip->gain_control ()->Changed.connect (_signal_connections, MISSING_INVALIDATOR,
|
||||
boost::bind<void> (observer), event_loop ());
|
||||
boost::bind<void> (StripGainObserver (), this, strip_n), event_loop ());
|
||||
|
||||
// pan
|
||||
observer = [this, strip_n] () {
|
||||
update_all (Node::strip_pan, { strip_n }, strips ().strip_pan (strip_n));
|
||||
struct StripPanObserver {
|
||||
void operator() (ArdourFeedback* p, uint32_t strip_n) {
|
||||
p->update_all (Node::strip_pan, strip_n, p->strips ().strip_pan (strip_n));
|
||||
}
|
||||
};
|
||||
strip->pan_azimuth_control ()->Changed.connect (_signal_connections, MISSING_INVALIDATOR,
|
||||
boost::bind<void> (observer), event_loop ());
|
||||
boost::bind<void> (StripPanObserver (), this, strip_n), event_loop ());
|
||||
|
||||
// mute
|
||||
observer = [this, strip_n] () {
|
||||
update_all (Node::strip_mute, { strip_n }, strips ().strip_mute (strip_n));
|
||||
struct StripMuteObserver {
|
||||
void operator() (ArdourFeedback* p, uint32_t strip_n) {
|
||||
p->update_all (Node::strip_mute, strip_n, p->strips ().strip_mute (strip_n));
|
||||
}
|
||||
};
|
||||
strip->mute_control ()->Changed.connect (_signal_connections, MISSING_INVALIDATOR,
|
||||
boost::bind<void> (observer), event_loop ());
|
||||
boost::bind<void> (StripMuteObserver (), this, strip_n), event_loop ());
|
||||
|
||||
observe_strip_plugins (strip_n, strip);
|
||||
}
|
||||
|
|
@ -121,18 +128,20 @@ ArdourFeedback::observe_strip_plugins (uint32_t strip_n, boost::shared_ptr<ARDOU
|
|||
break;
|
||||
}
|
||||
|
||||
SignalObserver observer = [this, strip_n, plugin_n] () {
|
||||
update_all (Node::strip_plugin_enable, { strip_n, plugin_n },
|
||||
strips ().strip_plugin_enabled (strip_n, plugin_n));
|
||||
};
|
||||
|
||||
uint32_t bypass = insert->plugin ()->designated_bypass_port ();
|
||||
Evoral::Parameter param = Evoral::Parameter (PluginAutomation, 0, bypass);
|
||||
boost::shared_ptr<AutomationControl> control = insert->automation_control (param);
|
||||
|
||||
if (control) {
|
||||
struct PluginBypassObserver {
|
||||
void operator() (ArdourFeedback* p, uint32_t strip_n, uint32_t plugin_n) {
|
||||
p->update_all (Node::strip_plugin_enable, strip_n, plugin_n,
|
||||
p->strips ().strip_plugin_enabled (strip_n, plugin_n));
|
||||
}
|
||||
};
|
||||
|
||||
control->Changed.connect (_signal_connections, MISSING_INVALIDATOR,
|
||||
boost::bind<void> (observer), event_loop ());
|
||||
boost::bind<void> (PluginBypassObserver (), this, strip_n, plugin_n), event_loop ());
|
||||
}
|
||||
|
||||
observe_strip_plugin_param_values (strip_n, plugin_n, insert);
|
||||
|
|
@ -153,18 +162,62 @@ ArdourFeedback::observe_strip_plugin_param_values (uint32_t strip_n,
|
|||
continue;
|
||||
}
|
||||
|
||||
SignalObserver observer = [this, control, strip_n, plugin_n, param_n] () {
|
||||
update_all (Node::strip_plugin_param_value, { strip_n, plugin_n, param_n },
|
||||
ArdourStrips::plugin_param_value (control));
|
||||
struct PluginParamValueObserver {
|
||||
void operator() (ArdourFeedback* p, uint32_t strip_n, uint32_t plugin_n,
|
||||
uint32_t param_n, boost::shared_ptr<AutomationControl> control) {
|
||||
p->update_all (
|
||||
Node::strip_plugin_param_value,
|
||||
strip_n, plugin_n, param_n,
|
||||
ArdourStrips::plugin_param_value (control)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
control->Changed.connect (_signal_connections, MISSING_INVALIDATOR,
|
||||
boost::bind<void> (observer), event_loop ());
|
||||
boost::bind<void> (PluginParamValueObserver (), this, strip_n, plugin_n, param_n,
|
||||
control), event_loop ());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ArdourFeedback::update_all (std::string node, std::vector<uint32_t> addr, TypedValue val) const
|
||||
ArdourFeedback::update_all (std::string node, TypedValue value) const
|
||||
{
|
||||
server ().update_all_clients ({ node, addr, { val }}, false);
|
||||
update_all (node, ADDR_NONE, ADDR_NONE, ADDR_NONE, value);
|
||||
}
|
||||
|
||||
void
|
||||
ArdourFeedback::update_all (std::string node, uint32_t strip_n, TypedValue value) const
|
||||
{
|
||||
update_all (node, strip_n, ADDR_NONE, ADDR_NONE, value);
|
||||
}
|
||||
|
||||
void
|
||||
ArdourFeedback::update_all (std::string node, uint32_t strip_n, uint32_t plugin_n,
|
||||
TypedValue value) const
|
||||
{
|
||||
update_all (node, strip_n, plugin_n, ADDR_NONE, value);
|
||||
}
|
||||
|
||||
void
|
||||
ArdourFeedback::update_all (std::string node, uint32_t strip_n, uint32_t plugin_n, uint32_t param_n,
|
||||
TypedValue value) const
|
||||
{
|
||||
AddressVector addr = AddressVector ();
|
||||
|
||||
if (strip_n != ADDR_NONE) {
|
||||
addr.push_back (strip_n);
|
||||
}
|
||||
|
||||
if (plugin_n != ADDR_NONE) {
|
||||
addr.push_back (plugin_n);
|
||||
}
|
||||
|
||||
if (param_n != ADDR_NONE) {
|
||||
addr.push_back (param_n);
|
||||
}
|
||||
|
||||
ValueVector val = ValueVector ();
|
||||
val.push_back (value);
|
||||
|
||||
server ().update_all_clients (NodeState (node, addr, val), false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,10 @@ class ArdourFeedback : public SurfaceComponent
|
|||
void observe_strip_plugin_param_values (uint32_t, uint32_t,
|
||||
boost::shared_ptr<ARDOUR::PluginInsert>);
|
||||
|
||||
void update_all (std::string, std::vector<uint32_t>, TypedValue) const;
|
||||
void update_all (std::string, TypedValue) const;
|
||||
void update_all (std::string, uint32_t, TypedValue) const;
|
||||
void update_all (std::string, uint32_t, uint32_t, TypedValue) const;
|
||||
void update_all (std::string, uint32_t, uint32_t, uint32_t, TypedValue) const;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -26,8 +26,7 @@ NodeState::NodeState () { }
|
|||
NodeState::NodeState (std::string node)
|
||||
: _node (node) { }
|
||||
|
||||
NodeState::NodeState (std::string node, std::vector<uint32_t> addr,
|
||||
std::vector<TypedValue> val)
|
||||
NodeState::NodeState (std::string node, AddressVector addr, ValueVector val)
|
||||
: _node (node)
|
||||
, _addr (addr)
|
||||
, _val (val) { }
|
||||
|
|
@ -41,12 +40,12 @@ NodeState::debug_str () const
|
|||
if (!_addr.empty ()) {
|
||||
s << std::endl << " addr = ";
|
||||
|
||||
for (std::vector<uint32_t>::const_iterator it = _addr.begin (); it != _addr.end (); ++it) {
|
||||
for (AddressVector::const_iterator it = _addr.begin (); it != _addr.end (); ++it) {
|
||||
s << *it << ";";
|
||||
}
|
||||
}
|
||||
|
||||
for (std::vector<TypedValue>::const_iterator it = _val.begin (); it != _val.end (); ++it) {
|
||||
for (ValueVector::const_iterator it = _val.begin (); it != _val.end (); ++it) {
|
||||
s << std::endl << " val " << it->debug_str ();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,14 +39,16 @@ namespace Node {
|
|||
const std::string strip_plugin_param_value = "strip_plugin_param_value";
|
||||
}
|
||||
|
||||
typedef std::vector<uint32_t> AddressVector;
|
||||
typedef std::vector<TypedValue> ValueVector;
|
||||
|
||||
class NodeState {
|
||||
|
||||
public:
|
||||
|
||||
NodeState ();
|
||||
NodeState (std::string);
|
||||
NodeState (std::string, std::vector<uint32_t>,
|
||||
std::vector<TypedValue> = std::vector<TypedValue>());
|
||||
NodeState (std::string, AddressVector, ValueVector = ValueVector());
|
||||
|
||||
std::string debug_str () const;
|
||||
|
||||
|
|
@ -67,8 +69,8 @@ class NodeState {
|
|||
private:
|
||||
|
||||
std::string _node;
|
||||
std::vector<uint32_t> _addr;
|
||||
std::vector<TypedValue> _val;
|
||||
AddressVector _addr;
|
||||
ValueVector _val;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue