MuseScore/omr
Andres Fernandez de Prado 33dff96a20 This commit contains changes required for MuseScore to compile under MSVC with no warnings.
This commit contains changes required for MuseScore to compile under MSVC with no warnings.

MuseScore is being compiled with the /W4 setting (warning level 4), which is similar to -wall -wextra on clang. This generates lots of warnings on MSVC, mainly for non-standard constructs and for constructs which might be bugs or might lead to bugs.

Most warnings are in the following categories:
- Name hiding: a variable hides a variable with the same name on a larger scope (or a field, or a function parameter). This can easily lead to bugs, and it is a best practice to avoid hiding variable names (see recommendation ES.12 in the C++ Core Guidelines by Stroustrop & Sutter (http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-reuse : ES.12: Do not reuse names in nested scopes)
- Narrowing conversion: a numeric conversion results in loss of significant digits (for example, double -> float). The general recommendation is to use a cast to indicate this is designed behaviour.
- Unreachable code: in several instances, there is unreachable code. The unreachable code is commented out.
- (Potentially) uninitialized local variable. Just initialized the vars.
- foreach(,) -> for(:): this does not generate a warning per-se (only a few of these generate warnings due to name hiding), but changed in keeping with "MuseScore Coding Rules" (https://musescore.org/en/handbook/musescore-coding-rules#Loops), which tells explicitly "Use C++11's "for" instead of Qt's "foreach":" ... "If you happen to be fixing some code and see a "foreach", please change that loop into a "for"."

Most changes are in the categories indicated above. The next listing shows detailed changes for files which are *not* of the aforementioned types.

- all.h: Disable warning C4127 (conditional expression is constant - generated in Qt header file qvector.h)
- awl/aslider.h: unreachable code.
- awl/knob.cpp: name hiding
- awl/mslider.cpp: name hiding
- awl/slider.cpp: name hiding
- bww2mxml/parser.cpp: name hiding
- effects/compressor/compressor.cpp: narrowing conversion
- effects/zita1/zitagui.cpp: name hiding
- fluid/fluid.cpp: foreach replacement. Name hiding.
- fluid/mod.cpp: name hiding.
- fluid/sfont.cpp: foreach replacement. Name hiding. Initialize vars.
- fluid/voice.cpp: Name hiding.
- libmscore/accidental.cpp: Name hiding.
- libmscore/ambitus.cpp: Initialize vars.
- libmscore/barline.cpp: Name hiding. Unreachable code.
- libmscore/beam.cpp: Name hiding.
- libmscore/chordrest.cpp: Unreachable code.
- libmscore/scorefile.cpp: Name hiding.
- manual/genManual.cpp: Name hiding. foreach replacement.
- midi/midifile.cpp: Name hiding. Unreachable code.
- omr/importpdf.cpp: Name hiding. foreach replacement.
- omr/omr.cpp: Name hiding. foreach replacement.
- omr/omrpage.cpp: Name hiding. foreach replacement.
- omr/omrview.cpp: Name hiding. foreach replacement.
- synthesizer/event.cpp: Unreachable code.
- zerberus\channel.cpp: Narrowing conversion.
- zerberus\instrument.cpp: Name hiding.
- zerberus\sfz.cpp: Name hiding.
- zerberus\voice.h: Suppress warning C4201: "nonstandard extension used: nameless struct/union"
- zerberus\zerberus.cpp: Name hiding. Unreferenced parameter.
- zerberus\zerberusgui.cpp: Name hiding.
2018-08-03 09:15:42 +02:00
..
CMakeLists.txt This commit contains all the changes to the CMake build system required to generate a valid Visual Studio 2017 solution and projects for MuseScore. 2018-08-03 09:15:42 +02:00
image.h add namespace Ms 2013-05-13 19:43:59 +02:00
importpdf.cpp This commit contains changes required for MuseScore to compile under MSVC with no warnings. 2018-08-03 09:15:42 +02:00
importpdf.h Fix #110306: Enable and improve OMR module 2016-05-17 11:48:38 -04:00
ocr.cpp add namespace Ms 2013-05-13 19:43:59 +02:00
ocr.h add namespace Ms 2013-05-13 19:43:59 +02:00
omr.cpp This commit contains changes required for MuseScore to compile under MSVC with no warnings. 2018-08-03 09:15:42 +02:00
omr.h rename Xml() -> XmlWriter() 2016-11-19 11:51:21 +01:00
omrpage.cpp This commit contains changes required for MuseScore to compile under MSVC with no warnings. 2018-08-03 09:15:42 +02:00
omrpage.h rename Xml() -> XmlWriter() 2016-11-19 11:51:21 +01:00
omrview.cpp This commit contains changes required for MuseScore to compile under MSVC with no warnings. 2018-08-03 09:15:42 +02:00
omrview.h add namespace Ms 2013-05-13 19:43:59 +02:00
pattern.cpp fix some warning/error messages from lupdate 2016-09-29 08:05:39 +02:00
pattern.h Fix #110306: Enable and improve OMR module 2016-05-17 11:48:38 -04:00
pdf.cpp fix staff line order in omr output and update poppler using its qt5 wrapper to render pdf to image 2016-06-08 12:35:51 -04:00
pdf.h fix staff line order in omr output and update poppler using its qt5 wrapper to render pdf to image 2016-06-08 12:35:51 -04:00
README.md fix headings and typos in omr/README.md 2017-12-26 10:53:56 +01:00
skew.cpp add namespace Ms 2013-05-13 19:43:59 +02:00
TODO Fix #100396: change "note heads" to "noteheads" 2016-05-02 21:22:29 -04:00
utils.cpp add namespace Ms 2013-05-13 19:43:59 +02:00
utils.h add namespace Ms 2013-05-13 19:43:59 +02:00

Updates on Optical Music Recognition

Graphical Model for System Identification

  1. We can simply use vertical line detection to find bar lines. But the detection performance is unreliable due to noise such as note stems or lines in text. The other problem of solely relying on line detection is that we can hardly interpret the structure of systems based on what has been detected. The solution to this problem is using a graphical model to represent the system structure and encode useful distance or non-overlapping constraints, with which we can determine the grouping of staves into systems and the location of barlines in each system at the same time (simultaneously estimate both).

  2. Suppose we have n staves (n-1 gaps), then there'll be 2^(n-1) ways of grouping systems if taking each gap as a binary switch connecting or not connecting the adjacent staves. In each system (staff group), barline positions will be commonly shared (a very strong and useful constraint!). We can use a nested dynamic programming to solve this problem. The optimal hypothesis (how the staves are grouped together) until the k-th stave yielding the max score h(k) = max(h(i) + system(i+1, ..., k)), based on previous optimal hypotheses h(i), i= 1,2,...,k-1. In each hypothesized system(i,...,j) from i-th to j-th staves, we recognize shared barlines from left to right by finding the best scoring configuration b_opt = max(b(k1) + b(k2) + ... + b(kn)) supposing each horizontal location corresponds to a bar or just background, where b(.) is the scoring function for barline in that column. We can also incorporate negative constraints (clef, key sigs, time sigs, or note stem) into this bar line recognition process.

Demo

Screenshots of some results

Todo

  • Add robust note detector to impose negative constraints for bar line identification. (see here)
  • Fix staff detection for vector graphs
  • Optimize OMR performance and add clef/key recognitions