This repository has been archived by the owner on Aug 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathmusicscore.proto
164 lines (149 loc) · 6.11 KB
/
musicscore.proto
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto2";
package tensorflow.moonlight;
// TODO(ringw): Fix python import issue, then load magenta with a prefix of
// "magenta" instead of "magenta/magenta". The import here should be
// "magenta/music/protobuf/music.proto".
import "protobuf/music.proto";
// Alpha-stage OMR page model. Most protos (except Glyph.Type) are subject to
// backwards-incompatible changes (e.g. renumbering or replacing fields).
// A score, containing multiple pages.
message Score {
repeated Page page = 1;
}
// A page, holding all detected objects.
message Page {
repeated StaffSystem system = 1;
}
// A staff system, holding one or more staves connected by barline(s).
// Contains zero or more bars, x coordinates where there is a vertical barline.
// If there are no bars, the staff contains a single measure spanning the width
// of the page. If there is a single bar, the staff contains a single measure
// spanning [bar[0], width). Otherwise, for n bars, there are n - 1 measures
// bounded by each adjacent pair of bars.
message StaffSystem {
repeated Staff staff = 1;
repeated Bar bar = 2;
message Bar {
optional int32 x = 1;
optional Type type = 2;
enum Type {
UNKNOWN_BAR = 0;
STANDARD_BAR = 1;
DOUBLE_BAR = 2;
END_BAR = 3;
BEGIN_REPEAT_BAR = 4;
END_REPEAT_BAR = 5;
BEGIN_AND_END_REPEAT_BAR = 6;
}
}
}
// A staff is represented by the distance between consecutive horizontal lines,
// and line segments that make up the center line (3rd out of 5 lines).
message Staff {
// The vertical distance between the horizontal lines that make up the staff.
// This is assumed to be constant for printed music scores.
optional int64 staffline_distance = 1;
// The approximately horizontal staff center line (third line of the staff).
// The other lines must be a multiple of staffline_distance above and below.
// Currently, the line always starts at x = 0 and ends at x = width - 1.
repeated Point center_line = 2;
// Glyphs which belong to the staff, sorted by x coordinate.
repeated Glyph glyph = 3;
}
// A musical element which is attached to a staff. The y_position represents the
// the staffline or staff space that a glyph is placed on. The center line
// (third staff line) has position 0, and the y_position increases with
// decreasing y coordinates (towards musically higher notes).
// For example, in treble clef, position 0 is B4, position -6 is C4, and
// position 1 is C5. For more details, see:
// g3doc/learning/brain/research/magenta/models/omr/g3doc/glyphs.md
message Glyph {
optional Type type = 1;
optional int64 x = 2;
optional int64 y_position = 3;
// Noteheads may be attached to a Stem. The reader joins noteheads with the
// same Stem as chords, which makes them all have the same timing.
optional LineSegment stem = 4;
// The Stem may intersect with Beam(s). A NOTEHEAD_FILLED has a duration of 1
// which is halved for each incident Beam.
repeated LineSegment beam = 5;
// Dots are attached to noteheads and alter their duration. Each dot adds half
// of the previous dot's value (or half the original duration, for the first
// dot) to the final duration.
repeated Point dot = 6;
// The Glyph may be detected as a Note by ScoreReader. The Note is stored as
// part of the Glyph.
optional magenta.NoteSequence.Note note = 7;
// Glyph Types are used as labels for the Examples in our corpus. Don't change
// or reuse the numbers!
enum Type {
// Default value.
UNKNOWN_TYPE = 0;
// No glyph at the given position. This is used for classification, where
// we will evaluate every pixel as a possible center point for a glyph.
NONE = 1;
// G clef. Typically centered on the second line from the bottom of the
// staff (G4 in treble clef). May be shifted in other, uncommon clefs.
CLEF_TREBLE = 2;
// F clef. Typically centered on the fourth line from the bottom of the
// staff (F3 in bass clef). May be shifted in other, uncommon clefs.
CLEF_BASS = 3;
// C clef is the clef symbol used for alto, tenor, and other clefs. In each
// such clef, the line that the C clef is centered on represents C4.
CLEF_C = 13;
// "Common time" is a stylized "c" which is equivalent to a 4/4 time
// signature. Note that numeral time signatures are not detected here. They
// will need to be detected in a post-processing step using OCR.
TIME_COMMON = 18;
// "Cut time" has a vertical line through the "common time" symbol, and is
// equivalent to 2/2 time.
TIME_CUT = 19;
NOTEHEAD_FILLED = 4;
NOTEHEAD_EMPTY = 5;
NOTEHEAD_WHOLE = 6;
// Note that whole and half rests will likely not be labeled for the
// classifier. They can easily be detected as rectangular connected
// components after staff removal, and are distinguished by their absolute
// position on the staff. However, the two currently look identical on the
// extracted patches because we use staff removal.
REST_WHOLE = 14;
REST_HALF = 15;
REST_QUARTER = 7;
REST_EIGHTH = 8;
REST_SIXTEENTH = 9;
// TODO(ringw): Sixty-fourth rests don't fit within our typical patch
// size (3 times the staffline distance), so they can't be detected under
// the current model.
REST_THIRTYSECOND = 17;
FLAT = 10;
SHARP = 11;
DOUBLE_SHARP = 16;
NATURAL = 12;
// Next tag: 20
}
}
message LineSegment {
optional Point start = 1;
optional Point end = 2;
}
message Rect {
optional Point top_left = 1;
optional Point bottom_right = 2;
}
message Point {
optional int64 x = 1;
optional int64 y = 2;
}