Skip to content

Commit

Permalink
Merge pull request musescore#167 from watery/17906-midichordinput
Browse files Browse the repository at this point in the history
fix musescore#17906: chord MIDI input is fixed
  • Loading branch information
wschweer committed Jan 21, 2013
2 parents 97f3329 + 6cc6f32 commit a1804fe
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
17 changes: 17 additions & 0 deletions libmscore/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Chord*>(_is.cr());
Expand Down Expand Up @@ -1616,6 +1617,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
//---------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions libmscore/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ class Score : public QObject {
void moveDown(Chord*);

void moveInputPos(Segment* s);
void moveToPrevInputPos();
void moveToNextInputPos();

void padToggle(int n);
Expand Down
2 changes: 1 addition & 1 deletion mscore/musescore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a1804fe

Please sign in to comment.