mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-25 16:07:49 +01:00
rework - instead of having one state vecotr, have a seperate one for routes, groups, and vcas
This commit is contained in:
parent
88b42e5c5d
commit
6b4e2a2151
2 changed files with 107 additions and 19 deletions
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "pbd/stateful.h"
|
||||
#include "pbd/xml++.h"
|
||||
#include "pbd/id.h"
|
||||
|
||||
#include "ardour/session.h"
|
||||
#include "ardour/route.h"
|
||||
|
|
@ -50,11 +51,14 @@ class MixerSnapshot //: public PBD::Stateful
|
|||
void clear();
|
||||
|
||||
struct State {
|
||||
PBD::ID id;
|
||||
std::string name;
|
||||
XMLNode node;
|
||||
XMLNode node;
|
||||
};
|
||||
|
||||
std::vector<State> states;
|
||||
std::vector<State> route_states;
|
||||
std::vector<State> group_states;
|
||||
std::vector<State> vca_states;
|
||||
};
|
||||
|
||||
#endif /* __ardour_mixer_snapshot_h__ */
|
||||
|
|
@ -3,8 +3,13 @@
|
|||
|
||||
#include "ardour/mixer_snapshot.h"
|
||||
#include "ardour/audioengine.h"
|
||||
#include "ardour/route_group.h"
|
||||
#include "ardour/vca_manager.h"
|
||||
#include "ardour/vca.h"
|
||||
|
||||
#include "pbd/stateful.h"
|
||||
#include "pbd/id.h"
|
||||
#include "pbd/i18n.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace ARDOUR;
|
||||
|
|
@ -25,7 +30,9 @@ MixerSnapshot::~MixerSnapshot()
|
|||
void MixerSnapshot::clear()
|
||||
{
|
||||
timestamp = time(0);
|
||||
states.clear();
|
||||
route_states.clear();
|
||||
group_states.clear();
|
||||
vca_states.clear();
|
||||
}
|
||||
|
||||
// void MixerSnapshot::snap(Route* route)
|
||||
|
|
@ -35,6 +42,9 @@ void MixerSnapshot::clear()
|
|||
// if(route) {
|
||||
// string name = route->name();
|
||||
// XMLNode previous_state (route->get_state());
|
||||
|
||||
// string group_name;
|
||||
// get_property(X_("route-group"), group_name);
|
||||
|
||||
// State state {name, previous_state};
|
||||
// states.push_back(state);
|
||||
|
|
@ -51,31 +61,105 @@ void MixerSnapshot::snap()
|
|||
return;
|
||||
|
||||
RouteList rl = _session->get_routelist();
|
||||
for(RouteList::iterator i = rl.begin(); i != rl.end(); i++) {
|
||||
string name = (*i)->name();
|
||||
|
||||
if(rl.empty())
|
||||
return;
|
||||
// for(RouteList::iterator i = rl.begin(); i != rl.end(); i++) {
|
||||
// string route_name = (*i)->name();
|
||||
|
||||
XMLNode& current_state = (*i)->get_state();
|
||||
XMLNode previous_state (current_state);
|
||||
// XMLNode& current_state = (*i)->get_state();
|
||||
// XMLNode previous_state (current_state);
|
||||
|
||||
// string group_name = "";
|
||||
// current_state.get_property(X_("route-group"), group_name);
|
||||
|
||||
// RouteGroup* group = _session->route_group_by_name(group_name);
|
||||
|
||||
// XMLNode group_state = XMLNode("");
|
||||
// if(group) {
|
||||
// group_state = XMLNode(group->get_state());
|
||||
// }
|
||||
|
||||
State state {name, previous_state};
|
||||
states.push_back(state);
|
||||
cout << timestamp << ": " << state.name << endl;
|
||||
// State state {(*i)->id(), route_name, group_name, "", previous_state, group_state, XMLNode("")};
|
||||
// states.push_back(state);
|
||||
// cout << timestamp << ": " << state.route_name << endl;
|
||||
// }
|
||||
|
||||
for(RouteList::const_iterator i = rl.begin(); i != rl.end(); i++) {
|
||||
//copy current state to node obj
|
||||
XMLNode node ((*i)->get_state());
|
||||
|
||||
State state {(*i)->id(), (string) (*i)->name(), node};
|
||||
route_states.push_back(state);
|
||||
}
|
||||
|
||||
//push back groups
|
||||
list<RouteGroup*> gl = _session->route_groups();
|
||||
for(list<RouteGroup*>::const_iterator i = gl.begin(); i != gl.end(); i++) {
|
||||
//copy current state to node obj
|
||||
XMLNode node ((*i)->get_state());
|
||||
|
||||
State state {(*i)->id(), (string) (*i)->name(), node};
|
||||
group_states.push_back(state);
|
||||
}
|
||||
|
||||
//push back VCA's
|
||||
VCAList _vcas = _session->vca_manager().vcas();
|
||||
for(VCAList::const_iterator i = _vcas.begin(); i != _vcas.end(); i++) {
|
||||
cout << (*i)->name() << endl;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void MixerSnapshot::recall() {
|
||||
for(vector<State>::const_iterator i = states.begin(); i != states.end(); i++) {
|
||||
string name = (*i).name;
|
||||
boost::shared_ptr<Route> route = _session->route_by_name(name);
|
||||
|
||||
for(vector<State>::const_iterator i = route_states.begin(); i != route_states.end(); i++) {
|
||||
State state = (*i);
|
||||
|
||||
if(route) {
|
||||
route->set_state((*i).node, PBD::Stateful::loading_state_version);
|
||||
} else {
|
||||
cout << "couldn't find " << name << " in session" << endl;
|
||||
continue;
|
||||
boost::shared_ptr<Route> route = _session->route_by_id(state.id);
|
||||
|
||||
if(!route)
|
||||
route = _session->route_by_name(state.name);
|
||||
|
||||
if(route)
|
||||
route->set_state(state.node, PBD::Stateful::loading_state_version);
|
||||
else
|
||||
cout << "couldn't find " << state.name << " in session ... we won't be creating this." << endl;
|
||||
|
||||
// //establish group association if applicable
|
||||
// if((*i).group_name != "") {
|
||||
// RouteGroup* group = _session->route_group_by_name((*i).group_name);
|
||||
|
||||
// if(!group) {
|
||||
// group = new RouteGroup(*_session, (*i).group_name);
|
||||
// _session->add_route_group(group);
|
||||
// }
|
||||
|
||||
// if(group) {
|
||||
// group->set_state((*i).group_state, PBD::Stateful::loading_state_version);
|
||||
// group->changed();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
for(vector<State>::const_iterator i = group_states.begin(); i != group_states.end(); i++) {
|
||||
State state = (*i);
|
||||
|
||||
RouteGroup* group = _session->route_group_by_name(state.name);
|
||||
|
||||
if(!group){
|
||||
group = new RouteGroup(*_session, state.name);
|
||||
//notify session
|
||||
_session->add_route_group(group);
|
||||
}
|
||||
|
||||
if(group) {
|
||||
group->set_state(state.node, PBD::Stateful::loading_state_version);
|
||||
group->changed()
|
||||
} else {
|
||||
cout << "not found" << endl;
|
||||
}
|
||||
cout << timestamp << ": " << name << endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue