@@ -345,7 +345,7 @@ void GPConverter::convert(const std::vector<std::unique_ptr<GPMasterBar> >& mast
345345
346346 addTempoMap ();
347347 addInstrumentChanges ();
348- m_guitarBendImporter->applyBendsToChords ();
348+ m_guitarBendImporter->addElementsToScore ();
349349
350350 addFermatas ();
351351 addContinuousSlideHammerOn ();
@@ -1999,64 +1999,71 @@ void GPConverter::collectHammerOn(const GPNote* gpnote, Note* note)
19991999 }
20002000}
20012001
2002- void GPConverter::addBend (const GPNote* gpnote, Note* note )
2002+ static mu::engraving::PitchValues gpBendCurveToPitchValues (const GPNote::Bend& b )
20032003{
2004- if (!gpnote->bend () || gpnote->bend ()->isEmpty ()) {
2005- return ;
2006- }
2007-
20082004 using namespace mu ::engraving;
20092005
20102006 auto gpTimeToMuTime = [] (float time) {
20112007 return time * PitchValue::MAX_TIME / 100 ;
20122008 };
20132009
2014- const GPNote::Bend* gpBend = gpnote->bend ();
2015-
20162010 bool bendHasMiddleValue = true ;
2017- if (gpBend-> middleOffset1 == 12 && gpBend-> middleOffset2 == 12 ) {
2011+ if (b. middleOffset1 == 12 && b. middleOffset2 == 12 ) {
20182012 bendHasMiddleValue = false ;
20192013 }
20202014
20212015 PitchValues pitchValues;
20222016
2023- pitchValues.push_back (PitchValue (gpTimeToMuTime (gpBend-> originOffset ), gpBend-> originValue ));
2017+ pitchValues.push_back (PitchValue (gpTimeToMuTime (b. originOffset ), b. originValue ));
20242018 PitchValue lastPoint = pitchValues.back ();
20252019
20262020 if (bendHasMiddleValue) {
2027- if (PitchValue value (gpTimeToMuTime (gpBend-> middleOffset1 ), gpBend-> middleValue );
2028- gpBend-> middleOffset1 >= 0 && gpBend-> middleOffset1 < gpBend-> destinationOffset && value != lastPoint) {
2021+ if (PitchValue value (gpTimeToMuTime (b. middleOffset1 ), b. middleValue );
2022+ b. middleOffset1 >= 0 && b. middleOffset1 < b. destinationOffset && value != lastPoint) {
20292023 pitchValues.push_back (std::move (value));
20302024 }
20312025
2032- if (PitchValue value (gpTimeToMuTime (gpBend-> middleOffset2 ), gpBend-> middleValue );
2033- gpBend-> middleOffset2 >= 0 && gpBend-> middleOffset2 != gpBend-> middleOffset1
2034- && gpBend-> middleOffset2 < gpBend-> destinationOffset
2026+ if (PitchValue value (gpTimeToMuTime (b. middleOffset2 ), b. middleValue );
2027+ b. middleOffset2 >= 0 && b. middleOffset2 != b. middleOffset1
2028+ && b. middleOffset2 < b. destinationOffset
20352029 && value != lastPoint) {
20362030 pitchValues.push_back (std::move (value));
20372031 }
20382032
2039- if (gpBend-> middleOffset1 == -1 && gpBend-> middleOffset2 == -1 && gpBend-> middleValue != -1 ) {
2033+ if (b. middleOffset1 == -1 && b. middleOffset2 == -1 && b. middleValue != -1 ) {
20402034 // !@NOTE It seems when middle point is places exactly in the middle
20412035 // !of bend GP6 stores this value equal -1
2042- if (gpBend-> destinationOffset > 50 ) {
2043- pitchValues.push_back (PitchValue (gpTimeToMuTime (50 ), gpBend-> middleValue ));
2036+ if (b. destinationOffset > 50 ) {
2037+ pitchValues.push_back (PitchValue (gpTimeToMuTime (50 ), b. middleValue ));
20442038 }
20452039 }
20462040 }
20472041
2048- if (gpBend-> destinationOffset <= 0 ) {
2049- PitchValue fixGpxValue = PitchValue (gpTimeToMuTime (50 ), gpBend-> middleValue );
2050- if (gpBend-> middleValue > gpBend-> destinationValue && pitchValues.back () != fixGpxValue) {
2042+ if (b. destinationOffset <= 0 ) {
2043+ PitchValue fixGpxValue = PitchValue (gpTimeToMuTime (50 ), b. middleValue );
2044+ if (b. middleValue > b. destinationValue && pitchValues.back () != fixGpxValue) {
20512045 pitchValues.push_back (fixGpxValue);
20522046 }
2053- pitchValues.push_back (PitchValue (gpTimeToMuTime (100 ), gpBend-> destinationValue )); // ! In .gpx this value might be exist
2047+ pitchValues.push_back (PitchValue (gpTimeToMuTime (100 ), b. destinationValue )); // ! In .gpx this value might be exist
20542048 } else {
2055- if (PitchValue value (gpTimeToMuTime (gpBend-> destinationOffset ), gpBend-> destinationValue ); value != lastPoint) {
2049+ if (PitchValue value (gpTimeToMuTime (b. destinationOffset ), b. destinationValue ); value != lastPoint) {
20562050 pitchValues.push_back (std::move (value));
20572051 }
20582052 }
20592053
2054+ return pitchValues;
2055+ }
2056+
2057+ void GPConverter::addBend (const GPNote* gpnote, Note* note)
2058+ {
2059+ if (!gpnote->bend () || gpnote->bend ()->isEmpty ()) {
2060+ return ;
2061+ }
2062+
2063+ using namespace mu ::engraving;
2064+
2065+ PitchValues pitchValues = gpBendCurveToPitchValues (*gpnote->bend ());
2066+
20602067 if (pitchValues.size () < 2 ) {
20612068 return ;
20622069 }
@@ -2355,7 +2362,13 @@ void GPConverter::addPalmMute(const GPBeat* gpbeat, ChordRest* cr)
23552362void GPConverter::addDive (const GPBeat* beat, ChordRest* cr)
23562363{
23572364 m_continiousElementsBuilder->buildContiniousElement (cr, ElementType::WHAMMY_BAR , ContiniousElementsBuilder::ImportType::WHAMMY_BAR ,
2358- beat->dive ());
2365+ beat->hasWhammy ());
2366+
2367+ if (!beat->hasWhammy () || !cr->isChord ()) {
2368+ return ;
2369+ }
2370+
2371+ m_guitarBendImporter->collectDive (toChord (cr), gpBendCurveToPitchValues (beat->whammy ()));
23592372}
23602373
23612374void GPConverter::addPickScrape (const GPBeat* beat, ChordRest* cr)
0 commit comments