log MIDI note collisions we let sounding (that would’ve been restruck)
authormirabilos <tg@debian.org>
Sun, 2 Jun 2019 19:38:59 +0000 (21:38 +0200)
committermirabilos <mirabilos@evolvis.org>
Sun, 2 Jun 2019 19:38:59 +0000 (21:38 +0200)
debian/changelog
debian/patches/experiments/factor-out-statusbar.diff [new file with mode: 0644]
debian/patches/experiments/revert-restriking-patch.diff
debian/patches/series

index a0c7bf4..301736e 100644 (file)
@@ -1,3 +1,9 @@
+musescore2 (2.3.2+dfsg3-2) UNRELEASED; urgency=medium
+
+  * Log prevented note collisions in revert-restriking patch
+
+ -- Thorsten Glaser <tg@mirbsd.de>  Sun, 02 Jun 2019 21:37:46 +0200
+
 musescore2 (2.3.2+dfsg3-1) wtf; urgency=low
 
   * Renamed source package, to complete castling (src:musescore builds
diff --git a/debian/patches/experiments/factor-out-statusbar.diff b/debian/patches/experiments/factor-out-statusbar.diff
new file mode 100644 (file)
index 0000000..0cbbb32
--- /dev/null
@@ -0,0 +1,105 @@
+Description: Factor out getInfoForElement()
+Author: mirabilos <m@mirbsd.org>
+Forwarded: no
+
+--- a/mscore/scoreaccessibility.cpp
++++ b/mscore/scoreaccessibility.cpp
+@@ -94,6 +94,44 @@ void ScoreAccessibility::clearAccessibil
+             }
+       }
++QString ScoreAccessibility::getInfoForElement(Element* e)
++      {
++      Element* el = e->isSpannerSegment() ? static_cast<SpannerSegment*>(e)->spanner() : e;
++      QString barsAndBeats = "";
++      std::pair<int, float> bar_beat;
++      if (el->isSpanner()){
++            Spanner* s = static_cast<Spanner*>(el);
++            bar_beat = barbeat(s->startSegment());
++            barsAndBeats += tr("Start Measure: %1; Start Beat: %2").arg(QString::number(bar_beat.first)).arg(QString::number(bar_beat.second));
++            Segment* seg = s->endSegment();
++            if(!seg)
++                  seg = score->lastSegment()->prev1MM(Segment::Type::ChordRest);
++
++            if (seg->tick() != score->lastSegment()->prev1MM(Segment::Type::ChordRest)->tick() &&
++                s->type() != Element::Type::SLUR                                               &&
++                s->type() != Element::Type::TIE                                                )
++                  seg = seg->prev1MM(Segment::Type::ChordRest);
++
++            bar_beat = barbeat(seg);
++            barsAndBeats += "; " + tr("End Measure: %1; End Beat: %2").arg(QString::number(bar_beat.first)).arg(QString::number(bar_beat.second));
++            }
++      else {
++            std::pair<int, float>bar_beat = barbeat(el);
++            if (bar_beat.first) {
++                  barsAndBeats += " " + tr("Measure: %1").arg(QString::number(bar_beat.first));
++                  if (bar_beat.second)
++                        barsAndBeats += "; " + tr("Beat: %1").arg(QString::number(bar_beat.second));
++                  }
++            }
++
++      QString rez = e->accessibleInfo();
++      if (!barsAndBeats.isEmpty())
++            rez += "; " + barsAndBeats;
++      if (e->staffIdx() + 1)
++            rez += "; " + tr("Staff: %1").arg(QString::number(e->staffIdx() + 1));
++      return rez;
++      }
++
+ void ScoreAccessibility::currentInfoChanged()
+       {
+       clearAccessibilityInfo();
+@@ -105,42 +143,11 @@ void ScoreAccessibility::currentInfoChan
+             if (!e) {
+                   return;
+                   }
+-            Element* el = e->isSpannerSegment() ? static_cast<SpannerSegment*>(e)->spanner() : e;
+-            QString barsAndBeats = "";
+-            std::pair<int, float> bar_beat;
+-            if (el->isSpanner()){
+-                  Spanner* s = static_cast<Spanner*>(el);
+-                  bar_beat = barbeat(s->startSegment());
+-                  barsAndBeats += tr("Start Measure: %1; Start Beat: %2").arg(QString::number(bar_beat.first)).arg(QString::number(bar_beat.second));
+-                  Segment* seg = s->endSegment();
+-                  if(!seg)
+-                        seg = score->lastSegment()->prev1MM(Segment::Type::ChordRest);
+-
+-                  if (seg->tick() != score->lastSegment()->prev1MM(Segment::Type::ChordRest)->tick() &&
+-                      s->type() != Element::Type::SLUR                                               &&
+-                      s->type() != Element::Type::TIE                                                )
+-                        seg = seg->prev1MM(Segment::Type::ChordRest);
+-
+-                  bar_beat = barbeat(seg);
+-                  barsAndBeats += "; " + tr("End Measure: %1; End Beat: %2").arg(QString::number(bar_beat.first)).arg(QString::number(bar_beat.second));
+-                  }
+-            else {
+-                  std::pair<int, float>bar_beat = barbeat(el);
+-                  if (bar_beat.first) {
+-                        barsAndBeats += " " + tr("Measure: %1").arg(QString::number(bar_beat.first));
+-                        if (bar_beat.second)
+-                              barsAndBeats += "; " + tr("Beat: %1").arg(QString::number(bar_beat.second));
+-                        }
+-                  }
+-
+-            QString rez = e->accessibleInfo();
+-            if (!barsAndBeats.isEmpty())
+-                  rez += "; " + barsAndBeats;
++            QString rez = getInfoForElement(e);
+             QString staff = "";
+             if (e->staffIdx() + 1) {
+                   staff = tr("Staff %1").arg(QString::number(e->staffIdx() + 1));
+-                  rez = QString("%1; %2").arg(rez).arg(staff);
+                   }
+             statusBarLabel->setText(rez);
+--- a/mscore/scoreaccessibility.h
++++ b/mscore/scoreaccessibility.h
+@@ -36,6 +36,7 @@ public:
+       ~ScoreAccessibility();
+       void updateAccessibilityInfo();
+       void clearAccessibilityInfo();
++      QString getInfoForElement(Element* e);
+       static void createInstance(QMainWindow* statusBar);
+       static ScoreAccessibility* instance();
+       void currentInfoChanged();
index 4334673..68d2320 100644 (file)
@@ -8,6 +8,7 @@ Author: mirabilos <m@mirbsd.org>
 Bug: https://musescore.org/en/node/12971
 Forwarded: https://github.com/musescore/MuseScore/pull/3797
  except reversal of commit d5a81add16497f9b4b7fac5717ea005c31dcc1cf
+ and except collision logging
 
 --- a/libmscore/rendermidi.cpp
 +++ b/libmscore/rendermidi.cpp
@@ -214,8 +215,43 @@ Forwarded: https://github.com/musescore/MuseScore/pull/3797
              out << qSetFieldWidth(5) << "   Type  = ";
 --- a/synthesizer/event.cpp
 +++ b/synthesizer/event.cpp
-@@ -390,28 +390,37 @@ void EventMap::fixupMIDI()
+@@ -375,6 +375,29 @@ void EventList::insert(const Event& e)
+ //   class EventMap::fixupMIDI
+ //---------------------------------------------------------
  
++static void logCollisionNote(ScoreAccessibility *sa, const Note *note, unsigned int indent)
++      {
++      fprintf(stderr, "%*s%s\n", indent, "- ", qPrintable(sa->getInfoForElement(note)));
++      }
++
++static void logCollisionNotes(ScoreAccessibility *sa, NPlayEvent *event)
++      {
++      for (auto it = event->notes.cbegin(); it != event->notes.cend(); ++it) {
++            const Note* note1 = *it;
++            unsigned int indent = /* initial */ 2;
++            while (note1) {
++                  logCollisionNote(sa, note1, indent);
++                  indent += /* linked */ 4;
++                  for (ScoreElement* se : note1->linkList()) {
++                        if (se != note1 && se->isNote())
++                              logCollisionNote(sa, toNote(se), indent);
++                        }
++                  indent -= (/* linked */ 4 - /* next level */ 2);
++                  note1 = note1->tieFor() ? note1->tieFor()->endNote() : 0;
++                  }
++            }
++      }
++
+ void EventMap::fixupMIDI()
+       {
+       /* track info for each of the 128 possible MIDI notes */
+@@ -388,30 +411,48 @@ void EventMap::fixupMIDI()
+       /* track info for each channel (on the heap, 0-initialised) */
+       struct channelInfo *info = (struct channelInfo *)calloc(_highestChannel + 1, sizeof(struct channelInfo));
++      /* needed to log collision info */
++      ScoreAccessibility *sa = ScoreAccessibility::instance();
++
        auto it = begin();
        while (it != end()) {
 +            bool discard = false;
@@ -243,6 +279,12 @@ Forwarded: https://github.com/musescore/MuseScore/pull/3797
 +                  else if (++np > 1) {
 +                        /* already playing */
 +                        discard = true;
++                        /* log the collision */
++                        fprintf(stderr, "MIDI collision detected: newly played...\n");
++                        logCollisionNotes(sa, &(it->second));
++                        fprintf(stderr, "... interfere with already playing...\n");
++                        logCollisionNotes(sa, info[it->second.channel()].event[it->second.pitch()]);
++                        fprintf(stderr, "... which, as resolution, will continue to sound.\n");
 +                        /* carry over the corresponding score notes */
 +                        info[it->second.channel()].event[it->second.pitch()]->notes.insert(info[it->second.channel()].event[it->second.pitch()]->notes.end(), it->second.notes.begin(), it->second.notes.end());
                          }
index d61138f..5fce5a0 100644 (file)
@@ -12,4 +12,5 @@ upstream/update-AppData.diff
 debian-specific/fixup-AppData.diff
 experiments/lyrics-hyphen-max-8sp.diff
 experiments/musescore-2.1.0-qt-5.12.patch
+experiments/factor-out-statusbar.diff
 experiments/revert-restriking-patch.diff