Allow to filter MixerScene restore by AutomationType
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "ardour/libardour_visibility.h"
|
||||
#include "ardour/session_handle.h"
|
||||
#include "ardour/types.h"
|
||||
|
||||
namespace PBD {
|
||||
class Controllable;
|
||||
@@ -40,7 +41,7 @@ public:
|
||||
|
||||
void snapshot ();
|
||||
bool apply () const;
|
||||
bool apply (PBD::ControllableSet const&) const;
|
||||
bool apply (PBD::ControllableSet const&, AutomationTypeSet const& ts = AutomationTypeSet()) const;
|
||||
void clear ();
|
||||
bool empty () const { return _ctrl_map.empty (); }
|
||||
|
||||
@@ -55,7 +56,7 @@ public:
|
||||
private:
|
||||
typedef std::map<PBD::ID, double> ControllableValueMap;
|
||||
|
||||
bool recurse_to_master (boost::shared_ptr<PBD::Controllable>, std::set <PBD::ID>&) const;
|
||||
bool recurse_to_master (boost::shared_ptr<PBD::Controllable>, std::set <PBD::ID>&, AutomationTypeSet const&) const;
|
||||
|
||||
ControllableValueMap _ctrl_map;
|
||||
std::string _name;
|
||||
|
||||
@@ -639,6 +639,7 @@ typedef std::list<boost::weak_ptr <Route> > WeakRouteList;
|
||||
typedef std::list<boost::weak_ptr <Stripable> > WeakStripableList;
|
||||
typedef std::list<boost::shared_ptr<AutomationControl> > ControlList;
|
||||
typedef std::list<boost::shared_ptr<SlavableAutomationControl> > SlavableControlList;
|
||||
typedef std::set <AutomationType> AutomationTypeSet;
|
||||
|
||||
typedef std::list<boost::shared_ptr<VCA> > VCAList;
|
||||
|
||||
|
||||
@@ -1848,7 +1848,7 @@ LuaBindings::common (lua_State* L)
|
||||
|
||||
.beginWSPtrClass <MixerScene> ("MixerScene")
|
||||
.addFunction ("apply", (bool (MixerScene::*)() const)&MixerScene::apply)
|
||||
.addFunction ("apply_to", (bool (MixerScene::*)(PBD::ControllableSet const&) const)&MixerScene::apply)
|
||||
.addFunction ("apply_to", (bool (MixerScene::*)(PBD::ControllableSet const&, AutomationTypeSet const&) const)&MixerScene::apply)
|
||||
.addFunction ("snapshot", &MixerScene::snapshot)
|
||||
.addFunction ("clear", &MixerScene::clear)
|
||||
.addFunction ("empty", &MixerScene::empty)
|
||||
@@ -2150,6 +2150,10 @@ LuaBindings::common (lua_State* L)
|
||||
.beginStdSet <boost::shared_ptr<PBD::Controllable>> ("ControllableSet")
|
||||
.endClass ()
|
||||
|
||||
// typedef std::set <enum AutomationType> AutomationTypeSet;
|
||||
.beginStdSet <AutomationType> ("AutomationTypeSet")
|
||||
.endClass ()
|
||||
|
||||
// typedef std::vector<samplepos_t> XrunPositions
|
||||
.beginStdVector <samplepos_t> ("XrunPositions")
|
||||
.endClass ()
|
||||
|
||||
@@ -77,25 +77,35 @@ MixerScene::snapshot ()
|
||||
}
|
||||
|
||||
bool
|
||||
MixerScene::recurse_to_master (boost::shared_ptr<PBD::Controllable> c, std::set <PBD::ID>& done) const
|
||||
MixerScene::recurse_to_master (boost::shared_ptr<PBD::Controllable> c, std::set <PBD::ID>& done, AutomationTypeSet const& ts) const
|
||||
{
|
||||
if (done.find (c->id()) != done.end ()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#if 1 /* ignore controls in Write, or Touch + touching() state */
|
||||
auto ac = boost::dynamic_pointer_cast<AutomationControl> (c);
|
||||
#if 1 /* ignore controls in Write, or Touch + touching() state */
|
||||
if (ac && ac->automation_write ()) {
|
||||
done.insert (c->id ());
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
if (!ts.empty ()) {
|
||||
if (!ac) {
|
||||
done.insert (c->id ());
|
||||
return false;
|
||||
}
|
||||
if (ts.find (ac->desc().type) == ts.end ()) {
|
||||
done.insert (c->id ());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
auto sc = boost::dynamic_pointer_cast<SlavableAutomationControl> (c);
|
||||
if (sc && sc->slaved ()) {
|
||||
/* first set masters, then set own value */
|
||||
for (auto const& m : sc->masters ()) {
|
||||
recurse_to_master (m, done);
|
||||
recurse_to_master (m, done, ts);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,22 +140,23 @@ MixerScene::apply () const
|
||||
{
|
||||
bool rv = false;
|
||||
std::set<PBD::ID> done;
|
||||
AutomationTypeSet ts;
|
||||
|
||||
for (auto const& c : Controllable::registered_controllables ()) {
|
||||
rv |= recurse_to_master (c, done);
|
||||
rv |= recurse_to_master (c, done, ts);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool
|
||||
MixerScene::apply (ControllableSet const& acs) const
|
||||
MixerScene::apply (PBD::ControllableSet const& acs, AutomationTypeSet const& ts) const
|
||||
{
|
||||
bool rv = false;
|
||||
std::set<PBD::ID> done;
|
||||
|
||||
for (auto const& c : acs) {
|
||||
rv |= recurse_to_master (c, done);
|
||||
rv |= recurse_to_master (c, done, ts);
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
||||
Reference in New Issue
Block a user