set up recall flags for later usage

This commit is contained in:
Nikolaus Gullotta 2019-04-10 10:47:51 -05:00 committed by Nikolaus Gullotta
parent f1619a2adc
commit 6dc4227cc4
No known key found for this signature in database
GPG key ID: 565F60578092AA31
3 changed files with 89 additions and 27 deletions

View file

@ -32,6 +32,14 @@ namespace ARDOUR {
class LIBARDOUR_API MixerSnapshot
{
public:
enum RecallFlags {
RecallEQ = 0x1,
RecallComp = 0x2,
RecallIO = 0x4,
RecallGroup = 0x8,
RecallVCA = 0x10,
};
MixerSnapshot(ARDOUR::Session*);
MixerSnapshot(ARDOUR::Session*, std::string);
~MixerSnapshot();
@ -65,13 +73,25 @@ class LIBARDOUR_API MixerSnapshot
std::vector<State> get_groups() {return group_states;};
std::vector<State> get_vcas() {return vca_states;};
bool recall_eq() { return _flags & RecallEQ;};
bool recall_comp() { return _flags & RecallComp;};
bool recall_io() { return _flags & RecallIO;};
bool recall_group() { return _flags & RecallGroup;};
bool recall_vca() { return _flags & RecallVCA;};
void set_recall_eq(bool);
void set_recall_comp(bool);
void set_recall_io(bool);
void set_recall_group(bool);
void set_recall_vca(bool);
unsigned int get_id() {return id;};
void set_id(unsigned int new_id) {id = new_id;};
std::string get_label() {return label;};
void set_label(std::string new_label) {label = new_label;};
bool get_favorite() {return timestamp;};
bool get_favorite() {return favorite;};
void set_favorite(bool yn) {favorite = yn;};
std::time_t get_timestamp() {return timestamp;};
@ -87,16 +107,19 @@ class LIBARDOUR_API MixerSnapshot
void reassign_masters(boost::shared_ptr<ARDOUR::Slavable>, XMLNode);
void load_from_session(std::string);
void load_from_session(XMLNode&);
bool set_flag(bool, RecallFlags);
unsigned int id;
bool favorite;
std::string label;
std::time_t timestamp;
std::string last_modified_with;
RecallFlags _flags;
std::vector<State> route_states;
std::vector<State> group_states;
std::vector<State> vca_states;
};
} // namespace ARDOUR

View file

@ -40,6 +40,7 @@
#include "ardour/io.h"
#include "ardour/location.h"
#include "ardour/midi_model.h"
#include "ardour/mixer_snapshot.h"
#include "ardour/mode.h"
#include "ardour/mute_master.h"
#include "ardour/presentation_info.h"
@ -159,6 +160,7 @@ setup_enum_writer ()
LoopFadeChoice _LoopFadeChooice;
TransportState _TransportState;
LocateTransportDisposition _LocateTransportDisposition;
MixerSnapshot::RecallFlags _Recall_Flags;
#define REGISTER(e) enum_writer.register_distinct (typeid(e).name(), i, s); i.clear(); s.clear()
#define REGISTER_BITS(e) enum_writer.register_bits (typeid(e).name(), i, s); i.clear(); s.clear()
@ -848,6 +850,12 @@ setup_enum_writer ()
REGISTER_ENUM (MustRoll);
REGISTER_ENUM (RollIfAppropriate);
REGISTER (_LocateTransportDisposition);
REGISTER_CLASS_ENUM (MixerSnapshot, RecallEQ);
REGISTER_CLASS_ENUM (MixerSnapshot, RecallComp);
REGISTER_CLASS_ENUM (MixerSnapshot, RecallIO);
REGISTER_CLASS_ENUM (MixerSnapshot, RecallGroup);
REGISTER_CLASS_ENUM (MixerSnapshot, RecallVCA);
REGISTER_BITS (_Recall_Flags);
}
} /* namespace ARDOUR */

View file

@ -18,6 +18,18 @@
#include <iostream>
#include <glibmm.h>
#include <glibmm/fileutils.h>
#include "pbd/file_utils.h"
#include "pbd/i18n.h"
#include "pbd/memento_command.h"
#include "pbd/types_convert.h"
#include "pbd/stl_delete.h"
#include "pbd/xml++.h"
#include "pbd/enumwriter.h"
#include "ardour/mixer_snapshot.h"
#include "ardour/route_group.h"
#include "ardour/vca_manager.h"
@ -26,24 +38,23 @@
#include "ardour/session_state_utils.h"
#include "ardour/revision.h"
#include "ardour/session_directory.h"
#include "ardour/types_convert.h"
#include "pbd/i18n.h"
#include "pbd/xml++.h"
#include "pbd/memento_command.h"
#include "pbd/file_utils.h"
#include <glibmm.h>
#include <glibmm/fileutils.h>
namespace PBD {
DEFINE_ENUM_CONVERT(ARDOUR::MixerSnapshot::RecallFlags)
}
using namespace std;
using namespace ARDOUR;
MixerSnapshot::MixerSnapshot(Session* s)
: id(0)
, favorite(false)
, label("snapshot")
, timestamp(time(0))
, last_modified_with(string_compose("%1 %2", PROGRAM_NAME, revision))
, _flags(RecallFlags(0))
{
if(s) {
_session = s;
@ -56,6 +67,7 @@ MixerSnapshot::MixerSnapshot(Session* s, string file_path)
, label("snapshot")
, timestamp(time(0))
, last_modified_with(string_compose("%1 %2", PROGRAM_NAME, revision))
, _flags(RecallFlags(0))
{
if(s) {
_session = s;
@ -79,6 +91,29 @@ MixerSnapshot::~MixerSnapshot()
{
}
bool MixerSnapshot::set_flag(bool yn, RecallFlags flag)
{
if (yn) {
if (!(_flags & flag)) {
_flags = RecallFlags (_flags | flag);
return true;
}
} else {
if (_flags & flag) {
_flags = RecallFlags (_flags & ~flag);
return true;
}
}
return false;
}
void MixerSnapshot::set_recall_eq(bool yn) { set_flag(yn, RecallEQ);};
void MixerSnapshot::set_recall_comp(bool yn) { set_flag(yn, RecallComp);};
void MixerSnapshot::set_recall_io(bool yn) { set_flag(yn, RecallIO);};
void MixerSnapshot::set_recall_group(bool yn) { set_flag(yn, RecallGroup);};
void MixerSnapshot::set_recall_vca(bool yn) { set_flag(yn, RecallVCA);};
bool MixerSnapshot::has_specials()
{
if(empty()) {
@ -326,14 +361,18 @@ void MixerSnapshot::write(const string path)
return;
}
set_recall_eq(true);
set_recall_io(true);
set_recall_vca(true);
XMLNode* node = new XMLNode("MixerSnapshot");
node->set_property(X_("flags"), _flags);
node->set_property(X_("favorite"), favorite);
node->set_property(X_("modified-with"), last_modified_with);
XMLNode* child;
child = node->add_child ("ProgramVersion");
child->set_property("modified-with", last_modified_with);
child = node->add_child ("Favorite");
child->set_property("favorite", favorite);
// child = node->add_child ("ProgramVersion");
// child->set_property("modified-with", last_modified_with);
child = node->add_child("Routes");
for(vector<State>::iterator i = route_states.begin(); i != route_states.end(); i++) {
@ -370,24 +409,16 @@ void MixerSnapshot::load(const string path)
return;
}
XMLNode* version_node = find_named_node(*root, "ProgramVersion");
XMLNode* fav_node = find_named_node(*root, "Favorite");
string fav;
root->get_property(X_("flags"), _flags);
root->get_property(X_("favorite"), fav);
root->get_property(X_("modified-with"), last_modified_with);
set_favorite(atoi(fav.c_str()));
XMLNode* route_node = find_named_node(*root, "Routes");
XMLNode* group_node = find_named_node(*root, "Groups");
XMLNode* vca_node = find_named_node(*root, "VCAS");
if(version_node) {
string version;
version_node->get_property(X_("modified-with"), version);
last_modified_with = version;
}
if(fav_node) {
string fav;
fav_node->get_property(X_("favorite"), fav);
favorite = atoi(fav.c_str());
}
if(route_node) {
XMLNodeList nlist = route_node->children();
for(XMLNodeConstIterator niter = nlist.begin(); niter != nlist.end(); niter++) {