This commit is contained in:
ws 2014-04-23 11:08:51 +02:00
parent 790927b67d
commit 5fb591e966
2 changed files with 46 additions and 25 deletions

View file

@ -453,7 +453,8 @@ void Score::cmdAddInterval(int val, const QList<Note*>& 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<Note*>& 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();
}

View file

@ -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
//---------------------------------------------------------