From 5fb591e96619cb579a97f632cfc2cb173fe530d3 Mon Sep 17 00:00:00 2001 From: ws Date: Wed, 23 Apr 2014 11:08:51 +0200 Subject: [PATCH] fix #25411 --- libmscore/cmd.cpp | 31 ++++++++++++++++++++++++++----- libmscore/note.cpp | 40 ++++++++++++++++++++-------------------- 2 files changed, 46 insertions(+), 25 deletions(-) diff --git a/libmscore/cmd.cpp b/libmscore/cmd.cpp index 699fc2b6f3..0e838e9381 100644 --- a/libmscore/cmd.cpp +++ b/libmscore/cmd.cpp @@ -453,7 +453,8 @@ void Score::cmdAddInterval(int val, const QList& nl) int valTmp = val < 0 ? val+1 : val-1; int npitch; - int ntpc; + int ntpc1; + int ntpc2; if (abs(valTmp) != 7) { int line = on->line() - valTmp; int tick = chord->tick(); @@ -461,22 +462,42 @@ void Score::cmdAddInterval(int val, const QList& nl) ClefType clef = estaff->clef(tick); int key = estaff->key(tick).accidentalType(); npitch = line2pitch(line, clef, key); - ntpc = pitch2tpc(npitch, key, PREFER_NEAREST); + + int ntpc = pitch2tpc(npitch, key, PREFER_NEAREST); + Interval v = on->staff()->part()->instr()->transpose(); + if (v.isZero()) + ntpc1 = ntpc2 = ntpc; + else { + if (styleB(ST_concertPitch)) { + v.flip(); + ntpc1 = ntpc; + ntpc2 = Ms::transposeTpc(ntpc, v, false); + } + else { + npitch += v.chromatic; + ntpc2 = ntpc; + ntpc1 = Ms::transposeTpc(ntpc, v, false); + } + } } else { //special case for octave Interval interval(7, 12); if (val < 0) interval.flip(); - transposeInterval(on->pitch(), on->tpc(), &npitch, &ntpc, interval, false); + transposeInterval(on->pitch(), on->tpc(), &npitch, &ntpc1, interval, false); + ntpc1 = on->tpc1(); + ntpc2 = on->tpc2(); } - note->setPitch(npitch, ntpc, ntpc); + note->setPitch(npitch, ntpc1, ntpc2); undoAddElement(note); _playNote = true; - setLayoutAll(true); select(note, SELECT_SINGLE, 0); } + Chord* c = nl.front()->chord(); + c->measure()->cmdUpdateNotes(c->staffIdx()); + setLayoutAll(true); _is.moveToNextInputPos(); endCmd(); } diff --git a/libmscore/note.cpp b/libmscore/note.cpp index c2addf6cca..0a58eb2746 100644 --- a/libmscore/note.cpp +++ b/libmscore/note.cpp @@ -388,6 +388,26 @@ int Note::tpc() const return _tpc[concertPitchIdx()]; } +//--------------------------------------------------------- +// transposeTpc +// return transposed tpc +// If in concertPitch mode return tpc for transposed view +// else return tpc for concert pitch view. +//--------------------------------------------------------- + +int Note::transposeTpc(int tpc) + { + Interval v = staff()->part()->instr()->transpose(); + if (v.isZero()) + return tpc; + if (concertPitch()) { + v.flip(); + return Ms::transposeTpc(tpc, v, false); + } + else + return Ms::transposeTpc(tpc, v, false); + } + //--------------------------------------------------------- // noteHead //--------------------------------------------------------- @@ -1921,26 +1941,6 @@ void Note::setNval(NoteVal nval) _headGroup = NoteHeadGroup(nval.headGroup); } -//--------------------------------------------------------- -// transposeTpc -// return transposed tpc -// If in concertPitch mode return tpc for transposed view -// else return tpc for concert pitch view. -//--------------------------------------------------------- - -int Note::transposeTpc(int tpc) - { - Interval v = staff()->part()->instr()->transpose(); - if (v.isZero()) - return tpc; - if (concertPitch()) { - v.flip(); - return Ms::transposeTpc(tpc, v, false); - } - else - return Ms::transposeTpc(tpc, v, false); - } - //--------------------------------------------------------- // getProperty //---------------------------------------------------------