mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-08 06:35:46 +01:00
lib_ardour part: add mixer_snapshot class
This commit is contained in:
parent
42cc09af13
commit
0ae8268bf0
3 changed files with 135 additions and 0 deletions
58
libs/ardour/ardour/mixer_snapshot.h
Normal file
58
libs/ardour/ardour/mixer_snapshot.h
Normal file
|
|
@ -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 <utility>
|
||||
#include <vector>
|
||||
#include <ctime>
|
||||
|
||||
#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<State> states;
|
||||
};
|
||||
|
||||
#endif /* __ardour_mixer_snapshot_h__ */
|
||||
76
libs/ardour/mixer_snapshot.cc
Normal file
76
libs/ardour/mixer_snapshot.cc
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
#include <iostream>
|
||||
#include <ctime>
|
||||
|
||||
#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<State>::const_iterator i = states.begin(); i != states.end(); i++) {
|
||||
string name = (*i).name;
|
||||
boost::shared_ptr<Route> 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;
|
||||
}
|
||||
|
|
@ -146,6 +146,7 @@ libardour_sources = [
|
|||
'mididm.cc',
|
||||
'midiport_manager.cc',
|
||||
'mix.cc',
|
||||
'mixer_snapshot.cc',
|
||||
'mode.cc',
|
||||
'monitor_control.cc',
|
||||
'monitor_processor.cc',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue