Use XMLNode::get/set_property API in ARDOUR::MidiTrack class
This commit is contained in:
parent
46bd1e7758
commit
03ad6ae50a
@ -30,7 +30,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "pbd/enumwriter.h"
|
#include "pbd/enumwriter.h"
|
||||||
#include "pbd/convert.h"
|
#include "pbd/types_convert.h"
|
||||||
#include "evoral/midi_util.h"
|
#include "evoral/midi_util.h"
|
||||||
|
|
||||||
#include "ardour/beats_frames_converter.h"
|
#include "ardour/beats_frames_converter.h"
|
||||||
@ -52,6 +52,7 @@
|
|||||||
#include "ardour/route_group_specialized.h"
|
#include "ardour/route_group_specialized.h"
|
||||||
#include "ardour/session.h"
|
#include "ardour/session.h"
|
||||||
#include "ardour/session_playlists.h"
|
#include "ardour/session_playlists.h"
|
||||||
|
#include "ardour/types_convert.h"
|
||||||
#include "ardour/utils.h"
|
#include "ardour/utils.h"
|
||||||
|
|
||||||
#include "pbd/i18n.h"
|
#include "pbd/i18n.h"
|
||||||
@ -165,15 +166,11 @@ MidiTrack::midi_diskstream() const
|
|||||||
int
|
int
|
||||||
MidiTrack::set_state (const XMLNode& node, int version)
|
MidiTrack::set_state (const XMLNode& node, int version)
|
||||||
{
|
{
|
||||||
XMLProperty const * prop;
|
|
||||||
|
|
||||||
/* This must happen before Track::set_state(), as there will be a buffer
|
/* This must happen before Track::set_state(), as there will be a buffer
|
||||||
fill during that call, and we must fill buffers using the correct
|
fill during that call, and we must fill buffers using the correct
|
||||||
_note_mode.
|
_note_mode.
|
||||||
*/
|
*/
|
||||||
if ((prop = node.property (X_("note-mode"))) != 0) {
|
if (!node.get_property (X_("note-mode"), _note_mode)) {
|
||||||
_note_mode = NoteMode (string_2_enum (prop->value(), _note_mode));
|
|
||||||
} else {
|
|
||||||
_note_mode = Sustained;
|
_note_mode = Sustained;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,25 +181,24 @@ MidiTrack::set_state (const XMLNode& node, int version)
|
|||||||
// No destructive MIDI tracks (yet?)
|
// No destructive MIDI tracks (yet?)
|
||||||
_mode = Normal;
|
_mode = Normal;
|
||||||
|
|
||||||
if ((prop = node.property ("input-active")) != 0) {
|
bool yn;
|
||||||
set_input_active (string_is_affirmative (prop->value()));
|
if (node.get_property ("input-active", yn)) {
|
||||||
|
set_input_active (yn);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChannelMode playback_channel_mode = AllChannels;
|
ChannelMode playback_channel_mode = AllChannels;
|
||||||
ChannelMode capture_channel_mode = AllChannels;
|
ChannelMode capture_channel_mode = AllChannels;
|
||||||
|
|
||||||
if ((prop = node.property ("playback-channel-mode")) != 0) {
|
node.get_property ("playback-channel-mode", playback_channel_mode);
|
||||||
playback_channel_mode = ChannelMode (string_2_enum(prop->value(), playback_channel_mode));
|
node.get_property ("capture-channel-mode", capture_channel_mode);
|
||||||
}
|
|
||||||
if ((prop = node.property ("capture-channel-mode")) != 0) {
|
if (node.get_property ("channel-mode", playback_channel_mode)) {
|
||||||
capture_channel_mode = ChannelMode (string_2_enum(prop->value(), capture_channel_mode));
|
|
||||||
}
|
|
||||||
if ((prop = node.property ("channel-mode")) != 0) {
|
|
||||||
/* 3.0 behaviour where capture and playback modes were not separated */
|
/* 3.0 behaviour where capture and playback modes were not separated */
|
||||||
playback_channel_mode = ChannelMode (string_2_enum(prop->value(), playback_channel_mode));
|
|
||||||
capture_channel_mode = playback_channel_mode;
|
capture_channel_mode = playback_channel_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XMLProperty const * prop;
|
||||||
|
|
||||||
unsigned int playback_channel_mask = 0xffff;
|
unsigned int playback_channel_mask = 0xffff;
|
||||||
unsigned int capture_channel_mask = 0xffff;
|
unsigned int capture_channel_mask = 0xffff;
|
||||||
|
|
||||||
@ -243,12 +239,12 @@ MidiTrack::state(bool full_state)
|
|||||||
XMLNode* inode;
|
XMLNode* inode;
|
||||||
|
|
||||||
freeze_node = new XMLNode (X_("freeze-info"));
|
freeze_node = new XMLNode (X_("freeze-info"));
|
||||||
freeze_node->add_property ("playlist", _freeze_record.playlist->name());
|
freeze_node->set_property ("playlist", _freeze_record.playlist->name());
|
||||||
freeze_node->add_property ("state", enum_2_string (_freeze_record.state));
|
freeze_node->set_property ("state", _freeze_record.state);
|
||||||
|
|
||||||
for (vector<FreezeRecordProcessorInfo*>::iterator i = _freeze_record.processor_info.begin(); i != _freeze_record.processor_info.end(); ++i) {
|
for (vector<FreezeRecordProcessorInfo*>::iterator i = _freeze_record.processor_info.begin(); i != _freeze_record.processor_info.end(); ++i) {
|
||||||
inode = new XMLNode (X_("processor"));
|
inode = new XMLNode (X_("processor"));
|
||||||
inode->add_property (X_("id"), id().to_s ());
|
inode->set_property (X_("id"), id());
|
||||||
inode->add_child_copy ((*i)->state);
|
inode->add_child_copy ((*i)->state);
|
||||||
|
|
||||||
freeze_node->add_child_nocopy (*inode);
|
freeze_node->add_child_nocopy (*inode);
|
||||||
@ -257,16 +253,16 @@ MidiTrack::state(bool full_state)
|
|||||||
root.add_child_nocopy (*freeze_node);
|
root.add_child_nocopy (*freeze_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
root.add_property("playback_channel-mode", enum_2_string(get_playback_channel_mode()));
|
root.set_property("playback_channel-mode", get_playback_channel_mode());
|
||||||
root.add_property("capture_channel-mode", enum_2_string(get_capture_channel_mode()));
|
root.set_property("capture_channel-mode", get_capture_channel_mode());
|
||||||
snprintf (buf, sizeof(buf), "0x%x", get_playback_channel_mask());
|
snprintf (buf, sizeof(buf), "0x%x", get_playback_channel_mask());
|
||||||
root.add_property("playback-channel-mask", buf);
|
root.set_property("playback-channel-mask", std::string(buf));
|
||||||
snprintf (buf, sizeof(buf), "0x%x", get_capture_channel_mask());
|
snprintf (buf, sizeof(buf), "0x%x", get_capture_channel_mask());
|
||||||
root.add_property("capture-channel-mask", buf);
|
root.set_property("capture-channel-mask", std::string(buf));
|
||||||
|
|
||||||
root.add_property ("note-mode", enum_2_string (_note_mode));
|
root.set_property ("note-mode", _note_mode);
|
||||||
root.add_property ("step-editing", (_step_editing ? "yes" : "no"));
|
root.set_property ("step-editing", _step_editing);
|
||||||
root.add_property ("input-active", (_input_active ? "yes" : "no"));
|
root.set_property ("input-active", _input_active);
|
||||||
|
|
||||||
for (Controls::const_iterator c = _controls.begin(); c != _controls.end(); ++c) {
|
for (Controls::const_iterator c = _controls.begin(); c != _controls.end(); ++c) {
|
||||||
if (boost::dynamic_pointer_cast<MidiTrack::MidiControl>(c->second)) {
|
if (boost::dynamic_pointer_cast<MidiTrack::MidiControl>(c->second)) {
|
||||||
@ -283,7 +279,6 @@ void
|
|||||||
MidiTrack::set_state_part_two ()
|
MidiTrack::set_state_part_two ()
|
||||||
{
|
{
|
||||||
XMLNode* fnode;
|
XMLNode* fnode;
|
||||||
XMLProperty const * prop;
|
|
||||||
LocaleGuard lg;
|
LocaleGuard lg;
|
||||||
|
|
||||||
/* This is called after all session state has been restored but before
|
/* This is called after all session state has been restored but before
|
||||||
@ -303,8 +298,9 @@ MidiTrack::set_state_part_two ()
|
|||||||
}
|
}
|
||||||
_freeze_record.processor_info.clear ();
|
_freeze_record.processor_info.clear ();
|
||||||
|
|
||||||
if ((prop = fnode->property (X_("playlist"))) != 0) {
|
std::string str;
|
||||||
boost::shared_ptr<Playlist> pl = _session.playlists->by_name (prop->value());
|
if (fnode->get_property (X_("playlist"), str)) {
|
||||||
|
boost::shared_ptr<Playlist> pl = _session.playlists->by_name (str);
|
||||||
if (pl) {
|
if (pl) {
|
||||||
_freeze_record.playlist = boost::dynamic_pointer_cast<MidiPlaylist> (pl);
|
_freeze_record.playlist = boost::dynamic_pointer_cast<MidiPlaylist> (pl);
|
||||||
} else {
|
} else {
|
||||||
@ -314,9 +310,7 @@ MidiTrack::set_state_part_two ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((prop = fnode->property (X_("state"))) != 0) {
|
fnode->get_property (X_("state"), _freeze_record.state);
|
||||||
_freeze_record.state = FreezeState (string_2_enum (prop->value(), _freeze_record.state));
|
|
||||||
}
|
|
||||||
|
|
||||||
XMLNodeConstIterator citer;
|
XMLNodeConstIterator citer;
|
||||||
XMLNodeList clist = fnode->children();
|
XMLNodeList clist = fnode->children();
|
||||||
@ -326,13 +320,13 @@ MidiTrack::set_state_part_two ()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((prop = (*citer)->property (X_("id"))) == 0) {
|
if (!(*citer)->get_property (X_("id"), str)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
FreezeRecordProcessorInfo* frii = new FreezeRecordProcessorInfo (*((*citer)->children().front()),
|
FreezeRecordProcessorInfo* frii = new FreezeRecordProcessorInfo (*((*citer)->children().front()),
|
||||||
boost::shared_ptr<Processor>());
|
boost::shared_ptr<Processor>());
|
||||||
frii->id = prop->value ();
|
frii->id = str;
|
||||||
_freeze_record.processor_info.push_back (frii);
|
_freeze_record.processor_info.push_back (frii);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user