File: log-collisions.diff

package info (click to toggle)
musescore3 3.2.3%2Bdfsg2-21
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 219,852 kB
  • sloc: cpp: 291,412; xml: 200,226; sh: 3,779; ansic: 1,447; python: 393; makefile: 246; perl: 82; pascal: 79
file content (59 lines) | stat: -rw-r--r-- 2,619 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Description: Log unison collisions (that would otherwise be restruck)
Author: mirabilos <m@mirbsd.org>
Forwarded: not-yet
Justification: depends on experiments/revert-restriking-patch.diff

--- a/synthesizer/event.cpp
+++ b/synthesizer/event.cpp
@@ -13,6 +13,7 @@
 #include "libmscore/xml.h"
 #include "libmscore/note.h"
 #include "libmscore/sig.h"
+#include "libmscore/tie.h"
 #include "event.h"
 #include "libmscore/staff.h"
 #include "libmscore/instrument.h"
@@ -396,6 +397,30 @@ void EventList::insert(const Event& e)
 //   class EventMap::fixupMIDI
 //---------------------------------------------------------
 
+static void logCollisionNote(const Note* note, unsigned int indent)
+      {
+      QString info = note->accessibleInfo() + 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 += /* linked */ 4;
+                  for (ScoreElement* se : note1->linkList()) {
+                        if (se != note1 && se->isNote())
+                              logCollisionNote(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 */
@@ -431,6 +456,12 @@ void EventMap::fixupMIDI()
                   else if (++np > 1) {
                         /* already playing */
                         discard = true;
+                        /* log the collision */
+                        fprintf(stderr, "MIDI collision detected: newly played...\n");
+                        logCollisionNotes(&event);
+                        fprintf(stderr, " ... interferes with already playing...\n");
+                        logCollisionNotes(info[event.channel()].event[event.pitch()]);
+                        fprintf(stderr, " ... which will continue to sound.\n");
                         /* carry over the corresponding score notes */
                         info[event.channel()].event[event.pitch()]->notes.insert(info[event.channel()].event[event.pitch()]->notes.end(), event.notes.begin(), event.notes.end());
                         }