Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix #33366
  • Loading branch information
wschweer committed Sep 22, 2014
1 parent daf130a commit 58763e6
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 26 deletions.
17 changes: 12 additions & 5 deletions libmscore/cmd.cpp
Expand Up @@ -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);
}
}
Expand Down
21 changes: 14 additions & 7 deletions libmscore/edit.cpp
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down
21 changes: 10 additions & 11 deletions libmscore/note.cpp
Expand Up @@ -2079,34 +2079,32 @@ void Note::updateLine()

//---------------------------------------------------------
// setNval
// set note properties from NoteVal
//---------------------------------------------------------

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];
else {
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);
}

Expand Down Expand Up @@ -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();
Expand Down
5 changes: 3 additions & 2 deletions libmscore/note.h
Expand Up @@ -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 };
Expand Down Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions libmscore/utils.h
Expand Up @@ -82,6 +82,7 @@ extern int pitch2step(int pitch);
extern int step2pitch(int step);



} // namespace Ms
#endif

2 changes: 1 addition & 1 deletion mscore/scoreview.cpp
Expand Up @@ -5195,7 +5195,7 @@ void ScoreView::cmdRepeatSelection()
Chord* c = static_cast<Note*>(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();
Expand Down

0 comments on commit 58763e6

Please sign in to comment.