Skip to content

Commit

Permalink
fix #3056: change the way MuseScore guess which notes to enter
Browse files Browse the repository at this point in the history
  • Loading branch information
lasconic committed Sep 5, 2013
1 parent 3a46158 commit d96fbd5
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 15 deletions.
6 changes: 0 additions & 6 deletions libmscore/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,6 @@ void Score::cmdAddInterval(int val, const QList<Note*>& nl)
setLayoutAll(true);

select(note, SELECT_SINGLE, 0);
_is.pitch = note->pitch();
}
moveToNextInputPos();
endCmd();
Expand Down Expand Up @@ -1253,7 +1252,6 @@ void Score::upDown(bool up, UpDownMode mode)
}
break;
}
_is.pitch = newPitch;

if ((oNote->pitch() != newPitch) || (oNote->tpc() != newTpc)) {
// remove accidental if present to make sure
Expand Down Expand Up @@ -2135,7 +2133,6 @@ void Score::cmd(const QAction* a)
Element* e = upAlt(el);
if (e) {
if (e->type() == Element::NOTE) {
_is.pitch = static_cast<Note*>(e)->pitch();
_playNote = true;
}
select(e, SELECT_SINGLE, 0);
Expand All @@ -2149,7 +2146,6 @@ void Score::cmd(const QAction* a)
Element* e = downAlt(el);
if (e) {
if (e->type() == Element::NOTE) {
_is.pitch = static_cast<Note*>(e)->pitch();
_playNote = true;
}
select(e, SELECT_SINGLE, 0);
Expand All @@ -2163,7 +2159,6 @@ void Score::cmd(const QAction* a)
Element* e = upAltCtrl(static_cast<Note*>(el));
if (e) {
if (e->type() == Element::NOTE) {
_is.pitch = static_cast<Note*>(e)->pitch();
_playNote = true;
}
select(e, SELECT_SINGLE, 0);
Expand All @@ -2177,7 +2172,6 @@ void Score::cmd(const QAction* a)
Element* e = downAltCtrl(static_cast<Note*>(el));
if (e) {
if (e->type() == Element::NOTE) {
_is.pitch = static_cast<Note*>(e)->pitch();
_playNote = true;
}
select(e, SELECT_SINGLE, 0);
Expand Down
3 changes: 0 additions & 3 deletions libmscore/edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,6 @@ void Score::putNote(const Position& p, bool replace)
break;
}

_is.pitch = nval.pitch;
expandVoice();
ChordRest* cr = _is.cr();
bool addToChord = false;
Expand Down Expand Up @@ -828,8 +827,6 @@ void Score::repitchNote(const Position& p, bool replace)
nval.pitch = step2pitch(step) + octave * 12 + acci;
nval.tpc = step2tpc(step % 7, acci);

_is.pitch = nval.pitch;

Chord* chord;
if (_is.cr()->type() == Element::REST) {
undoRemoveElement(_is.cr());
Expand Down
1 change: 0 additions & 1 deletion libmscore/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ InputState::InputState() :
_string(VISUAL_STRING_NONE),
_repitchMode(false),
rest(false),
pitch(72),
noteType(NOTE_NORMAL),
beamMode(BeamMode::AUTO),
noteEntryMode(false),
Expand Down
1 change: 0 additions & 1 deletion libmscore/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class InputState {

public:
bool rest; // rest mode
int pitch; // last pitch
NoteType noteType;
BeamMode beamMode;
bool noteEntryMode;
Expand Down
1 change: 0 additions & 1 deletion libmscore/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2703,7 +2703,6 @@ void Score::setInputState(Element* e)
_is.setDuration(chord->durationType());
_is.rest = false;
_is.setTrack(note->track());
_is.pitch = note->pitch();
_is.noteType = note->noteType();
_is.beamMode = chord->beamMode();
}
Expand Down
30 changes: 27 additions & 3 deletions mscore/scoreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4809,7 +4809,7 @@ void ScoreView::cmdAddPitch(int note, bool addFlag)
return;
}
Drumset* ds = is.drumset();
int octave = is.pitch / 12;
int octave = 4;
if (ds) {
char note1 = "CDEFGAB"[note];
int pitch = -1;
Expand All @@ -4829,9 +4829,33 @@ void ScoreView::cmdAddPitch(int note, bool addFlag)
octave = pitch / 12;
}
else {
static const int tab[] = { 0, 2, 4, 5, 7, 9, 11 };
int delta = octave * 12 + tab[note] - is.pitch;
int curPitch = -1;
if(is.segment()) {
Segment* seg = is.segment()->prev1(Segment::SegChordRest | Segment::SegClef);
while(seg) {
if(seg->segmentType() == Segment::SegChordRest) {
Element* p = seg->element(is.track());
if(p && p->type() == Element::CHORD) {
Chord* ch = static_cast<Chord*>(p);
curPitch = ch->downNote()->pitch();
break;
}
}
else if(seg->segmentType() == Segment::SegClef) {
Element* p = seg->element( (is.track() / VOICES) * VOICES); // clef on voice 1
if(p && p->type() == Element::CLEF) {
Clef* clef = static_cast<Clef*>(p);
curPitch = line2pitch(4, clef->clefType(), 0); // C 72 for treble clef
break;
}
}
seg = seg->prev1(Segment::SegChordRest | Segment::SegClef);
}
octave = curPitch / 12;
}

static const int tab[] = { 0, 2, 4, 5, 7, 9, 11 };
int delta = octave * 12 + tab[note] - curPitch;
if (delta > 6)
--octave;
else if (delta < -6)
Expand Down

0 comments on commit d96fbd5

Please sign in to comment.