diff --git a/libs/ardour/ardour/segment_descriptor.h b/libs/ardour/ardour/segment_descriptor.h index f9e7aac285..55ed7cf6da 100644 --- a/libs/ardour/ardour/segment_descriptor.h +++ b/libs/ardour/ardour/segment_descriptor.h @@ -19,9 +19,13 @@ #ifndef __libardour_segment_descriptor_h__ #define __libardour_segment_descriptor_h__ +#include + #include "temporal/timeline.h" #include "temporal/tempo.h" +#include "evoral/SMF.h" + class XMLNode; namespace ARDOUR { @@ -58,6 +62,9 @@ public: Temporal::Tempo tempo() const { return _tempo; } void set_tempo (Temporal::Tempo const&); + Evoral::SMF::UsedChannels used_channels() const { return _used_channels; } + void set_used_channels (Evoral::SMF::UsedChannels); + Temporal::Meter meter() const { return _meter; } void set_meter (Temporal::Meter const&); @@ -69,6 +76,8 @@ public: private: Temporal::TimeDomain _time_domain; + Evoral::SMF::UsedChannels _used_channels; + /* cannot use a union for these because Temporal::Beats has a "non-trivial" constructor. */ diff --git a/libs/ardour/segment_descriptor.cc b/libs/ardour/segment_descriptor.cc index 32e246e270..4c8ef5fdc9 100644 --- a/libs/ardour/segment_descriptor.cc +++ b/libs/ardour/segment_descriptor.cc @@ -16,6 +16,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include + #include "pbd/enumwriter.h" #include "pbd/failed_constructor.h" #include "pbd/i18n.h" @@ -128,6 +130,12 @@ SegmentDescriptor::set_meter (Meter const & m) _meter = m; } +void +SegmentDescriptor::set_used_channels (Evoral::SMF::UsedChannels used) +{ + _used_channels = used; +} + XMLNode& SegmentDescriptor::get_state (void) const { @@ -146,6 +154,9 @@ SegmentDescriptor::get_state (void) const root->add_child_nocopy (_tempo.get_state()); root->add_child_nocopy (_meter.get_state()); + std::string uchan = string_compose ("%1", _used_channels.to_ulong()); + root->set_property (X_("used-channels"), uchan); + return *root; } @@ -160,6 +171,18 @@ SegmentDescriptor::set_state (XMLNode const & node, int version) return -1; } + std::string uchan; + if (node.get_property (X_("used-channels"), uchan)) { + } else { + unsigned long ul; + std::stringstream ss (uchan); + ss >> ul; + if (!ss) { + return -1; + } + _used_channels = Evoral::SMF::UsedChannels(ul); + } + if (_time_domain == Temporal::AudioTime) { if (node.get_property (X_("position"), _position_samples)) { return -1;