Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/importexport/guitarpro/internal/gtp/gpconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ void GPConverter::convertNotes(const std::vector<std::shared_ptr<GPNote> >& note
if (cr->isChord()) {
Chord* ch = toChord(cr);
ch->sortNotes();
mu::iex::guitarpro::utils::createGhostNoteParenGroups(ch);
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/importexport/guitarpro/internal/importgtp-gp5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,11 @@ Fraction GuitarPro5::readBeat(const Fraction& tick, int voice, Measure* measure,
}
delnote.clear();
}
if (cr && cr->isChord()) {
Chord* chord = toChord(cr);
chord->sortNotes();
mu::iex::guitarpro::utils::createGhostNoteParenGroups(chord);
}
createSlur(hasSlur, staffIdx, cr);
if (lyrics) {
cr->add(lyrics);
Expand Down
42 changes: 42 additions & 0 deletions src/importexport/guitarpro/internal/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
#include "utils.h"

#include "realfn.h"
#include "engraving/dom/chord.h"
#include "engraving/dom/factory.h"
#include "engraving/dom/note.h"
#include "engraving/dom/parenthesis.h"
#include "engraving/dom/score.h"
#include "engraving/dom/measure.h"

Expand Down Expand Up @@ -139,4 +142,43 @@ Chord* getLocatedChord(mu::engraving::Score* score, Fraction tickFr, track_idx_t

return chord;
}

static void addParenthesesToNotes(Chord* ch, const std::vector<Note*>& notes)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
{
auto createParen = [ch](DirectionH dir) {
Parenthesis* p = Factory::createParenthesis(ch);
p->setParent(ch);
p->setTrack(ch->track());
p->setDirection(dir);
return p;
};

NoteParenthesisInfo* parenInfo = new NoteParenthesisInfo(createParen(DirectionH::LEFT), createParen(DirectionH::RIGHT), notes);
Comment thread
mikekirin marked this conversation as resolved.
ch->addNoteParenthesisInfo(parenInfo);
Comment thread
coderabbitai[bot] marked this conversation as resolved.

for (Note* n : notes) {
n->setProperty(Pid::HAS_PARENTHESES, PropertyValue::fromValue(ParenthesesMode::BOTH));
n->setHideGeneratedParens(true);
}
}

void createGhostNoteParenGroups(Chord* ch)
{
if (!ch->noteParentheses().empty()) {
return;
}

const std::vector<Note*>& notes = ch->notes();
const size_t count = notes.size();
std::vector<Note*> currentGroup;

for (size_t i = 0; i <= count; ++i) {
if (i < count && notes[i]->ghost()) {
currentGroup.push_back(notes[i]);
} else if (!currentGroup.empty()) {
addParenthesesToNotes(ch, currentGroup);
currentGroup.clear();
}
}
}
} // namespace mu::iex::guitarpro
1 change: 1 addition & 0 deletions src/importexport/guitarpro/internal/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ int harmonicOvertone(mu::engraving::Note* note, float harmonicValue, int harmoni
std::vector<int> standardTuningFor(int midiProgram, int stringsCount);
bool isStandardTuning(int midiProgram, const std::vector<int>& tuning);
mu::engraving::Chord* getLocatedChord(mu::engraving::Score* score, mu::engraving::Fraction tickFr, mu::engraving::track_idx_t track);
void createGhostNoteParenGroups(mu::engraving::Chord* ch);
} // mu::iex::guitarpro
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
<fret>12</fret>
<string>3</string>
<ghost>1</ghost>
<hideGeneratedParentheses>1</hideGeneratedParentheses>
</Note>
<NoteParenGroup>
<Notes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
<fret>12</fret>
<string>3</string>
<ghost>1</ghost>
<hideGeneratedParentheses>1</hideGeneratedParentheses>
</Note>
<NoteParenGroup>
<Notes>
Expand Down
Loading