Skip to content

Commit

Permalink
Merge pull request musescore#18455 from mikekirin/gp5-grace-import-fix
Browse files Browse the repository at this point in the history
Grace notes import from gp5 fix
  • Loading branch information
mikekirin committed Jul 7, 2023
2 parents ab483e5 + b65c4a5 commit 9d84acf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/importexport/guitarpro/internal/importgtp-gp5.cpp
Expand Up @@ -1074,18 +1074,30 @@ GuitarPro::ReadNoteResult GuitarPro5::readNoteEffects(Note* note)
int fret = readUInt8(); // grace fret
/*int dynamic =*/ readUInt8(); // grace dynamic
int transition = readUInt8(); // grace transition
/*int duration =*/ readUInt8(); // grace duration
int duration = readUInt8(); // grace duration
int gflags = readUInt8();

int grace_len = Constants::DIVISION / 8;
if (duration == 2) {
grace_len = Constants::DIVISION / 6; //24th
} else if (duration == 3) {
grace_len = Constants::DIVISION / 4; //16th
}
NoteType note_type = NoteType::ACCIACCATURA;

if (gflags & NOTE_APPOGIATURA) { //on beat
note_type = NoteType::APPOGGIATURA;
}

int grace_pitch = note->staff()->part()->instrument()->stringData()->getPitch(note->string(), fret, nullptr);
auto gnote = score->setGraceNote(note->chord(), grace_pitch, note_type, Constants::DIVISION / 2);

auto gnote = score->setGraceNote(note->chord(), grace_pitch, note_type, grace_len);
score->deselect(gnote);

// gp5 not supports more than one grace note,
// so it's always should be shown as eight note
gnote->chord()->setDurationType(Fraction { 1, 8 });

gnote->setString(note->string());
auto sd = note->part()->instrument()->stringData();
gnote->setFret(grace_pitch - sd->stringList().at(sd->stringList().size() - note->string() - 1).pitch);
Expand Down
5 changes: 5 additions & 0 deletions src/importexport/guitarpro/tests/data/grace.gp5-ref.mscx
Expand Up @@ -95,6 +95,7 @@
</Tempo>
<Chord>
<durationType>eighth</durationType>
<duration>1/32</duration>
<acciaccatura/>
<Note>
<Accidental>
Expand Down Expand Up @@ -126,6 +127,7 @@
</Chord>
<Chord>
<durationType>eighth</durationType>
<duration>7/128</duration>
<appoggiatura/>
<Note>
<Accidental>
Expand Down Expand Up @@ -161,6 +163,7 @@
<voice>
<Chord>
<durationType>eighth</durationType>
<duration>1/32</duration>
<acciaccatura/>
<Note>
<Accidental>
Expand Down Expand Up @@ -192,6 +195,7 @@
</Chord>
<Chord>
<durationType>eighth</durationType>
<duration>1/16</duration>
<Spanner type="Slur">
<Slur>
</Slur>
Expand Down Expand Up @@ -245,6 +249,7 @@
<voice>
<Chord>
<durationType>eighth</durationType>
<duration>1/16</duration>
<acciaccatura/>
<Note>
<Accidental>
Expand Down

0 comments on commit 9d84acf

Please sign in to comment.