Skip to content

Commit

Permalink
Merge pull request #5774 from AntonioBL/tremolopaste
Browse files Browse the repository at this point in the history
fix #292393 : Pasting tremolo between dotted notes leads to wrong rhythm
  • Loading branch information
anatoly-os committed Jun 2, 2020
2 parents 5011d47 + 6bbdab8 commit f0b24ae
Show file tree
Hide file tree
Showing 4 changed files with 505 additions and 3 deletions.
23 changes: 20 additions & 3 deletions libmscore/paste.cpp
Expand Up @@ -562,13 +562,30 @@ void Score::pasteChordRest(ChordRest* cr, const Fraction& t, const Interval& src
{
Fraction tick(t);
// qDebug("pasteChordRest %s at %d, len %d/%d", cr->name(), tick, cr->ticks().numerator(), cr->ticks().denominator() );
if (cr->isChord())
transposeChord(toChord(cr), srcTranspose, tick);

Measure* measure = tick2measure(tick);
if (!measure)
return;

int twoNoteTremoloFactor = 1;
if (cr->isChord()) {
transposeChord(toChord(cr), srcTranspose, tick);
if (toChord(cr)->tremolo() && toChord(cr)->tremolo()->twoNotes())
twoNoteTremoloFactor = 2;
else if (cr->durationTypeTicks() == (cr->actualTicks() * 2)) {
// this could be the 2nd note of a two-note tremolo
// check previous CR on same track, if it has a two-note tremolo, then set twoNoteTremoloFactor to 2
Segment* seg = measure->undoGetSegment(SegmentType::ChordRest, tick);
ChordRest* crt = seg->nextChordRest(cr->track(), true);
if (crt && crt->isChord()) {
Chord* chrt = toChord(crt);
Tremolo* tr = chrt->tremolo();
if (tr && tr->twoNotes())
twoNoteTremoloFactor = 2;
}
}
}

// we can paste a measure rest as such only at start of measure
// and only if the lengths of the rest and measure match
// otherwise, we need to convert to duration rest(s)
Expand All @@ -584,7 +601,7 @@ void Score::pasteChordRest(ChordRest* cr, const Fraction& t, const Interval& src
if (cr->isRepeatMeasure())
partialCopy = toRepeatMeasure(cr)->actualTicks() != measure->ticks();
else if (!isGrace && !cr->tuplet())
partialCopy = cr->durationTypeTicks() != cr->actualTicks();
partialCopy = cr->durationTypeTicks() != (cr->actualTicks() * twoNoteTremoloFactor);

// if note is too long to fit in measure, split it up with a tie across the barline
// exclude tuplets from consideration
Expand Down
247 changes: 247 additions & 0 deletions mtest/libmscore/copypaste/copypaste_tremolo-ref.mscx
@@ -0,0 +1,247 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="3.01">
<Score>
<LayerTag id="0" tag="default"></LayerTag>
<currentLayer>0</currentLayer>
<Division>480</Division>
<Style>
<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">voice-paste1</metaTag>
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>Standard</name>
</StaffType>
</Staff>
<trackName>Violin</trackName>
<Instrument>
<longName>Violin</longName>
<shortName>Vln.</shortName>
<trackName>Violin</trackName>
<minPitchP>55</minPitchP>
<maxPitchP>103</maxPitchP>
<minPitchA>55</minPitchA>
<maxPitchA>88</maxPitchA>
<StringData>
<frets>24</frets>
<string>55</string>
<string>62</string>
<string>69</string>
<string>76</string>
</StringData>
<Articulation>
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="staccato">
<velocity>100</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="tenuto">
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="sforzato">
<velocity>120</velocity>
<gateTime>100</gateTime>
</Articulation>
<Channel>
<program value="40"/>
</Channel>
<Channel name="pizzicato">
<program value="45"/>
</Channel>
<Channel name="tremolo">
<program value="44"/>
</Channel>
</Instrument>
</Part>
<Staff id="1">
<VBox>
<height>10</height>
<Text>
<style>Title</style>
<text>voice-paste</text>
</Text>
</VBox>
<Measure>
<voice>
<Clef>
<concertClefType>G</concertClefType>
<transposingClefType>G</transposingClefType>
</Clef>
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
</TimeSig>
<Rest>
<durationType>quarter</durationType>
</Rest>
<Chord>
<dots>1</dots>
<durationType>half</durationType>
<duration>3/8</duration>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
<Tremolo>
<subtype>c16</subtype>
</Tremolo>
</Chord>
<Chord>
<dots>1</dots>
<durationType>half</durationType>
<duration>3/8</duration>
<Note>
<pitch>76</pitch>
<tpc>18</tpc>
</Note>
</Chord>
</voice>
<voice>
<Rest>
<durationType>quarter</durationType>
</Rest>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>62</pitch>
<tpc>16</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>64</pitch>
<tpc>18</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>65</pitch>
<tpc>13</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<dots>1</dots>
<durationType>quarter</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
<Chord>
<durationType>eighth</durationType>
<Note>
<pitch>76</pitch>
<tpc>18</tpc>
</Note>
</Chord>
<Rest>
<durationType>half</durationType>
</Rest>
</voice>
<voice>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>62</pitch>
<tpc>16</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>64</pitch>
<tpc>18</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<dots>1</dots>
<durationType>half</durationType>
<duration>3/8</duration>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
<Tremolo>
<subtype>c16</subtype>
</Tremolo>
</Chord>
<Chord>
<dots>1</dots>
<durationType>half</durationType>
<duration>3/8</duration>
<Note>
<pitch>76</pitch>
<tpc>18</tpc>
</Note>
</Chord>
<Rest>
<durationType>quarter</durationType>
</Rest>
</voice>
<voice>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>62</pitch>
<tpc>16</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>64</pitch>
<tpc>18</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>65</pitch>
<tpc>13</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Rest>
<durationType>measure</durationType>
<duration>4/4</duration>
</Rest>
<BarLine>
<subtype>end</subtype>
<span>1</span>
</BarLine>
</voice>
</Measure>
</Staff>
</Score>
</museScore>

0 comments on commit f0b24ae

Please sign in to comment.