From 58763e6cc5762bb8ee588f6740a13d02d5524048 Mon Sep 17 00:00:00 2001 From: ws Date: Mon, 22 Sep 2014 14:31:28 +0200 Subject: [PATCH] fix #33366 --- libmscore/cmd.cpp | 17 ++++++++++++----- libmscore/edit.cpp | 21 ++++++++++++++------- libmscore/note.cpp | 21 ++++++++++----------- libmscore/note.h | 5 +++-- libmscore/utils.h | 1 + mscore/scoreview.cpp | 2 +- 6 files changed, 41 insertions(+), 26 deletions(-) diff --git a/libmscore/cmd.cpp b/libmscore/cmd.cpp index 9abcc1b56183..dc36cf9d6a6f 100644 --- a/libmscore/cmd.cpp +++ b/libmscore/cmd.cpp @@ -1660,11 +1660,18 @@ bool Score::processMidiInput() } NoteVal nval(ev.pitch); Staff* st = staff(inputState().track() / VOICES); - Key key = st->key(inputState().tick()); - nval.tpc = pitch2tpc(nval.pitch, key, Prefer::NEAREST); - if (!styleB(StyleIdx::concertPitch)) { - nval.pitch += st->part()->instr(inputState().tick())->transpose().chromatic; - } + Key key = st->key(inputState().tick()); + + if (styleB(StyleIdx::concertPitch)) { + nval.tpc1 = pitch2tpc(nval.pitch, key, Prefer::NEAREST); + nval.tpc2 = nval.tpc1; // DEBUG + } + else { + nval.pitch += st->part()->instr(inputState().tick())->transpose().chromatic; + nval.tpc2 = pitch2tpc(nval.pitch, key, Prefer::NEAREST); + nval.tpc1 = nval.tpc2; // DEBUG + } + addPitch(nval, ev.chord); } } diff --git a/libmscore/edit.cpp b/libmscore/edit.cpp index c987795a846e..89b0d2d3ca55 100644 --- a/libmscore/edit.cpp +++ b/libmscore/edit.cpp @@ -765,12 +765,15 @@ NoteVal Score::noteValForPosition(Position pos, bool &error) case StaffGroup::STANDARD: { AccidentalVal acci = s->measure()->findAccidental(s, staffIdx, line); - int step = absStep(line, clef); - int octave = step/7; - nval.pitch = step2pitch(step) + octave * 12 + int(acci); - if (!styleB(StyleIdx::concertPitch)) + int step = absStep(line, clef); + int octave = step/7; + nval.pitch = step2pitch(step) + octave * 12 + int(acci); + if (styleB(StyleIdx::concertPitch)) + nval.tpc1 = step2tpc(step % 7, acci); + else { nval.pitch += instr->transpose().chromatic; - nval.tpc = step2tpc(step % 7, acci); + nval.tpc2 = step2tpc(step % 7, acci); + } } break; } @@ -1054,9 +1057,13 @@ void Score::repitchNote(const Position& p, bool replace) int step = absStep(p.line, clef); int octave = step / 7; nval.pitch = step2pitch(step) + octave * 12 + int(acci); - if (!styleB(StyleIdx::concertPitch)) + + if (styleB(StyleIdx::concertPitch)) + nval.tpc1 = step2tpc(step % 7, acci); + else { nval.pitch += st->part()->instr(s->tick())->transpose().chromatic; - nval.tpc = step2tpc(step % 7, acci); + nval.tpc2 = step2tpc(step % 7, acci); + } Chord* chord; if (_is.cr()->type() == Element::Type::REST) { //skip rests diff --git a/libmscore/note.cpp b/libmscore/note.cpp index c545db05fd55..491cd1fddc57 100644 --- a/libmscore/note.cpp +++ b/libmscore/note.cpp @@ -2079,6 +2079,7 @@ void Note::updateLine() //--------------------------------------------------------- // setNval +// set note properties from NoteVal //--------------------------------------------------------- void Note::setNval(const NoteVal& nval) @@ -2086,9 +2087,15 @@ void Note::setNval(const NoteVal& nval) setPitch(nval.pitch); _fret = nval.fret; _string = nval.string; - if (nval.tpc == Tpc::TPC_INVALID) { + + _tpc[0] = nval.tpc1; + _tpc[1] = nval.tpc2; + + if (nval.tpc1 == Tpc::TPC_INVALID) { Key key = staff()->key(chord()->tick()); _tpc[0] = pitch2tpc(nval.pitch, key, Prefer::NEAREST); + } + if (nval.tpc2 == Tpc::TPC_INVALID) { Interval v = staff()->part()->instr()->transpose(); if (v.isZero()) _tpc[1] = _tpc[0]; @@ -2096,17 +2103,8 @@ void Note::setNval(const NoteVal& nval) v.flip(); _tpc[1] = Ms::transposeTpc(_tpc[0], v, false); } - return; } - if (concertPitch()) { - _tpc[0] = nval.tpc; - _tpc[1] = transposeTpc(nval.tpc); - } - else { - _tpc[0] = transposeTpc(nval.tpc); - _tpc[1] = nval.tpc; - } _headGroup = NoteHead::Group(nval.headGroup); } @@ -2490,7 +2488,8 @@ NoteVal Note::noteVal() const { NoteVal nval; nval.pitch = pitch(); - nval.tpc = tpc1(); + nval.tpc1 = tpc1(); + nval.tpc2 = tpc2(); nval.fret = fret(); nval.string = string(); nval.headGroup = headGroup(); diff --git a/libmscore/note.h b/libmscore/note.h index fd4cb5733c1a..0b51cfbf36bd 100644 --- a/libmscore/note.h +++ b/libmscore/note.h @@ -99,7 +99,8 @@ class NoteHead : public Symbol { struct NoteVal { int pitch { -1 }; - int tpc { Tpc::TPC_INVALID }; + int tpc1 { Tpc::TPC_INVALID }; + int tpc2 { Tpc::TPC_INVALID }; int fret { FRET_NONE }; int string { STRING_NONE }; NoteHead::Group headGroup { NoteHead::Group::HEAD_NORMAL }; @@ -302,7 +303,7 @@ class Note : public Element { Accidental* accidental() const { return _accidental; } void setAccidental(Accidental* a) { _accidental = a; } - + Accidental::Type accidentalType() const { return _accidental ? _accidental->accidentalType() : Accidental::Type::NONE; } void setAccidentalType(Accidental::Type type); diff --git a/libmscore/utils.h b/libmscore/utils.h index dd6a5b25c965..60b80b5efd56 100644 --- a/libmscore/utils.h +++ b/libmscore/utils.h @@ -82,6 +82,7 @@ extern int pitch2step(int pitch); extern int step2pitch(int step); + } // namespace Ms #endif diff --git a/mscore/scoreview.cpp b/mscore/scoreview.cpp index 83b895f91303..0641614fb9c3 100644 --- a/mscore/scoreview.cpp +++ b/mscore/scoreview.cpp @@ -5195,7 +5195,7 @@ void ScoreView::cmdRepeatSelection() Chord* c = static_cast(el)->chord(); for (Note* note : c->notes()) { NoteVal nval = note->noteVal(); - _score->addPitch(nval, addTo); + Note* n = _score->addPitch(nval, addTo); addTo = true; } _score->endCmd();