Skip to content

Commit b767148

Browse files
committed
Clamp pedal OFF event time and simplify gap calculation
1 parent c83d31b commit b767148

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/engraving/compat/midi/compatmidirenderinternal.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,7 +1482,7 @@ void CompatMidiRendererInternal::doRenderSpanners(EventsHolder& events, Spanner*
14821482
int gapTicks = 1;
14831483
if (MScore::pedalReleaseGapMs > 0) {
14841484
double bps = score->tempomap()->multipliedTempo(st).val;
1485-
gapTicks = std::max(1, static_cast<int>((1000LL * MScore::pedalReleaseGapMs * bps * Constants::DIVISION) / 1000000));
1485+
gapTicks = std::max(1, static_cast<int>((MScore::pedalReleaseGapMs * bps * Constants::DIVISION) / 1000.0));
14861486
}
14871487

14881488
if (!lastEvent.on && lastEvent.tick >= (st + 2)) {
@@ -1492,7 +1492,7 @@ void CompatMidiRendererInternal::doRenderSpanners(EventsHolder& events, Spanner*
14921492
int a = st + 2;
14931493
pedalEventList.emplace_back(a, true, staffIdx);
14941494

1495-
int t = s->tick2().ticks() + (2 - gapTicks);
1495+
int t = std::max(a + 1, s->tick2().ticks() + (2 - gapTicks));
14961496
if (!score->repeatList().empty()) {
14971497
const RepeatSegment& lastRepeat = *score->repeatList().back();
14981498
if (t > lastRepeat.utick + lastRepeat.len()) {

0 commit comments

Comments
 (0)