Skip to content

Commit

Permalink
more fixes for #30336: Palm mute are now spanners
Browse files Browse the repository at this point in the history
  • Loading branch information
lasconic committed Aug 24, 2017
1 parent be69199 commit 11a58ef
Show file tree
Hide file tree
Showing 8 changed files with 229 additions and 148 deletions.
6 changes: 5 additions & 1 deletion mscore/importgtp-gp4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,9 @@ bool GuitarPro4::readNote(int string, int staffIdx, Note* note)
chord->add(a);
}
if (modMask2 & EFFECT_PALM_MUTE)
addPalmMute(note);
addPalmMute(note->chord(), note->staffIdx(), true);
else
addPalmMute(note->chord(), note->staffIdx(), false);

if (modMask2 & EFFECT_TREMOLO) { // tremolo picking length
int tremoloDivision = readUChar();
Expand Down Expand Up @@ -665,9 +667,11 @@ void GuitarPro4::read(QFile* fp)

slurs = new Slur*[staves];
letRings = new Pedal*[staves];
palmMutes = new TextLine*[staves];
for (int i = 0; i < staves; ++i) {
slurs[i] = 0;
letRings[i] = 0;
palmMutes[i] = 0;
}

Measure* measure = score->firstMeasure();
Expand Down
6 changes: 5 additions & 1 deletion mscore/importgtp-gp5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,11 @@ void GuitarPro5::read(QFile* fp)

slurs = new Slur*[staves];
letRings = new Pedal*[staves];
palmMutes = new TextLine*[staves];
for (int i = 0; i < staves; ++i) {
slurs[i] = 0;
letRings[i] = 0;
palmMutes[i] = 0;
}

int tnumerator = 4;
Expand Down Expand Up @@ -719,7 +721,9 @@ bool GuitarPro5::readNoteEffects(Note* note)
chord->add(a);
}
if (modMask2 & EFFECT_PALM_MUTE)
addPalmMute(note);
addPalmMute(note->chord(), note->staffIdx(), true);
else
addPalmMute(note->chord(), note->staffIdx(), false);

if (modMask2 & EFFECT_TREMOLO) { // tremolo picking length
int tremoloDivision = readUChar();
Expand Down
13 changes: 8 additions & 5 deletions mscore/importgtp-gp6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ int GuitarPro6::readBeats(QString beats, GPPartInfo* partInfo, Measure* measure,

QString harmonicText = "";
bool hasSlur = false;
bool hasPalmMute = false;
while (!currentProperty.isNull()) {
QString argument = currentProperty.attributes().namedItem("name").toAttr().value();
if (argument == "String")
Expand Down Expand Up @@ -896,7 +897,7 @@ int GuitarPro6::readBeats(QString beats, GPPartInfo* partInfo, Measure* measure,
}
else if (argument == "PalmMuted") {
if (!currentProperty.firstChild().nodeName().compare("Enable"))
addPalmMute(note);
hasPalmMute = true;
}
else if (argument == "Tapped") {
if (!currentProperty.firstChild().nodeName().compare("Enable"))
Expand Down Expand Up @@ -966,7 +967,7 @@ int GuitarPro6::readBeats(QString beats, GPPartInfo* partInfo, Measure* measure,
}
currentProperty = currentProperty.nextSibling();
}

addPalmMute(chord, staffIdx, hasPalmMute);
if (midi != "")
note->setPitch(midi.toInt());
else if (element != "")
Expand Down Expand Up @@ -1966,6 +1967,7 @@ void GuitarPro6::readGpif(QByteArray* data)
legatos = new Slur*[staves * VOICES];
letRings = new Pedal*[staves];
barres = new TextLine*[staves];
palmMutes = new TextLine*[staves];
ottava.assign(staves * VOICES, 0);
ottavaFound.assign(staves * VOICES, 0);
ottavaValue.assign(staves * VOICES, "");
Expand All @@ -1976,6 +1978,7 @@ void GuitarPro6::readGpif(QByteArray* data)
for (int i = 0; i < staves; ++i) {
letRings[i] = 0;
barres[i] = 0;
palmMutes[i] = 0;
}

// MasterBars node
Expand Down Expand Up @@ -2090,11 +2093,11 @@ void GuitarPro6::addBarre(Chord* chord, int staffIdx, bool hasBarre, QString tex
if (hasBarre) {
TextLine* tl = barres[staffIdx];
if (tl && tl->beginText() == text) {
// we already have pedal, let's expand it
// we already have barre, let's expand it
tl->setTick2(chord->tick() + chord->actualTicks());
}
else {
// we don't have pedal. Let's create one
// we don't have barre. Let's create one
tl = new TextLine(score);
tl->setParent(0);
tl->setBeginText(text);
Expand All @@ -2111,7 +2114,7 @@ void GuitarPro6::addBarre(Chord* chord, int staffIdx, bool hasBarre, QString tex
}
}
else {
// no more ring
// no more barre
TextLine* tl = barres[staffIdx];
if (tl)
barres[staffIdx] = 0;
Expand Down
34 changes: 29 additions & 5 deletions mscore/importgtp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,36 @@ void GuitarPro::initGuitarProDrumset()
// addPalmMate
//---------------------------------------------------------

void GuitarPro::addPalmMute(Note* note)
void GuitarPro::addPalmMute(Chord* chord, int staffIdx, bool hasPM)
{
QString palmMute = "P.M.";
TextStyle textStyle;
textStyle.setAlign(AlignmentFlags::CENTER);
addTextToNote(palmMute, textStyle, note);
TextLine* tl = palmMutes[staffIdx];
if (hasPM) {
if (tl) {
// we already have pm, let's expand it
tl->setTick2(chord->tick() + chord->actualTicks());
}
else {
// we don't have pm. Let's create one
tl = new TextLine(score);
tl->setParent(0);
tl->setBeginText("P.M.");
tl->setContinueText("P.M.");
tl->setEndHook(true);
tl->setTick(chord->tick());
tl->setTrack(chord->track());
tl->setTrack2(chord->track());
tl->setLineStyle(Qt::DashLine);
tl->setEndHookHeight(Spatium(1));
tl->setYoff(-2.5);
palmMutes[staffIdx] = tl;
score->addElement(tl);
}
}
else {
// no more pm
if (tl)
palmMutes[staffIdx] = 0;
}
}

//---------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion mscore/importgtp.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ class GuitarPro {
QTextCodec* _codec;
Slur** slurs;
Pedal** letRings;
TextLine** palmMutes;

void skip(qint64 len);
void read(void* p, qint64 len);
Expand Down Expand Up @@ -224,7 +225,7 @@ class GuitarPro {
void createSlide(int slide, ChordRest* cr, int staffIdx);
void createCrecDim(int staffIdx, int track, int tick, bool crec);
void addTextToNote(QString string, TextStyle textStyle, Note* note);
void addPalmMute(Note* note);
void addPalmMute(Chord* chord, int staffIdx, bool hasPM);
void addLetRing(Chord* chord, int staffIdx, bool hasLetRing);
void addTap(Note* note);
void addSlap(Note* note);
Expand Down
105 changes: 60 additions & 45 deletions mtest/guitarpro/palm-mute.gp4-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -102,53 +102,58 @@
<velocity>80</velocity>
<lid>5</lid>
</Dynamic>
<TextLine id="2">
<endHook>1</endHook>
<endHookHeight>1</endHookHeight>
<lid>15</lid>
<lineWidth>0.15</lineWidth>
<lineStyle>2</lineStyle>
<beginText>
<text>P.M.</text>
</beginText>
<continueText>
<text>P.M.</text>
</continueText>
</TextLine>
<Chord>
<lid>6</lid>
<durationType>quarter</durationType>
<Note>
<lid>7</lid>
<Text>
<lid>8</lid>
<style></style>
<halign>center</halign>
<valign>center</valign>
<xoffset>0</xoffset>
<yoffset>-2</yoffset>
<text>P.M.</text>
</Text>
<pitch>60</pitch>
<tpc>14</tpc>
<fret>5</fret>
<string>2</string>
</Note>
</Chord>
<endSpanner id="2"/>
<Chord>
<lid>9</lid>
<lid>8</lid>
<durationType>quarter</durationType>
<Note>
<lid>10</lid>
<lid>9</lid>
<pitch>57</pitch>
<tpc>17</tpc>
<fret>2</fret>
<string>2</string>
</Note>
</Chord>
<Chord>
<lid>11</lid>
<lid>10</lid>
<durationType>quarter</durationType>
<Note>
<lid>12</lid>
<lid>11</lid>
<pitch>59</pitch>
<tpc>19</tpc>
<fret>4</fret>
<string>2</string>
</Note>
</Chord>
<Chord>
<lid>13</lid>
<lid>12</lid>
<durationType>quarter</durationType>
<Note>
<lid>14</lid>
<lid>13</lid>
<pitch>62</pitch>
<tpc>16</tpc>
<fret>7</fret>
Expand Down Expand Up @@ -284,53 +289,58 @@
<velocity>80</velocity>
<lid>5</lid>
</Dynamic>
<TextLine id="3">
<endHook>1</endHook>
<endHookHeight>1</endHookHeight>
<lid>15</lid>
<lineWidth>0.15</lineWidth>
<lineStyle>2</lineStyle>
<beginText>
<text>P.M.</text>
</beginText>
<continueText>
<text>P.M.</text>
</continueText>
</TextLine>
<Chord>
<lid>6</lid>
<durationType>quarter</durationType>
<Note>
<lid>7</lid>
<Text>
<lid>8</lid>
<style></style>
<halign>center</halign>
<valign>center</valign>
<xoffset>0</xoffset>
<yoffset>-2</yoffset>
<text>P.M.</text>
</Text>
<pitch>60</pitch>
<tpc>14</tpc>
<fret>5</fret>
<string>2</string>
</Note>
</Chord>
<endSpanner id="3"/>
<Chord>
<lid>9</lid>
<lid>8</lid>
<durationType>quarter</durationType>
<Note>
<lid>10</lid>
<lid>9</lid>
<pitch>57</pitch>
<tpc>17</tpc>
<fret>2</fret>
<string>2</string>
</Note>
</Chord>
<Chord>
<lid>11</lid>
<lid>10</lid>
<durationType>quarter</durationType>
<Note>
<lid>12</lid>
<lid>11</lid>
<pitch>59</pitch>
<tpc>19</tpc>
<fret>4</fret>
<string>2</string>
</Note>
</Chord>
<Chord>
<lid>13</lid>
<lid>12</lid>
<durationType>quarter</durationType>
<Note>
<lid>14</lid>
<lid>13</lid>
<pitch>62</pitch>
<tpc>16</tpc>
<fret>7</fret>
Expand All @@ -349,53 +359,58 @@
<lid>2</lid>
<accidental>0</accidental>
</KeySig>
<TextLine id="4">
<endHook>1</endHook>
<endHookHeight>1</endHookHeight>
<lid>15</lid>
<lineWidth>0.15</lineWidth>
<lineStyle>2</lineStyle>
<beginText>
<text>P.M.</text>
</beginText>
<continueText>
<text>P.M.</text>
</continueText>
</TextLine>
<Chord>
<lid>6</lid>
<durationType>quarter</durationType>
<Note>
<lid>7</lid>
<Text>
<lid>8</lid>
<style></style>
<halign>center</halign>
<valign>center</valign>
<xoffset>0</xoffset>
<yoffset>-2</yoffset>
<text>P.M.</text>
</Text>
<pitch>60</pitch>
<tpc>14</tpc>
<fret>5</fret>
<string>2</string>
</Note>
</Chord>
<endSpanner id="4"/>
<Chord>
<lid>9</lid>
<lid>8</lid>
<durationType>quarter</durationType>
<Note>
<lid>10</lid>
<lid>9</lid>
<pitch>57</pitch>
<tpc>17</tpc>
<fret>2</fret>
<string>2</string>
</Note>
</Chord>
<Chord>
<lid>11</lid>
<lid>10</lid>
<durationType>quarter</durationType>
<Note>
<lid>12</lid>
<lid>11</lid>
<pitch>59</pitch>
<tpc>19</tpc>
<fret>4</fret>
<string>2</string>
</Note>
</Chord>
<Chord>
<lid>13</lid>
<lid>12</lid>
<durationType>quarter</durationType>
<Note>
<lid>14</lid>
<lid>13</lid>
<pitch>62</pitch>
<tpc>16</tpc>
<fret>7</fret>
Expand Down
Loading

0 comments on commit 11a58ef

Please sign in to comment.