From f8ebb4582d4d881fbda75a6bc9cd9c50f5c921f3 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 28 Dec 2010 18:19:40 +0000 Subject: Unify program change and bank handling so that they are manipulated together. git-svn-id: svn://localhost/ardour2/branches/3.0@8346 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/midi_model.h | 59 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'libs/ardour/ardour/midi_model.h') diff --git a/libs/ardour/ardour/midi_model.h b/libs/ardour/ardour/midi_model.h index 83fe00567a..23e4b9de56 100644 --- a/libs/ardour/ardour/midi_model.h +++ b/libs/ardour/ardour/midi_model.h @@ -172,8 +172,66 @@ public: Change unmarshal_change (XMLNode *); }; + class PatchChangeDiffCommand : public DiffCommand { + public: + PatchChangeDiffCommand (boost::shared_ptr, const std::string &); + PatchChangeDiffCommand (boost::shared_ptr, const XMLNode &); + + int set_state (const XMLNode &, int version); + XMLNode & get_state (); + + void operator() (); + void undo (); + + void add (PatchChangePtr); + void remove (PatchChangePtr); + void change_time (PatchChangePtr, TimeType); + void change_channel (PatchChangePtr, uint8_t); + void change_program (PatchChangePtr, uint8_t); + void change_bank (PatchChangePtr, int); + + enum Property { + Time, + Channel, + Program, + Bank + }; + + private: + + struct Change { + PatchChangePtr patch; + Property property; + union { + TimeType old_time; + uint8_t old_channel; + int old_bank; + uint8_t old_program; + }; + union { + uint8_t new_channel; + TimeType new_time; + uint8_t new_program; + int new_bank; + }; + }; + + typedef std::list ChangeList; + ChangeList _changes; + + std::list _added; + std::list _removed; + + XMLNode & marshal_change (const Change &); + Change unmarshal_change (XMLNode *); + + XMLNode & marshal_patch_change (constPatchChangePtr); + PatchChangePtr unmarshal_patch_change (XMLNode *); + }; + MidiModel::NoteDiffCommand* new_note_diff_command (const std::string name = "midi edit"); MidiModel::SysExDiffCommand* new_sysex_diff_command (const std::string name = "midi edit"); + MidiModel::PatchChangeDiffCommand* new_patch_change_diff_command (const std::string name = "midi edit"); void apply_command (Session& session, Command* cmd); void apply_command_as_subcommand (Session& session, Command* cmd); @@ -193,6 +251,7 @@ public: void set_midi_source (boost::shared_ptr); boost::shared_ptr > find_note (NotePtr); + PatchChangePtr find_patch_change (Evoral::event_id_t); boost::shared_ptr > find_note (gint note_id); boost::shared_ptr > find_sysex (gint); -- cgit v1.2.3