};
/* Currently this class only supports changes of sys-ex time, but could be expanded */
- class SysexDiffCommand : public DiffCommand {
+ class SysExDiffCommand : public DiffCommand {
public:
- SysexDiffCommand (boost::shared_ptr<MidiModel> m, const XMLNode& node);
+ SysExDiffCommand (boost::shared_ptr<MidiModel> m, const XMLNode& node);
enum Property {
Time,
private:
struct Change {
boost::shared_ptr<Evoral::Event<TimeType> > sysex;
- SysexDiffCommand::Property property;
+ SysExDiffCommand::Property property;
TimeType old_time;
TimeType new_time;
};
Change unmarshal_change (XMLNode *);
};
- MidiModel::NoteDiffCommand* new_note_diff_command (const std::string name="midi edit");
+ MidiModel::NoteDiffCommand* new_note_diff_command (const std::string name = "midi edit");
+ MidiModel::SysExDiffCommand* new_sysex_diff_command (const std::string name = "midi edit");
void apply_command (Session& session, Command* cmd);
void apply_command_as_subcommand (Session& session, Command* cmd);
MidiModel::NoteDiffCommand::change (const NotePtr note, Property prop,
uint8_t new_value)
{
+ assert (note);
+
NoteChange change;
switch (prop) {
MidiModel::NoteDiffCommand::change (const NotePtr note, Property prop,
TimeType new_time)
{
+ assert (note);
+
NoteChange change;
switch (prop) {
for (set<NotePtr>::iterator i = temporary_removals.begin(); i != temporary_removals.end(); ++i) {
NoteDiffCommand side_effects (model(), "side effects");
- _model->add_note_unlocked (*i, &side_effects);
- *this += side_effects;
+ if (_model->add_note_unlocked (*i, &side_effects)) {
+ /* The note was re-added ok */
+ *this += side_effects;
+ } else {
+ /* The note that we removed earlier could not be re-added. This change record
+ must say that the note was removed. It is an un-note.
+ */
+
+ /* We didn't change it... */
+ for (ChangeList::iterator j = _changes.begin(); j != _changes.end(); ) {
+
+ ChangeList::iterator k = j;
+ ++k;
+
+ if (*i == j->note) {
+ _changes.erase (j);
+ }
+
+ j = k;
+ }
+
+ /* ...in fact, we removed it */
+ _removed_notes.push_back (*i);
+ }
}
if (!side_effect_removals.empty()) {
TimeType note_length = note->length();
DEBUG_TRACE (DEBUG::Sequence, string_compose ("%1 checking overlaps for note %2 @ %3\n", this, (int)note->note(), note->time()));
-
+
for (Pitches::const_iterator i = p.lower_bound (search_note);
i != p.end() && (*i)->note() == note->note(); ++i) {
TimeType eb = (*i)->end_time();
OverlapType overlap = OverlapNone;
-
if ((sb > sa) && (eb <= ea)) {
overlap = OverlapInternal;
} else if ((eb >= sa) && (eb <= ea)) {
continue;
}
- DEBUG_TRACE (DEBUG::Sequence, string_compose ("\toverlap is %1 for (%2,%3) vs (%4,%5)\n", enum_2_string(overlap),
+ DEBUG_TRACE (DEBUG::Sequence, string_compose ("\toverlap is %1 for (%2,%3) vs (%4,%5)\n", enum_2_string(overlap),
sa, ea, sb, eb));
if (insert_merge_policy() == InsertMergeReject) {