Add API to restore mixer scenes for given set or Routes only

This commit is contained in:
Robin Gareus 2022-10-17 06:44:29 +02:00
parent 800d07a633
commit aaddf5f385
5 changed files with 43 additions and 2 deletions

View file

@ -40,6 +40,7 @@ public:
void snapshot ();
bool apply () const;
bool apply (AutomationControlSet const&) const;
void clear ();
bool empty () const { return _ctrl_map.empty (); }

View file

@ -1215,6 +1215,7 @@ public:
boost::shared_ptr<PBD::Controllable> recently_touched_controllable () const;
bool apply_nth_mixer_scene (size_t);
bool apply_nth_mixer_scene (size_t, RouteList const&);
void store_nth_mixer_scene (size_t);
bool nth_mixer_scene_valid (size_t) const;

View file

@ -1846,7 +1846,8 @@ LuaBindings::common (lua_State* L)
.endClass ()
.beginWSPtrClass <MixerScene> ("MixerScene")
.addFunction ("apply", &MixerScene::apply)
.addFunction ("apply", (bool (MixerScene::*)() const)&MixerScene::apply)
.addFunction ("apply_to", (bool (MixerScene::*)(AutomationControlSet const&) const)&MixerScene::apply)
.addFunction ("snapshot", &MixerScene::snapshot)
.addFunction ("clear", &MixerScene::clear)
.addFunction ("empty", &MixerScene::empty)
@ -2809,7 +2810,8 @@ LuaBindings::common (lua_State* L)
.addFunction ("bundles", &Session::bundles)
.addFunction ("apply_nth_mixer_scene", &Session::apply_nth_mixer_scene)
.addFunction ("apply_nth_mixer_scene", (bool (Session::*)(size_t))&Session::apply_nth_mixer_scene)
.addFunction ("apply_nth_mixer_scene_to", (bool (Session::*)(size_t, RouteList const&))&Session::apply_nth_mixer_scene)
.addFunction ("store_nth_mixer_scene", &Session::store_nth_mixer_scene)
.addFunction ("nth_mixer_scene_valid", &Session::nth_mixer_scene_valid)
.addFunction ("nth_mixer_scene", &Session::nth_mixer_scene)

View file

@ -138,6 +138,19 @@ MixerScene::apply () const
return rv;
}
bool
MixerScene::apply (AutomationControlSet const& acs) const
{
bool rv = false;
std::set<PBD::ID> done;
for (auto const& c : acs) {
rv |= recurse_to_master (c, done);
}
return rv;
}
XMLNode&
MixerScene::get_state () const
{

View file

@ -7536,6 +7536,30 @@ Session::apply_nth_mixer_scene (size_t nth)
return scene->apply ();
}
bool
Session::apply_nth_mixer_scene (size_t nth, RouteList const& rl)
{
boost::shared_ptr<MixerScene> scene;
{
Glib::Threads::RWLock::ReaderLock lm (_mixer_scenes_lock);
if (_mixer_scenes.size () <= nth) {
return false;
}
if (!_mixer_scenes[nth]) {
return false;
}
scene = _mixer_scenes[nth];
}
assert (scene);
AutomationControlSet acs;
for (auto const& r : rl) {
r->automatables (acs);
}
return scene->apply (acs);
}
void
Session::store_nth_mixer_scene (size_t nth)
{