Skip to content

Commit 91f58f4

Browse files
fix musescore#27661: render normal tie over repeat as partial tie
1 parent bf216f1 commit 91f58f4

File tree

3 files changed

+156
-31
lines changed

3 files changed

+156
-31
lines changed

src/engraving/playback/utils/repeatutils.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#pragma once
2424

2525
#include "dom/note.h"
26-
#include "dom/partialtie.h"
2726
#include "dom/repeatlist.h"
2827

2928
#include "playback/renderingcontext.h"
@@ -100,8 +99,8 @@ inline PartiallyTiedNoteInfo findIncomingNoteInNextRepeat(const Note* outgoingNo
10099
}
101100

102101
const Note* incomingNote = toChord(firstChordRest)->findNote(outgoingNote->pitch());
103-
const PartialTie* partialTie = incomingNote ? incomingNote->incomingPartialTie() : nullptr;
104-
if (partialTie && partialTie->playSpanner()) {
102+
const Tie* tie = incomingNote ? incomingNote->tieBack() : nullptr;
103+
if (tie && tie->playSpanner()) {
105104
return { nextRepeat, incomingNote };
106105
}
107106

src/engraving/tests/playback/playbackeventsrenderer_data/tied_notes_and_repeats.mscx

100755100644
+120-20
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<museScore version="4.40">
2+
<museScore version="4.50">
33
<programVersion>4.5.0</programVersion>
4-
<programRevision></programRevision>
5-
<LastEID>1176</LastEID>
4+
<programRevision>28c68b6</programRevision>
65
<Score>
6+
<eid>97Z0vopWEMC_FONP93YwiR</eid>
77
<Division>480</Division>
88
<showInvisible>1</showInvisible>
99
<showUnprintable>1</showUnprintable>
@@ -137,35 +137,37 @@
137137
</Part>
138138
<Staff id="1">
139139
<Measure>
140+
<eid>uRgMxTgGrSG_ffaQU4kE3OH</eid>
140141
<voice>
141142
<KeySig>
142-
<eid>1554778161175</eid>
143+
<eid>nX89TmsQ+JM_zbQ43pbvyyJ</eid>
143144
<concertKey>0</concertKey>
144145
</KeySig>
145146
<TimeSig>
146-
<eid>1546188226585</eid>
147+
<eid>cc8m79KxRAK_Q9fJ6Ma43xF</eid>
147148
<sigN>4</sigN>
148149
<sigD>4</sigD>
149150
</TimeSig>
150151
<Rest>
151-
<eid>1563368095770</eid>
152+
<eid>YoCy9IemNZE_mkIWdl6oAwH</eid>
152153
<durationType>measure</durationType>
153154
<duration>4/4</duration>
154155
</Rest>
155156
</voice>
156157
</Measure>
157158
<Measure>
159+
<eid>tZaz2QDP8kP_Q9BwXXipAGE</eid>
158160
<startRepeat/>
159161
<endRepeat>2</endRepeat>
160162
<voice>
161163
<Chord>
162-
<eid>4423816314994</eid>
164+
<eid>KYor0yYyE6L_6uMZ4gzBg+D</eid>
163165
<durationType>quarter</durationType>
164166
<Note>
165-
<eid>4419521347604</eid>
167+
<eid>bQWnEGNAUoG_8x/Iua0iQhF</eid>
166168
<Spanner type="Tie">
167169
<Tie>
168-
<eid>4668629450783</eid>
170+
<eid>NhYap6sJN1E_qdt7+ywcV9H</eid>
169171
</Tie>
170172
<next>
171173
<location>
@@ -178,10 +180,10 @@
178180
</Note>
179181
</Chord>
180182
<Chord>
181-
<eid>4514010628210</eid>
183+
<eid>Tl4WDGr4sM_AJpCRVrCSIM</eid>
182184
<durationType>quarter</durationType>
183185
<Note>
184-
<eid>4509715660820</eid>
186+
<eid>w5kf5dwaJ1D_N0AqNzTmi9K</eid>
185187
<Spanner type="Tie">
186188
<prev>
187189
<location>
@@ -194,13 +196,13 @@
194196
</Note>
195197
</Chord>
196198
<Chord>
197-
<eid>2774548873330</eid>
199+
<eid>j1E+Xh3igzG_ycGaBttQ7RK</eid>
198200
<durationType>half</durationType>
199201
<Note>
200-
<eid>2770253905940</eid>
202+
<eid>6ZaoRBuLIeP_1YMCRles9aB</eid>
201203
<Spanner type="Tie">
202204
<Tie>
203-
<eid>3401614098463</eid>
205+
<eid>ufnw5ilWNzJ_V9soscTyH5B</eid>
204206
</Tie>
205207
<next>
206208
<location>
@@ -216,12 +218,13 @@
216218
</voice>
217219
</Measure>
218220
<Measure>
221+
<eid>YWseZF5oCN_EIH0ziy5cXL</eid>
219222
<voice>
220223
<Chord>
221-
<eid>3242700308594</eid>
222-
<durationType>whole</durationType>
224+
<eid>3GcKq0QWaVD_0zy8lDqsBDO</eid>
225+
<durationType>quarter</durationType>
223226
<Note>
224-
<eid>3238405341204</eid>
227+
<eid>N7fq9YxWqmO_HMUd63CXaJI</eid>
225228
<Spanner type="Tie">
226229
<prev>
227230
<location>
@@ -234,14 +237,111 @@
234237
<tpc>17</tpc>
235238
</Note>
236239
</Chord>
240+
<Rest>
241+
<eid>QTVN+NnIvID_D21ALwqeeOO</eid>
242+
<durationType>quarter</durationType>
243+
</Rest>
244+
<Rest>
245+
<eid>b2/aX/DFz7_F7DEN18iPBI</eid>
246+
<durationType>quarter</durationType>
247+
</Rest>
248+
<Chord>
249+
<eid>vAUkCDgMvaO_DsBgRjZVG3L</eid>
250+
<durationType>quarter</durationType>
251+
<Note>
252+
<eid>Os/3dyTjKcN_uDCN5jqe94I</eid>
253+
<Spanner type="Tie">
254+
<Tie>
255+
<eid>Do9O3WwEMDC_SzvS7TkUVjE</eid>
256+
</Tie>
257+
<next>
258+
<location>
259+
<measures>1</measures>
260+
<fractions>-3/4</fractions>
261+
</location>
262+
</next>
263+
</Spanner>
264+
<pitch>71</pitch>
265+
<tpc>19</tpc>
266+
</Note>
267+
</Chord>
237268
</voice>
238269
</Measure>
239270
<Measure>
271+
<eid>iLObfwkDGFD_BbVHlL+0mjN</eid>
272+
<startRepeat/>
273+
<endRepeat>2</endRepeat>
240274
<voice>
275+
<Chord>
276+
<eid>yV4TDPZ2riP_YSYGHtQgfJ</eid>
277+
<durationType>quarter</durationType>
278+
<Note>
279+
<eid>fgEGER1m1dG_PlKqQK9ZcQE</eid>
280+
<Spanner type="Tie">
281+
<prev>
282+
<location>
283+
<measures>-1</measures>
284+
<fractions>3/4</fractions>
285+
</location>
286+
</prev>
287+
</Spanner>
288+
<pitch>71</pitch>
289+
<tpc>19</tpc>
290+
</Note>
291+
</Chord>
241292
<Rest>
242-
<eid>3934190043162</eid>
243-
<durationType>measure</durationType>
244-
<duration>4/4</duration>
293+
<eid>9o0KUbhEWzM_rXwNGdo5RLE</eid>
294+
<durationType>quarter</durationType>
295+
</Rest>
296+
<Rest>
297+
<eid>j43U/z2jYyM_1jthRQ1sIVJ</eid>
298+
<durationType>quarter</durationType>
299+
</Rest>
300+
<Chord>
301+
<eid>Di1ggiBpqxG_jmq0fXBgPuH</eid>
302+
<durationType>quarter</durationType>
303+
<Note>
304+
<eid>oU0SsF8bFRF_rotcP50lRZD</eid>
305+
<Spanner type="Tie">
306+
<Tie>
307+
<eid>YTcgyXUN8oK_YxAzy6co9uP</eid>
308+
</Tie>
309+
<next>
310+
<location>
311+
<measures>1</measures>
312+
<fractions>-3/4</fractions>
313+
</location>
314+
</next>
315+
</Spanner>
316+
<pitch>71</pitch>
317+
<tpc>19</tpc>
318+
</Note>
319+
</Chord>
320+
</voice>
321+
</Measure>
322+
<Measure>
323+
<eid>5zZnoD9QeNK_hxN5BLQ8B/M</eid>
324+
<voice>
325+
<Chord>
326+
<eid>yKux6Q2oJTN_A3hCRtw2aeG</eid>
327+
<durationType>half</durationType>
328+
<Note>
329+
<eid>rwI53fIoChK_LQaVbEA1Y2H</eid>
330+
<Spanner type="Tie">
331+
<prev>
332+
<location>
333+
<measures>-1</measures>
334+
<fractions>3/4</fractions>
335+
</location>
336+
</prev>
337+
</Spanner>
338+
<pitch>71</pitch>
339+
<tpc>19</tpc>
340+
</Note>
341+
</Chord>
342+
<Rest>
343+
<eid>Pl1ZMxbWcIB_nsmGUxFKd8C</eid>
344+
<durationType>half</durationType>
245345
</Rest>
246346
</voice>
247347
</Measure>

src/engraving/tests/playback/playbackeventsrendering_tests.cpp

+34-8
Original file line numberDiff line numberDiff line change
@@ -2944,10 +2944,12 @@ TEST_F(Engraving_PlaybackEventsRendererTests, Pauses)
29442944
* @brief PlaybackEventsRendererTests_TiedNotesAndRepeats
29452945
* @details Checks whether we correctly calculate tied note durations when they are inside/outside repeats. See:
29462946
* https://github.com/musescore/MuseScore/issues/22863
2947+
* https://github.com/musescore/MuseScore/issues/27661
29472948
*/
29482949
TEST_F(Engraving_PlaybackEventsRendererTests, TiedNotesAndRepeats)
29492950
{
29502951
Score* score = ScoreRW::readScore(PLAYBACK_EVENTS_RENDERING_DIR + "tied_notes_and_repeats.mscx");
2952+
ASSERT_TRUE(score);
29512953

29522954
// [GIVEN] Fulfill articulations profile with dummy patterns
29532955
m_defaultProfile->setPattern(ArticulationType::Standard, m_dummyPattern);
@@ -2959,7 +2961,7 @@ TEST_F(Engraving_PlaybackEventsRendererTests, TiedNotesAndRepeats)
29592961
PlaybackEventsMap result;
29602962

29612963
for (const RepeatSegment* repeatSegment : score->repeatList()) {
2962-
int tickPositionOffset = repeatSegment->utick - repeatSegment->tick;
2964+
const int tickPositionOffset = repeatSegment->utick - repeatSegment->tick;
29632965

29642966
for (const Measure* m : repeatSegment->measureList()) {
29652967
for (const Segment* s = m->first(SegmentType::ChordRest); s; s = s->next(SegmentType::ChordRest)) {
@@ -2974,28 +2976,52 @@ TEST_F(Engraving_PlaybackEventsRendererTests, TiedNotesAndRepeats)
29742976
}
29752977

29762978
// [THEN] Expected pitch, time and duration of each event
2977-
std::vector<pitch_level_t> expectedPitchList {
2979+
const std::vector<pitch_level_t> expectedPitchList {
2980+
// 1st measure (no notes)
2981+
2982+
// 2nd measure
29782983
pitchLevel(PitchClass::C, 5),
29792984
pitchLevel(PitchClass::A, 4),
2985+
2986+
// 2nd measure (repeated)
29802987
pitchLevel(PitchClass::C, 5),
29812988
pitchLevel(PitchClass::A, 4),
2989+
2990+
// 3rd measure
2991+
pitchLevel(PitchClass::B, 4),
2992+
2993+
// 4th measure
2994+
pitchLevel(PitchClass::B, 4),
2995+
2996+
// 4th measure (repeated)
2997+
pitchLevel(PitchClass::B, 4),
29822998
};
29832999

2984-
timestamp_t secondMeasureTime = WHOLE_NOTE_DURATION;
2985-
timestamp_t secondMesaureRepeatedTime = secondMeasureTime + QUARTER_NOTE_DURATION * 2 + HALF_NOTE_DURATION;
3000+
constexpr timestamp_t secondMeasureTime = WHOLE_NOTE_DURATION;
3001+
constexpr timestamp_t secondMesaureRepeatedTime = WHOLE_NOTE_DURATION * 2;
3002+
constexpr timestamp_t thirdMeasure = WHOLE_NOTE_DURATION * 3;
3003+
constexpr timestamp_t fourthMeasure = WHOLE_NOTE_DURATION * 4;
3004+
constexpr timestamp_t fourthMeasureRepeated = WHOLE_NOTE_DURATION * 5;
29863005

2987-
std::vector<TimestampAndDuration> expectedTnDList {
3006+
const std::vector<TimestampAndDuration> expectedTnDList {
29883007
// 1st measure (no notes)
29893008

29903009
// 2nd measure
29913010
{ secondMeasureTime, QUARTER_NOTE_DURATION* 2 }, // 2 tied C5
2992-
{ secondMeasureTime + QUARTER_NOTE_DURATION * 2, HALF_NOTE_DURATION }, // A4 tied to a whole A4 outside of the repeat
3011+
{ secondMeasureTime + QUARTER_NOTE_DURATION * 2, HALF_NOTE_DURATION }, // A4 tied to a quarter A4 outside of the repeat
29933012

29943013
// 2nd measure (repeated)
29953014
{ secondMesaureRepeatedTime, QUARTER_NOTE_DURATION* 2 }, // 2 tied C5
2996-
{ secondMesaureRepeatedTime + QUARTER_NOTE_DURATION * 2, HALF_NOTE_DURATION + WHOLE_NOTE_DURATION }, // A4 tied to a whole A4 outside of the repeat
3015+
{ secondMesaureRepeatedTime + HALF_NOTE_DURATION, HALF_NOTE_DURATION + QUARTER_NOTE_DURATION }, // A4 tied to a quarter A4 outside of the repeat
3016+
3017+
// 3rd measure
3018+
{ thirdMeasure + QUARTER_NOTE_DURATION * 3, QUARTER_NOTE_DURATION* 2 }, // B4 tied to a quarter B4 in the next measure
3019+
3020+
// 4th measure
3021+
{ fourthMeasure + QUARTER_NOTE_DURATION * 3, QUARTER_NOTE_DURATION* 2 }, // B4 tied to a quarter B4 in the next repeat segment
29973022

2998-
// 3rd measure (there is only the whole tied A4)
3023+
// 4th measure (repeated)
3024+
{ fourthMeasureRepeated + QUARTER_NOTE_DURATION * 3, QUARTER_NOTE_DURATION + HALF_NOTE_DURATION }, // B4 tied to a half B4 in the next measure
29993025
};
30003026

30013027
ASSERT_EQ(expectedPitchList.size(), expectedTnDList.size());

0 commit comments

Comments
 (0)