minor patch description tweak
[alioth/musescore.git] / debian / patches / experiments / log-collisions.diff
1 Description: Log unison collisions (that would otherwise be restruck)
2 Author: mirabilos <m@mirbsd.org>
3 Forwarded: not-yet
4 Justification: depends on experiments/revert-restriking-patch.diff
5
6 --- a/synthesizer/event.cpp
7 +++ b/synthesizer/event.cpp
8 @@ -14,6 +14,7 @@
9  #include "libmscore/xml.h"
10  #include "libmscore/note.h"
11  #include "libmscore/sig.h"
12 +#include "libmscore/tie.h"
13  #include "event.h"
14  
15  namespace Ms {
16 @@ -375,6 +376,25 @@ void EventList::insert(const Event& e)
17  //   class EventMap::fixupMIDI
18  //---------------------------------------------------------
19  
20 +static void logCollisionNote(const Note* note, unsigned int indent)
21 +      {
22 +      QString info = note->accessibleInfoConst() + note->accessibleBarbeat();
23 +      fprintf(stderr, " %*s%s\n", indent, "- ", qPrintable(info));
24 +      }
25 +
26 +static void logCollisionNotes(const NPlayEvent* event)
27 +      {
28 +      for (auto it = event->notes.cbegin(); it != event->notes.cend(); ++it) {
29 +            const Note* note1 = *it;
30 +            unsigned int indent = /* initial */ 2;
31 +            while (note1) {
32 +                  logCollisionNote(note1, indent);
33 +                  indent += /* next level */ 2;
34 +                  note1 = note1->tieFor() ? note1->tieFor()->endNote() : 0;
35 +                  }
36 +            }
37 +      }
38 +
39  void EventMap::fixupMIDI()
40        {
41        /* track info for each of the 128 possible MIDI notes */
42 @@ -409,6 +429,12 @@ void EventMap::fixupMIDI()
43                    else if (++np > 1) {
44                          /* already playing */
45                          discard = true;
46 +                        /* log the collision */
47 +                        fprintf(stderr, "MIDI collision detected: newly played...\n");
48 +                        logCollisionNotes(&(it->second));
49 +                        fprintf(stderr, " ... interferes with already playing...\n");
50 +                        logCollisionNotes(info[it->second.channel()].event[it->second.pitch()]);
51 +                        fprintf(stderr, " ... which will continue to sound.\n");
52                          /* carry over the corresponding score notes */
53                          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());
54                          }