From 82a35b64eb49d4bfc7f7f0950190e4e9a73308cd Mon Sep 17 00:00:00 2001 From: Nikolaus Gullotta Date: Wed, 6 Mar 2019 13:53:45 -0600 Subject: [PATCH] lib_ardour part: add mixer_snapshot class --- libs/ardour/ardour/mixer_snapshot.h | 58 ++++++++++++++++++++++ libs/ardour/mixer_snapshot.cc | 76 +++++++++++++++++++++++++++++ libs/ardour/wscript | 1 + 3 files changed, 135 insertions(+) create mode 100644 libs/ardour/ardour/mixer_snapshot.h create mode 100644 libs/ardour/mixer_snapshot.cc diff --git a/libs/ardour/ardour/mixer_snapshot.h b/libs/ardour/ardour/mixer_snapshot.h new file mode 100644 index 0000000000..6a7393bac6 --- /dev/null +++ b/libs/ardour/ardour/mixer_snapshot.h @@ -0,0 +1,58 @@ +/* + Copyright (C) 20XX Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __ardour_mixer_snapshot_h__ +#define __ardour_mixer_snapshot_h__ + +#include +#include +#include + +#include "pbd/stateful.h" +#include "pbd/xml++.h" + +#include "ardour/session.h" +#include "ardour/route.h" + +class MixerSnapshot //: public PBD::Stateful +{ + public: + MixerSnapshot(); + ~MixerSnapshot(); + + void snap(ARDOUR::Route*); + void snap(ARDOUR::Session*); + void recall(ARDOUR::Session*); + + int id; + char label[255]; + std::time_t timestamp; + + private: + void clear(); + + struct State { + std::string name; + XMLNode node; + }; + + std::vector states; +}; + +#endif /* __ardour_mixer_snapshot_h__ */ \ No newline at end of file diff --git a/libs/ardour/mixer_snapshot.cc b/libs/ardour/mixer_snapshot.cc new file mode 100644 index 0000000000..38265a91a5 --- /dev/null +++ b/libs/ardour/mixer_snapshot.cc @@ -0,0 +1,76 @@ +#include +#include + +#include "ardour/mixer_snapshot.h" +#include "ardour/audioengine.h" + +#include "pbd/stateful.h" + +using namespace std; +using namespace ARDOUR; + +MixerSnapshot::MixerSnapshot() + : id(0) + , label("") + , timestamp(time(0)) +{ +} + +MixerSnapshot::~MixerSnapshot() +{ +} + +void MixerSnapshot::clear() +{ + timestamp = time(0); + states.clear(); +} + +void MixerSnapshot::snap(Route* route) +{ + clear(); + + if(route) { + string name = route->name(); + XMLNode previous_state (route->get_state()); + + State state {name, previous_state}; + states.push_back(state); + cout << timestamp << " " << state.name << endl; + } + return; +} + +void MixerSnapshot::snap(Session* session) +{ + clear(); + + RouteList rl = session->get_routelist(); + for(RouteList::iterator i = rl.begin(); i != rl.end(); i++) { + string name = (*i)->name(); + + XMLNode& current_state = (*i)->get_state(); + XMLNode previous_state (current_state); + + State state {name, previous_state}; + states.push_back(state); + cout << timestamp << ": " << state.name << endl; + } + return; +} + +void MixerSnapshot::recall(Session* session) { + for(vector::const_iterator i = states.begin(); i != states.end(); i++) { + string name = (*i).name; + boost::shared_ptr route = session->route_by_name(name); + + if(route) { + route->set_state((*i).node, PBD::Stateful::loading_state_version); + } else { + cout << "couldn't find " << name << " in session" << endl; + continue; + } + cout << timestamp << ": " << name << endl; + } + return; +} \ No newline at end of file diff --git a/libs/ardour/wscript b/libs/ardour/wscript index 51e9a761c4..4bbba226d6 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -145,6 +145,7 @@ libardour_sources = [ 'mididm.cc', 'midiport_manager.cc', 'mix.cc', + 'mixer_snapshot.cc', 'mode.cc', 'monitor_control.cc', 'monitor_processor.cc',