Skip to content
Merged
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
3 changes: 3 additions & 0 deletions global/settings/types/preferencekeys.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
#define PREF_APP_TELEMETRY_ALLOWED "application/telemetry/allowed"
#define PREF_APP_BACKUP_GENERATE_BACKUP "application/backup/generateBackup"
#define PREF_APP_BACKUP_SUBFOLDER "application/backup/subfolder"
#define PREF_APP_SHOW_PROGRESS_LAYOUT "application/show/progressBar/layout"
#define PREF_APP_SHOW_PROGRESS_SAVE "application/show/progressBar/save"
#define PREF_APP_SHOW_PROGRESS_AUTOSAVE "application/show/progressBar/autosave"
#define PREF_EXPORT_AUDIO_NORMALIZE "export/audio/normalize"
#define PREF_EXPORT_AUDIO_SAMPLERATE "export/audio/sampleRate"
#define PREF_EXPORT_AUDIO_PCMRATE "export/audio/PCMRate"
Expand Down
47 changes: 28 additions & 19 deletions libmscore/check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,18 @@ qDebug("checkScore: remove empty ChordRest segment");
if (lcr) {
Fraction timeStretch = st->timeStretch(lcr->tick());
Fraction f = cr->globalTicks() * timeStretch;
qDebug("Chord/Rest gap at tick %d(%s+%d)-%d(%s) staffIdx %d measure %d (len = %d)",
tick.ticks(), lcr->name(), f.ticks(),
s->tick().ticks(), cr->name(), staffIdx, cr->measure()->no(),
(cr->tick() - tick).ticks());
qDebug().nospace().noquote()
<< "Chord/Rest gap at tick " << tick.print()
<< "(" << lcr->name() << "+" << f.print() << ")"
<< "-" << s->tick().print() << "(" << cr->name() <<")"
<< " staffIdx " << staffIdx << " measure " << cr->measure()->no()
<< " (len = " << (cr->tick() - tick).print() << ")";
}
else {
qDebug("Chord/Rest gap at tick %d-%d(%s) staffIdx %d measure %d (len = %d)",
tick.ticks(),
s->tick().ticks(), cr->name(), staffIdx, cr->measure()->no(),
(cr->tick() - tick).ticks());
qDebug().nospace().noquote()
<< "Chord/Rest gap at tick " << tick.print() << "-" << s->tick().print()
<< "(" << cr->name() << ")" << " staffIdx " << staffIdx << " measure " << cr->measure()->no()
<< " (len = " << (cr->tick() - tick).print() << ")";
}
#if 0
if (cr->tick() > tick) {
Expand Down Expand Up @@ -262,8 +264,9 @@ bool Score::checkKeys()
k = toKeySig(element)->key();
}
if (staff(i)->key(m->tick()) != k) {
qDebug("measure %d (tick %d) : key %d, map %d", m->no(), m->tick().ticks(), int(k),
int(staff(i)->key(m->tick())));
qDebug().nospace().noquote()
<< "measure " << m->no() << "(tick " << m->tick().print() <<") : "
<< "key " << int(k) << ", map " << int(staff(i)->key(m->tick()));
rc = false;
}
}
Expand Down Expand Up @@ -315,12 +318,9 @@ bool Score::checkClefs()

void Measure::fillGap(const Fraction& pos, const Fraction& len, int track, const Fraction& stretch, bool useGapRests)
{
qDebug("measure %6d pos %d, len %d/%d, stretch %d/%d track %d",
tick().ticks(),
pos.ticks(),
len.numerator(), len.denominator(),
stretch.numerator(), stretch.denominator(),
track);
qDebug().nospace().noquote()
<< "measure " << tick().print() << " pos " << pos.print() << ", "
<< "len " << len.print() << " stretch " << stretch.print() << " track " << track;
TDuration d;
d.setVal(len.ticks());
if (d.isValid()) {
Expand Down Expand Up @@ -363,11 +363,17 @@ void Measure::checkMeasure(int staffIdx, bool useGapRests)
currentPos = seg->rtick() * stretch;

if (currentPos < expectedPos) {
qDebug("in measure overrun %6d at %d-%d track %d", tick().ticks(), (currentPos/stretch).ticks(), (expectedPos/stretch).ticks(), track);
qDebug().nospace().noquote()
<< "in measure overrun" << tick().print()
<< "at " << (currentPos/stretch).ticks() << "-" << (expectedPos/stretch).ticks()
<< " track " << track;
break;
}
else if (currentPos > expectedPos) {
qDebug("in measure underrun %6d at %d-%d track %d", tick().ticks(), (currentPos/stretch).ticks(), (expectedPos/stretch).ticks(), track);
qDebug().nospace().noquote()
<< "in measure underrun " << tick().print()
<< " at " << (currentPos/stretch).ticks() << "-" << (expectedPos/stretch).ticks()
<< " track " << track;
fillGap(expectedPos, currentPos - expectedPos, track, stretch);
}

Expand All @@ -385,7 +391,10 @@ void Measure::checkMeasure(int staffIdx, bool useGapRests)
fillGap(expectedPos, f - expectedPos, track, stretch, useGapRests);
}
else if (f < expectedPos)
qDebug("measure overrun %6d, %d > %d, track %d", tick().ticks(), expectedPos.ticks(), f.ticks(), track);
qDebug().nospace().noquote()
<< "measure overrun "<< tick().print() << ","
<< expectedPos.print() << " > " << f.print() << ", "
<< "track " << track;
}
}

Expand Down
38 changes: 35 additions & 3 deletions libmscore/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1711,7 +1711,9 @@ void Score::connectTies(bool silent)
nnote = searchTieNote(n);
if (nnote == 0) {
if (!silent) {
qDebug("next note at %d track %d for tie not found (version %d)", s->tick().ticks(), i, _mscVersion);
qDebug().nospace().noquote()
<< "next note at " << s->tick().print()
<<" track " << i <<" for tie not found (version " << _mscoreVersion << ")";
delete tie;
n->setTieFor(0);
}
Expand Down Expand Up @@ -4558,7 +4560,9 @@ System* Score::collectSystem(LayoutContext& lc)

#ifndef NDEBUG
if (!qFuzzyCompare(mw, minWidth))
qDebug("==layoutSystem %6d old %.1f new %.1f", system->measures().front()->tick().ticks(), minWidth, mw);
qDebug().nospace().noquote()
<< "==layoutSystem " << system->measures().front()->tick().print()
<< " old " << minWidth << " new " << mw;
#endif
rest = systemWidth - minWidth;
//
Expand Down Expand Up @@ -5699,12 +5703,38 @@ void Score::doLayoutRange(const Fraction& st, const Fraction& et)
void LayoutContext::layout()
{
MeasureBase* lmb;

QProgressDialog progress;
const bool layoutAll = (startTick <= Fraction(0,1) && (endTick < Fraction(0,1) || endTick >= score->last()->endTick()));

const bool showProgress = (MScore::showProgressBarForLayout && layoutAll) || (MScore::showProgressBarForPartialLayout);
if (showProgress) {
const int totalMeasures = score->measures() ? score->measures()->size() : 0;
QString label;
if (layoutAll)
label = QObject::tr("Performing full layout") + QObject::tr(" for") + ":\n" + score->title() + "…";
else
label = QObject::tr("Performing partial layout between ") + startTick.print() + " and " + endTick.print()
+ QObject::tr(" for") + ":\n" + score->title() + "…";

progress.setLabelText(label);
progress.setWindowFlags(Qt::WindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint));
progress.setRange(0, totalMeasures);
progress.setCancelButton(nullptr);
progress.setWindowModality(Qt::WindowModal);
progress.setValue(0);
progress.setMinimumDuration(0);
}

do {
getNextPage();
collectPage();

if (page && !page->systems().isEmpty())
if (page && !page->systems().isEmpty()) {
lmb = page->systems().back()->measures().back();
if (showProgress)
progress.setValue(lmb->index());
}
else
lmb = nullptr;

Expand All @@ -5720,6 +5750,8 @@ void LayoutContext::layout()
} while (curSystem && !(rangeDone && lmb == pageOldMeasure));
// && page->system(0)->measures().back()->tick() > endTick // FIXME: perhaps the first measure was meant? Or last system?

progress.close();

if (!curSystem) {
// The end of the score. The remaining systems are not needed...
qDeleteAll(systemList);
Expand Down
4 changes: 3 additions & 1 deletion libmscore/line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,9 @@ QPointF SLine::linePos(Grip grip, System** sys) const
// it is possible CR won't be in correct track
// prefer element in current track if available
if (!cr)
qDebug("no end for lyricsline segment - start %d, ticks %d", tick().ticks(), ticks().ticks());
qDebug().nospace().noquote()
<< "no end for lyricsline segmente - start " << tick().print() << ", "
<< "ticks " << ticks().print();
else if (cr->track() != track()) {
Element* e = cr->segment()->element(track());
if (e)
Expand Down
5 changes: 5 additions & 0 deletions libmscore/mscore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ bool MScore::showSystemBoundingRect = false;
bool MScore::showCorruptedMeasures = true;
bool MScore::useFallbackFont = true;

bool MScore::showProgressBarForLayout = true;
bool MScore::showProgressBarForPartialLayout = false;
bool MScore::showProgressBarForSave = true;
bool MScore::showProgressBarForAutosave = true;

bool MScore::saveTemplateMode = false;
bool MScore::noGui = false;

Expand Down
5 changes: 5 additions & 0 deletions libmscore/mscore.h
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,11 @@ class MScore {
static bool debugMode;
static bool testMode;

static bool showProgressBarForLayout;
static bool showProgressBarForPartialLayout;
static bool showProgressBarForSave;
static bool showProgressBarForAutosave;

static int division;
static int sampleRate;
static int mtcType;
Expand Down
29 changes: 29 additions & 0 deletions libmscore/rendermidi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#include <set>

#include <QProgressDialog>

#include "arpeggio.h"
#include "articulation.h"
#include "bend.h"
Expand Down Expand Up @@ -2638,9 +2640,36 @@ void Score::renderMidi(EventMap* events, bool metronome, bool expandRepeats, con
void MidiRenderer::renderScore(EventMap* events, const Context& ctx)
{
updateState();

int currentChunk = 0;
QProgressDialog progress;
if (MScore::showProgressBarForLayout) {
const int totalChunks = chunks.size();
QString label = QObject::tr("Rendering MIDI events") + " "
+ QObject::tr("for") + ":\n"
+ score->title() + "…\n"
+ QObject::tr("Safe to cancel early");

progress.setLabelText(label);
progress.setCancelButtonText(QObject::tr("Cancel"));
progress.setWindowFlags(Qt::WindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint));
progress.setRange(0, totalChunks);
progress.setWindowModality(Qt::WindowModal);
progress.setValue(0);
progress.setMinimumDuration(2500);
}

for (const Chunk& chunk : chunks) {
if (MScore::showProgressBarForLayout) {
progress.setValue(++currentChunk);
// Allow user to prematurely break rendering:
if (progress.wasCanceled())
break;
}

renderChunk(chunk, events, ctx);
}
progress.close();
}

void MidiRenderer::renderChunk(const Chunk& chunk, EventMap* events, const Context& ctx)
Expand Down
3 changes: 3 additions & 0 deletions libmscore/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ class Score : public QObject, public ScoreElement {
bool _showVBox { true };
bool _printing { false }; ///< True if we are drawing to a printer
bool _autosaveDirty { true };
bool _isAutosaving { false };
bool _savedCapture { false }; ///< True if we saved an image capture
bool _saved { false }; ///< True if project was already saved; only on first
///< save a backup file will be created, subsequent
Expand Down Expand Up @@ -914,6 +915,8 @@ class Score : public QObject, public ScoreElement {
void setPrinting(bool val) { _printing = val; }
void setAutosaveDirty(bool v) { _autosaveDirty = v; }
bool autosaveDirty() const { return _autosaveDirty; }
bool isAutosaving() const { return _isAutosaving; }
void setAutosaving(bool v) { _isAutosaving = v; }
virtual bool playlistDirty() const;
virtual void setPlaylistDirty();

Expand Down
26 changes: 26 additions & 0 deletions libmscore/scorefile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,26 @@ void Score::writeMovement(XmlWriter& xml, bool selectionOnly)
xml.setCurTrack(0);
xml.setTrackDiff(-staffStart * VOICES);
if (measureStart) {

// progress bar
const bool showOnSave = (!isAutosaving() && MScore::showProgressBarForSave);
const bool showOnAutosave = (isAutosaving() && MScore::showProgressBarForAutosave);
int currentMeasureIdx = 0;
QProgressDialog progress;
if (showOnSave || showOnAutosave) {
int totalMeasuresByStaff = (staffEnd - staffStart) * score()->measures()->size();
QString label = (showOnAutosave ? QObject::tr("Performing Autosave")
: QObject::tr("Save File")) + ":\n"
+ score()->title() + "…";
progress.setLabelText(label);
progress.setWindowFlags(Qt::WindowFlags(Qt::Dialog | Qt::FramelessWindowHint));
progress.setCancelButton(nullptr);
progress.setRange(0, totalMeasuresByStaff);
progress.setWindowModality(Qt::WindowModal);
progress.setValue(0);
progress.setMinimumDuration(0);
}

for (int staffIdx = staffStart; staffIdx < staffEnd; ++staffIdx) {
xml.stag(staff(staffIdx), QString("id=\"%1\"").arg(staffIdx + 1 - staffStart));
xml.setCurTick(measureStart->tick());
Expand All @@ -238,11 +258,17 @@ void Score::writeMovement(XmlWriter& xml, bool selectionOnly)
else
forceTimeSig = false;
}

if (showOnSave || showOnAutosave)
progress.setValue(++currentMeasureIdx);

// Largest consumption of time for file-saving:
writeMeasure(xml, m, staffIdx, writeSystemElements, forceTimeSig);
}
xml.etag();
}

progress.close();
}
xml.setCurTrack(-1);
if (isMaster()) {
Expand Down
12 changes: 9 additions & 3 deletions libmscore/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ Measure* Score::tick2measure(const Fraction& tick) const
// check last measure
if (lm && (tick >= lm->tick()) && (tick <= lm->endTick()))
return lm;
qDebug("tick2measure %d (max %d) not found", tick.ticks(), lm ? lm->tick().ticks() : -1);
qDebug().nospace().noquote()
<< "tick2measure " << tick.print() << " (max " << (lm ? lm->tick().print() : Fraction::fromTicks(-1).print()) << ") "
<< "not found";
return 0;
}

Expand Down Expand Up @@ -91,7 +93,9 @@ Measure* Score::tick2measureMM(const Fraction& t) const
// check last measure
if (lm && (tick >= lm->tick()) && (tick <= lm->endTick()))
return lm;
qDebug("tick2measureMM %d (max %d) not found", tick.ticks(), lm ? lm->tick().ticks() : -1);
qDebug().nospace().noquote()
<< "tick2measureMM " << tick.print() << "(max " << (lm ? lm->tick().print() : Fraction::fromTicks(-1).print()) << ") "
<< "not found";
return 0;
}

Expand Down Expand Up @@ -159,7 +163,9 @@ Segment* Score::tick2segment(const Fraction& t, bool first, SegmentType st, bool
}
segment = nsegment;
}
qDebug("no segment for tick %d (start search at %d (measure %d))", tick.ticks(), t.ticks(), m->tick().ticks());
qDebug().nospace().noquote()
<< "no segment for tick " << tick.print() << " (start search at " << t.print()
<< " (measure "<< m->tick().print() << "))";
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions mscore/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ void MuseScore::askAboutApplyingEdwinIfNeed(const QString& fileSuffix)

Score* MuseScore::openScore(const QString& fn, bool switchTab, const bool considerInCurrentSession, const QString& name)
{
ScoreLoad sl;
//
// make sure we load a file only once
//
Expand Down Expand Up @@ -2549,8 +2550,7 @@ Score::FileError readScore(MasterScore* score, QString name, bool ignoreVersionE
score->updateChannel();
score->updateExpressive(MuseScore::synthesizer("Fluid"));
score->setSaved(false);
// TEST: Omit updating here since MuseScore::openScore() performs full layout after this
// score->update();
// TEST: Omitting score->update() since MuseScore::openScore() performs full layout after this
score->styleChanged();

if (!ignoreVersionError && !MScore::noGui)
Expand Down
Loading
Loading