segment_descriptor: stash UsedChannels here
* similar to segment_tempo, it is conceivable that a midi file would use different midi channels in different time ranges of the source
This commit is contained in:
parent
75e3646ed8
commit
bda8048873
|
@ -19,9 +19,13 @@
|
||||||
#ifndef __libardour_segment_descriptor_h__
|
#ifndef __libardour_segment_descriptor_h__
|
||||||
#define __libardour_segment_descriptor_h__
|
#define __libardour_segment_descriptor_h__
|
||||||
|
|
||||||
|
#include <bitset>
|
||||||
|
|
||||||
#include "temporal/timeline.h"
|
#include "temporal/timeline.h"
|
||||||
#include "temporal/tempo.h"
|
#include "temporal/tempo.h"
|
||||||
|
|
||||||
|
#include "evoral/SMF.h"
|
||||||
|
|
||||||
class XMLNode;
|
class XMLNode;
|
||||||
|
|
||||||
namespace ARDOUR {
|
namespace ARDOUR {
|
||||||
|
@ -58,6 +62,9 @@ public:
|
||||||
Temporal::Tempo tempo() const { return _tempo; }
|
Temporal::Tempo tempo() const { return _tempo; }
|
||||||
void set_tempo (Temporal::Tempo const&);
|
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; }
|
Temporal::Meter meter() const { return _meter; }
|
||||||
void set_meter (Temporal::Meter const&);
|
void set_meter (Temporal::Meter const&);
|
||||||
|
|
||||||
|
@ -69,6 +76,8 @@ public:
|
||||||
private:
|
private:
|
||||||
Temporal::TimeDomain _time_domain;
|
Temporal::TimeDomain _time_domain;
|
||||||
|
|
||||||
|
Evoral::SMF::UsedChannels _used_channels;
|
||||||
|
|
||||||
/* cannot use a union for these because Temporal::Beats has a
|
/* cannot use a union for these because Temporal::Beats has a
|
||||||
"non-trivial" constructor.
|
"non-trivial" constructor.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
#include "pbd/enumwriter.h"
|
#include "pbd/enumwriter.h"
|
||||||
#include "pbd/failed_constructor.h"
|
#include "pbd/failed_constructor.h"
|
||||||
#include "pbd/i18n.h"
|
#include "pbd/i18n.h"
|
||||||
|
@ -128,6 +130,12 @@ SegmentDescriptor::set_meter (Meter const & m)
|
||||||
_meter = m;
|
_meter = m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SegmentDescriptor::set_used_channels (Evoral::SMF::UsedChannels used)
|
||||||
|
{
|
||||||
|
_used_channels = used;
|
||||||
|
}
|
||||||
|
|
||||||
XMLNode&
|
XMLNode&
|
||||||
SegmentDescriptor::get_state (void) const
|
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 (_tempo.get_state());
|
||||||
root->add_child_nocopy (_meter.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;
|
return *root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,6 +171,18 @@ SegmentDescriptor::set_state (XMLNode const & node, int version)
|
||||||
return -1;
|
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 (_time_domain == Temporal::AudioTime) {
|
||||||
if (node.get_property (X_("position"), _position_samples)) {
|
if (node.get_property (X_("position"), _position_samples)) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user