Debian Codegraph @

texk/gregorio/gregorio-src/src/gregoriotex/gregoriotex.h

raw
1 /*
2 * Gregorio is a program that translates gabc files to GregorioTeX
3 * This header prototypes GregorioTeX writing data structures and entry points.
4 *
5 * Copyright (C) 2006-2025 The Gregorio Project (see CONTRIBUTORS.md)
6 *
7 * This file is part of Gregorio.
8 *
9 * This program is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation, either version 3 of the License, or (at your option)
12 * any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * more details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23 #ifndef GREGORIOTEX_H
24 #define GREGORIOTEX_H
25
26 #include "bool.h"
27
28 #define OFFSET_CASE(name) static const char *const name = #name
29
30 /*
31 * Here are the different types, they must be the same as in squarize.py
32 */
33
34 typedef enum gtex_type {
35 T_ONE_NOTE = 1,
36 /* two note neumes */
37 T_PES,
38 T_PES_QUADRATUM,
39 T_QUILISMA_PES,
40 T_PES_QUASSUS,
41 T_QUILISMA_PES_QUADRATUM,
42 T_FLEXUS,
43 T_FLEXUS_ORISCUS,
44 T_FLEXUS_ORISCUS_SCAPUS,
45 T_PES_ORISCUS,
46 /* three note neumes */
47 T_PORRECTUS,
48 T_TORCULUS,
49 T_TORCULUS_QUILISMA,
50 T_SCANDICUS, /* only deminutus */
51 T_ANCUS, /* only deminutus */
52 T_SALICUS,
53 /* four note neumes */
54 T_SALICUS_FLEXUS,
55 T_PORRECTUS_FLEXUS,
56 T_TORCULUS_RESUPINUS,
57 T_TORCULUS_LIQUESCENS,
58 T_TORCULUS_RESUPINUS_FLEXUS
59 } gtex_type;
60
61 /* the different types for the alignment of the notes in GregorioTeX
62 * these values are numbers coded into GregorioTeX */
63 typedef enum gtex_alignment {
64 AT_ONE_NOTE = 0,
65 AT_FLEXUS = 1,
66 AT_PORRECTUS = 2,
67 AT_INITIO_DEBILIS = 3,
68 AT_QUILISMA = 4,
69 AT_ORISCUS = 5,
70 AT_PUNCTUM_INCLINATUM = 6,
71 AT_STROPHA = 7,
72 AT_FLEXUS_1 = 8,
73 AT_FLEXUS_DEMINUTUS = 9,
74 AT_VIRGULA = 10,
75 AT_DIVISIO_MINIMA = 11,
76 AT_DIVISIO_MINOR = 12,
77 AT_DIVISIO_MAIOR = 13,
78 AT_DIVISIO_DOMINICAN = 14,
79 AT_VIRGULA_PAREN = 15,
80 AT_DIVISIO_MINIMA_PAREN = 16,
81 AT_DIVISIO_FINALIS = 17,
82 AT_EMPTY_SYLLABLE = 18
83 } gtex_alignment;
84
85 typedef enum gtex_alteration {
86 ALT_NONE = 0,
87 ALT_FLAT = 1,
88 ALT_NATURAL = 2,
89 ALT_SHARP = 3,
90 ALT_FLAT_PAREN = 4,
91 ALT_NATURAL_PAREN = 5,
92 ALT_SHARP_PAREN = 6,
93 ALT_FLAT_SOFT = 7,
94 ALT_NATURAL_SOFT = 8,
95 ALT_SHARP_SOFT = 9
96 } gtex_alteration;
97
98 /* Here we define a function that will determine the number of the
99 * liquescentia that we will add to the glyph number. There are several types
100 * as all glyphs can't have all liquescentiae. Let's first define the
101 * different types: */
102
103 typedef enum gtex_glyph_liquescentia {
104 LG_ALL = 0, /* for glyphs that accept all liquecentiae */
105 LG_NO_INITIO, /* for glyphs that don't accept initio debilis */
106 LG_NONE, /* for glyphs that don't accept liquescentia */
107 LG_ONLY_DEMINUTUS,
108 LG_FUSIBLE_INITIO
109 } gtex_glyph_liquescentia;
110
111 typedef enum gtex_sign_type {
112 ST_H_EPISEMA = 0,
113 ST_V_EPISEMA = 1
114 } gtex_sign_type;
115
116 #define HEPISEMA_FIRST_TWO 12
117
118 static __inline bool choral_sign_here_is_low(const gregorio_glyph *const glyph,
119 const gregorio_note *const note, bool *const kind_of_pes)
120 {
121 if (kind_of_pes) {
122 *kind_of_pes = false;
123 }
124
125 switch (glyph->u.notes.glyph_type) {
126 case G_FLEXA:
127 case G_TORCULUS:
128 case G_TORCULUS_LIQUESCENS:
129 case G_TORCULUS_RESUPINUS_FLEXUS:
130 case G_PORRECTUS_FLEXUS:
131 if (!note->next) {
132 return true;
133 }
134 break;
135
136 case G_PODATUS:
137 case G_PORRECTUS:
138 case G_TORCULUS_RESUPINUS:
139 if (!note->next || note->next->next) {
140 break;
141 }
142 if (kind_of_pes) {
143 *kind_of_pes = true;
144 }
145 return true;
146
147 default:
148 break;
149 }
150
151 return false;
152 }
153
154 static __inline bool is_on_a_line(const char pitch)
155 {
156 return pitch % 2 == 0;
157 }
158
159 static __inline bool is_between_lines(const char pitch)
160 {
161 return pitch % 2 == 1;
162 }
163
164 bool gtex_is_h_episema_above_shown(const gregorio_note *const note);
165 bool gtex_is_h_episema_below_shown(const gregorio_note *const note);
166 const char *gregoriotex_determine_glyph_name(const gregorio_glyph *const glyph,
167 gtex_alignment *const type, gtex_type *const gtype);
168 void gregoriotex_compute_positioning(const gregorio_element *element,
169 const gregorio_score *score);
170 void gregoriotex_compute_cross_syllable_positioning(
171 const gregorio_score *score);
172
173 #endif