0

I am curious is it possible to convert scores to notes in codes?

For example, convert this image of melody to ['0','C#5', 'G#5', 'F#5', 'E5', 'D#5', 'C#5', 'B5', ]... or convert to [-1, 73, 80, 78, 76, 75, 73, 83]... enter image description here

I know that the way to convert pitch notes to MIDI numbers is (This answer was found by https://stackoverflow.com/a/57587216/14724837)

NOTES_FLAT = ['C', 'Db', 'D', 'Eb', 'E', 'F', 'Gb', 'G', 'Ab', 'A', 'Bb', 'B']
NOTES_SHARP = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']

def NoteToMidi(KeyOctave):
    # KeyOctave is formatted like 'C#3'
    key = KeyOctave[:-1]  # eg C, Db
    octave = KeyOctave[-1]   # eg 3, 4
    answer = -1

    try:
        if 'b' in key:
            pos = NOTES_FLAT.index(key)
        else:
            pos = NOTES_SHARP.index(key)
    except:
        print('The key is not valid', key)
        return answer

    answer += pos + 12 * (int(octave) + 1) + 1
    return answer

But i don't know the way to convert form musical scores.

Megan
  • 541
  • 1
  • 3
  • 14

1 Answers1

0

Converting a music score image into music data is called Optical Music Recognition (OMR). You'll need a specialized library to do the work (you can find most of them on GitHub). Note that OMR is a difficult task. As Wikipedia will tell you:

"Many OMR projects have been realized in academia, but only a few of them reached a mature state and were successfully deployed to users."

Or from Audiveris, a mature OMR library:

Significant progresses have been made, especially regarding poor-quality scores, but experience tells us that 100% recognition ratio is simply out of reach in many cases.

jjazzboss
  • 1,261
  • 8
  • 14
  • I see. Indeed, I found that the process is complicated, maybe needs some tutorial to understand the step. BTW, Audiveris is for Java, and i haven't learned about JAVA LOL – Megan Oct 18 '22 at 03:44