Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/engraving/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
muse_create_module(engraving)

# TODO: convert to target-based variant of qt_add_resources
# (Not easy because of heavy use of aliases, which is much more cumbersome
# (Not easy because of heavy use of aliases, which is much more cumbersome
# in CMake than in .qrc files)
muse_module_add_qrc(engraving
muse_module_add_qrc(engraving
engraving.qrc
data/fonts/fonts_Smufl.qrc
)
Expand Down Expand Up @@ -342,7 +342,7 @@ else()
)
endif()

set_source_files_properties(
set_source_files_properties(
# For these files, Unity Build does not work
dom/excerpt.cpp
#api/vi/excerpt.cpp
Expand Down Expand Up @@ -427,3 +427,7 @@ endif()
if (QT_SUPPORT)
add_subdirectory(qml/MuseScore/Engraving)
endif()

if (MSVC_IDE)
target_sources(engraving PRIVATE engraving.natvis)
endif()
9 changes: 7 additions & 2 deletions src/engraving/dom/anchors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <climits>

#include "anchors.h"
#include "dom/timesig.h"
#include "dom/utils.h"
#include "factory.h"
#include "figuredbass.h"
Expand Down Expand Up @@ -86,8 +87,12 @@ void EditTimeTickAnchors::updateAnchors(Measure* measure, staff_idx_t staffIdx,
Fraction startTick = Fraction(0, 1);
Fraction endTick = measure->ticks();

Fraction timeSig = measure->timesig();
Fraction halfDivision = Fraction(1, 2 * timeSig.denominator());
TimeSig* timeSig = measure->score()->staff(staffIdx)->timeSig(measure->tick());
Fraction timeSigFrac = timeSig ? timeSig->sig() : measure->timesig();
Fraction halfDivision = Fraction(1, 2 * timeSigFrac.denominator());
if (timeSig) {
halfDivision /= timeSig->stretch();
}
Comment on lines +90 to +95
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One issue with this is that once the time ticks are populated, we see the union of the time ticks for all the different local time signatures, even though many of them are unusable as drop targets in one time signature or the other.

It would be nicer if we had a way to filter which time ticks are visible when drag-dropping, but I'm not sure how best to accomplish that.


std::set<Fraction> anchorTicks { additionalAnchorRelTicks };
for (Fraction tick = startTick; tick <= endTick; tick += halfDivision) {
Expand Down
14 changes: 7 additions & 7 deletions src/engraving/dom/check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,27 +260,27 @@ bool Score::checkKeys()
// fillGap
//---------------------------------------------------------

void Measure::fillGap(const Fraction& pos, const Fraction& len, track_idx_t track, const Fraction& stretch, bool useGapRests)
void Measure::fillGap(const Fraction& rtickStart, const Fraction& len, track_idx_t track, const Fraction& stretch, bool useGapRests)
{
LOGN("measure %6d pos %d, len %d/%d, stretch %d/%d track %zu",
tick().ticks(),
pos.ticks(),
rtickStart.ticks(),
len.numerator(), len.denominator(),
stretch.numerator(), stretch.denominator(),
track);

// break the gap into shorter durations if necessary
std::vector<TDuration> durationList = toRhythmicDurationList(len, true, pos, timesig(), this, 0);
std::vector<TDuration> durationList = toRhythmicDurationList(len, true, rtickStart, timesig(), this, 0, stretch);

Fraction curTick = pos;
Fraction curTick = tick() + actualTicks(rtickStart, nullptr, stretch);
for (TDuration d : durationList) {
Rest* rest = Factory::createRest(score()->dummy()->segment());
rest->setTicks(d.isMeasure() ? ticks() : d.fraction());
rest->setTicks(d.isMeasure() ? ticks() * stretch : d.fraction());
rest->setDurationType(d);
rest->setTrack(track);
rest->setGap(useGapRests);
score()->undoAddCR(rest, this, curTick + tick());
curTick += d.fraction() / stretch;
score()->undoAddCR(rest, this, curTick);
curTick += rest->actualTicks();
}
}

Expand Down
15 changes: 12 additions & 3 deletions src/engraving/dom/durationtype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,8 @@ TDuration& TDuration::operator+=(const TDuration& t)

//---------------------------------------------------------
// toDurationList
// - l is in local time
// - returned durations are in local time
//---------------------------------------------------------

std::vector<TDuration> toDurationList(Fraction l, bool useDots, int maxDots, bool printRestRemains)
Expand All @@ -502,17 +504,24 @@ std::vector<TDuration> toDurationList(Fraction l, bool useDots, int maxDots, boo

//---------------------------------------------------------
// toRhythmicDurationList
// - l and rtickStart are in local (stretched) time
// - returned durations are in local time
//---------------------------------------------------------

std::vector<TDuration> toRhythmicDurationList(const Fraction& l, bool isRest, Fraction rtickStart,
const TimeSigFrac& nominal, Measure* msr, int maxDots)
const TimeSigFrac& nominal, Measure* msr, int maxDots,
const Fraction& timeStretch)
{
IF_ASSERT_FAILED(l > Fraction(0, 1)) {
return {};
}

std::vector<TDuration> dList;
dList.reserve(8);

if (msr->isAnacrusis()) {
rtickStart += msr->anacrusisOffset();
} else if (isRest && l == msr->ticks()) {
rtickStart += msr->anacrusisOffset() * timeStretch;
} else if (isRest && l == msr->ticks() * timeStretch) {
TDuration d = TDuration(DurationType::V_MEASURE);
dList.push_back(d);
return dList;
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/dom/durationtype.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class TDuration

std::vector<TDuration> toDurationList(Fraction l, bool useDots, int maxDots = 4, bool printRestRemains = true);
std::vector<TDuration> toRhythmicDurationList(const Fraction& l, bool isRest, Fraction rtickStart, const TimeSigFrac& nominal, Measure* msr,
int maxDots);
int maxDots, const Fraction& timeStretch = Fraction(1, 1));

bool forceRhythmicSplit(bool isRest, BeatType startBeat, BeatType endBeat, int beatsCrossed, BeatType strongestBeatCrossed,
const TimeSigFrac& nominal);
Expand Down
8 changes: 6 additions & 2 deletions src/engraving/dom/measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1892,8 +1892,12 @@ void Measure::adjustToLen(Fraction nf, bool appendRestsIfNecessary)
/*rtickStart=*/ Fraction(0, 1),
/*nominal=*/ score()->sigmap()->timesig(tick().ticks()).nominal(),
/*measure=*/ this,
/*maxDots=*/ 0);

/*maxDots=*/ 0,
stretch);
if (durList.empty()) {
LOGD("Could not make durations for: %d/%d", (nf * stretch).numerator(), (nf * stretch).denominator());
continue;
}
// set the existing rest to the first value of the duration list
TDuration firstDur = durList[0];
rest->undoChangeProperty(Pid::DURATION, firstDur.isMeasure() ? ticks() : firstDur.fraction());
Expand Down
1 change: 1 addition & 0 deletions src/engraving/dom/mscore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ std::string MScore::errorToString(MsError err)
case MsError::CANNOT_JOIN_MEASURE_STAFFTYPE_CHANGE: return "CANNOT_JOIN_MEASURE_STAFFTYPE_CHANGE";
case MsError::CANNOT_REPEAT_SELECTION: return "CANNOT_REPEAT_SELECTION";
case MsError::TRANSPOSE_NO_FRET_DIAGRAM: return "TRANSPOSE_NO_FRET_DIAGRAM";
case MsError::CANNOT_EXPLODE_IMPLODE_LOCAL_TIMESIG: return "CANNOT_EXPLODE_IMPLODE_LOCAL_TIMESIG";
}

return {};
Expand Down
1 change: 1 addition & 0 deletions src/engraving/dom/mscore.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ enum class MsError : unsigned char {
CANNOT_JOIN_MEASURE_STAFFTYPE_CHANGE,
CANNOT_REPEAT_SELECTION,
TRANSPOSE_NO_FRET_DIAGRAM,
CANNOT_EXPLODE_IMPLODE_LOCAL_TIMESIG,
};

/// \cond PLUGIN_API \private \endcond
Expand Down
Loading
Loading