From 8e5caa4909df20ed16e481b9142af3b593c6f673 Mon Sep 17 00:00:00 2001 From: AntonioBL Date: Sun, 8 Nov 2020 22:37:01 +0100 Subject: [PATCH] fix #259771 : make tremolo between notes play correct rhythm when between tuplets --- libmscore/rendermidi.cpp | 5 +- .../midi/testMultiNoteTremoloTuplet-ref.txt | 118 ++++++ .../midi/testMultiNoteTremoloTuplet.mscx | 360 ++++++++++++++++++ mtest/libmscore/midi/tst_midi.cpp | 1 + 4 files changed, 483 insertions(+), 1 deletion(-) create mode 100644 mtest/libmscore/midi/testMultiNoteTremoloTuplet-ref.txt create mode 100644 mtest/libmscore/midi/testMultiNoteTremoloTuplet.mscx diff --git a/libmscore/rendermidi.cpp b/libmscore/rendermidi.cpp index ad77e9b1145af..cf3927428792b 100644 --- a/libmscore/rendermidi.cpp +++ b/libmscore/rendermidi.cpp @@ -1352,6 +1352,9 @@ void renderTremolo(Chord* chord, QList& ell) // render tremolo with multiple events if (chord->tremoloChordType() == TremoloChordType::TremoloFirstNote) { int t = MScore::division / (1 << (tremolo->lines() + chord->durationType().hooks())); + if (t == 0) { // avoid crash on very short tremolo + t = 1; + } SegmentType st = SegmentType::ChordRest; Segment* seg2 = seg->next(st); int track = chord->track(); @@ -1376,7 +1379,7 @@ void renderTremolo(Chord* chord, QList& ell) if (c2->type() == ElementType::CHORD) { int notes2 = int(c2->notes().size()); int tnotes = qMax(notes, notes2); - int tticks = chord->actualTicks().ticks() * 2; // use twice the size + int tticks = chord->ticks().ticks() * 2; // use twice the size int n = tticks / t; n /= 2; int l = 2000 * t / tticks; diff --git a/mtest/libmscore/midi/testMultiNoteTremoloTuplet-ref.txt b/mtest/libmscore/midi/testMultiNoteTremoloTuplet-ref.txt new file mode 100644 index 0000000000000..12e2a6f5f661c --- /dev/null +++ b/mtest/libmscore/midi/testMultiNoteTremoloTuplet-ref.txt @@ -0,0 +1,118 @@ +Tick = 0 Type = 144 Pitch = 65 Velocity = 80 Channel = 0 +Tick = 0 Type = 3 Pitch = 0 Velocity = 127 Channel = 0 +Tick = 227 Type = 144 Pitch = 65 Velocity = 0 Channel = 0 +Tick = 240 Type = 144 Pitch = 72 Velocity = 80 Channel = 0 +Tick = 467 Type = 144 Pitch = 72 Velocity = 0 Channel = 0 +Tick = 480 Type = 144 Pitch = 65 Velocity = 80 Channel = 0 +Tick = 480 Type = 4 Pitch = 0 Velocity = 80 Channel = 0 +Tick = 707 Type = 144 Pitch = 65 Velocity = 0 Channel = 0 +Tick = 720 Type = 144 Pitch = 72 Velocity = 80 Channel = 0 +Tick = 947 Type = 144 Pitch = 72 Velocity = 0 Channel = 0 +Tick = 960 Type = 144 Pitch = 65 Velocity = 80 Channel = 0 +Tick = 960 Type = 144 Pitch = 69 Velocity = 80 Channel = 0 +Tick = 960 Type = 4 Pitch = 0 Velocity = 127 Channel = 0 +Tick = 1110 Type = 144 Pitch = 65 Velocity = 0 Channel = 0 +Tick = 1110 Type = 144 Pitch = 69 Velocity = 0 Channel = 0 +Tick = 1119 Type = 144 Pitch = 74 Velocity = 80 Channel = 0 +Tick = 1269 Type = 144 Pitch = 74 Velocity = 0 Channel = 0 +Tick = 1279 Type = 144 Pitch = 65 Velocity = 80 Channel = 0 +Tick = 1279 Type = 144 Pitch = 69 Velocity = 80 Channel = 0 +Tick = 1429 Type = 144 Pitch = 65 Velocity = 0 Channel = 0 +Tick = 1429 Type = 144 Pitch = 69 Velocity = 0 Channel = 0 +Tick = 1439 Type = 144 Pitch = 74 Velocity = 80 Channel = 0 +Tick = 1440 Type = 4 Pitch = 0 Velocity = 80 Channel = 0 +Tick = 1589 Type = 144 Pitch = 74 Velocity = 0 Channel = 0 +Tick = 1599 Type = 144 Pitch = 65 Velocity = 80 Channel = 0 +Tick = 1599 Type = 144 Pitch = 69 Velocity = 80 Channel = 0 +Tick = 1749 Type = 144 Pitch = 65 Velocity = 0 Channel = 0 +Tick = 1749 Type = 144 Pitch = 69 Velocity = 0 Channel = 0 +Tick = 1759 Type = 144 Pitch = 74 Velocity = 80 Channel = 0 +Tick = 1909 Type = 144 Pitch = 74 Velocity = 0 Channel = 0 +Tick = 1920 Type = 144 Pitch = 69 Velocity = 80 Channel = 0 +Tick = 1920 Type = 3 Pitch = 0 Velocity = 127 Channel = 0 +Tick = 2223 Type = 144 Pitch = 69 Velocity = 0 Channel = 0 +Tick = 2240 Type = 144 Pitch = 72 Velocity = 80 Channel = 0 +Tick = 2400 Type = 4 Pitch = 0 Velocity = 80 Channel = 0 +Tick = 2543 Type = 144 Pitch = 72 Velocity = 0 Channel = 0 +Tick = 2560 Type = 144 Pitch = 69 Velocity = 80 Channel = 0 +Tick = 2660 Type = 144 Pitch = 69 Velocity = 0 Channel = 0 +Tick = 2666 Type = 144 Pitch = 72 Velocity = 80 Channel = 0 +Tick = 2766 Type = 144 Pitch = 72 Velocity = 0 Channel = 0 +Tick = 2773 Type = 144 Pitch = 69 Velocity = 80 Channel = 0 +Tick = 2873 Type = 144 Pitch = 69 Velocity = 0 Channel = 0 +Tick = 2879 Type = 144 Pitch = 72 Velocity = 80 Channel = 0 +Tick = 2880 Type = 4 Pitch = 0 Velocity = 127 Channel = 0 +Tick = 2979 Type = 144 Pitch = 72 Velocity = 0 Channel = 0 +Tick = 2986 Type = 144 Pitch = 69 Velocity = 80 Channel = 0 +Tick = 3086 Type = 144 Pitch = 69 Velocity = 0 Channel = 0 +Tick = 3092 Type = 144 Pitch = 72 Velocity = 80 Channel = 0 +Tick = 3192 Type = 144 Pitch = 72 Velocity = 0 Channel = 0 +Tick = 3200 Type = 144 Pitch = 69 Velocity = 80 Channel = 0 +Tick = 3300 Type = 144 Pitch = 69 Velocity = 0 Channel = 0 +Tick = 3306 Type = 144 Pitch = 72 Velocity = 80 Channel = 0 +Tick = 3360 Type = 4 Pitch = 0 Velocity = 80 Channel = 0 +Tick = 3406 Type = 144 Pitch = 72 Velocity = 0 Channel = 0 +Tick = 3413 Type = 144 Pitch = 69 Velocity = 80 Channel = 0 +Tick = 3513 Type = 144 Pitch = 69 Velocity = 0 Channel = 0 +Tick = 3519 Type = 144 Pitch = 72 Velocity = 80 Channel = 0 +Tick = 3619 Type = 144 Pitch = 72 Velocity = 0 Channel = 0 +Tick = 3627 Type = 144 Pitch = 69 Velocity = 80 Channel = 0 +Tick = 3828 Type = 144 Pitch = 69 Velocity = 0 Channel = 0 +Tick = 3840 Type = 144 Pitch = 74 Velocity = 80 Channel = 0 +Tick = 3840 Type = 144 Pitch = 77 Velocity = 80 Channel = 0 +Tick = 3840 Type = 144 Pitch = 70 Velocity = 80 Channel = 0 +Tick = 3840 Type = 3 Pitch = 0 Velocity = 127 Channel = 0 +Tick = 3914 Type = 144 Pitch = 70 Velocity = 0 Channel = 0 +Tick = 3919 Type = 144 Pitch = 62 Velocity = 80 Channel = 0 +Tick = 3919 Type = 144 Pitch = 69 Velocity = 80 Channel = 0 +Tick = 3993 Type = 144 Pitch = 62 Velocity = 0 Channel = 0 +Tick = 3993 Type = 144 Pitch = 69 Velocity = 0 Channel = 0 +Tick = 3999 Type = 144 Pitch = 70 Velocity = 80 Channel = 0 +Tick = 4073 Type = 144 Pitch = 70 Velocity = 0 Channel = 0 +Tick = 4079 Type = 144 Pitch = 62 Velocity = 80 Channel = 0 +Tick = 4079 Type = 144 Pitch = 69 Velocity = 80 Channel = 0 +Tick = 4153 Type = 144 Pitch = 62 Velocity = 0 Channel = 0 +Tick = 4153 Type = 144 Pitch = 69 Velocity = 0 Channel = 0 +Tick = 4158 Type = 144 Pitch = 70 Velocity = 80 Channel = 0 +Tick = 4232 Type = 144 Pitch = 70 Velocity = 0 Channel = 0 +Tick = 4238 Type = 144 Pitch = 62 Velocity = 80 Channel = 0 +Tick = 4238 Type = 144 Pitch = 69 Velocity = 80 Channel = 0 +Tick = 4295 Type = 144 Pitch = 74 Velocity = 0 Channel = 0 +Tick = 4295 Type = 144 Pitch = 77 Velocity = 0 Channel = 0 +Tick = 4312 Type = 144 Pitch = 62 Velocity = 0 Channel = 0 +Tick = 4312 Type = 144 Pitch = 69 Velocity = 0 Channel = 0 +Tick = 4318 Type = 144 Pitch = 70 Velocity = 80 Channel = 0 +Tick = 4320 Type = 144 Pitch = 82 Velocity = 80 Channel = 0 +Tick = 4320 Type = 4 Pitch = 0 Velocity = 80 Channel = 0 +Tick = 4392 Type = 144 Pitch = 70 Velocity = 0 Channel = 0 +Tick = 4397 Type = 144 Pitch = 62 Velocity = 80 Channel = 0 +Tick = 4397 Type = 144 Pitch = 69 Velocity = 80 Channel = 0 +Tick = 4471 Type = 144 Pitch = 62 Velocity = 0 Channel = 0 +Tick = 4471 Type = 144 Pitch = 69 Velocity = 0 Channel = 0 +Tick = 4477 Type = 144 Pitch = 70 Velocity = 80 Channel = 0 +Tick = 4551 Type = 144 Pitch = 70 Velocity = 0 Channel = 0 +Tick = 4557 Type = 144 Pitch = 62 Velocity = 80 Channel = 0 +Tick = 4557 Type = 144 Pitch = 69 Velocity = 80 Channel = 0 +Tick = 4631 Type = 144 Pitch = 62 Velocity = 0 Channel = 0 +Tick = 4631 Type = 144 Pitch = 69 Velocity = 0 Channel = 0 +Tick = 4636 Type = 144 Pitch = 70 Velocity = 80 Channel = 0 +Tick = 4710 Type = 144 Pitch = 70 Velocity = 0 Channel = 0 +Tick = 4716 Type = 144 Pitch = 62 Velocity = 80 Channel = 0 +Tick = 4716 Type = 144 Pitch = 69 Velocity = 80 Channel = 0 +Tick = 4775 Type = 144 Pitch = 82 Velocity = 0 Channel = 0 +Tick = 4790 Type = 144 Pitch = 62 Velocity = 0 Channel = 0 +Tick = 4790 Type = 144 Pitch = 69 Velocity = 0 Channel = 0 +Tick = 4800 Type = 144 Pitch = 74 Velocity = 80 Channel = 0 +Tick = 4800 Type = 144 Pitch = 79 Velocity = 80 Channel = 0 +Tick = 4800 Type = 144 Pitch = 65 Velocity = 80 Channel = 0 +Tick = 4800 Type = 144 Pitch = 68 Velocity = 80 Channel = 0 +Tick = 4800 Type = 4 Pitch = 0 Velocity = 127 Channel = 0 +Tick = 5255 Type = 144 Pitch = 74 Velocity = 0 Channel = 0 +Tick = 5255 Type = 144 Pitch = 79 Velocity = 0 Channel = 0 +Tick = 5255 Type = 144 Pitch = 65 Velocity = 0 Channel = 0 +Tick = 5255 Type = 144 Pitch = 68 Velocity = 0 Channel = 0 +Tick = 5280 Type = 144 Pitch = 84 Velocity = 80 Channel = 0 +Tick = 5280 Type = 144 Pitch = 58 Velocity = 80 Channel = 0 +Tick = 5280 Type = 4 Pitch = 0 Velocity = 80 Channel = 0 +Tick = 5735 Type = 144 Pitch = 84 Velocity = 0 Channel = 0 +Tick = 5735 Type = 144 Pitch = 58 Velocity = 0 Channel = 0 diff --git a/mtest/libmscore/midi/testMultiNoteTremoloTuplet.mscx b/mtest/libmscore/midi/testMultiNoteTremoloTuplet.mscx new file mode 100644 index 0000000000000..4c0695afcac98 --- /dev/null +++ b/mtest/libmscore/midi/testMultiNoteTremoloTuplet.mscx @@ -0,0 +1,360 @@ + + + 3.5.2 + 465e7b6 + + + 0 + 480 + + 1 + 1 + 1 + 0 + + + + 2020-11-08 + + + + Microsoft Windows + + + + + test MultiNote Tremolo + + + + stdNormal + + + Piano + + Piano + Pno. + Piano + 21 + 108 + 21 + 108 + keyboard.piano + F + + 100 + 95 + + + 100 + 33 + + + 100 + 50 + + + 100 + 67 + + + 100 + 100 + + + 120 + 67 + + + 120 + 100 + + + + Fluid + + + + + + 10 + + + test MultiNote Tremolo in tuplets + + + + + + 4 + 4 + + + half + 1/4 + + 65 + 13 + + + c8 + + + + half + 1/4 + + 72 + 14 + + + + 2 + 3 + quarter + + + 3 + + + + 1 + half + 3/8 + + 65 + 13 + + + 69 + 17 + + + c8 + + + + 1 + half + 3/8 + + 74 + 16 + + + + + + + + + + 2 + 3 + half + + + 3 + + + + quarter + + 69 + 17 + + + + quarter + + 72 + 14 + + + + 2 + 3 + quarter + + + 3 + + + + 1 + half + 3/8 + + 69 + 17 + + + c8 + + + + 1 + half + 3/8 + + 72 + 14 + + + + + 2 + 3 + quarter + + + 3 + + + + half + 1/4 + + 69 + 17 + + + c8 + + + + half + 1/4 + + 72 + 14 + + + + quarter + + 69 + 17 + + + + + + + + + + quarter + + 74 + 16 + + + 77 + 13 + + + + quarter + + + accidentalFlat + + 82 + 12 + + + + quarter + + 74 + 16 + + + 79 + 15 + + + + quarter + + 84 + 14 + + + + end + 1 + + + + + 2 + 3 + quarter + + + 3 + + + + 1 + half + 3/8 + + + accidentalFlat + + 70 + 12 + + + c16 + + + + 1 + half + 3/8 + + 62 + 16 + + + 69 + 17 + + + + + quarter + + 65 + 13 + + + + accidentalFlat + + 68 + 10 + + + + quarter + + + accidentalFlat + + 58 + 12 + + + + + + + diff --git a/mtest/libmscore/midi/tst_midi.cpp b/mtest/libmscore/midi/tst_midi.cpp index bc73d4038ca09..5aef43554f91d 100644 --- a/mtest/libmscore/midi/tst_midi.cpp +++ b/mtest/libmscore/midi/tst_midi.cpp @@ -137,6 +137,7 @@ void TestMidi::events_data() // QTest::newRow("testPedal") << "testPedal"; // multi note tremolo QTest::newRow("testMultiNoteTremolo") << "testMultiNoteTremolo"; + QTest::newRow("testMultiNoteTremoloTuplet") << "testMultiNoteTremoloTuplet"; // Test Pauses QTest::newRow("testPauses") << "testPauses"; QTest::newRow("testPausesRepeats") << "testPausesRepeats";