Skip to content

Commit

Permalink
Merge pull request #166 from muelleki/17906-chords
Browse files Browse the repository at this point in the history
#17906: Chord input from MIDI works again
  • Loading branch information
wschweer committed Jan 21, 2013
2 parents 12cd120 + e8159e1 commit 0bc14e8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
10 changes: 7 additions & 3 deletions libmscore/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,12 @@ qDebug("add pitch %d %d", pitch, addFlag);
Note* n = addNote(chord, pitch);
setLayoutAll(false);
setLayout(chord->measure());
moveToNextInputPos();
return n;
}
if (_is.moveBeforeAdding())
moveToNextInputPos();
else
_is.setMoveBeforeAdding(true);
expandVoice();

// insert note
Expand Down Expand Up @@ -444,7 +447,6 @@ qDebug("add pitch %d %d", pitch, addFlag);
qDebug("addPitch: cannot find slur note");
setLayoutAll(true);
}
moveToNextInputPos();
return note;
}

Expand Down Expand Up @@ -1573,7 +1575,9 @@ bool Score::processMidiInput()
startCmd();
cmdActive = true;
}
n = addPitch(ev.pitch, ev.chord);
Note* n2 = addPitch(ev.pitch, ev.chord);
if (n2)
n = n2;
}
}
if (cmdActive) {
Expand Down
1 change: 1 addition & 0 deletions libmscore/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ InputState::InputState() :
_segment(0),
_string(VISUAL_STRING_NONE),
_repitchMode(false),
_moveBeforeAdding(false),
rest(false),
pitch(72),
noteType(NOTE_NORMAL),
Expand Down
4 changes: 4 additions & 0 deletions libmscore/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class InputState {
Segment* _segment; // current segment
int _string; // visual string selected for input (TAB staves only)
bool _repitchMode;
bool _moveBeforeAdding;

public:
bool rest; // rest mode
Expand Down Expand Up @@ -70,6 +71,9 @@ class InputState {
bool repitchMode() const { return _repitchMode; }
void setRepitchMode(bool val) { _repitchMode = val; }

bool moveBeforeAdding() const { return _moveBeforeAdding; }
void setMoveBeforeAdding(bool val) { _moveBeforeAdding = val; }

StaffGroup staffGroup() const;
};

Expand Down
1 change: 1 addition & 0 deletions libmscore/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2705,6 +2705,7 @@ void Score::setInputState(Element* e)
e = static_cast<Chord*>(e)->upNote();

_is.setDrumNote(-1);
_is.setMoveBeforeAdding(false);
// _is.setDrumset(0);
if (e->type() == Element::NOTE) {
Note* note = static_cast<Note*>(e);
Expand Down
4 changes: 3 additions & 1 deletion mscore/scoreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3501,7 +3501,9 @@ void ScoreView::adjustCanvasPosition(const Element* el, bool playBack)
}

const Measure* m;
if (el->type() == Element::NOTE)
if (!el)
return;
else if (el->type() == Element::NOTE)
m = static_cast<const Note*>(el)->chord()->measure();
else if (el->type() == Element::REST)
m = static_cast<const Rest*>(el)->measure();
Expand Down

2 comments on commit 0bc14e8

@krlmlr
Copy link

@krlmlr krlmlr commented on 0bc14e8 Jan 21, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This conflicts with #167, although the second commit of pull request #166 (3e11d32) is fine. See also the discussion on http://musescore.org/en/node/17906.

@krlmlr
Copy link

@krlmlr krlmlr commented on 0bc14e8 Jan 25, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have added a pull request to undo my conflicting changes: #182

Please sign in to comment.