From 6cc6f320f095ee08a386d8e228f0a91fa705ca78 Mon Sep 17 00:00:00 2001 From: Marco Radaelli Date: Fri, 11 Jan 2013 02:06:36 +0100 Subject: [PATCH] fix #17906: when a chord is detected on MIDI input, the cursor is moved back before adding each subsequent note after the first, so that all of them become part of the same chord at the same position; the 'active' variable in MuseScore::midiNoteReceived() is used in a comparison, instead of directly as a parameter, since sometimes it can be -1 --- libmscore/cmd.cpp | 17 +++++++++++++++++ libmscore/score.h | 1 + mscore/musescore.cpp | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/libmscore/cmd.cpp b/libmscore/cmd.cpp index 2bfb3aa2708d..c8374fab1f8d 100644 --- a/libmscore/cmd.cpp +++ b/libmscore/cmd.cpp @@ -378,6 +378,7 @@ Note* Score::addPitch(int pitch, bool addFlag) qDebug("add pitch %d %d", pitch, addFlag); if (addFlag) { + moveToPrevInputPos(); if (_is.cr() == 0 || _is.cr()->type() != Element::CHORD) return 0; Chord* chord = static_cast(_is.cr()); @@ -1610,6 +1611,22 @@ void Score::moveInputPos(Segment* s) } //--------------------------------------------------------- +// moveToPrevInputPos +// Derived from moveToNextInputPos() +//--------------------------------------------------------- + +void Score::moveToPrevInputPos() + { + Segment* s = _is.segment(); + Measure* m = s->measure(); + int track = _is.track(); + for (s = s->prev1(Segment::SegChordRest); s; s = s->prev1(Segment::SegChordRest)) { + if (s->element(track) || s->measure() != m) + break; + } + moveInputPos(s); + } +//--------------------------------------------------------- // moveToNextInputPos // TODO: special case: note is first note of tie: goto to last note of tie //--------------------------------------------------------- diff --git a/libmscore/score.h b/libmscore/score.h index f4a29e1303c9..1fe5aa70b6e0 100644 --- a/libmscore/score.h +++ b/libmscore/score.h @@ -374,6 +374,7 @@ class Score : public QObject { void moveDown(Chord*); void moveInputPos(Segment* s); + void moveToPrevInputPos(); void moveToNextInputPos(); void padToggle(int n); diff --git a/mscore/musescore.cpp b/mscore/musescore.cpp index 1c2fb18c462c..289107565dc3 100644 --- a/mscore/musescore.cpp +++ b/mscore/musescore.cpp @@ -1742,7 +1742,7 @@ void MuseScore::midiNoteReceived(int channel, int pitch, int velo) iter = 0; } // qDebug(" midiNoteReceived %d active %d", pitch, active); - cv->midiNoteReceived(pitch, active); + cv->midiNoteReceived(pitch, active > 0); ++active; } else {