redo it in multiple smaller patches
authormirabilos <tg@debian.org>
Sun, 2 Jun 2019 22:58:07 +0000 (00:58 +0200)
committermirabilos <mirabilos@evolvis.org>
Sun, 2 Jun 2019 22:58:07 +0000 (00:58 +0200)
debian/changelog
debian/patches/experiments/element-barbeat.diff [new file with mode: 0644]
debian/patches/experiments/log-collisions.diff [new file with mode: 0644]
debian/patches/experiments/note-accessibleInfo-const.diff [new file with mode: 0644]
debian/patches/series

index 21f4c44..75277db 100644 (file)
@@ -1,4 +1,4 @@
-musescore2 (2.3.2+dfsg3-2) wtf; urgency=low
+musescore2 (2.3.2+dfsg3-2) wtf; urgency=medium
 
   * Log prevented note collisions in revert-restriking patch
   * debian/buildtest: move nocheck test here
@@ -6,7 +6,7 @@ musescore2 (2.3.2+dfsg3-2) wtf; urgency=low
   * Build under the C.UTF-8 locale
   * Add patch to show two pitches (in transposing mode) in status line
 
- -- Thorsten Glaser <tg@mirbsd.de>  Sun, 02 Jun 2019 21:53:08 +0200
+ -- Thorsten Glaser <tg@mirbsd.de>  Mon, 03 Jun 2019 00:57:49 +0200
 
 musescore2 (2.3.2+dfsg3-1) wtf; urgency=low
 
diff --git a/debian/patches/experiments/element-barbeat.diff b/debian/patches/experiments/element-barbeat.diff
new file mode 100644 (file)
index 0000000..8b302da
--- /dev/null
@@ -0,0 +1,178 @@
+Description: Add Element::barbeat() and Element::accessibleBarbeat()
+ These are const, and useful for determining the positions of elements
+ within the score, generally; used by experiments/log-collisions.diff
+ .
+ Also fix some screenreader label mistakes.
+Author: mirabilos <m@mirbsd.org>
+Forwarded: no
+
+--- a/libmscore/element.cpp
++++ b/libmscore/element.cpp
+@@ -1998,4 +1998,51 @@ bool Element::isUserModified() const
+       return !visible() || !userOff().isNull() || (color() != MScore::defaultColor);
+       }
++//---------------------------------------------------------
++//   barbeat
++//---------------------------------------------------------
++
++std::pair<int, float> Element::barbeat() const
++      {
++      int bar = 0;
++      int beat = 0;
++      int ticks = 0;
++      TimeSigMap* tsm = this->score()->sigmap();
++      const Element* p = this;
++      while(p && p->type() != Element::Type::SEGMENT && p->type() != Element::Type::MEASURE)
++            p = p->parent();
++
++      if (!p) {
++            return std::pair<int, float>(0, 0);
++            }
++      else if (p->type() == Element::Type::SEGMENT) {
++            const Segment* seg = static_cast<const Segment*>(p);
++            tsm->tickValues(seg->tick(), &bar, &beat, &ticks);
++            }
++      else if (p->type() == Element::Type::MEASURE) {
++            const Measure* m = static_cast<const Measure*>(p);
++            bar = m->no();
++            beat = -1;
++            ticks = 0;
++            }
++      return std::pair<int,float>(bar + 1, beat + 1 + ticks / static_cast<float>(MScore::division));
++      }
++
++//---------------------------------------------------------
++//   accessibleBarbeat
++//---------------------------------------------------------
++
++QString Element::accessibleBarbeat() const
++      {
++      QString barsAndBeats = "";
++      std::pair<int, float>bar_beat = barbeat();
++      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));
++            }
++      if (staffIdx() + 1)
++            barsAndBeats += "; " + tr("Staff: %1").arg(QString::number(staffIdx() + 1));
++      return barsAndBeats;
++      }
+ }
+--- a/libmscore/element.h
++++ b/libmscore/element.h
+@@ -327,6 +327,8 @@ class Element : public QObject, public S
+       Element* findMeasure();
+       qreal spatium() const;
++      std::pair<int, float>barbeat() const;
++      QString accessibleBarbeat() const;
+       bool selected() const                   { return _selected;   }
+       virtual void setSelected(bool f)        { _selected = f;      }
+--- a/mscore/scoreaccessibility.cpp
++++ b/mscore/scoreaccessibility.cpp
+@@ -110,8 +110,8 @@ void ScoreAccessibility::currentInfoChan
+             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));
++                  bar_beat = s->startSegment()->barbeat();
++                  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);
+@@ -121,11 +121,11 @@ void ScoreAccessibility::currentInfoChan
+                       s->type() != Element::Type::TIE                                                )
+                         seg = seg->prev1MM(Segment::Type::ChordRest);
+-                  bar_beat = barbeat(seg);
++                  bar_beat = seg->barbeat();
+                   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);
++                  std::pair<int, float>bar_beat = el->barbeat();
+                   if (bar_beat.first) {
+                         barsAndBeats += " " + tr("Measure: %1").arg(QString::number(bar_beat.first));
+                         if (bar_beat.second)
+@@ -135,12 +135,12 @@ void ScoreAccessibility::currentInfoChan
+             QString rez = e->accessibleInfo();
+             if (!barsAndBeats.isEmpty())
+-                  rez += "; " + barsAndBeats;
++                  rez += ";" + barsAndBeats;
+             QString staff = "";
+             if (e->staffIdx() + 1) {
+                   staff = tr("Staff %1").arg(QString::number(e->staffIdx() + 1));
+-                  rez = QString("%1; %2").arg(rez).arg(staff);
++                  rez += "; " + tr("Staff: %1").arg(QString::number(e->staffIdx() + 1));
+                   }
+             statusBarLabel->setText(rez);
+@@ -151,7 +151,7 @@ void ScoreAccessibility::currentInfoChan
+             QString barsAndBeats = "";
+             std::pair<int, float> bar_beat;
+-            bar_beat = barbeat(score->selection().startSegment());
++            bar_beat = score->selection().startSegment()->barbeat();
+             barsAndBeats += " " + tr("Start Measure: %1; Start Beat: %2").arg(QString::number(bar_beat.first)).arg(QString::number(bar_beat.second));
+             Segment* endSegment = score->selection().endSegment();
+@@ -160,7 +160,7 @@ void ScoreAccessibility::currentInfoChan
+             else
+                   endSegment = endSegment->prev1MM();
+-            bar_beat = barbeat(endSegment);
++            bar_beat = endSegment->barbeat();
+             barsAndBeats += " " + tr("End Measure: %1; End Beat: %2").arg(QString::number(bar_beat.first)).arg(QString::number(bar_beat.second));
+             statusBarLabel->setText(tr("Range Selection") + barsAndBeats);
+             score->setAccessibleInfo(tr("Range Selection") + barsAndBeats);
+@@ -204,34 +204,4 @@ void ScoreAccessibility::updateAccessibi
+       QAccessibleValueChangeEvent ev(obj, w->score()->accessibleInfo());
+       QAccessible::updateAccessibility(&ev);
+       }
+-
+-std::pair<int, float> ScoreAccessibility::barbeat(Element *e)
+-      {
+-      if (!e) {
+-            return std::pair<int, float>(0, 0);
+-            }
+-
+-      int bar = 0;
+-      int beat = 0;
+-      int ticks = 0;
+-      TimeSigMap* tsm = e->score()->sigmap();
+-      Element* p = e;
+-      while(p && p->type() != Element::Type::SEGMENT && p->type() != Element::Type::MEASURE)
+-            p = p->parent();
+-
+-      if (!p) {
+-            return std::pair<int, float>(0, 0);
+-            }
+-      else if (p->type() == Element::Type::SEGMENT) {
+-            Segment* seg = static_cast<Segment*>(p);
+-            tsm->tickValues(seg->tick(), &bar, &beat, &ticks);
+-            }
+-      else if (p->type() == Element::Type::MEASURE) {
+-            Measure* m = static_cast<Measure*>(p);
+-            bar = m->no();
+-            beat = -1;
+-            ticks = 0;
+-            }
+-      return pair<int,float>(bar + 1, beat + 1 + ticks / static_cast<float>(MScore::division));
+-      }
+ }
+--- a/mscore/scoreaccessibility.h
++++ b/mscore/scoreaccessibility.h
+@@ -30,7 +30,6 @@ private:
+       QMainWindow* mainWindow;
+       QLabel* statusBarLabel;
+       ScoreAccessibility(QMainWindow* statusBar);
+-      std::pair<int, float>barbeat(Element* e);
+ public:
+       ~ScoreAccessibility();
diff --git a/debian/patches/experiments/log-collisions.diff b/debian/patches/experiments/log-collisions.diff
new file mode 100644 (file)
index 0000000..2f09ab7
--- /dev/null
@@ -0,0 +1,54 @@
+Description: Log unison collisions (that would otherwise be restruck)
+Author: mirabilos <m@mirbsd.org>
+Forwarded: no
+Justification: depends on experiments/revert-restriking-patch.diff
+
+--- a/synthesizer/event.cpp
++++ b/synthesizer/event.cpp
+@@ -14,6 +14,7 @@
+ #include "libmscore/xml.h"
+ #include "libmscore/note.h"
+ #include "libmscore/sig.h"
++#include "libmscore/tie.h"
+ #include "event.h"
+ namespace Ms {
+@@ -375,6 +376,25 @@ void EventList::insert(const Event& e)
+ //   class EventMap::fixupMIDI
+ //---------------------------------------------------------
++static void logCollisionNote(const Note* note, unsigned int indent)
++      {
++      QString info = note->accessibleInfoConst() + note->accessibleBarbeat();
++      fprintf(stderr, "%*s%s\n", indent, "- ", qPrintable(info));
++      }
++
++static void logCollisionNotes(const 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(note1, indent);
++                  indent += /* next level */ 2;
++                  note1 = note1->tieFor() ? note1->tieFor()->endNote() : 0;
++                  }
++            }
++      }
++
+ void EventMap::fixupMIDI()
+       {
+       /* track info for each of the 128 possible MIDI notes */
+@@ -409,6 +429,12 @@ void EventMap::fixupMIDI()
+                   else if (++np > 1) {
+                         /* already playing */
+                         discard = true;
++                        /* log the collision */
++                        fprintf(stderr, "MIDI collision detected: newly played...\n");
++                        logCollisionNotes(&(it->second));
++                        fprintf(stderr, "... interfere with already playing...\n");
++                        logCollisionNotes(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());
+                         }
diff --git a/debian/patches/experiments/note-accessibleInfo-const.diff b/debian/patches/experiments/note-accessibleInfo-const.diff
new file mode 100644 (file)
index 0000000..709d716
--- /dev/null
@@ -0,0 +1,39 @@
+Description: Add Note::accessibleInfoConst()
+Author: mirabilos <m@mirbsd.org>
+Forwarded: no
+Justification: when forwarding it’ll be better to make them all const
+
+--- a/libmscore/note.cpp
++++ b/libmscore/note.cpp
+@@ -2642,7 +2642,7 @@ void Note::setScore(Score* s)
+ //   accessibleInfo
+ //---------------------------------------------------------
+-QString Note::accessibleInfo()
++QString Note::accessibleInfoConst() const
+       {
+       QString duration = chord()->durationUserName();
+       QString voice = tr("Voice: %1").arg(QString::number(track() % VOICES + 1));
+@@ -2664,6 +2664,11 @@ QString Note::accessibleInfo()
+       return tr("%1; Pitch: %2; Duration: %3%4").arg(noteTypeUserName()).arg(pitchName).arg(duration).arg((chord()->isGrace() ? "" : QString("; %1").arg(voice)));
+       }
++QString Note::accessibleInfo()
++      {
++      return this->accessibleInfoConst();
++      }
++
+ //---------------------------------------------------------
+ //   screenReaderInfo
+ //---------------------------------------------------------
+--- a/libmscore/note.h
++++ b/libmscore/note.h
+@@ -464,6 +464,8 @@ class Note : public Element {
+       virtual QString accessibleInfo() override;
+       virtual QString screenReaderInfo() override;
+       virtual QString accessibleExtraInfo() override;
++      // for the synthesiser
++      QString accessibleInfoConst() const;
+       };
+ // extern const SymId noteHeads[2][int(NoteHead::Group::HEAD_GROUPS)][int(NoteHead::Type::HEAD_TYPES)];
index 308cbd7..3b5781a 100644 (file)
@@ -12,5 +12,8 @@ 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/revert-restriking-patch.diff
 experiments/statusline-concert-transposing-pitch.diff
+experiments/note-accessibleInfo-const.diff
+experiments/element-barbeat.diff
+experiments/revert-restriking-patch.diff
+experiments/log-collisions.diff