Skip to content

Commit

Permalink
Merge pull request #26755 from RomanPudashkin/450_port_fixes
Browse files Browse the repository at this point in the history
Porting some PRs to 4.5.0
  • Loading branch information
RomanPudashkin authored Feb 26, 2025
2 parents c787bd6 + a7eee97 commit 29fd3da
Show file tree
Hide file tree
Showing 41 changed files with 262 additions and 131 deletions.
1 change: 1 addition & 0 deletions src/appshell/view/appmenumodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ MenuItem* AppMenuModel::makeDiagnosticsMenu()

MenuItemList items {
makeMenuItem("diagnostic-save-diagnostic-files"),
makeMenuItem("playback-reload-cache"),
makeMenu(TranslatableString("appshell/menu/diagnostics", "&System"), systemItems, "menu-system")
};

Expand Down
6 changes: 6 additions & 0 deletions src/engraving/dom/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4300,6 +4300,12 @@ void Score::cmdRealizeChordSymbols(bool literal, Voicing voicing, HDuration dura
note->setNval(nval, tick);
}

if (!seg->isChordRestType()) {
Segment* newCrSeg = seg->measure()->undoGetSegment(SegmentType::ChordRest, seg->tick());
newCrSeg->setTicks(seg->ticks());
seg = newCrSeg;
}

setChord(this, seg, h->track(), chord, duration); //add chord using template
delete chord;
}
Expand Down
1 change: 1 addition & 0 deletions src/engraving/dom/edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2971,6 +2971,7 @@ void Score::deleteItem(EngravingItem* el)

case ElementType::STEM_SLASH: // cannot delete this elements
case ElementType::HOOK:
case ElementType::GUITAR_BEND_TEXT:
LOGD("cannot remove %s", el->typeName());
break;

Expand Down
9 changes: 9 additions & 0 deletions src/engraving/dom/fret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,15 @@ PropertyValue FretDiagram::propertyDefault(Pid pid) const
return EngravingItem::propertyDefault(pid);
}

void FretDiagram::setTrack(track_idx_t val)
{
EngravingItem::setTrack(val);

if (m_harmony) {
m_harmony->setTrack(val);
}
}

//---------------------------------------------------------
// endEditDrag
//---------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/engraving/dom/fret.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ class FretDiagram final : public EngravingItem
bool setProperty(Pid propertyId, const PropertyValue&) override;
PropertyValue propertyDefault(Pid) const override;

void setTrack(track_idx_t val) override;

String accessibleInfo() const override;
String screenReaderInfo() const override;

Expand Down
2 changes: 2 additions & 0 deletions src/engraving/dom/guitarbend.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ class GuitarBendText final : public TextBase
public:
GuitarBendText(GuitarBendSegment* parent);
GuitarBendText* clone() const override { return new GuitarBendText(*this); }

bool isEditable() const override { return false; }
};
} // namespace mu::engraving

Expand Down
26 changes: 20 additions & 6 deletions src/engraving/dom/harmony.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,9 +849,14 @@ Fraction Harmony::ticksTillNext(int utick, bool stopAtMeasureEnd) const
{
Segment* seg = getParentSeg();
Fraction duration = seg->ticks();
Segment* cur = seg->next();
auto rsIt = score()->repeatList().findRepeatSegmentFromUTick(utick);

const RepeatList& repeats = score()->repeatList();
auto rsIt = repeats.findRepeatSegmentFromUTick(utick);
if (rsIt == repeats.cend()) {
return duration;
}

Segment* cur = seg->next();
Measure const* currentMeasure = seg->measure();
Measure const* endMeasure = (stopAtMeasureEnd) ? currentMeasure : (*rsIt)->lastMeasure();
Harmony const* nextHarmony = nullptr;
Expand Down Expand Up @@ -892,9 +897,9 @@ Fraction Harmony::ticksTillNext(int utick, bool stopAtMeasureEnd) const
// End of repeatSegment or search boundary reached
if (stopAtMeasureEnd) {
break;
} else {
} else if (!nextHarmony) {
// move to next RepeatSegment
if (++rsIt != score()->repeatList().end()) {
if (++rsIt != repeats.end()) {
currentMeasure = (*rsIt)->firstMeasure();
endMeasure = (*rsIt)->lastMeasure();
cur = currentMeasure->first();
Expand All @@ -903,6 +908,12 @@ Fraction Harmony::ticksTillNext(int utick, bool stopAtMeasureEnd) const
}
} while ((nextHarmony == nullptr) && (cur != nullptr));

if (nextHarmony && rsIt != repeats.end()) {
int tickOffset = (*rsIt)->utick - (*rsIt)->tick;
int nextHarmonyUtick = nextHarmony->tick().ticks() + tickOffset;
duration = Fraction::fromTicks(nextHarmonyUtick - utick);
}

return duration;
}

Expand Down Expand Up @@ -1062,9 +1073,12 @@ const ChordDescription* Harmony::getDescription(const String& name, const Parsed

const RealizedHarmony& Harmony::getRealizedHarmony() const
{
Fraction tick = this->tick();
const Staff* st = staff();
IF_ASSERT_FAILED(st) {
return m_realizedHarmony;
}

const Fraction tick = this->tick();
const CapoParams& capo = st->capo(tick);

int offset = 0;
Expand All @@ -1080,7 +1094,7 @@ const RealizedHarmony& Harmony::getRealizedHarmony() const
//Adjust for Nashville Notation, might be temporary
// TODO: set dirty on add/remove of keysig
if (m_harmonyType == HarmonyType::NASHVILLE && !m_realizedHarmony.valid()) {
Key key = staff()->key(tick);
Key key = st->key(tick);

//parse root
int rootTpc = function2Tpc(m_function, key);
Expand Down
12 changes: 8 additions & 4 deletions src/engraving/dom/repeatlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,14 @@ int RepeatList::utime2utick(double secs) const
///
std::vector<RepeatSegment*>::const_iterator RepeatList::findRepeatSegmentFromUTick(int utick) const
{
return std::lower_bound(this->cbegin(), this->cend(), utick, [](RepeatSegment const* rs, int utick) {
// Skip RS where endtick is less than us
return utick > (rs->utick + rs->len());
});
for (auto it = cbegin(); it != cend(); ++it) {
const RepeatSegment* seg = *it;
if (utick >= seg->utick && utick < seg->utick + seg->len()) {
return it;
}
}

return cend();
}

//---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/dom/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ void Score::rebuildTempoAndTimeSigMaps(Measure* measure, std::optional<BeatsPerS
staff(staffIdx)->addTimeSig(ts);
}
}
} else if (segment.isChordRestType()) {
} else if (segment.isChordRestType() || segment.isTimeTickType()) {
if (!isMaster()) {
continue;
}
Expand Down
17 changes: 17 additions & 0 deletions src/engraving/dom/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,23 @@ struct ScoreChangesRange {
{
return isValidBoundary() || !changedTypes.empty();
}

void clear()
{
*this = ScoreChangesRange();
}

void combine(const ScoreChangesRange& r)
{
tickFrom = std::min(tickFrom, r.tickFrom);
tickTo = std::max(tickTo, r.tickTo);
staffIdxFrom = std::min(staffIdxFrom, r.staffIdxFrom);
staffIdxTo = std::max(staffIdxTo, r.staffIdxTo);
changedItems.insert(r.changedItems.begin(), r.changedItems.end());
changedTypes.insert(r.changedTypes.begin(), r.changedTypes.end());
changedPropertyIdSet.insert(r.changedPropertyIdSet.begin(), r.changedPropertyIdSet.end());
changedStyleIdSet.insert(r.changedStyleIdSet.begin(), r.changedStyleIdSet.end());
}
};
} // namespace mu::engraving

Expand Down
15 changes: 12 additions & 3 deletions src/engraving/playback/playbackeventsrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ void PlaybackEventsRenderer::renderChordSymbol(const Harmony* chordSymbol,
return;
}

const Staff* staff = chordSymbol->staff();
IF_ASSERT_FAILED(staff) {
return;
}

const RealizedHarmony& realized = chordSymbol->getRealizedHarmony();
const RealizedHarmony::PitchMap& notes = realized.notes();

Expand All @@ -130,7 +135,7 @@ void PlaybackEventsRenderer::renderChordSymbol(const Harmony* chordSymbol,

voice_layer_idx_t voiceIdx = static_cast<voice_layer_idx_t>(chordSymbol->voice());
staff_layer_idx_t staffIdx = static_cast<staff_layer_idx_t>(chordSymbol->staffIdx());
Key key = chordSymbol->staff()->key(chordSymbol->tick());
Key key = staff->key(chordSymbol->tick());

ArticulationMap articulations = makeStandardArticulationMap(profile, eventTimestamp, duration);

Expand Down Expand Up @@ -161,15 +166,19 @@ void PlaybackEventsRenderer::renderChordSymbol(const Harmony* chordSymbol, const
return;
}

const Staff* staff = chordSymbol->staff();
IF_ASSERT_FAILED(staff) {
return;
}

const RealizedHarmony& realized = chordSymbol->getRealizedHarmony();
const RealizedHarmony::PitchMap& notes = realized.notes();

PlaybackEventList& events = result[actualTimestamp];

voice_layer_idx_t voiceIdx = static_cast<voice_layer_idx_t>(chordSymbol->voice());
staff_layer_idx_t staffIdx = static_cast<staff_layer_idx_t>(chordSymbol->staffIdx());

Key key = chordSymbol->staff()->key(chordSymbol->tick());
Key key = staff->key(chordSymbol->tick());

ArticulationMap articulations = makeStandardArticulationMap(profile, actualTimestamp, actualDuration);

Expand Down
8 changes: 6 additions & 2 deletions src/engraving/playback/playbackmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,10 @@ void PlaybackModel::processSegment(const int tickPositionOffset, const Segment*
collectChangesTracks(trackId, trackChanges);
}

if (segment->isTimeTickType()) {
return; // optimization: search only for annotations
}

for (const EngravingItem* item : segment->elist()) {
if (!item || !item->isChordRest() || !item->part()) {
continue;
Expand Down Expand Up @@ -457,7 +461,7 @@ void PlaybackModel::processMeasureRepeat(const int tickPositionOffset, const Mea
bool isFirstSegmentOfRepeatedMeasure = true;

for (const Segment* seg = referringMeasure->first(); seg; seg = seg->next()) {
if (!seg->isChordRestType()) {
if (!seg->isChordRestType() && !seg->isTimeTickType()) {
continue;
}

Expand Down Expand Up @@ -497,7 +501,7 @@ void PlaybackModel::updateEvents(const int tickFrom, const int tickTo, const tra
bool isFirstSegmentOfMeasure = true;

for (Segment* segment = measure->first(); segment; segment = segment->next()) {
if (!segment->isChordRestType()) {
if (!segment->isChordRestType() && !segment->isTimeTickType()) {
continue;
}

Expand Down
4 changes: 4 additions & 0 deletions src/framework/audio/internal/worker/eventaudiosource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ void EventAudioSource::setIsActive(const bool active)
return;
}

if (m_synth->isActive() == active) {
return;
}

m_synth->setIsActive(active);
m_synth->flushSound();
}
Expand Down
Loading

0 comments on commit 29fd3da

Please sign in to comment.