Merge pull request #1544 from MarcSabatella/41511-transpose-tpc

fix #41511: bad tpc1 for notes entered in keys other than C
This commit is contained in:
Werner Schweer 2014-12-16 15:13:20 +01:00
commit 7573e44bc0
6 changed files with 332 additions and 6 deletions

View file

@ -510,7 +510,7 @@ Segment* Score::setNoteRest(Segment* segment, int track, NoteVal nval, Fraction
chord->setDuration(d.fraction());
chord->setStemDirection(stemDirection);
chord->add(note);
note->setNval(nval);
note->setNval(nval, tick);
ncr = chord;
if (i+1 < n) {
tie = new Tie(this);

View file

@ -2122,7 +2122,7 @@ void Note::updateLine()
// set note properties from NoteVal
//---------------------------------------------------------
void Note::setNval(const NoteVal& nval)
void Note::setNval(const NoteVal& nval, int tick)
{
setPitch(nval.pitch);
_fret = nval.fret;
@ -2132,7 +2132,9 @@ void Note::setNval(const NoteVal& nval)
_tpc[1] = nval.tpc2;
if (nval.tpc1 == Tpc::TPC_INVALID) {
Key key = staff()->key(chord()->tick());
if (tick == -1)
tick = chord()->tick();
Key key = staff()->key(tick);
_tpc[0] = pitch2tpc(nval.pitch, key, Prefer::NEAREST);
}
if (nval.tpc2 == Tpc::TPC_INVALID) {

View file

@ -389,7 +389,7 @@ class Note : public Element {
QQmlListProperty<Ms::NoteDot> qmlDots();
void updateAccidental(AccidentalState*);
void updateLine();
void setNval(const NoteVal&);
void setNval(const NoteVal&, int tick = -1);
NoteEventList& playEvents() { return _playEvents; }
const NoteEventList& playEvents() const { return _playEvents; }
NoteEvent* noteEvent(int idx) { return &_playEvents[idx]; }

View file

@ -0,0 +1,172 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="2.00">
<Score>
<LayerTag id="0" tag="default"></LayerTag>
<currentLayer>0</currentLayer>
<Division>480</Division>
<Style>
<concertPitch>1</concertPitch>
<page-layout>
<page-height>1584</page-height>
<page-width>1224</page-width>
<page-margins type="even">
<left-margin>56.6929</left-margin>
<right-margin>90.1417</right-margin>
<top-margin>56.6929</top-margin>
<bottom-margin>113.386</bottom-margin>
</page-margins>
<page-margins type="odd">
<left-margin>56.6929</left-margin>
<right-margin>90.1417</right-margin>
<top-margin>56.6929</top-margin>
<bottom-margin>113.386</bottom-margin>
</page-margins>
</page-layout>
<Spatium>1.76389</Spatium>
</Style>
<showInvisible>1</showInvisible>
<showUnprintable>1</showUnprintable>
<showFrames>1</showFrames>
<showMargins>0</showMargins>
<metaTag name="arranger"></metaTag>
<metaTag name="composer"></metaTag>
<metaTag name="copyright"></metaTag>
<metaTag name="lyricist"></metaTag>
<metaTag name="movementNumber"></metaTag>
<metaTag name="movementTitle"></metaTag>
<metaTag name="poet"></metaTag>
<metaTag name="source"></metaTag>
<metaTag name="translator"></metaTag>
<metaTag name="workNumber"></metaTag>
<metaTag name="workTitle"></metaTag>
<PageList>
<Page>
<System>
</System>
</Page>
</PageList>
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<bracket type="-1" span="0"/>
</Staff>
<trackName>Flute</trackName>
<Instrument>
<longName pos="0">Flute</longName>
<shortName pos="0">Fl.</shortName>
<trackName>Flute</trackName>
<minPitchP>59</minPitchP>
<maxPitchP>98</maxPitchP>
<minPitchA>60</minPitchA>
<maxPitchA>93</maxPitchA>
<Articulation>
<velocity>100</velocity>
<gateTime>95</gateTime>
</Articulation>
<Articulation name="staccatissimo">
<velocity>100</velocity>
<gateTime>33</gateTime>
</Articulation>
<Articulation name="staccato">
<velocity>100</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="portato">
<velocity>100</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="tenuto">
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="marcato">
<velocity>120</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="sforzato">
<velocity>120</velocity>
<gateTime>100</gateTime>
</Articulation>
<Channel>
<program value="73"/>
</Channel>
</Instrument>
</Part>
<Staff id="1">
<Measure number="1">
<KeySig>
<accidental>-5</accidental>
</KeySig>
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
<showCourtesySig>1</showCourtesySig>
</TimeSig>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>61</pitch>
<tpc>9</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>63</pitch>
<tpc>11</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>65</pitch>
<tpc>13</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>66</pitch>
<tpc>8</tpc>
</Note>
</Chord>
</Measure>
<Measure number="2">
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>68</pitch>
<tpc>10</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>70</pitch>
<tpc>12</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>73</pitch>
<tpc>9</tpc>
</Note>
</Chord>
<BarLine>
<subtype>end</subtype>
<span>1</span>
</BarLine>
</Measure>
</Staff>
</Score>
</museScore>

View file

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="2.00">
<Score>
<LayerTag id="0" tag="default"></LayerTag>
<currentLayer>0</currentLayer>
<Division>480</Division>
<Style>
<page-layout>
<page-height>1584</page-height>
<page-width>1224</page-width>
<page-margins type="even">
<left-margin>56.6929</left-margin>
<right-margin>90.1417</right-margin>
<top-margin>56.6929</top-margin>
<bottom-margin>113.386</bottom-margin>
</page-margins>
<page-margins type="odd">
<left-margin>56.6929</left-margin>
<right-margin>90.1417</right-margin>
<top-margin>56.6929</top-margin>
<bottom-margin>113.386</bottom-margin>
</page-margins>
</page-layout>
<Spatium>1.76389</Spatium>
</Style>
<showInvisible>1</showInvisible>
<showUnprintable>1</showUnprintable>
<showFrames>1</showFrames>
<showMargins>0</showMargins>
<metaTag name="arranger"></metaTag>
<metaTag name="composer"></metaTag>
<metaTag name="copyright"></metaTag>
<metaTag name="lyricist"></metaTag>
<metaTag name="movementNumber"></metaTag>
<metaTag name="movementTitle"></metaTag>
<metaTag name="poet"></metaTag>
<metaTag name="source"></metaTag>
<metaTag name="translator"></metaTag>
<metaTag name="workNumber"></metaTag>
<metaTag name="workTitle"></metaTag>
<PageList>
<Page>
<System>
</System>
</Page>
</PageList>
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<bracket type="-1" span="0"/>
</Staff>
<trackName>Flute</trackName>
<Instrument>
<longName pos="0">Flute</longName>
<shortName pos="0">Fl.</shortName>
<trackName>Flute</trackName>
<minPitchP>59</minPitchP>
<maxPitchP>98</maxPitchP>
<minPitchA>60</minPitchA>
<maxPitchA>93</maxPitchA>
<Articulation>
<velocity>100</velocity>
<gateTime>95</gateTime>
</Articulation>
<Articulation name="staccatissimo">
<velocity>100</velocity>
<gateTime>33</gateTime>
</Articulation>
<Articulation name="staccato">
<velocity>100</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="portato">
<velocity>100</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="tenuto">
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="marcato">
<velocity>120</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="sforzato">
<velocity>120</velocity>
<gateTime>100</gateTime>
</Articulation>
<Channel>
<program value="73"/>
</Channel>
</Instrument>
</Part>
<Staff id="1">
<Measure number="1">
<KeySig>
<accidental>-5</accidental>
</KeySig>
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
<showCourtesySig>1</showCourtesySig>
</TimeSig>
<Rest>
<durationType>measure</durationType>
<duration z="4" n="4"/>
</Rest>
</Measure>
<Measure number="2">
<Rest>
<durationType>measure</durationType>
<duration z="4" n="4"/>
</Rest>
<BarLine>
<subtype>end</subtype>
<span>1</span>
</BarLine>
</Measure>
</Staff>
</Score>
</museScore>

View file

@ -39,6 +39,7 @@ class TestNote : public QObject, public MTest
void initTestCase();
void note();
void grace();
void tpc();
};
//---------------------------------------------------------
@ -324,10 +325,8 @@ void TestNote::grace()
// delete n;
// tie
score->startCmd();
score->select(gn);
score->cmdAddTie();
score->endCmd();
// n = static_cast<Note*>(writeReadElement(gn));
// QVERIFY(n->tieFor() != 0);
// delete n;
@ -360,6 +359,36 @@ void TestNote::grace()
}
//---------------------------------------------------------
/// tpc
/// read/write test of note tpc values
//---------------------------------------------------------
void TestNote::tpc()
{
Score* score = readScore(DIR + "tpc.mscx");
score->doLayout();
score->inputState().setTrack(0);
score->inputState().setSegment(score->tick2segment(0, false, Segment::Type::ChordRest));
score->inputState().setDuration(TDuration::DurationType::V_QUARTER);
score->inputState().setNoteEntryMode(true);
int octave = 5 * 7;
score->cmdAddPitch(octave + 1, false);
score->cmdAddPitch(octave + 2, false);
score->cmdAddPitch(octave + 3, false);
score->cmdAddPitch(octave + 4, false);
score->cmdAddPitch(octave + 5, false);
score->cmdAddPitch(octave + 6, false);
score->cmdAddPitch(octave + 7, false);
score->cmdAddPitch(octave + 8, false);
score->cmdConcertPitchChanged(true, true);
QVERIFY(saveCompareScore(score, "tpc-test.mscx", DIR + "tpc-ref.mscx"));
}
QTEST_MAIN(TestNote)
#include "tst_note.moc"