X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fmidi_scene_change.cc;h=969dadbf7596cc66d70c427457c551614c863d38;hb=f371ac1beb035716ef2e1def831a61bd4b5020c2;hp=81a74911a97cbbf2267889cf73ff352311a46882;hpb=2cf411e4be0b10e6ecf47d2070963299b6a810e7;p=ardour.git diff --git a/libs/ardour/midi_scene_change.cc b/libs/ardour/midi_scene_change.cc index 81a74911a9..969dadbf75 100644 --- a/libs/ardour/midi_scene_change.cc +++ b/libs/ardour/midi_scene_change.cc @@ -23,14 +23,13 @@ #include "ardour/midi_port.h" #include "ardour/midi_scene_change.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace PBD; using namespace ARDOUR; -MIDISceneChange::MIDISceneChange (framepos_t time, int c, int b, int p) - : SceneChange (time) - , _bank (b) +MIDISceneChange::MIDISceneChange (int c, int b, int p) + : _bank (b) , _program (p) , _channel (c & 0xf) { @@ -44,8 +43,7 @@ MIDISceneChange::MIDISceneChange (framepos_t time, int c, int b, int p) } MIDISceneChange::MIDISceneChange (const XMLNode& node, int version) - : SceneChange (0) - , _bank (-1) + : _bank (-1) , _program (-1) , _channel (-1) { @@ -65,7 +63,7 @@ MIDISceneChange::get_bank_msb_message (uint8_t* buf, size_t size) const buf[0] = 0xB0 | (_channel & 0xf); buf[1] = 0x0; - buf[2] = (_bank & 0xf700) >> 8; + buf[2] = (_bank >> 7) & 0x7f; return 3; } @@ -79,7 +77,7 @@ MIDISceneChange::get_bank_lsb_message (uint8_t* buf, size_t size) const buf[0] = 0xB0 | (_channel & 0xf); buf[1] = 0x20; - buf[2] = (_bank & 0xf7); + buf[2] = _bank & 0x7f; return 3; } @@ -92,7 +90,7 @@ MIDISceneChange::get_program_message (uint8_t* buf, size_t size) const } buf[0] = 0xC0 | (_channel & 0xf); - buf[1] = _program & 0xf7; + buf[1] = _program & 0x7f; return 2; } @@ -112,6 +110,8 @@ MIDISceneChange::get_state () node->add_property (X_("bank"), buf); snprintf (buf, sizeof (buf), "%d", (int) _channel); node->add_property (X_("channel"), buf); + snprintf (buf, sizeof (buf), "%u", _color); + node->add_property (X_("color"), buf); return *node; } @@ -123,7 +123,7 @@ MIDISceneChange::set_state (const XMLNode& node, int /* version-ignored */) return -1; } - const XMLProperty* prop; + XMLProperty const * prop; if ((prop = node.property (X_("program"))) == 0) { return -1; @@ -140,5 +140,39 @@ MIDISceneChange::set_state (const XMLNode& node, int /* version-ignored */) } _channel = atoi (prop->value()); + if ((prop = node.property (X_("color"))) != 0) { + _color = atoi (prop->value()); + } else { + _color = out_of_bound_color; + } + return 0; } + +bool +MIDISceneChange::operator==(const MIDISceneChange& other) const +{ + return _program == other._program && + _bank == other._bank && + _channel == other._channel; +} + +void +MIDISceneChange::set_channel (int channel) +{ + _channel = channel; +} + +void +MIDISceneChange::set_program (int program) +{ + _program = program; +} + +void +MIDISceneChange::set_bank (int bank) +{ + _bank = bank; +} + +