From a07c81b81438c5478c983b4efbb6103e8e088de2 Mon Sep 17 00:00:00 2001 From: "Henry So, Jr." Date: Wed, 1 Apr 2015 01:33:25 -0400 Subject: [PATCH 1/3] Converted remaining defines into enums and included then via unions. --- .indent.pro | 11 + src/dump/dump.c | 395 +++++----- src/dump/dump.h | 35 +- src/gabc/gabc-elements-determination.c | 28 +- src/gabc/gabc-glyphs-determination.c | 1007 ++++++++++++------------ src/gabc/gabc-notes-determination.l | 108 ++- src/gabc/gabc-score-determination.y | 25 +- src/gabc/gabc-write.c | 102 +-- src/gabc/gabc.h | 74 +- src/gregoriotex/gregoriotex-write.c | 891 +++++++++++---------- src/gregoriotex/gregoriotex.h | 8 +- src/struct.c | 585 +++++++------- src/struct.h | 614 ++++++++------- 13 files changed, 2070 insertions(+), 1813 deletions(-) diff --git a/.indent.pro b/.indent.pro index 8badb950c..eead5e6fa 100644 --- a/.indent.pro +++ b/.indent.pro @@ -32,3 +32,14 @@ -T gregorio_word_position -T gregorio_lyric_centering -T gregorio_type +-T gregorio_shape +-T gregorio_bar +-T gregorio_sign +-T gregorio_space +-T gregorio_liquescentia +-T gregorio_h_episemus +-T gregorio_glyph_type +-T gregorio_word_position +-T gregorio_lyric_centering +-T gregorio_extra_info +-T gregorio_misc_element_info diff --git a/src/dump/dump.c b/src/dump/dump.c index 6689e993e..d70fb6c6d 100644 --- a/src/dump/dump.c +++ b/src/dump/dump.c @@ -131,8 +131,8 @@ void dump_write_score(FILE *f, gregorio_score *score) fprintf(f, " initial_key %d (%s)\n", voice_info->initial_key, dump_key_to_char(voice_info->initial_key)); - if (voice_info->flatted_key == FLAT_KEY) { - fprintf(f, " flat_key FLAT_KEY\n"); + if (voice_info->flatted_key) { + fprintf(f, " flatted_key true\n"); } } for (annotation_num = 0; annotation_num < NUM_ANNOTATIONS; @@ -163,9 +163,9 @@ void dump_write_score(FILE *f, gregorio_score *score) syllable->position, dump_syllable_position(syllable->position)); } - if (syllable->additional_infos) { - fprintf(f, " additional infos %s\n", - dump_rare_sign(syllable->additional_infos)); + if (syllable->special_sign) { + fprintf(f, " special sign %s\n", + dump_special_sign(syllable->special_sign)); } if (syllable->no_linebreak_area != NLBA_NORMAL) { fprintf(f, " no line break area %s\n", @@ -202,170 +202,210 @@ void dump_write_score(FILE *f, gregorio_score *score) fprintf(f, " type %d (%s)\n", element->type, dump_type(element->type)); } - if (element->element_type && element->type == GRE_ELEMENT) { - fprintf(f, " element_type %d (%s)\n", - element->element_type, - dump_element_type(element->element_type)); - } - if (element->element_type && element->type == GRE_CUSTO) { + if (element->type == GRE_CUSTO && element->u.misc.pitched.pitch) { fprintf(f, " pitch %c \n", - element->element_type); + element->u.misc.pitched.pitch); } - if (element->element_type && element->type == GRE_SPACE) { - fprintf(f, " element_type %d (%s)\n", - element->element_type, - dump_space_type(element->element_type)); + if (element->type == GRE_SPACE + && element->u.misc.unpitched.info.space) { + fprintf(f, " space %d (%s)\n", + element->u.misc.unpitched.info.space, + dump_space_type(element->u.misc.unpitched.info.space)); } if (element->type == GRE_TEXVERB_ELEMENT) { fprintf(f, " TeX string \"%s\"\n", element->texverb); } if (element->type == GRE_NLBA) { - fprintf(f, " element_type %d (%s)\n", - element->element_type, - dump_nlba_to_string(element->element_type)); + fprintf(f, " nlba %d (%s)\n", + element->u.misc.unpitched.info.nlba, + dump_nlba_to_string(element->u.misc.unpitched.info. + nlba)); } if (element->type == GRE_ALT) { fprintf(f, " Above lines text \"%s\"\n", element->texverb); } - if (element->element_type && element->type == GRE_BAR) { - fprintf(f, " element_type %d (%s)\n", - element->element_type, - dump_bar_type(element->element_type)); - if (element->additional_infos) { - fprintf(f, " additional_infos %d (%s)\n", - element->element_type, - dump_rare_sign(element->additional_infos)); + if (element->type == GRE_BAR && element->u.misc.unpitched.info.bar) { + fprintf(f, " bar %d (%s)\n", + element->u.misc.unpitched.info.bar, + dump_bar_type(element->u.misc.unpitched.info.bar)); + if (element->u.misc.unpitched.special_sign) { + fprintf(f, " special sign %d (%s)\n", + element->u.misc.unpitched.special_sign, + dump_special_sign(element->u.misc.unpitched. + special_sign)); } } - if (element->element_type && element->type == GRE_C_KEY_CHANGE) { - fprintf(f, " element_type %d (c%d)\n", - element->element_type, element->element_type - 48); - if (element->additional_infos == FLAT_KEY) { - fprintf(f, " additional_infos FLAT_KEY\n"); + if (element->type == GRE_C_KEY_CHANGE + && element->u.misc.pitched.pitch) { + fprintf(f, " clef %d (c%d)\n", + element->u.misc.pitched.pitch, + element->u.misc.pitched.pitch - '0'); + if (element->u.misc.pitched.flatted_key) { + fprintf(f, " flatted_key true\n"); } } - if (element->element_type && element->type == GRE_F_KEY_CHANGE) { - fprintf(f, " element_type %d (f%d)\n", - element->element_type, element->element_type - 48); - if (element->additional_infos == FLAT_KEY) { - fprintf(f, " additional_infos FLAT_KEY\n"); + if (element->type == GRE_F_KEY_CHANGE + && element->u.misc.pitched.pitch) { + fprintf(f, " clef %d (f%d)\n", + element->u.misc.pitched.pitch, + element->u.misc.pitched.pitch - '0'); + if (element->u.misc.pitched.flatted_key) { + fprintf(f, " flatted_key true\n"); } } - if (element->element_type && element->type == GRE_END_OF_LINE) { - fprintf(f, " element_type %d (%s)\n", - element->element_type, - dump_type(element->element_type)); + if (element->type == GRE_END_OF_LINE + && element->u.misc.unpitched.info.sub_type) { + fprintf(f, " sub_type %d (%s)\n", + element->u.misc.unpitched.info.sub_type, + dump_type(element->u.misc.unpitched.info.sub_type)); } - glyph = element->first_glyph; - while (glyph) { - fprintf(f, - "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n"); - if (glyph->type) { - fprintf(f, " type %d (%s)\n", - glyph->type, dump_type(glyph->type)); - } - if (glyph->type == GRE_TEXVERB_GLYPH) { - fprintf(f, " TeX string \"%s\"\n", - glyph->texverb); - } - if (glyph->glyph_type) { - if (glyph->type == GRE_SPACE) { - fprintf(f, " glyph_type %d (%s)\n", - glyph->glyph_type, - dump_space_type(glyph->glyph_type)); + if (element->type == GRE_ELEMENT) { + glyph = element->u.glyphs.first_glyph; + while (glyph) { + fprintf(f, + "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n"); + if (glyph->type) { + fprintf(f, " type %d (%s)\n", + glyph->type, dump_type(glyph->type)); } - if (glyph->type == GRE_BAR) { + switch (glyph->type) { + case GRE_TEXVERB_GLYPH: + fprintf(f, " TeX string \"%s\"\n", + glyph->texverb); + break; + + case GRE_SPACE: + fprintf(f, " space %d (%s)\n", + glyph->u.misc.unpitched.info.space, + dump_space_type(glyph->u.misc.unpitched.info. + space)); + break; + + case GRE_BAR: fprintf(f, " glyph_type %d (%s)\n", - glyph->glyph_type, - dump_bar_type(glyph->glyph_type)); - } - if ((glyph->type == GRE_FLAT) - || (glyph->type == GRE_NATURAL) - || (glyph->type == GRE_SHARP)) { + glyph->u.misc.unpitched.info.bar, + dump_bar_type(glyph->u.misc.unpitched.info. + bar)); + if (glyph->u.misc.unpitched.special_sign) { + fprintf(f, " special sign %d (%s)\n", + glyph->u.misc.unpitched.special_sign, + dump_special_sign(glyph->u.misc.unpitched. + special_sign)); + } + break; + + case GRE_FLAT: + case GRE_NATURAL: + case GRE_SHARP: fprintf(f, " glyph_type %d (%c)\n", - glyph->glyph_type, glyph->glyph_type); - } - if ((glyph->type != GRE_SPACE) && (glyph->type != GRE_BAR) - && (glyph->type != GRE_FLAT) - && (glyph->type != GRE_NATURAL) - && (glyph->type != GRE_SHARP)) { + glyph->u.misc.pitched.pitch, + glyph->u.misc.pitched.pitch); + break; + + case GRE_GLYPH: fprintf(f, " glyph_type %d (%s)\n", - glyph->glyph_type, - dump_glyph_type(glyph->glyph_type)); - } - } - if (glyph->liquescentia && glyph->type != GRE_BAR) { - fprintf(f, " liquescentia %d (%s)\n", - glyph->liquescentia, - dump_liquescentia(glyph->liquescentia)); - } - if (glyph->liquescentia && glyph->type == GRE_BAR) { - fprintf(f, " liquescentia %d (%s)\n", - glyph->liquescentia, - dump_rare_sign(glyph->liquescentia)); - } - note = glyph->first_note; - while (note) { - fprintf(f, - "- - - - - - - - - - - - - - - - - - - - - - - \n"); - if (note->type) { - fprintf(f, " type %d (%s)\n", - note->type, dump_type(note->type)); - } - if (note->pitch) { - fprintf(f, " pitch %c\n", - note->pitch); - } - if (note->texverb) { - fprintf(f, " TeX string \"%s\"\n", - note->texverb); - } - if (note->choral_sign) { - fprintf(f, " Choral Sign \"%s\"\n", - note->choral_sign); - } - if (note->shape) { - fprintf(f, " shape %d (%s)\n", - note->shape, dump_shape(note->shape)); - } - if (note->signs) { - fprintf(f, " signs %d (%s)\n", - note->signs, dump_signs(note->signs)); - } - if (note->rare_sign) { - fprintf(f, " rare sign %d (%s)\n", - note->rare_sign, - dump_rare_sign(note->rare_sign)); - } - if (note->liquescentia) { - fprintf(f, " liquescentia %d (%s)\n", - note->liquescentia, - dump_liquescentia(note->liquescentia)); - } - if (note->h_episemus_type) { - fprintf(f, " h_episemus_type %d (", - note->h_episemus_type); - fprintf(f, "%s", - dump_h_episemus_type(simple_htype - (note->h_episemus_type))); - if (has_bottom(note->h_episemus_type)) { - fprintf(f, " & H_BOTTOM"); + glyph->u.notes.glyph_type, + dump_glyph_type(glyph->u.notes.glyph_type)); + if (glyph->u.notes.liquescentia) { + fprintf(f, " liquescentia %d (%s)\n", + glyph->u.notes.liquescentia, + dump_liquescentia(glyph->u.notes. + liquescentia)); } - fprintf(f, ")\n"); - } - if (note->h_episemus_top_note) { - fprintf(f, " h_episemus_top_note %c\n", - note->h_episemus_top_note); + break; + + default: + fprintf(f, " !!! UNKNOWN !!! !!!\n"); + break; } - if (note->h_episemus_bottom_note) { - fprintf(f, " h_episemus_bottom_note %c\n", - note->h_episemus_bottom_note); + if (glyph->type == GRE_GLYPH) { + note = glyph->u.notes.first_note; + while (note) { + fprintf(f, + "- - - - - - - - - - - - - - - - - - - - - - - \n"); + if (note->type) { + fprintf(f, + " type %d (%s)\n", + note->type, dump_type(note->type)); + } + switch (note->type) { + case GRE_NOTE: + if (note->u.note.pitch) { + fprintf(f, + " pitch %c\n", + note->u.note.pitch); + } + if (note->u.note.shape) { + fprintf(f, + " shape %d (%s)\n", + note->u.note.shape, + dump_shape(note->u.note.shape)); + } + if (note->u.note.liquescentia) { + fprintf(f, + " liquescentia %d (%s)\n", + note->u.note.liquescentia, + dump_liquescentia(note->u.note. + liquescentia)); + } + break; + + default: + fprintf(f, + " !!! NOT ALLOWED !!! !!!\n"); + break; + } + if (note->texverb) { + fprintf(f, + " TeX string \"%s\"\n", + note->texverb); + } + if (note->choral_sign) { + fprintf(f, + " Choral Sign \"%s\"\n", + note->choral_sign); + } + if (note->signs) { + fprintf(f, + " signs %d (%s)\n", + note->signs, dump_signs(note->signs)); + } + if (note->special_sign) { + fprintf(f, + " special sign %d (%s)\n", + note->special_sign, + dump_special_sign(note->special_sign)); + } + if (note->h_episemus_type) { + fprintf(f, + " h_episemus_type %d (", + note->h_episemus_type); + fprintf(f, "%s", + dump_h_episemus_type(simple_htype + (note-> + h_episemus_type))); + if (has_bottom(note->h_episemus_type)) { + fprintf(f, " & H_BOTTOM"); + } + fprintf(f, ")\n"); + } + if (note->h_episemus_top_note) { + fprintf(f, + " h_episemus_top_note %c\n", + note->h_episemus_top_note); + } + if (note->h_episemus_bottom_note) { + fprintf(f, + " h_episemus_bottom_note %c\n", + note->h_episemus_bottom_note); + } + note = note->next; + } } - note = note->next; + glyph = glyph->next; } - glyph = glyph->next; } element = element->next; } @@ -375,7 +415,8 @@ void dump_write_score(FILE *f, gregorio_score *score) } } -const char *dump_translation_type_to_string(unsigned char translation_type) +const char *dump_translation_type_to_string(gregorio_tr_centering + translation_type) { switch (translation_type) { case TR_NORMAL: @@ -393,7 +434,7 @@ const char *dump_translation_type_to_string(unsigned char translation_type) } } -const char *dump_nlba_to_string(unsigned char no_linebreak_area) +const char *dump_nlba_to_string(gregorio_nlba no_linebreak_area) { switch (no_linebreak_area) { case NLBA_NORMAL: @@ -411,7 +452,7 @@ const char *dump_nlba_to_string(unsigned char no_linebreak_area) } } -const char *dump_style_to_string(unsigned char style) +const char *dump_style_to_string(grestyle_style style) { switch (style) { case ST_NO_STYLE: @@ -513,7 +554,7 @@ const char *dump_key_to_char(int key) return str; } -const char *dump_syllable_position(char pos) +const char *dump_syllable_position(gregorio_word_position pos) { const char *str; switch (pos) { @@ -536,7 +577,7 @@ const char *dump_syllable_position(char pos) return str; } -const char *dump_type(char type) +const char *dump_type(gregorio_type type) { const char *str; switch (type) { @@ -601,7 +642,7 @@ const char *dump_type(char type) return str; } -const char *dump_bar_type(char element_type) +const char *dump_bar_type(gregorio_bar element_type) { const char *str; switch (element_type) { @@ -648,7 +689,7 @@ const char *dump_bar_type(char element_type) return str; } -const char *dump_space_type(char element_type) +const char *dump_space_type(gregorio_space element_type) { const char *str; switch (element_type) { @@ -686,49 +727,7 @@ const char *dump_space_type(char element_type) return str; } -// not so sure it has still a meaning now... -const char *dump_element_type(char element_type) -{ - const char *str; - switch (element_type) { - case 0: - str = "ELT_NO_ELEMENT"; - break; - case 1: - str = "ELT_PRAEPUNCTA"; - break; - case 2: - str = "ELT_ONE_GLYPH"; - break; - case 3: - str = "ELT_PRAEPUNCTA_ONE_GLYPH"; - break; - case 4: - str = "ELT_TWO_GLYPH"; - break; - case 5: - str = "ELT_PRAEPUNCTA_TWO_GLYPH"; - break; - case 6: - str = "ELT_ONE_GLYPH_SUBPUNCTA"; - break; - case 7: - str = "ELT_PRAEPUNCTA_ONE_GLYPH_SUBPUNCTA"; - break; - case 8: - str = "ELT_TWO_GLYPH_SUBPUNCTA"; - break; - case 9: - str = "ELT_PRAEPUNCTA_TWO_GLYPH_SUBPUNCTA"; - break; - default: - str = "unknown"; - break; - } - return str; -} - -const char *dump_liquescentia(char liquescentia) +const char *dump_liquescentia(gregorio_liquescentia liquescentia) { const char *str; switch (liquescentia) { @@ -769,7 +768,7 @@ const char *dump_liquescentia(char liquescentia) return str; } -const char *dump_glyph_type(char glyph_type) +const char *dump_glyph_type(gregorio_glyph_type glyph_type) { const char *str; switch (glyph_type) { @@ -891,7 +890,7 @@ const char *dump_glyph_type(char glyph_type) return str; } -const char *dump_shape(char shape) +const char *dump_shape(gregorio_shape shape) { const char *str; switch (shape) { @@ -977,7 +976,7 @@ const char *dump_shape(char shape) return str; } -const char *dump_signs(char signs) +const char *dump_signs(gregorio_sign signs) { const char *str; switch (signs) { @@ -1006,11 +1005,11 @@ const char *dump_signs(char signs) return str; } -// a function dumping rare_signs or additional_informations -const char *dump_rare_sign(char rare_sign) +// a function dumping special signs +const char *dump_special_sign(gregorio_sign special_sign) { const char *str; - switch (rare_sign) { + switch (special_sign) { case _ACCENTUS: str = "_ACCENTUS"; break; @@ -1066,7 +1065,7 @@ const char *dump_rare_sign(char rare_sign) return str; } -const char *dump_h_episemus_type(unsigned char h_episemus_type) +const char *dump_h_episemus_type(gregorio_h_episemus h_episemus_type) { const char *str; switch (h_episemus_type) { diff --git a/src/dump/dump.h b/src/dump/dump.h index 70b399484..63917b598 100644 --- a/src/dump/dump.h +++ b/src/dump/dump.h @@ -19,38 +19,39 @@ #ifndef DUMP_H #define DUMP_H -void write_score (FILE *f, gregorio_score *score); +#include -const char *dump_key_to_char (int key); +void write_score(FILE *f, gregorio_score *score); -const char *dump_syllable_position (char pos); +const char *dump_key_to_char(int key); -const char *dump_type (char type); +const char *dump_syllable_position(gregorio_word_position pos); -const char *dump_bar_type (char element_type); +const char *dump_type(gregorio_type type); -const char *dump_space_type (char element_type); +const char *dump_bar_type(gregorio_bar element_type); -const char *dump_element_type (char element_type); +const char *dump_space_type(gregorio_space element_type); -const char *dump_liquescentia (char liquescentia); +const char *dump_liquescentia(gregorio_liquescentia liquescentia); -const char *dump_glyph_type (char glyph_type); +const char *dump_glyph_type(gregorio_glyph_type glyph_type); -const char *dump_shape (char shape); +const char *dump_shape(gregorio_shape shape); -const char *dump_signs (char signs); +const char *dump_signs(gregorio_sign signs); -const char *dump_rare_sign (char rare_sign); +const char *dump_special_sign(gregorio_sign rare_sign); -const char *dump_h_episemus_type (unsigned char h_episemus_type); +const char *dump_h_episemus_type(gregorio_h_episemus h_episemus_type); -void dump_write_characters (FILE *f, gregorio_character *current_character); +void dump_write_characters(FILE *f, gregorio_character *current_character); -const char *dump_style_to_string (unsigned char style); +const char *dump_style_to_string(grestyle_style style); -const char *dump_translation_type_to_string (unsigned char translation_type); +const char *dump_translation_type_to_string(gregorio_tr_centering + translation_type); -const char * dump_nlba_to_string (unsigned char no_linebreak_area); +const char *dump_nlba_to_string(gregorio_nlba no_linebreak_area); #endif diff --git a/src/gabc/gabc-elements-determination.c b/src/gabc/gabc-elements-determination.c index bca6a97ae..2979946cc 100644 --- a/src/gabc/gabc-elements-determination.c +++ b/src/gabc/gabc-elements-determination.c @@ -166,7 +166,7 @@ gregorio_element *gabc_det_elements_from_glyphs(gregorio_glyph *current_glyph) } // we must not cut after a zero_width_space if (current_glyph->type == GRE_SPACE - && current_glyph->glyph_type == SP_ZERO_WIDTH) { + && current_glyph->u.misc.unpitched.info.space == SP_ZERO_WIDTH) { if (!current_glyph->next) { close_element(¤t_element, first_glyph); } @@ -188,19 +188,15 @@ gregorio_element *gabc_det_elements_from_glyphs(gregorio_glyph *current_glyph) // if statement to make neumatic cuts not appear in elements, as // there is always one between elements if (current_glyph->type != GRE_SPACE - || current_glyph->glyph_type != SP_NEUMATIC_CUT) + || current_glyph->u.misc.unpitched.info.space != SP_NEUMATIC_CUT) // clef change or space other thant neumatic cut { if (!first_element) { first_element = current_element; } - gregorio_add_special_as_element(¤t_element, - current_glyph->type, - current_glyph->glyph_type, - current_glyph->liquescentia, - current_glyph->texverb); - } else { - + gregorio_add_misc_element(¤t_element, current_glyph->type, + current_glyph->u.misc, + current_glyph->texverb); } first_glyph = current_glyph->next; previous_glyph = current_glyph->next; @@ -235,19 +231,19 @@ gregorio_element *gabc_det_elements_from_glyphs(gregorio_glyph *current_glyph) } break; case G_ONE_NOTE: - if (current_glyph->first_note - && (current_glyph->first_note->shape == S_STROPHA - || current_glyph->first_note->shape == S_VIRGA - || current_glyph->first_note->shape == S_VIRGA_REVERSA)) { + if (current_glyph->u.notes.first_note + && (current_glyph->u.notes.first_note->u.note.shape == S_STROPHA + || current_glyph->u.notes.first_note->u.note.shape == S_VIRGA + || current_glyph->u.notes.first_note->u.note.shape == S_VIRGA_REVERSA)) { // we determine the last pitch char last_pitch; gregorio_note *tmp_note; - tmp_note = previous_glyph->first_note; + tmp_note = previous_glyph->u.notes.first_note; while (tmp_note->next) { tmp_note = tmp_note->next; } - last_pitch = tmp_note->pitch; - if (current_glyph->first_note->pitch == last_pitch) { + last_pitch = tmp_note->u.note.pitch; + if (current_glyph->u.notes.first_note->u.note.pitch == last_pitch) { previous_glyph = current_glyph; break; } diff --git a/src/gabc/gabc-glyphs-determination.c b/src/gabc/gabc-glyphs-determination.c index 00ce5d7c1..fdaf9ccf6 100644 --- a/src/gabc/gabc-glyphs-determination.c +++ b/src/gabc/gabc-glyphs-determination.c @@ -18,21 +18,12 @@ #include "config.h" #include +#include #include "struct.h" #include "messages.h" #include "gabc.h" -void -close_glyph(gregorio_glyph **current_glyph, char glyph_type, - gregorio_note **first_note, char liquescentia, - gregorio_note *current_note); - -char -gregorio_add_note_to_a_glyph(char current_glyph_type, char current_pitch, - char last_pitch, char shape, char liquescentia, - char *end_of_glyph); - gregorio_glyph *gabc_det_glyphs_from_string(char *str, int *initial_key, char *macros[10]) { @@ -58,8 +49,8 @@ gregorio_glyph *gabc_det_glyphs_from_string(char *str, int *initial_key, ****************************/ void -close_glyph(gregorio_glyph **last_glyph, char glyph_type, - gregorio_note **first_note, char liquescentia, +close_glyph(gregorio_glyph **last_glyph, gregorio_glyph_type glyph_type, + gregorio_note **first_note, gregorio_liquescentia liquescentia, gregorio_note *current_note) { // a variable necessary for the patch for G_BIVIRGA & co. @@ -91,48 +82,50 @@ close_glyph(gregorio_glyph **last_glyph, char glyph_type, { gregorio_go_to_first_note(¤t_note); while (current_note) { - switch (current_note->shape) { - case S_TRIVIRGA: - gregorio_add_note(&added_notes, current_note->pitch, S_VIRGA, - _NO_SIGN, L_NO_LIQUESCENTIA, - current_note->h_episemus_type); - case S_BIVIRGA: - gregorio_add_note(&added_notes, current_note->pitch, S_VIRGA, - _NO_SIGN, L_NO_LIQUESCENTIA, - current_note->h_episemus_type); - gregorio_add_note(&added_notes, current_note->pitch, S_VIRGA, - current_note->signs, - current_note->liquescentia, - current_note->h_episemus_type); - break; - case S_TRISTROPHA: - gregorio_add_note(&added_notes, current_note->pitch, S_STROPHA, - _NO_SIGN, L_NO_LIQUESCENTIA, - current_note->h_episemus_type); - case S_DISTROPHA: - gregorio_add_note(&added_notes, current_note->pitch, S_STROPHA, - _NO_SIGN, L_NO_LIQUESCENTIA, - current_note->h_episemus_type); - gregorio_add_note(&added_notes, current_note->pitch, S_STROPHA, - current_note->signs, - current_note->liquescentia, - current_note->h_episemus_type); - break; - case S_TRISTROPHA_AUCTA: - gregorio_add_note(&added_notes, current_note->pitch, S_STROPHA, - _NO_SIGN, L_NO_LIQUESCENTIA, - current_note->h_episemus_type); - case S_DISTROPHA_AUCTA: - gregorio_add_note(&added_notes, current_note->pitch, S_STROPHA, - _NO_SIGN, L_NO_LIQUESCENTIA, - current_note->h_episemus_type); - gregorio_add_note(&added_notes, current_note->pitch, - S_STROPHA_AUCTA, current_note->signs, - current_note->liquescentia, - current_note->h_episemus_type); - break; - default: - break; + if (current_note->type == GRE_NOTE) { + switch (current_note->u.note.shape) { + case S_TRIVIRGA: + gregorio_add_note(&added_notes, current_note->u.note.pitch, + S_VIRGA, _NO_SIGN, L_NO_LIQUESCENTIA, + current_note->h_episemus_type); + case S_BIVIRGA: + gregorio_add_note(&added_notes, current_note->u.note.pitch, + S_VIRGA, _NO_SIGN, L_NO_LIQUESCENTIA, + current_note->h_episemus_type); + gregorio_add_note(&added_notes, current_note->u.note.pitch, + S_VIRGA, current_note->signs, + current_note->u.note.liquescentia, + current_note->h_episemus_type); + break; + case S_TRISTROPHA: + gregorio_add_note(&added_notes, current_note->u.note.pitch, + S_STROPHA, _NO_SIGN, L_NO_LIQUESCENTIA, + current_note->h_episemus_type); + case S_DISTROPHA: + gregorio_add_note(&added_notes, current_note->u.note.pitch, + S_STROPHA, _NO_SIGN, L_NO_LIQUESCENTIA, + current_note->h_episemus_type); + gregorio_add_note(&added_notes, current_note->u.note.pitch, + S_STROPHA, current_note->signs, + current_note->u.note.liquescentia, + current_note->h_episemus_type); + break; + case S_TRISTROPHA_AUCTA: + gregorio_add_note(&added_notes, current_note->u.note.pitch, + S_STROPHA, _NO_SIGN, L_NO_LIQUESCENTIA, + current_note->h_episemus_type); + case S_DISTROPHA_AUCTA: + gregorio_add_note(&added_notes, current_note->u.note.pitch, + S_STROPHA, _NO_SIGN, L_NO_LIQUESCENTIA, + current_note->h_episemus_type); + gregorio_add_note(&added_notes, current_note->u.note.pitch, + S_STROPHA_AUCTA, current_note->signs, + current_note->u.note.liquescentia, + current_note->h_episemus_type); + break; + default: + break; + } } // this is the case of two separate virga that have been spotted // as a bivirga @@ -154,14 +147,13 @@ close_glyph(gregorio_glyph **last_glyph, char glyph_type, current_note = added_notes; break; } else { - gregorio_free_one_note(¤t_note); // automatically sets - // first_note to the next - // note + gregorio_free_one_note(¤t_note); + // automatically sets first_note to the next note } } gregorio_go_to_first_note(¤t_note); // finally we set the just added glyph first_note to current_note - (*last_glyph)->first_note = current_note; + (*last_glyph)->u.notes.first_note = current_note; } } @@ -177,22 +169,26 @@ char gabc_determine_custo_pitch(gregorio_note *current_note, int current_key) while (current_note) { if (current_note->type == GRE_C_KEY_CHANGE || current_note->type == GRE_C_KEY_CHANGE_FLATED) { - newkey = - gregorio_calculate_new_key(C_KEY, current_note->pitch - 48); + newkey = gregorio_calculate_new_key(C_KEY, + current_note->u.note.pitch - + '0'); pitch_difference = newkey - current_key; } if (current_note->type == GRE_F_KEY_CHANGE || current_note->type == GRE_F_KEY_CHANGE_FLATED) { - newkey = - gregorio_calculate_new_key(F_KEY, current_note->pitch - 48); + newkey = gregorio_calculate_new_key(F_KEY, + current_note->u.note.pitch - + '0'); pitch_difference = newkey - current_key; } if (current_note->type == GRE_NOTE) { - pitch_difference = (int) current_note->pitch - pitch_difference; + pitch_difference = + (int) current_note->u.note.pitch - pitch_difference; if (pitch_difference < (int) 'a' || pitch_difference > (int) 'm') { - gregorio_message(_ - ("pitch difference too high to set automatic custo (z0), please check your score"), - "gabc_determine_custo_pitch", ERROR, 0); + gregorio_message(_("pitch difference too high to set " + "automatic custo (z0), please check your " + "score"), "gabc_determine_custo_pitch", + ERROR, 0); } return (char) pitch_difference; } @@ -203,441 +199,99 @@ char gabc_determine_custo_pitch(gregorio_note *current_note, int current_key) /**************************** * - * Function called with a list of gregorio_notes as argument, this - * list is determined from gabc notation by the function - * gabc_det_notes_from_string. + * This function is the basis of all the determination of glyphs. The + * phylosophy of the function is to say : We have a glyph that we have + * determined, and we have the following note, can we "add" it to the + * glyph, or will it be the first note of another glyph ? * - * In this function we create a list of glyphs, by determining their - * type according to the sequence of notes (we look at their height, - * shape, etc.). Each glyph has a pointer gregorio_note *first_note - * that will be filled with the good note (and notes will be cut as - * explained in the comments on close_glyph function). + * current_glyph_type is the type of the current_glyph (current_glyph + * as meant in gabc_det_glyphs_from_notes). curent_pitch + * is the height of the note that we want to "add" to the glyph. + * last_pitch is the height of the last note of current_glyph. shape + * is the shape of the note we want to "add" to the glyph. * - * Here is how it works : - * current_glyph is the glyph we are currently determining, that is to - * say a glyph whose type may change according to the note we will add - * to it. - * current_note is the note we are currently dealing with. - * Let's take an example, if the list of notes is ab, the first step - * (current_glyph: undetermined, current_note: a) will be to add a to - * nothing, that will give a glyph "punctum" containing only one note: - * a. In the second step (current_glyph: punctum, current_note: b) we - * transform the glyph in "pes". - * For special notes like a key change or something, we stop the - * determination of the current glyph, we delete the note and we add - * it as a glyph. + * The function returns a char, which meaning is explained below. * - * When we determine the glyphs we can encounter the shapes - * S_QUADRATUM and S_QUILISMA_QUADRATUM, which means that the - * corresponding note is the first note of a pes quadratum (it can - * have the shape quilisma for very rare forms). But these shapes must - * not appear in the final form of the score, and we transform them - * respectively in punctum and quilisma (and the glyph type must be - * pes_quadratum, but it is done in gregorio_add_note_to_a_glyph). + * end_of_glyph is a pointer to the result of the determination, here + * are the meanings : + * + * DET_NO_END: we have successfully added the note to the glyph, and + * we return the new type of the glyph. We may again add notes to the + * glyph. + * + * DET_END_OF_PREVIOUS: we have not been able to add the note to the + * glyph, so we will have to close the glyph. + * + * DET_END_OF_CURRENT: we have been able to add the note to the glyph, + * but we won't be able to add more notes to the glyph, we can close + * it. The new type is returned. + + * DET_END_OF_BOTH: we have'nt been able to add the note to the glyph, + * and we won't be able to add notes to the new glyph. This special + * case is quite rare, we use it for trivirga, tristropha, etc. + + * When we encouter a S_QUADRATUM (or S_QUILISMA_QUADRATUM), we build + * a new glyph with the (temporary) shape G_PES_QUADRATUM_FIRST_PART + * (or G_PES_QUILISMA_QUADRATUM_FIRST_PART), and we wait for the next + * note. * ****************************/ -// this function updates current_key with the new values (with clef changes) - -gregorio_glyph *gabc_det_glyphs_from_notes(gregorio_note *current_note, - int *current_key) +char +gregorio_add_note_to_a_glyph(gregorio_glyph_type current_glyph_type, + char current_pitch, char last_pitch, + gregorio_shape shape, + gregorio_liquescentia liquescentia, + gabc_determination * end_of_glyph) { - // the first note of the current glyph, to be able to close it well: - // later we will cut the link (next_notes and previous_note) between - // this note and the previous one - gregorio_note *current_glyph_first_note = current_note; - - // the last glyph we have totally determined. It is automatically - // updated by close_glyph(). - gregorio_glyph *last_glyph = NULL; - - // type of the glyph we are currently determining - char current_glyph_type = G_UNDETERMINED; - char next_glyph_type = G_UNDETERMINED; - char last_pitch = USELESS_VALUE; - // a variable for the signs of bars and to tell if a key is flatted or not - char additional_infos = 0; - gregorio_note *next_note = NULL; - // determination of end of glyphs, see comments on - // gregorio_add_note_to_a_glyph - char end_of_glyph = DET_NO_END; + // next glyph type is the type of the glyph that will be returned (the + // new type of the glyph with the note added to it, or the type of the + // new glyph with the note alone. + gregorio_glyph_type next_glyph_type = G_UNDETERMINED; - // a char representing the liquescentia of the current glyph - char liquescentia = L_NO_LIQUESCENTIA; + *end_of_glyph = DET_NO_END; - if (current_note == NULL) { - return NULL; + // here we separate notes that would be logically in the same glyph + // but that are too far to be so + if (last_pitch) { + if (current_pitch - last_pitch > MAX_INTERVAL + || current_pitch - last_pitch < -MAX_INTERVAL) { + current_glyph_type = G_UNDETERMINED; + } } - gregorio_go_to_first_note(¤t_note); - - while (current_note) { - next_note = current_note->next; - if (current_note->type != GRE_NOTE) { - if (current_glyph_type != G_UNDETERMINED) { - close_glyph(&last_glyph, next_glyph_type, - ¤t_glyph_first_note, liquescentia, - current_note->previous); - current_glyph_type = G_UNDETERMINED; - liquescentia = L_NO_LIQUESCENTIA; - } - if (current_note->type == GRE_C_KEY_CHANGE) { - *current_key = - gregorio_calculate_new_key(C_KEY, current_note->pitch - 48); - } - if (current_note->type == GRE_F_KEY_CHANGE) { - *current_key = - gregorio_calculate_new_key(F_KEY, current_note->pitch - 48); - } - if (current_note->type == GRE_C_KEY_CHANGE_FLATED) { - *current_key = - gregorio_calculate_new_key(C_KEY, current_note->pitch - 48); - gregorio_add_special_as_glyph(&last_glyph, GRE_C_KEY_CHANGE, - current_note->pitch, FLAT_KEY, - NULL); - current_glyph_first_note = current_note->next; - gregorio_free_one_note(¤t_note); - last_pitch = USELESS_VALUE; - continue; - } - if (current_note->type == GRE_F_KEY_CHANGE_FLATED) { - *current_key = - gregorio_calculate_new_key(F_KEY, current_note->pitch - 48); - gregorio_add_special_as_glyph(&last_glyph, GRE_F_KEY_CHANGE, - current_note->pitch, FLAT_KEY, - NULL); - current_glyph_first_note = current_note->next; - gregorio_free_one_note(¤t_note); - last_pitch = USELESS_VALUE; - continue; - } - if (current_note->type == GRE_CUSTO) { - current_note->pitch = - gabc_determine_custo_pitch(current_note->next, - *current_key); - } - // we calculate the signs of the bars - if (current_note->type == GRE_BAR) { - if (current_note->signs == _V_EPISEMUS) { - switch (current_note->rare_sign) { - case _ICTUS_A: - additional_infos = _V_EPISEMUS_ICTUS_A; - break; - case _ICTUS_T: - additional_infos = _V_EPISEMUS_ICTUS_T; - break; - default: - additional_infos = _V_EPISEMUS; - break; - } - } else { - additional_infos = current_note->rare_sign; - } - if (current_note->h_episemus_type != H_NO_EPISEMUS) { - switch (additional_infos) { - case _ICTUS_A: - additional_infos = _H_EPISEMUS_ICTUS_A; - break; - case _ICTUS_T: - additional_infos = _H_EPISEMUS_ICTUS_T; - break; - case _V_EPISEMUS: - additional_infos = _V_EPISEMUS_H_EPISEMUS; - break; - case _V_EPISEMUS_ICTUS_T: - additional_infos = _V_EPISEMUS_H_EPISEMUS_ICTUS_T; - break; - case _V_EPISEMUS_ICTUS_A: - additional_infos = _V_EPISEMUS_H_EPISEMUS_ICTUS_T; - break; - default: - additional_infos = _H_EPISEMUS; - break; - } - } - } - gregorio_add_special_as_glyph(&last_glyph, current_note->type, - current_note->pitch, - additional_infos, - current_note->texverb); - current_glyph_first_note = current_note->next; - current_note->texverb = NULL; - gregorio_free_one_note(¤t_note); - last_pitch = USELESS_VALUE; - additional_infos = 0; - // TODO : change behaviour here for flat and natural - // UPDATE: what does this TODO mean?... - continue; - } + switch (shape) { + case S_PUNCTUM_CAVUM: + case S_LINEA_PUNCTUM: + case S_LINEA_PUNCTUM_CAVUM: + case S_LINEA: + next_glyph_type = G_PUNCTUM; + *end_of_glyph = DET_END_OF_BOTH; + break; + case S_PUNCTUM: /* - * first we do what must be done with liquescentia + * we determine here the shape of the thing if it is made of puncta */ - if (is_initio_debilis(current_note->liquescentia)) { - /* - * meaning that the note is an initio debilis, maybe more - */ - if (current_glyph_type != G_UNDETERMINED) { - /* - * if it is not the first glyph - */ - close_glyph(&last_glyph, current_glyph_type, - ¤t_glyph_first_note, - liquescentia, current_note->previous); - current_glyph_type = G_UNDETERMINED; - } - liquescentia = L_INITIO_DEBILIS; - } - - next_glyph_type = - gregorio_add_note_to_a_glyph(current_glyph_type, - current_note->pitch, last_pitch, - current_note->shape, - current_note->liquescentia, - &end_of_glyph); - - // patch to have good shapes in the special cases of pes quadratum and - // pes quilisma quadratum. - if (current_note->shape == S_QUADRATUM) { - current_note->shape = S_PUNCTUM; - } - if (current_note->shape == S_QUILISMA_QUADRATUM) { - current_note->shape = S_QUILISMA; - } - if (current_note->shape == S_ORISCUS_QUADRATUM) { - current_note->shape = S_ORISCUS; + if (current_pitch == last_pitch) { + next_glyph_type = G_PUNCTUM; + *end_of_glyph = DET_END_OF_PREVIOUS; + break; } - // see comments on gregorio_add_note_to_a_glyph for the meaning of - // end_of_glyph - switch (end_of_glyph) { - case DET_NO_END: - current_glyph_type = next_glyph_type; - /* - * we deal with liquescentia - */ - if (is_liquescentia(current_note->liquescentia)) { - // special cases of oriscus auctus, treated like normal oriscus - // in some cases. - if (current_note->shape == S_ORISCUS_AUCTUS - && current_note->next - && current_note->next->pitch < current_note->pitch) { - last_pitch = current_note->pitch; - current_note->shape = S_ORISCUS; - current_note->liquescentia = L_NO_LIQUESCENTIA; - current_note = next_note; - continue; - } - // special cases of the punctum inclinatum deminutus and auctus - if (current_note->shape == S_PUNCTUM_INCLINATUM) { - if (current_note->liquescentia == L_DEMINUTUS) { - current_note->shape = S_PUNCTUM_INCLINATUM_DEMINUTUS; - } - if (current_note->liquescentia == L_AUCTA - || current_note->liquescentia == L_AUCTUS_DESCENDENS - || current_note->liquescentia == L_AUCTUS_ASCENDENS) { - current_note->shape = S_PUNCTUM_INCLINATUM_AUCTUS; - } - - if (current_note->next - && current_note->next->shape == - S_PUNCTUM_INCLINATUM - && current_note->next->liquescentia == L_DEMINUTUS) { - last_pitch = current_note->pitch; - current_note = next_note; - continue; - } - } - liquescentia += current_note->liquescentia; - /* - * once again, only works with the good values in the header file - */ - close_glyph(&last_glyph, current_glyph_type, - ¤t_glyph_first_note, liquescentia, - current_note); - current_glyph_type = G_UNDETERMINED; - liquescentia = L_NO_LIQUESCENTIA; + switch (current_glyph_type) { + case G_PUNCTUM: + if (current_pitch > last_pitch) { + next_glyph_type = G_PODATUS; + } else { + next_glyph_type = G_FLEXA; } break; - case DET_END_OF_PREVIOUS: - if (current_note->previous) // we don't want to close previous - // glyph - // twice - { - close_glyph(&last_glyph, current_glyph_type, - ¤t_glyph_first_note, liquescentia, - current_note->previous); - } - current_glyph_type = next_glyph_type; - liquescentia = L_NO_LIQUESCENTIA; - last_pitch = USELESS_VALUE; - /* - * we deal with liquescentia - */ - if (is_liquescentia(current_note->liquescentia)) - // not an initio debilis, because we considered it in the first - // part... - { - // special cases of the punctum inclinatum deminutus and auctus - if (current_note->shape == S_PUNCTUM_INCLINATUM) { - if (current_note->liquescentia == L_DEMINUTUS) { - current_note->shape = S_PUNCTUM_INCLINATUM_DEMINUTUS; - } - if (current_note->liquescentia == L_AUCTA - || current_note->liquescentia == L_AUCTUS_DESCENDENS - || current_note->liquescentia == L_AUCTUS_ASCENDENS) { - current_note->shape = S_PUNCTUM_INCLINATUM_AUCTUS; - } - if (current_note->next - && current_note->next->shape == - S_PUNCTUM_INCLINATUM - && current_note->next->liquescentia == L_DEMINUTUS) { - last_pitch = current_note->pitch; - current_note = next_note; - continue; - } - } - close_glyph(&last_glyph, current_glyph_type, - ¤t_glyph_first_note, - current_note->liquescentia, current_note); - current_glyph_type = G_UNDETERMINED; - } - break; - case DET_END_OF_CURRENT: - liquescentia += current_note->liquescentia; - /* - * once again, only works with the good values in the header file - */ - close_glyph(&last_glyph, next_glyph_type, - ¤t_glyph_first_note, liquescentia, current_note); - current_glyph_type = G_UNDETERMINED; - liquescentia = L_NO_LIQUESCENTIA; - break; - default: // case DET_END_OF_BOTH: - if (current_note->previous) // we don't want to close previous - // glyph - // twice - { - close_glyph(&last_glyph, current_glyph_type, - ¤t_glyph_first_note, liquescentia, - current_note->previous); - } - current_glyph_type = G_UNDETERMINED; - liquescentia = L_NO_LIQUESCENTIA; - close_glyph(&last_glyph, next_glyph_type, - ¤t_glyph_first_note, - current_note->liquescentia, current_note); - break; - } - - if (!next_note && current_glyph_type != G_UNDETERMINED) { // we must - // end the - // determination - // here - close_glyph(&last_glyph, current_glyph_type, - ¤t_glyph_first_note, liquescentia, current_note); - } - - last_pitch = current_note->pitch; - current_note = next_note; - } // end of while - - gregorio_go_to_first_glyph(&last_glyph); - return last_glyph; -} - -/**************************** - * - * This function is the basis of all the determination of glyphs. The - * phylosophy of the function is to say : We have a glyph that we have - * determined, and we have the following note, can we "add" it to the - * glyph, or will it be the first note of another glyph ? - * - * current_glyph_type is the type of the current_glyph (current_glyph - * as meant in gabc_det_glyphs_from_notes). curent_pitch - * is the height of the note that we want to "add" to the glyph. - * last_pitch is the height of the last note of current_glyph. shape - * is the shape of the note we want to "add" to the glyph. - * - * The function returns a char, which meaning is explained below. - * - * *end_of_glyph is a pointer to the result of the determination, here - are the meanings : - - * DET_NO_END: we have successfully added the note to the glyph, and - we return the new type of the glyph. We may again add notes to the - glyph. - - * DET_END_OF_PREVIOUS: we have not been able to add the note to the - glyph, so we will have to close the glyph. - - * DET_END_OF_CURRENT: we have been able to add the note to the glyph, - * but we won't be able to add more notes to the glyph, we can close - * it. The new type is returned. - - * DET_END_OF_BOTH: we have'nt been able to add the note to the glyph, - * and we won't be able to add notes to the new glyph. This special - * case is quite rare, we use it for trivirga, tristropha, etc. - - * When we encouter a S_QUADRATUM (or S_QUILISMA_QUADRATUM), we build - * a new glyph with the (temporary) shape G_PES_QUADRATUM_FIRST_PART - * (or G_PES_QUILISMA_QUADRATUM_FIRST_PART), and we wait for the next - * note. - * -****************************/ - -char -gregorio_add_note_to_a_glyph(char current_glyph_type, char current_pitch, - char last_pitch, char shape, char liquescentia, - char *end_of_glyph) -{ - - // next glyph type is the type of the glyph that will be returned (the - // new type of the glyph with the note added to it, or the type of the - // new glyph with the note alone. - char next_glyph_type = G_UNDETERMINED; - - *end_of_glyph = DET_NO_END; - - // here we separate notes that would be logically in the same glyph - // but that are too far to be so - if (last_pitch) { - if (current_pitch - last_pitch > MAX_INTERVAL - || current_pitch - last_pitch < -MAX_INTERVAL) { - current_glyph_type = G_UNDETERMINED; - } - } - - switch (shape) { - case S_PUNCTUM_CAVUM: - case S_LINEA_PUNCTUM: - case S_LINEA_PUNCTUM_CAVUM: - case S_LINEA: - next_glyph_type = G_PUNCTUM; - *end_of_glyph = DET_END_OF_BOTH; - break; - case S_PUNCTUM: - /* - * we determine here the shape of the thing if it is made of puncta - */ - if (current_pitch == last_pitch) { - next_glyph_type = G_PUNCTUM; - *end_of_glyph = DET_END_OF_PREVIOUS; - break; - } - switch (current_glyph_type) { - case G_PUNCTUM: - if (current_pitch > last_pitch) { - next_glyph_type = G_PODATUS; - } else { - next_glyph_type = G_FLEXA; - } - break; - case G_PODATUS: - if (current_pitch > last_pitch) { - next_glyph_type = G_SCANDICUS; - *end_of_glyph = DET_END_OF_CURRENT; - } else { - next_glyph_type = G_TORCULUS; + case G_PODATUS: + if (current_pitch > last_pitch) { + next_glyph_type = G_SCANDICUS; + *end_of_glyph = DET_END_OF_CURRENT; + } else { + next_glyph_type = G_TORCULUS; } break; case G_PES_QUADRATUM_FIRST_PART: @@ -768,8 +422,10 @@ gregorio_add_note_to_a_glyph(char current_glyph_type, char current_pitch, } break; case S_PUNCTUM_INCLINATUM: - /** Warning : this part of the code is specific to the - declarations of the header file */ + /* + * Warning : this part of the code is specific to the + * declarations of the header file + */ if (current_glyph_type > G_PUNCTA_INCLINATA) { /* * meaning that the previous glyph is not a combination of puncta @@ -874,7 +530,8 @@ gregorio_add_note_to_a_glyph(char current_glyph_type, char current_pitch, break; default: break; - } // end of the main switch + } + // end of the main switch if (current_glyph_type == G_NO_GLYPH) { /* @@ -912,3 +569,379 @@ gregorio_add_note_to_a_glyph(char current_glyph_type, char current_pitch, return next_glyph_type; } + +/**************************** + * + * Function called with a list of gregorio_notes as argument, this + * list is determined from gabc notation by the function + * gabc_det_notes_from_string. + * + * In this function we create a list of glyphs, by determining their + * type according to the sequence of notes (we look at their height, + * shape, etc.). Each glyph has a pointer gregorio_note *first_note + * that will be filled with the good note (and notes will be cut as + * explained in the comments on close_glyph function). + * + * Here is how it works : + * current_glyph is the glyph we are currently determining, that is to + * say a glyph whose type may change according to the note we will add + * to it. + * current_note is the note we are currently dealing with. + * Let's take an example, if the list of notes is ab, the first step + * (current_glyph: undetermined, current_note: a) will be to add a to + * nothing, that will give a glyph "punctum" containing only one note: + * a. In the second step (current_glyph: punctum, current_note: b) we + * transform the glyph in "pes". + * For special notes like a key change or something, we stop the + * determination of the current glyph, we delete the note and we add + * it as a glyph. + * + * When we determine the glyphs we can encounter the shapes + * S_QUADRATUM and S_QUILISMA_QUADRATUM, which means that the + * corresponding note is the first note of a pes quadratum (it can + * have the shape quilisma for very rare forms). But these shapes must + * not appear in the final form of the score, and we transform them + * respectively in punctum and quilisma (and the glyph type must be + * pes_quadratum, but it is done in gregorio_add_note_to_a_glyph). + * +****************************/ + +// this function updates current_key with the new values (with clef changes) + +gregorio_glyph *gabc_det_glyphs_from_notes(gregorio_note *current_note, + int *current_key) +{ + // the first note of the current glyph, to be able to close it well: + // later we will cut the link (next_notes and previous_note) between + // this note and the previous one + gregorio_note *current_glyph_first_note = current_note; + + // the last glyph we have totally determined. It is automatically + // updated by close_glyph(). + gregorio_glyph *last_glyph = NULL; + + // type of the glyph we are currently determining + gregorio_glyph_type current_glyph_type = G_UNDETERMINED; + gregorio_glyph_type next_glyph_type = G_UNDETERMINED; + char last_pitch = USELESS_VALUE; + // a variable for the signs of bars and to tell if a key is flatted or not + gregorio_note *next_note = NULL; + + // determination of end of glyphs, see comments on + // gregorio_add_note_to_a_glyph + gabc_determination end_of_glyph = DET_NO_END; + + // a char representing the liquescentia of the current glyph + gregorio_liquescentia liquescentia = L_NO_LIQUESCENTIA; + + if (current_note == NULL) { + return NULL; + } + + gregorio_go_to_first_note(¤t_note); + + while (current_note) { + next_note = current_note->next; + if (current_note->type != GRE_NOTE) { + gregorio_type type = current_note->type; + char pitch = USELESS_VALUE; + bool flat = false; + gregorio_sign sign = _NO_SIGN; + + if (current_glyph_type != G_UNDETERMINED) { + close_glyph(&last_glyph, next_glyph_type, + ¤t_glyph_first_note, liquescentia, + current_note->previous); + current_glyph_type = G_UNDETERMINED; + liquescentia = L_NO_LIQUESCENTIA; + } + + switch (type) { + case GRE_C_KEY_CHANGE: + pitch = current_note->u.note.pitch; + *current_key = gregorio_calculate_new_key(C_KEY, pitch - '0'); + break; + + case GRE_F_KEY_CHANGE: + pitch = current_note->u.note.pitch; + *current_key = gregorio_calculate_new_key(F_KEY, pitch - '0'); + break; + + case GRE_C_KEY_CHANGE_FLATED: + pitch = current_note->u.note.pitch; + *current_key = gregorio_calculate_new_key(C_KEY, pitch - '0'); + type = GRE_C_KEY_CHANGE; + flat = true; + break; + + case GRE_F_KEY_CHANGE_FLATED: + pitch = current_note->u.note.pitch; + *current_key = gregorio_calculate_new_key(F_KEY, pitch - '0'); + type = GRE_F_KEY_CHANGE; + flat = true; + break; + + case GRE_CUSTO: + pitch = gabc_determine_custo_pitch(current_note->next, + *current_key); + break; + + case GRE_BAR: + // we calculate the signs of the bars + if (current_note->signs == _V_EPISEMUS) { + switch (current_note->special_sign) { + case _ICTUS_A: + sign = _V_EPISEMUS_ICTUS_A; + break; + case _ICTUS_T: + sign = _V_EPISEMUS_ICTUS_T; + break; + default: + sign = _V_EPISEMUS; + break; + } + } else { + sign = current_note->special_sign; + } + if (current_note->h_episemus_type != H_NO_EPISEMUS) { + switch (sign) { + case _ICTUS_A: + sign = _H_EPISEMUS_ICTUS_A; + break; + case _ICTUS_T: + sign = _H_EPISEMUS_ICTUS_T; + break; + case _V_EPISEMUS: + sign = _V_EPISEMUS_H_EPISEMUS; + break; + case _V_EPISEMUS_ICTUS_T: + sign = _V_EPISEMUS_H_EPISEMUS_ICTUS_T; + break; + case _V_EPISEMUS_ICTUS_A: + sign = _V_EPISEMUS_H_EPISEMUS_ICTUS_T; + break; + default: + sign = _H_EPISEMUS; + break; + } + } + break; + + case GRE_FLAT: + case GRE_SHARP: + case GRE_NATURAL: + pitch = current_note->u.note.pitch; + break; + } + + if (pitch == USELESS_VALUE) { + gregorio_add_unpitched_element_as_glyph(&last_glyph, type, + current_note->u.other, + sign, + current_note->texverb); + } else { + gregorio_add_pitched_element_as_glyph(&last_glyph, type, pitch, + flat, + current_note->texverb); + } + current_glyph_first_note = current_note->next; + current_note->texverb = NULL; + gregorio_free_one_note(¤t_note); + last_pitch = USELESS_VALUE; + continue; + } + + /* + * first we do what must be done with liquescentia + */ + if (is_initio_debilis(current_note->u.note.liquescentia)) { + /* + * meaning that the note is an initio debilis, maybe more + */ + if (current_glyph_type != G_UNDETERMINED) { + /* + * if it is not the first glyph + */ + close_glyph(&last_glyph, current_glyph_type, + ¤t_glyph_first_note, + liquescentia, current_note->previous); + current_glyph_type = G_UNDETERMINED; + } + liquescentia = L_INITIO_DEBILIS; + } + + next_glyph_type = + gregorio_add_note_to_a_glyph(current_glyph_type, + current_note->u.note.pitch, last_pitch, + current_note->u.note.shape, + current_note->u.note.liquescentia, + &end_of_glyph); + + // patch to have good shapes in the special cases of pes quadratum and + // pes quilisma quadratum. + switch (current_note->u.note.shape) { + case S_QUADRATUM: + current_note->u.note.shape = S_PUNCTUM; + break; + + case S_QUILISMA_QUADRATUM: + current_note->u.note.shape = S_QUILISMA; + break; + + case S_ORISCUS_QUADRATUM: + current_note->u.note.shape = S_ORISCUS; + break; + } + + // see comments on gregorio_add_note_to_a_glyph for the meaning of + // end_of_glyph + switch (end_of_glyph) { + case DET_NO_END: + current_glyph_type = next_glyph_type; + /* + * we deal with liquescentia + */ + if (is_liquescentia(current_note->u.note.liquescentia)) { + // special cases of oriscus auctus, treated like normal oriscus + // in some cases. + if (current_note->u.note.shape == S_ORISCUS_AUCTUS + && current_note->next + && current_note->next->type == GRE_NOTE + && current_note->next->u.note.pitch < + current_note->u.note.pitch) { + last_pitch = current_note->u.note.pitch; + current_note->u.note.shape = S_ORISCUS; + current_note->u.note.liquescentia = L_NO_LIQUESCENTIA; + current_note = next_note; + continue; + } + // special cases of the punctum inclinatum deminutus and auctus + if (current_note->u.note.shape == S_PUNCTUM_INCLINATUM) { + if (current_note->u.note.liquescentia == L_DEMINUTUS) { + current_note->u.note.shape = + S_PUNCTUM_INCLINATUM_DEMINUTUS; + } + if (current_note->u.note.liquescentia == L_AUCTA + || current_note->u.note.liquescentia == + L_AUCTUS_DESCENDENS + || current_note->u.note.liquescentia == + L_AUCTUS_ASCENDENS) { + current_note->u.note.shape = + S_PUNCTUM_INCLINATUM_AUCTUS; + } + + if (current_note->next + && current_note->next->type == GRE_NOTE + && current_note->next->u.note.shape == + S_PUNCTUM_INCLINATUM + && current_note->next->u.note.liquescentia == + L_DEMINUTUS) { + last_pitch = current_note->u.note.pitch; + current_note = next_note; + continue; + } + } + liquescentia += current_note->u.note.liquescentia; + /* + * once again, only works with the good values in the header file + */ + close_glyph(&last_glyph, current_glyph_type, + ¤t_glyph_first_note, liquescentia, + current_note); + current_glyph_type = G_UNDETERMINED; + liquescentia = L_NO_LIQUESCENTIA; + } + break; + case DET_END_OF_PREVIOUS: + if (current_note->previous) // we don't want to close previous + // glyph + // twice + { + close_glyph(&last_glyph, current_glyph_type, + ¤t_glyph_first_note, liquescentia, + current_note->previous); + } + current_glyph_type = next_glyph_type; + liquescentia = L_NO_LIQUESCENTIA; + last_pitch = USELESS_VALUE; + /* + * we deal with liquescentia + */ + if (is_liquescentia(current_note->u.note.liquescentia)) + // not an initio debilis, because we considered it in the first + // part... + { + // special cases of the punctum inclinatum deminutus and auctus + if (current_note->u.note.shape == S_PUNCTUM_INCLINATUM) { + if (current_note->u.note.liquescentia == L_DEMINUTUS) { + current_note->u.note.shape = + S_PUNCTUM_INCLINATUM_DEMINUTUS; + } + if (current_note->u.note.liquescentia == L_AUCTA + || current_note->u.note.liquescentia == + L_AUCTUS_DESCENDENS + || current_note->u.note.liquescentia == + L_AUCTUS_ASCENDENS) { + current_note->u.note.shape = + S_PUNCTUM_INCLINATUM_AUCTUS; + } + if (current_note->next + && current_note->next->type == GRE_NOTE + && current_note->next->u.note.shape == + S_PUNCTUM_INCLINATUM + && current_note->next->u.note.liquescentia == + L_DEMINUTUS) { + last_pitch = current_note->u.note.pitch; + current_note = next_note; + continue; + } + } + close_glyph(&last_glyph, current_glyph_type, + ¤t_glyph_first_note, + current_note->u.note.liquescentia, current_note); + current_glyph_type = G_UNDETERMINED; + } + break; + case DET_END_OF_CURRENT: + liquescentia += current_note->u.note.liquescentia; + /* + * once again, only works with the good values in the header file + */ + close_glyph(&last_glyph, next_glyph_type, + ¤t_glyph_first_note, liquescentia, current_note); + current_glyph_type = G_UNDETERMINED; + liquescentia = L_NO_LIQUESCENTIA; + break; + default: // case DET_END_OF_BOTH: + if (current_note->previous) // we don't want to close previous + // glyph + // twice + { + close_glyph(&last_glyph, current_glyph_type, + ¤t_glyph_first_note, liquescentia, + current_note->previous); + } + current_glyph_type = G_UNDETERMINED; + liquescentia = L_NO_LIQUESCENTIA; + close_glyph(&last_glyph, next_glyph_type, + ¤t_glyph_first_note, + current_note->u.note.liquescentia, current_note); + break; + } + + if (!next_note && current_glyph_type != G_UNDETERMINED) { // we must + // end the + // determination + // here + close_glyph(&last_glyph, current_glyph_type, + ¤t_glyph_first_note, liquescentia, current_note); + } + + last_pitch = current_note->u.note.pitch; + current_note = next_note; + } + // end of while + + gregorio_go_to_first_glyph(&last_glyph); + return last_glyph; +} diff --git a/src/gabc/gabc-notes-determination.l b/src/gabc/gabc-notes-determination.l index 787eb57db..9c3f0ea9a 100644 --- a/src/gabc/gabc-notes-determination.l +++ b/src/gabc/gabc-notes-determination.l @@ -34,7 +34,8 @@ char *notesmacros[10]; char *tempstr = NULL; static inline void -lex_add_note(int i, char shape, char signs, char liquescentia, char h_episemus) +lex_add_note(int i, gregorio_shape shape, char signs, char liquescentia, + char h_episemus) { nbof_isolated_episemus = 0; gregorio_add_note(¤t_note, tolower(gabc_notes_determination_text[i]), @@ -204,84 +205,82 @@ static inline void error() } [\t\r\n]+ /* ignore ends of line and tabs */; z { - gregorio_add_special_as_note(¤t_note, GRE_END_OF_LINE, - GRE_END_OF_LINE); + gregorio_add_end_of_line_as_note(¤t_note, GRE_END_OF_LINE); } z0 { - gregorio_add_special_as_note(¤t_note, GRE_CUSTO, USELESS_VALUE); + gregorio_add_custo_as_note(¤t_note); } Z { - gregorio_add_special_as_note(¤t_note, GRE_END_OF_LINE, - GRE_END_OF_PAR); + gregorio_add_end_of_line_as_note(¤t_note, GRE_END_OF_PAR); } (c|f)[1-4] { if (gabc_notes_determination_text[0]=='c') { - gregorio_add_special_as_note(¤t_note, GRE_C_KEY_CHANGE, - gabc_notes_determination_text[1]); + gregorio_add_clef_change_as_note(¤t_note, GRE_C_KEY_CHANGE, + gabc_notes_determination_text[1]); } else { - gregorio_add_special_as_note(¤t_note, GRE_F_KEY_CHANGE, - gabc_notes_determination_text[1]); + gregorio_add_clef_change_as_note(¤t_note, GRE_F_KEY_CHANGE, + gabc_notes_determination_text[1]); } } (cb|fb)[1-4] { if (gabc_notes_determination_text[0]=='c') { - gregorio_add_special_as_note(¤t_note, GRE_C_KEY_CHANGE_FLATED, - gabc_notes_determination_text[2]); + gregorio_add_clef_change_as_note(¤t_note, GRE_C_KEY_CHANGE_FLATED, + gabc_notes_determination_text[2]); } else { - gregorio_add_special_as_note(¤t_note, GRE_F_KEY_CHANGE_FLATED, - gabc_notes_determination_text[2]); + gregorio_add_clef_change_as_note(¤t_note, GRE_F_KEY_CHANGE_FLATED, + gabc_notes_determination_text[2]); } } ` { - gregorio_add_special_as_note(¤t_note, GRE_BAR, B_VIRGULA); + gregorio_add_bar_as_note(¤t_note, B_VIRGULA); } , { - gregorio_add_special_as_note(¤t_note, GRE_BAR, B_DIVISIO_MINIMA); + gregorio_add_bar_as_note(¤t_note, B_DIVISIO_MINIMA); } ,1 { - gregorio_add_special_as_note(¤t_note, GRE_BAR, B_DIVISIO_MINOR_D1); + gregorio_add_bar_as_note(¤t_note, B_DIVISIO_MINOR_D1); } ,2 { - gregorio_add_special_as_note(¤t_note, GRE_BAR, B_DIVISIO_MINOR_D2); + gregorio_add_bar_as_note(¤t_note, B_DIVISIO_MINOR_D2); } ,3 { - gregorio_add_special_as_note(¤t_note, GRE_BAR, B_DIVISIO_MINOR_D3); + gregorio_add_bar_as_note(¤t_note, B_DIVISIO_MINOR_D3); } ,4 { - gregorio_add_special_as_note(¤t_note, GRE_BAR, B_DIVISIO_MINOR_D4); + gregorio_add_bar_as_note(¤t_note, B_DIVISIO_MINOR_D4); } ,5 { - gregorio_add_special_as_note(¤t_note, GRE_BAR, B_DIVISIO_MINOR_D5); + gregorio_add_bar_as_note(¤t_note, B_DIVISIO_MINOR_D5); } ,6 { - gregorio_add_special_as_note(¤t_note, GRE_BAR, B_DIVISIO_MINOR_D6); + gregorio_add_bar_as_note(¤t_note, B_DIVISIO_MINOR_D6); } ; { - gregorio_add_special_as_note(¤t_note, GRE_BAR, B_DIVISIO_MINOR); + gregorio_add_bar_as_note(¤t_note, B_DIVISIO_MINOR); } ;1 { - gregorio_add_special_as_note(¤t_note, GRE_BAR, B_DIVISIO_MINOR_D1); + gregorio_add_bar_as_note(¤t_note, B_DIVISIO_MINOR_D1); } ;2 { - gregorio_add_special_as_note(¤t_note, GRE_BAR, B_DIVISIO_MINOR_D2); + gregorio_add_bar_as_note(¤t_note, B_DIVISIO_MINOR_D2); } ;3 { - gregorio_add_special_as_note(¤t_note, GRE_BAR, B_DIVISIO_MINOR_D3); + gregorio_add_bar_as_note(¤t_note, B_DIVISIO_MINOR_D3); } ;4 { - gregorio_add_special_as_note(¤t_note, GRE_BAR, B_DIVISIO_MINOR_D4); + gregorio_add_bar_as_note(¤t_note, B_DIVISIO_MINOR_D4); } ;5 { - gregorio_add_special_as_note(¤t_note, GRE_BAR, B_DIVISIO_MINOR_D5); + gregorio_add_bar_as_note(¤t_note, B_DIVISIO_MINOR_D5); } ;6 { - gregorio_add_special_as_note(¤t_note, GRE_BAR, B_DIVISIO_MINOR_D6); + gregorio_add_bar_as_note(¤t_note, B_DIVISIO_MINOR_D6); } : { - gregorio_add_special_as_note(¤t_note, GRE_BAR, B_DIVISIO_MAIOR); + gregorio_add_bar_as_note(¤t_note, B_DIVISIO_MAIOR); } :: { - gregorio_add_special_as_note(¤t_note, GRE_BAR, B_DIVISIO_FINALIS); + gregorio_add_bar_as_note(¤t_note, B_DIVISIO_FINALIS); } U { gregorio_add_special_sign(current_note, _ICTUS_A); @@ -314,75 +313,72 @@ r5 { gregorio_add_special_sign(current_note, _SEMI_CIRCULUS_REVERSUS); } [a-mA-M]x { - gregorio_add_special_as_note(¤t_note, GRE_FLAT, - gabc_notes_determination_text[0]); + gregorio_add_alteration_as_note(¤t_note, GRE_FLAT, + gabc_notes_determination_text[0]); } [a-mA-M]# { - gregorio_add_special_as_note(¤t_note, GRE_SHARP, - gabc_notes_determination_text[0]); + gregorio_add_alteration_as_note(¤t_note, GRE_SHARP, + gabc_notes_determination_text[0]); } [a-mA-M]y { - gregorio_add_special_as_note(¤t_note, GRE_NATURAL, - gabc_notes_determination_text[0]); + gregorio_add_alteration_as_note(¤t_note, GRE_NATURAL, + gabc_notes_determination_text[0]); } \/ { - gregorio_add_special_as_note(¤t_note, GRE_SPACE, SP_NEUMATIC_CUT); + gregorio_add_space_as_note(¤t_note, SP_NEUMATIC_CUT); } \/\/ { - gregorio_add_special_as_note(¤t_note, GRE_SPACE, SP_LARGER_SPACE); + gregorio_add_space_as_note(¤t_note, SP_LARGER_SPACE); } \ { - gregorio_add_special_as_note(¤t_note, GRE_SPACE, SP_GLYPH_SPACE); + gregorio_add_space_as_note(¤t_note, SP_GLYPH_SPACE); } !\/ { - gregorio_add_special_as_note(¤t_note, GRE_SPACE, - SP_NEUMATIC_CUT_NB); + gregorio_add_space_as_note(¤t_note, SP_NEUMATIC_CUT_NB); } !\/\/ { - gregorio_add_special_as_note(¤t_note, GRE_SPACE, - SP_LARGER_SPACE_NB); + gregorio_add_space_as_note(¤t_note, SP_LARGER_SPACE_NB); } !\ { - gregorio_add_special_as_note(¤t_note, GRE_SPACE, - SP_GLYPH_SPACE_NB); + gregorio_add_space_as_note(¤t_note, SP_GLYPH_SPACE_NB); } !/[^\/ ] { - gregorio_add_special_as_note(¤t_note, GRE_SPACE, SP_ZERO_WIDTH); + gregorio_add_space_as_note(¤t_note, SP_ZERO_WIDTH); } = { gregorio_change_shape(current_note, S_LINEA); } [a-mA-M]vv { - lex_add_note(0, S_BIVIRGA, _NO_SIGN, L_NO_LIQUESCENTIA,H_NO_EPISEMUS); + lex_add_note(0, S_BIVIRGA, _NO_SIGN, L_NO_LIQUESCENTIA, H_NO_EPISEMUS); } [a-mA-M]vvv { - lex_add_note(0, S_TRIVIRGA, _NO_SIGN, L_NO_LIQUESCENTIA,H_NO_EPISEMUS); + lex_add_note(0, S_TRIVIRGA, _NO_SIGN, L_NO_LIQUESCENTIA, H_NO_EPISEMUS); } [a-mA-M]VV { - lex_add_note(0, S_BIVIRGA, _NO_SIGN, L_NO_LIQUESCENTIA,H_NO_EPISEMUS); + lex_add_note(0, S_BIVIRGA, _NO_SIGN, L_NO_LIQUESCENTIA, H_NO_EPISEMUS); } [a-mA-M]VVV { - lex_add_note(0, S_TRIVIRGA, _NO_SIGN, L_NO_LIQUESCENTIA,H_NO_EPISEMUS); + lex_add_note(0, S_TRIVIRGA, _NO_SIGN, L_NO_LIQUESCENTIA, H_NO_EPISEMUS); } [a-mA-M]ss { - lex_add_note(0, S_DISTROPHA, _NO_SIGN, L_NO_LIQUESCENTIA,H_NO_EPISEMUS); + lex_add_note(0, S_DISTROPHA, _NO_SIGN, L_NO_LIQUESCENTIA, H_NO_EPISEMUS); } [a-mA-M]ss(\<|\>) { lex_add_note(0, S_DISTROPHA, _NO_SIGN, L_AUCTA,H_NO_EPISEMUS); } [a-mA-M]sss { - lex_add_note(0, S_TRISTROPHA, _NO_SIGN, L_NO_LIQUESCENTIA,H_NO_EPISEMUS); + lex_add_note(0, S_TRISTROPHA, _NO_SIGN, L_NO_LIQUESCENTIA, H_NO_EPISEMUS); } [a-mA-M]sss(\<|\>) { - lex_add_note(0, S_TRISTROPHA, _NO_SIGN, L_AUCTA,H_NO_EPISEMUS); + lex_add_note(0, S_TRISTROPHA, _NO_SIGN, L_AUCTA, H_NO_EPISEMUS); } [a-mA-M] { lex_add_note(0, gregorio_det_shape(gabc_notes_determination_text[0]), - _NO_SIGN, L_NO_LIQUESCENTIA,H_NO_EPISEMUS); + _NO_SIGN, L_NO_LIQUESCENTIA, H_NO_EPISEMUS); } -[a-mA-M] { lex_add_note(1, gregorio_det_shape(gabc_notes_determination_text[1]), - _NO_SIGN, L_INITIO_DEBILIS,H_NO_EPISEMUS); + _NO_SIGN, L_INITIO_DEBILIS, H_NO_EPISEMUS); } \' { gregorio_add_sign(current_note, _V_EPISEMUS); diff --git a/src/gabc/gabc-score-determination.y b/src/gabc/gabc-score-determination.y index b9ada9742..4c5c94919 100644 --- a/src/gabc/gabc-score-determination.y +++ b/src/gabc/gabc-score-determination.y @@ -172,10 +172,9 @@ void gabc_fix_custos(gregorio_score *score_to_check) NULL); newkey = gregorio_calculate_new_key(C_KEY, - current_element->element_type - - 48); + current_element->u.misc.pitched.pitch - '0'); pitch_difference = (char) newkey - (char) current_key; - custo_element->element_type = pitch - pitch_difference; + custo_element->u.misc.pitched.pitch = pitch - pitch_difference; current_key = newkey; break; case GRE_F_KEY_CHANGE: @@ -186,25 +185,21 @@ void gabc_fix_custos(gregorio_score *score_to_check) NULL); newkey = gregorio_calculate_new_key(F_KEY, - current_element->element_type - - 48); + current_element->u.misc.pitched.pitch - '0'); pitch_difference = (char) newkey - (char) current_key; - custo_element->element_type = pitch - pitch_difference; + custo_element->u.misc.pitched.pitch = pitch - pitch_difference; current_key = newkey; break; default: break; } - /* - * in ASCII, 97 is a and 109 is m - */ - if (custo_element->element_type < 97 - || custo_element->element_type > 109) { + if (custo_element->u.misc.pitched.pitch < 'a' + || custo_element->u.misc.pitched.pitch > 'm') { gregorio_message(_("pitch difference too high to set " "automatic custo (z0), please " "check your score"), "gabc_fix_custos", ERROR, 0); - custo_element->element_type = 'g'; + custo_element->u.misc.pitched.pitch = 'g'; } current_element = current_element->next; } @@ -214,15 +209,13 @@ void gabc_fix_custos(gregorio_score *score_to_check) || current_element->type == GRE_C_KEY_CHANGE_FLATED) { current_key = gregorio_calculate_new_key(C_KEY, - current_element->element_type - - 48); + current_element->u.misc.pitched.pitch - '0'); } if (current_element->type == GRE_F_KEY_CHANGE || current_element->type == GRE_F_KEY_CHANGE_FLATED) { current_key = gregorio_calculate_new_key(F_KEY, - current_element->element_type - - 48); + current_element->u.misc.pitched.pitch - '0'); } current_element = current_element->next; } diff --git a/src/gabc/gabc-write.c b/src/gabc/gabc-write.c index df7a31d8b..8c7f40801 100644 --- a/src/gabc/gabc-write.c +++ b/src/gabc/gabc-write.c @@ -115,7 +115,7 @@ void gabc_write_score(FILE *f, gregorio_score *score) // at present we only allow for one clef at the start of the gabc gregorio_det_step_and_line_from_key(score->first_voice_info->initial_key, &step, &line); - if (score->first_voice_info->flatted_key == FLAT_KEY) { + if (score->first_voice_info->flatted_key) { fprintf(f, "(%cb%d)", step, line); } else { fprintf(f, "(%c%d)", step, line); @@ -356,7 +356,7 @@ void gabc_write_gregorio_elements(FILE *f, gregorio_element *element) if (element->type != GRE_END_OF_LINE && (element->type != GRE_SPACE || (element->type == GRE_SPACE - && element->element_type == SP_NEUMATIC_CUT)) + && element->u.misc.unpitched.info.space == SP_NEUMATIC_CUT)) && element->next && element->next->type == GRE_ELEMENT) { fprintf(f, "/"); } @@ -381,7 +381,7 @@ void gabc_write_gregorio_element(FILE *f, gregorio_element *element) "gabc_write_gregorio_element", ERROR, 0); return; } - current_glyph = element->first_glyph; + current_glyph = element->u.glyphs.first_glyph; switch (element->type) { case GRE_ELEMENT: while (current_glyph) { @@ -400,21 +400,21 @@ void gabc_write_gregorio_element(FILE *f, gregorio_element *element) } break; case GRE_SPACE: - gabc_write_space(f, element->element_type); + gabc_write_space(f, element->u.misc.unpitched.info.space); break; case GRE_BAR: - gabc_write_bar(f, element->element_type); - gabc_write_bar_signs(f, element->additional_infos); + gabc_write_bar(f, element->u.misc.unpitched.info.bar); + gabc_write_bar_signs(f, element->u.misc.unpitched.special_sign); break; case GRE_C_KEY_CHANGE: gabc_write_key_change(f, C_KEY, - element->element_type - 48, - element->additional_infos); + element->u.misc.pitched.pitch - '0', + element->u.misc.pitched.flatted_key); break; case GRE_F_KEY_CHANGE: gabc_write_key_change(f, F_KEY, - element->element_type - 48, - element->additional_infos); + element->u.misc.pitched.pitch - '0', + element->u.misc.pitched.flatted_key); break; case GRE_END_OF_LINE: fprintf(f, "z"); @@ -447,7 +447,7 @@ void gabc_write_gregorio_glyph(FILE *f, gregorio_glyph *glyph) } switch (glyph->type) { case GRE_FLAT: - fprintf(f, "%cx", glyph->glyph_type); + fprintf(f, "%cx", glyph->u.misc.pitched.pitch); break; case GRE_TEXVERB_GLYPH: if (glyph->texverb) { @@ -455,13 +455,13 @@ void gabc_write_gregorio_glyph(FILE *f, gregorio_glyph *glyph) } break; case GRE_NATURAL: - fprintf(f, "%cy", glyph->glyph_type); + fprintf(f, "%cy", glyph->u.misc.pitched.pitch); break; case GRE_SHARP: - fprintf(f, "%c#", glyph->glyph_type); + fprintf(f, "%c#", glyph->u.misc.pitched.pitch); break; case GRE_SPACE: - if (glyph->glyph_type == SP_ZERO_WIDTH && glyph->next) { + if (glyph->u.misc.unpitched.info.space == SP_ZERO_WIDTH && glyph->next) { fprintf(f, "!"); } else { gregorio_message(_("bad space"), @@ -469,17 +469,17 @@ void gabc_write_gregorio_glyph(FILE *f, gregorio_glyph *glyph) } break; case GRE_GLYPH: - if (is_initio_debilis(glyph->liquescentia)) { + if (is_initio_debilis(glyph->u.notes.liquescentia)) { fprintf(f, "-"); } - current_note = glyph->first_note; + current_note = glyph->u.notes.first_note; while (current_note) { - gabc_write_gregorio_note(f, current_note, glyph->glyph_type); + gabc_write_gregorio_note(f, current_note, glyph->u.notes.glyph_type); // third argument necessary for the special shape pes quadratum current_note = current_note->next; } - gabc_write_end_liquescentia(f, glyph->liquescentia); + gabc_write_end_liquescentia(f, glyph->u.notes.liquescentia); break; default: @@ -525,9 +525,9 @@ void gabc_write_end_liquescentia(FILE *f, char liquescentia) * */ -void gabc_write_key_change(FILE *f, char step, int line, char has_flat) +void gabc_write_key_change(FILE *f, char step, int line, bool flatted_key) { - if (has_flat == FLAT_KEY) { + if (flatted_key) { fprintf(f, "%c%d", step, line); } else { fprintf(f, "%cb%d", step, line); @@ -685,98 +685,98 @@ void gabc_write_gregorio_note(FILE *f, gregorio_note *note, char glyph_type) if (glyph_type == G_PES_QUADRATUM) { shape = S_QUADRATUM; } else { - shape = note->shape; + shape = note->u.note.shape; } - note->pitch = tolower(note->pitch); + note->u.note.pitch = tolower(note->u.note.pitch); switch (shape) { // first we write the letters that determine the shapes case S_PUNCTUM: - fprintf(f, "%c", note->pitch); + fprintf(f, "%c", note->u.note.pitch); break; case S_PUNCTUM_INCLINATUM: - fprintf(f, "%c", toupper(note->pitch)); + fprintf(f, "%c", toupper(note->u.note.pitch)); break; case S_PUNCTUM_INCLINATUM_DEMINUTUS: if (note->next) { - fprintf(f, "%c~", toupper(note->pitch)); + fprintf(f, "%c~", toupper(note->u.note.pitch)); } else { - fprintf(f, "%c", toupper(note->pitch)); + fprintf(f, "%c", toupper(note->u.note.pitch)); } break; case S_PUNCTUM_INCLINATUM_AUCTUS: if (note->next) { - fprintf(f, "%c<", toupper(note->pitch)); + fprintf(f, "%c<", toupper(note->u.note.pitch)); } else { - fprintf(f, "%c", toupper(note->pitch)); + fprintf(f, "%c", toupper(note->u.note.pitch)); } break; case S_VIRGA: - fprintf(f, "%cv", note->pitch); + fprintf(f, "%cv", note->u.note.pitch); break; case S_VIRGA_REVERSA: - fprintf(f, "%cV", note->pitch); + fprintf(f, "%cV", note->u.note.pitch); break; case S_BIVIRGA: - fprintf(f, "%cvv", note->pitch); + fprintf(f, "%cvv", note->u.note.pitch); break; case S_TRIVIRGA: - fprintf(f, "%cvvv", note->pitch); + fprintf(f, "%cvvv", note->u.note.pitch); break; case S_ORISCUS: - fprintf(f, "%co", note->pitch); + fprintf(f, "%co", note->u.note.pitch); break; case S_ORISCUS_AUCTUS: - fprintf(f, "%co", note->pitch); // we consider that the AUCTUS is also + fprintf(f, "%co", note->u.note.pitch); // we consider that the AUCTUS is also // in the liquescentia break; case S_ORISCUS_DEMINUTUS: - fprintf(f, "%co", note->pitch); // we consider that the AUCTUS is also + fprintf(f, "%co", note->u.note.pitch); // we consider that the AUCTUS is also // in the liquescentia break; case S_QUILISMA: - fprintf(f, "%cw", note->pitch); + fprintf(f, "%cw", note->u.note.pitch); break; case S_LINEA: - fprintf(f, "%c=", note->pitch); + fprintf(f, "%c=", note->u.note.pitch); break; case S_PUNCTUM_CAVUM: - fprintf(f, "%cr", note->pitch); + fprintf(f, "%cr", note->u.note.pitch); break; case S_LINEA_PUNCTUM: - fprintf(f, "%cR", note->pitch); + fprintf(f, "%cR", note->u.note.pitch); break; case S_LINEA_PUNCTUM_CAVUM: - fprintf(f, "%cr0", note->pitch); + fprintf(f, "%cr0", note->u.note.pitch); break; case S_QUILISMA_QUADRATUM: - fprintf(f, "%cW", note->pitch); + fprintf(f, "%cW", note->u.note.pitch); break; case S_ORISCUS_QUADRATUM: - fprintf(f, "%cO", note->pitch); + fprintf(f, "%cO", note->u.note.pitch); break; case S_STROPHA: - fprintf(f, "%cs", note->pitch); + fprintf(f, "%cs", note->u.note.pitch); break; case S_STROPHA_AUCTA: - fprintf(f, "%cs", note->pitch); + fprintf(f, "%cs", note->u.note.pitch); break; case S_DISTROPHA: - fprintf(f, "%css", note->pitch); + fprintf(f, "%css", note->u.note.pitch); break; case S_DISTROPHA_AUCTA: - fprintf(f, "%css", note->pitch); + fprintf(f, "%css", note->u.note.pitch); break; case S_TRISTROPHA: - fprintf(f, "%csss", note->pitch); + fprintf(f, "%csss", note->u.note.pitch); break; case S_TRISTROPHA_AUCTA: - fprintf(f, "%csss", note->pitch); + fprintf(f, "%csss", note->u.note.pitch); break; case S_QUADRATUM: - fprintf(f, "%cq", note->pitch); + fprintf(f, "%cq", note->u.note.pitch); break; default: - fprintf(f, "%c", note->pitch); + fprintf(f, "%c", note->u.note.pitch); break; } switch (note->signs) { @@ -798,7 +798,7 @@ void gabc_write_gregorio_note(FILE *f, gregorio_note *note, char glyph_type) default: break; } - switch (note->rare_sign) { + switch (note->special_sign) { case _ACCENTUS: fprintf(f, "r1"); break; diff --git a/src/gabc/gabc.h b/src/gabc/gabc.h index 964f52780..8efe6b2f5 100644 --- a/src/gabc/gabc.h +++ b/src/gabc/gabc.h @@ -22,52 +22,54 @@ #define GABC_CURRENT_VERSION "0.9.3" // functions to read gabc -gregorio_score *read_score (FILE *f); +gregorio_score *read_score(FILE *f); -gregorio_note *gabc_det_notes_from_string (char *str, char *macros[10]); -gregorio_glyph *gabc_det_glyphs_from_string (char *str, int *current_key, - char *macros[10]); -gregorio_element *gabc_det_elements_from_string (char *str, int *current_key, - char *macros[10]); +gregorio_note *gabc_det_notes_from_string(char *str, char *macros[10]); +gregorio_glyph *gabc_det_glyphs_from_string(char *str, int *current_key, + char *macros[10]); +gregorio_element *gabc_det_elements_from_string(char *str, int *current_key, + char *macros[10]); -char gabc_determine_custo_pitch (gregorio_note *current_note, int current_key); +char gabc_determine_custo_pitch(gregorio_note *current_note, int current_key); -void close_element (gregorio_element **current_element, - gregorio_glyph *first_glyph); +void close_element(gregorio_element **current_element, + gregorio_glyph *first_glyph); -gregorio_element *gabc_det_elements_from_notes (gregorio_note *current_note, - int *current_key); -gregorio_element *gabc_det_elements_from_glyphs (gregorio_glyph *current_glyph); -gregorio_glyph *gabc_det_glyphs_from_notes (gregorio_note *current_note, - int *current_key); +gregorio_element *gabc_det_elements_from_notes(gregorio_note *current_note, + int *current_key); +gregorio_element *gabc_det_elements_from_glyphs(gregorio_glyph *current_glyph); +gregorio_glyph *gabc_det_glyphs_from_notes(gregorio_note *current_note, + int *current_key); // see comments on gregorio_add_note_to_a_glyph for meaning of these variables -#define DET_NO_END 'A' -#define DET_END_OF_CURRENT 'B' -#define DET_END_OF_PREVIOUS 'C' -#define DET_END_OF_BOTH 'D' +typedef enum gabc_determination { + DET_NO_END, + DET_END_OF_CURRENT, + DET_END_OF_PREVIOUS, + DET_END_OF_BOTH, +} gabc_determination; // defines the maximal interval between two notes of the same glyph #define MAX_INTERVAL 5 // functions to write gabc -void write_score (FILE *f, gregorio_score *score); -void gabc_write_voice_info (FILE *f, gregorio_voice_info *voice_info); -void gabc_write_gregorio_syllable (FILE *f, gregorio_syllable *syllable, - int number_of_voices); -void gabc_write_gregorio_elements (FILE *f, gregorio_element *element); -void gabc_write_gregorio_element (FILE *f, gregorio_element *element); -void gabc_write_gregorio_glyph (FILE *f, gregorio_glyph *glyph); -void gabc_write_end_liquescentia (FILE *f, char liquescentia); -void gabc_write_key_change (FILE *f, char step, int line, char has_flat); -void gabc_write_space (FILE *f, char type); -void gabc_write_bar (FILE *f, char type); -void gabc_write_bar_signs (FILE *f, char type); -void gabc_write_gregorio_note (FILE *f, gregorio_note *note, char glyph_type); -void gabc_write_begin (FILE *f, unsigned char style); -void gabc_write_end (FILE *f, unsigned char style); -void gabc_write_special_char (FILE *f, grewchar *special_char); -void gabc_write_verb (FILE *f, grewchar *verb_str); -void gabc_print_char (FILE *f, grewchar to_print); +void write_score(FILE *f, gregorio_score *score); +void gabc_write_voice_info(FILE *f, gregorio_voice_info *voice_info); +void gabc_write_gregorio_syllable(FILE *f, gregorio_syllable *syllable, + int number_of_voices); +void gabc_write_gregorio_elements(FILE *f, gregorio_element *element); +void gabc_write_gregorio_element(FILE *f, gregorio_element *element); +void gabc_write_gregorio_glyph(FILE *f, gregorio_glyph *glyph); +void gabc_write_end_liquescentia(FILE *f, char liquescentia); +void gabc_write_key_change(FILE *f, char step, int line, bool flatted_key); +void gabc_write_space(FILE *f, char type); +void gabc_write_bar(FILE *f, char type); +void gabc_write_bar_signs(FILE *f, char type); +void gabc_write_gregorio_note(FILE *f, gregorio_note *note, char glyph_type); +void gabc_write_begin(FILE *f, unsigned char style); +void gabc_write_end(FILE *f, unsigned char style); +void gabc_write_special_char(FILE *f, grewchar *special_char); +void gabc_write_verb(FILE *f, grewchar *verb_str); +void gabc_print_char(FILE *f, grewchar to_print); #endif diff --git a/src/gregoriotex/gregoriotex-write.c b/src/gregoriotex/gregoriotex-write.c index 630a9daa1..cbcdbd154 100644 --- a/src/gregoriotex/gregoriotex-write.c +++ b/src/gregoriotex/gregoriotex-write.c @@ -173,10 +173,10 @@ void gregoriotex_write_score(FILE *f, gregorio_score *score) } fprintf(f, "\\grebeginnotes %%\n"); if (score->first_voice_info) { - gregorio_det_step_and_line_from_key(score-> - first_voice_info->initial_key, - &clef_letter, &clef_line); - if (score->first_voice_info->flatted_key == FLAT_KEY) { + gregorio_det_step_and_line_from_key(score->first_voice_info-> + initial_key, &clef_letter, + &clef_line); + if (score->first_voice_info->flatted_key) { clef_flat = gregoriotex_clef_flat_height(clef_letter, clef_line); } else { clef_flat = NO_KEY_FLAT; @@ -292,29 +292,29 @@ void gregoriotex_print_change_line_clef(FILE *f, gregorio_element *current_element) { if (current_element->type == GRE_C_KEY_CHANGE) { - if (current_element->additional_infos == FLAT_KEY) { + if (current_element->u.misc.pitched.flatted_key) { fprintf(f, "\\gresetlinesclef{c}{%d}{1}{%c}%%\n", - current_element->element_type - 48, + current_element->u.misc.pitched.pitch - '0', gregoriotex_clef_flat_height('c', - current_element->element_type - - 48)); + current_element->u.misc. + pitched.pitch - '0')); } else { fprintf(f, "\\gresetlinesclef{c}{%d}{1}{%c}%%\n", - current_element->element_type - 48, NO_KEY_FLAT); + current_element->u.misc.pitched.pitch - 48, NO_KEY_FLAT); } } if (current_element->type == GRE_F_KEY_CHANGE) { - if (current_element->additional_infos == FLAT_KEY) { + if (current_element->u.misc.pitched.flatted_key) { // the third argument is 0 or 1 according to the need for a // space before the clef fprintf(f, "\\gresetlinesclef{f}{%d}{1}{%c}%%\n", - current_element->element_type - 48, + current_element->u.misc.pitched.pitch - '0', gregoriotex_clef_flat_height('f', - current_element->element_type - - 48)); + current_element->u.misc. + pitched.pitch - '0')); } else { fprintf(f, "\\gresetlinesclef{f}{%d}{1}{%c}%%\n", - current_element->element_type - 48, NO_KEY_FLAT); + current_element->u.misc.pitched.pitch - '0', NO_KEY_FLAT); } } } @@ -363,13 +363,15 @@ gregoriotex_write_syllable(FILE *f, if (line->additional_bottom_space == 0 && line->additional_top_space == 0 && line->translation == 0 && line->abovelinestext == 0) { - if ((syllable->elements)[0]->element_type != GRE_END_OF_PAR) { + if ((syllable->elements)[0]->u.misc.unpitched.info.sub_type != + GRE_END_OF_PAR) { fprintf(f, "%%\n%%\n\\grenewline %%\n%%\n%%\n"); } else { fprintf(f, "%%\n%%\n\\grenewparline %%\n%%\n%%\n"); } } else { - if ((syllable->elements)[0]->element_type != GRE_END_OF_PAR) { + if ((syllable->elements)[0]->u.misc.unpitched.info.sub_type != + GRE_END_OF_PAR) { fprintf(f, "%%\n%%\n\\grenewlinewithspace{%u}{%u}{%u}{%u}%%\n%%\n%%\n", line->additional_top_space, @@ -419,7 +421,8 @@ gregoriotex_write_syllable(FILE *f, } if ((syllable->elements)[0]->type == GRE_BAR) { if (!syllable->next_syllable && !syllable->text - && (syllable->elements)[0]->element_type == B_DIVISIO_FINALIS) { + && (syllable->elements)[0]->u.misc.unpitched.info.bar == + B_DIVISIO_FINALIS) { fprintf(f, "\\grefinaldivisiofinalis{0}%%\n"); if ((syllable->elements)[0]->next && (syllable->elements)[0]->next->type == @@ -432,7 +435,8 @@ gregoriotex_write_syllable(FILE *f, return; } if (!syllable->next_syllable && !syllable->text - && (syllable->elements)[0]->element_type == B_DIVISIO_MAIOR) { + && (syllable->elements)[0]->u.misc.unpitched.info.bar == + B_DIVISIO_MAIOR) { fprintf(f, "\\grefinaldivisiomaior{0}%%\n"); if ((syllable->elements)[0]->next && (syllable->elements)[0]->next->type == @@ -499,7 +503,7 @@ gregoriotex_write_syllable(FILE *f, current_element = (syllable->elements)[0]; while (current_element) { if (current_element->type == GRE_SPACE) { - switch (current_element->element_type) { + switch (current_element->u.misc.unpitched.info.space) { case SP_ZERO_WIDTH: fprintf(f, "\\greendofelement{3}{1}%%\n"); break; @@ -533,7 +537,7 @@ gregoriotex_write_syllable(FILE *f, continue; } if (current_element->type == GRE_NLBA) { - if (current_element->element_type == NLBA_BEGINNING) { + if (current_element->u.misc.unpitched.info.nlba == NLBA_BEGINNING) { fprintf(f, "\\grebeginnlbarea{0}{0}%%\n"); } else { fprintf(f, "\\greendnlbarea{0}{0}%%\n"); @@ -553,30 +557,34 @@ gregoriotex_write_syllable(FILE *f, if (current_element->type == GRE_C_KEY_CHANGE && first_of_disc != 1) { if (current_element->previous && current_element->previous->type == GRE_BAR) { - if (current_element->additional_infos == FLAT_KEY) { + if (current_element->u.misc.pitched.flatted_key) { // the third argument is 0 or 1 according to the need for a // space before the clef fprintf(f, "\\grechangeclef{c}{%d}{0}{%c}%%\n", - current_element->element_type - 48, + current_element->u.misc.pitched.pitch - '0', gregoriotex_clef_flat_height('c', - current_element-> - element_type - 48)); + current_element->u. + misc.pitched.pitch - + '0')); } else { fprintf(f, "\\grechangeclef{c}{%d}{0}{%c}%%\n", - current_element->element_type - 48, NO_KEY_FLAT); + current_element->u.misc.pitched.pitch - '0', + NO_KEY_FLAT); } } else { - if (current_element->additional_infos == FLAT_KEY) { + if (current_element->u.misc.pitched.flatted_key) { // the third argument is 0 or 1 according to the need for a // space before the clef fprintf(f, "\\grechangeclef{c}{%d}{1}{%c}%%\n", - current_element->element_type - 48, + current_element->u.misc.pitched.pitch - '0', gregoriotex_clef_flat_height('c', - current_element-> - element_type - 48)); + current_element->u. + misc.pitched.pitch - + 48)); } else { fprintf(f, "\\grechangeclef{c}{%d}{1}{%c}%%\n", - current_element->element_type - 48, NO_KEY_FLAT); + current_element->u.misc.pitched.pitch - '0', + NO_KEY_FLAT); } } current_element = current_element->next; @@ -588,30 +596,34 @@ gregoriotex_write_syllable(FILE *f, if (current_element->type == GRE_F_KEY_CHANGE && first_of_disc != 1) { if (current_element->previous && current_element->previous->type == GRE_BAR) { - if (current_element->additional_infos == FLAT_KEY) { + if (current_element->u.misc.pitched.flatted_key) { // the third argument is 0 or 1 according to the need for a // space before the clef fprintf(f, "\\grechangeclef{f}{%d}{0}{%c}%%\n", - current_element->element_type - 48, + current_element->u.misc.pitched.pitch - '0', gregoriotex_clef_flat_height('f', - current_element-> - element_type - 48)); + current_element->u. + misc.pitched.pitch - + '0')); } else { fprintf(f, "\\grechangeclef{f}{%d}{0}{%c}%%\n", - current_element->element_type - 48, NO_KEY_FLAT); + current_element->u.misc.pitched.pitch - '0', + NO_KEY_FLAT); } } else { - if (current_element->additional_infos == FLAT_KEY) { + if (current_element->u.misc.pitched.flatted_key) { // the third argument is 0 or 1 according to the need for a // space before the clef fprintf(f, "\\grechangeclef{f}{%d}{1}{%c}%%\n", - current_element->element_type - 48, + current_element->u.misc.pitched.pitch - '0', gregoriotex_clef_flat_height('f', - current_element-> - element_type - 48)); + current_element->u. + misc.pitched.pitch - + '0')); } else { fprintf(f, "\\grechangeclef{f}{%d}{1}{%c}%%\n", - current_element->element_type - 48, NO_KEY_FLAT); + current_element->u.misc.pitched.pitch - '0', + NO_KEY_FLAT); } } current_element = current_element->next; @@ -623,19 +635,23 @@ gregoriotex_write_syllable(FILE *f, if (current_element->type == GRE_CUSTO && first_of_disc != 1) { // we also print an unbreakable larger space before the custo fprintf(f, "\\greendofelement{1}{1}%%\n\\grecusto{%c}%%\n", - current_element->element_type); + current_element->u.misc.pitched.pitch); current_element = current_element->next; continue; } if (current_element->type == GRE_BAR) { if (current_element->next) { - gregoriotex_write_bar(f, current_element->element_type, - current_element->additional_infos, - INSIDE_BAR); + gregoriotex_write_bar(f, + current_element->u.misc.unpitched.info. + bar, + current_element->u.misc.unpitched. + special_sign, INSIDE_BAR); } else { - gregoriotex_write_bar(f, current_element->element_type, - current_element->additional_infos, - SYLLABLE_BAR); + gregoriotex_write_bar(f, + current_element->u.misc.unpitched.info. + bar, + current_element->u.misc.unpitched. + special_sign, SYLLABLE_BAR); } current_element = current_element->next; continue; @@ -648,13 +664,15 @@ gregoriotex_write_syllable(FILE *f, if (line->additional_bottom_space == 0 && line->additional_top_space == 0 && line->translation == 0 && line->abovelinestext == 0) { - if (current_element->element_type != GRE_END_OF_PAR) { + if (current_element->u.misc.unpitched.info.sub_type != + GRE_END_OF_PAR) { fprintf(f, "%%\n%%\n\\grenewline %%\n%%\n%%\n"); } else { fprintf(f, "%%\n%%\n\\grenewparline %%\n%%\n%%\n"); } } else { - if (current_element->element_type != GRE_END_OF_PAR) { + if (current_element->u.misc.unpitched.info.sub_type != + GRE_END_OF_PAR) { fprintf(f, "%%\n%%\n\\grenewlinewithspace{%u}{%u}{%u}{%u}%%\n%%\n%%\n", line->additional_top_space, @@ -761,7 +779,7 @@ void gregoriotex_getlineinfos(gregorio_syllable *syllable, gregorio_line *line) line->abovelinestext = 1; } if (element->type == GRE_BAR) { - switch (element->additional_infos) { + switch (element->u.misc.unpitched.special_sign) { case _ICTUS_A: case _ICTUS_T: case _V_EPISEMUS_ICTUS_A: @@ -778,20 +796,20 @@ void gregoriotex_getlineinfos(gregorio_syllable *syllable, gregorio_line *line) element = element->next; continue; } - glyph = element->first_glyph; + glyph = element->u.glyphs.first_glyph; while (glyph) { if (glyph->type != GRE_GLYPH) { glyph = glyph->next; continue; } - note = glyph->first_note; + note = glyph->u.notes.first_note; while (note) { i = i + 1; - if (note->rare_sign == _ICTUS_A - || note->rare_sign == _ICTUS_T) { + if (note->special_sign == _ICTUS_A + || note->special_sign == _ICTUS_T) { line->ictus = 1; } - switch (note->pitch) { + switch (note->u.note.pitch) { case 'a': if (line->additional_bottom_space < 3 && i < NUMBER_OF_NOTES) { @@ -1206,59 +1224,69 @@ gregoriotex_write_element(FILE *f, gregorio_syllable *syllable, gregorio_element *element) { - gregorio_glyph *current_glyph = element->first_glyph; - while (current_glyph) { - if (current_glyph->type == GRE_SPACE) { - // we assume here that it is a SP_ZERO_WIDTH, the only one a glyph - // can be - fprintf(f, "\\greendofglyph{1}%%\n"); - current_glyph = current_glyph->next; - continue; - } - if (current_glyph->type == GRE_TEXVERB_GLYPH && current_glyph->texverb) { - fprintf(f, - "%% verbatim text at glyph level:\n%s%%\n%% end of verbatim text\n", - current_glyph->texverb); - current_glyph = current_glyph->next; - continue; - } - if (current_glyph->type == GRE_FLAT) { - fprintf(f, "\\greflat{%c}{0}%%\n", current_glyph->glyph_type); - current_glyph = current_glyph->next; - continue; - } - if (current_glyph->type == GRE_NATURAL) { - fprintf(f, "\\grenatural{%c}{0}%%\n", current_glyph->glyph_type); - current_glyph = current_glyph->next; - continue; - } - if (current_glyph->type == GRE_SHARP) { - fprintf(f, "\\gresharp{%c}{0}%%\n", current_glyph->glyph_type); - current_glyph = current_glyph->next; - continue; - } - if (current_glyph->type == GRE_BAR) { - gregoriotex_write_bar(f, current_glyph->glyph_type, - current_glyph->liquescentia, INSIDE_BAR); - current_glyph = current_glyph->next; - continue; - } - if (current_glyph->type == GRE_TEXVERB_GLYPH && current_glyph->texverb) { - fprintf(f, "%s", current_glyph->texverb); - current_glyph = current_glyph->next; - continue; - } - // at this point glyph->type is GRE_GLYPH - gregoriotex_write_glyph(f, syllable, element, current_glyph); - if (current_glyph->next && current_glyph->next->type == GRE_GLYPH) { - if (is_puncta_inclinata(current_glyph->next->glyph_type) - || current_glyph->next->glyph_type == G_PUNCTA_INCLINATA) { - fprintf(f, "\\greendofglyph{9}%%\n"); - } else { - fprintf(f, "\\greendofglyph{0}%%\n"); + if (element->type == GRE_ELEMENT) { + gregorio_glyph *current_glyph = element->u.glyphs.first_glyph; + while (current_glyph) { + if (current_glyph->type == GRE_SPACE) { + // we assume here that it is a SP_ZERO_WIDTH, the only one a + // glyph can be + fprintf(f, "\\greendofglyph{1}%%\n"); + current_glyph = current_glyph->next; + continue; } + if (current_glyph->type == GRE_TEXVERB_GLYPH + && current_glyph->texverb) { + fprintf(f, + "%% verbatim text at glyph level:\n%s%%\n%% end of verbatim text\n", + current_glyph->texverb); + current_glyph = current_glyph->next; + continue; + } + if (current_glyph->type == GRE_FLAT) { + fprintf(f, "\\greflat{%c}{0}%%\n", + current_glyph->u.misc.pitched.pitch); + current_glyph = current_glyph->next; + continue; + } + if (current_glyph->type == GRE_NATURAL) { + fprintf(f, "\\grenatural{%c}{0}%%\n", + current_glyph->u.misc.pitched.pitch); + current_glyph = current_glyph->next; + continue; + } + if (current_glyph->type == GRE_SHARP) { + fprintf(f, "\\gresharp{%c}{0}%%\n", + current_glyph->u.misc.pitched.pitch); + current_glyph = current_glyph->next; + continue; + } + if (current_glyph->type == GRE_BAR) { + gregoriotex_write_bar(f, + current_glyph->u.misc.unpitched.info.bar, + current_glyph->u.misc.unpitched. + special_sign, INSIDE_BAR); + current_glyph = current_glyph->next; + continue; + } + if (current_glyph->type == GRE_TEXVERB_GLYPH + && current_glyph->texverb) { + fprintf(f, "%s", current_glyph->texverb); + current_glyph = current_glyph->next; + continue; + } + // at this point glyph->type is GRE_GLYPH + gregoriotex_write_glyph(f, syllable, element, current_glyph); + if (current_glyph->next && current_glyph->next->type == GRE_GLYPH) { + if (is_puncta_inclinata(current_glyph->next->u.notes.glyph_type) + || current_glyph->next->u.notes.glyph_type == + G_PUNCTA_INCLINATA) { + fprintf(f, "\\greendofglyph{9}%%\n"); + } else { + fprintf(f, "\\greendofglyph{0}%%\n"); + } + } + current_glyph = current_glyph->next; } - current_glyph = current_glyph->next; } } @@ -1450,19 +1478,19 @@ gregoriotex_write_glyph(FILE *f, "gregoriotex_write_glyph", ERROR, 0); return; } - if (!glyph->first_note) { + if (glyph->type != GRE_GLYPH || !glyph->u.notes.first_note) { gregorio_message(_ ("called with glyph without note"), "gregoriotex_write_glyph", ERROR, 0); return; } next_note_pitch = gregorio_determine_next_pitch(syllable, element, glyph); - current_note = glyph->first_note; + current_note = glyph->u.notes.first_note; // first we check if it is really a unique glyph in gregoriotex... the // glyphs that are not a unique glyph are : trigonus and pucta inclinata // in general, and torculus resupinus and torculus resupinus flexus, so // we first divide the glyph into real gregoriotex glyphs - switch (glyph->glyph_type) { + switch (glyph->u.notes.glyph_type) { case G_TRIGONUS: case G_PUNCTA_INCLINATA: case G_2_PUNCTA_INCLINATA_DESCENDENS: @@ -1482,15 +1510,16 @@ gregoriotex_write_glyph(FILE *f, } break; case G_SCANDICUS: - if (glyph->liquescentia == L_DEMINUTUS - || glyph->liquescentia == L_DEMINUTUS_INITIO_DEBILIS - || glyph->liquescentia == L_NO_LIQUESCENTIA) { + if (glyph->u.notes.liquescentia == L_DEMINUTUS + || glyph->u.notes.liquescentia == L_DEMINUTUS_INITIO_DEBILIS + || glyph->u.notes.liquescentia == L_NO_LIQUESCENTIA) { gregoriotex_determine_number_and_type(glyph, element, &type, >ype, &glyph_number); fprintf(f, "\\greglyph{\\char %d}{%c}{%c}{%d}", glyph_number, - glyph->first_note->pitch, next_note_pitch, type); + glyph->u.notes.first_note->u.note.pitch, next_note_pitch, + type); gregoriotex_write_signs(f, gtype, glyph, element, - glyph->first_note); + glyph->u.notes.first_note); } else { while (current_note) { gregoriotex_write_note(f, current_note, glyph, element, @@ -1502,14 +1531,15 @@ gregoriotex_write_glyph(FILE *f, } break; case G_ANCUS: - if (glyph->liquescentia == L_DEMINUTUS - || glyph->liquescentia == L_DEMINUTUS_INITIO_DEBILIS) { + if (glyph->u.notes.liquescentia == L_DEMINUTUS + || glyph->u.notes.liquescentia == L_DEMINUTUS_INITIO_DEBILIS) { gregoriotex_determine_number_and_type(glyph, element, &type, >ype, &glyph_number); fprintf(f, "\\greglyph{\\char %d}{%c}{%c}{%d}", glyph_number, - glyph->first_note->pitch, next_note_pitch, type); + glyph->u.notes.first_note->u.note.pitch, next_note_pitch, + type); gregoriotex_write_signs(f, gtype, glyph, element, - glyph->first_note); + glyph->u.notes.first_note); } else { while (current_note) { gregoriotex_write_note(f, current_note, glyph, element, @@ -1524,18 +1554,19 @@ gregoriotex_write_glyph(FILE *f, gregoriotex_write_note(f, current_note, glyph, element, next_note_pitch); gregoriotex_write_signs(f, T_ONE_NOTE_TRF, glyph, element, - glyph->first_note); - glyph->glyph_type = G_PORRECTUS_FLEXUS_NO_BAR; + glyph->u.notes.first_note); + glyph->u.notes.glyph_type = G_PORRECTUS_FLEXUS_NO_BAR; // tricky to have the good position for these glyphs - glyph->first_note = current_note->next; + glyph->u.notes.first_note = current_note->next; gregoriotex_determine_number_and_type(glyph, element, &type, >ype, &glyph_number); // TODO : fusion functions fprintf(f, "\\greglyph{\\char %d}{%c}{%c}{%d}", glyph_number, - glyph->first_note->pitch, next_note_pitch, type); - gregoriotex_write_signs(f, gtype, glyph, element, glyph->first_note); - glyph->first_note = current_note; - glyph->glyph_type = G_TORCULUS_RESUPINUS_FLEXUS; + glyph->u.notes.first_note->u.note.pitch, next_note_pitch, type); + gregoriotex_write_signs(f, gtype, glyph, element, + glyph->u.notes.first_note); + glyph->u.notes.first_note = current_note; + glyph->u.notes.glyph_type = G_TORCULUS_RESUPINUS_FLEXUS; break; case G_BIVIRGA: case G_TRIVIRGA: @@ -1566,20 +1597,22 @@ gregoriotex_write_glyph(FILE *f, } break; case G_PUNCTUM: - if (glyph->first_note->shape != S_ORISCUS - && glyph->first_note->shape != S_ORISCUS_AUCTUS - && glyph->first_note->shape != S_ORISCUS_DEMINUTUS) { - switch (glyph->liquescentia) { + if (glyph->u.notes.first_note->u.note.shape != S_ORISCUS + && glyph->u.notes.first_note->u.note.shape != S_ORISCUS_AUCTUS + && glyph->u.notes.first_note->u.note.shape != S_ORISCUS_DEMINUTUS) { + switch (glyph->u.notes.liquescentia) { case L_AUCTUS_ASCENDENS: - glyph->first_note->shape = S_PUNCTUM_AUCTUS_ASCENDENS; + glyph->u.notes.first_note->u.note.shape = + S_PUNCTUM_AUCTUS_ASCENDENS; break; case L_AUCTUS_DESCENDENS: case L_AUCTA: - glyph->first_note->shape = S_PUNCTUM_AUCTUS_DESCENDENS; + glyph->u.notes.first_note->u.note.shape = + S_PUNCTUM_AUCTUS_DESCENDENS; break; case L_DEMINUTUS: case L_INITIO_DEBILIS: - glyph->first_note->shape = S_PUNCTUM_DEMINUTUS; + glyph->u.notes.first_note->u.note.shape = S_PUNCTUM_DEMINUTUS; default: break; } @@ -1589,38 +1622,40 @@ gregoriotex_write_glyph(FILE *f, case G_VIRGA_REVERSA: case G_STROPHA: case G_STROPHA_AUCTA: - gregoriotex_write_note(f, glyph->first_note, glyph, element, + gregoriotex_write_note(f, glyph->u.notes.first_note, glyph, element, next_note_pitch); gregoriotex_write_signs(f, T_ONE_NOTE, glyph, element, current_note); break; default: // special case of the torculus resupinus which first note is not a // punctum - if (glyph->glyph_type == G_TORCULUS_RESUPINUS - && current_note->shape != S_PUNCTUM) { + if (glyph->u.notes.glyph_type == G_TORCULUS_RESUPINUS + && current_note->u.note.shape != S_PUNCTUM) { gregoriotex_write_note(f, current_note, glyph, element, next_note_pitch); gregoriotex_write_signs(f, T_ONE_NOTE, glyph, element, - glyph->first_note); + glyph->u.notes.first_note); // tricky to have the good position for these glyphs - glyph->first_note = current_note->next; - glyph->glyph_type = G_PORRECTUS_NO_BAR; + glyph->u.notes.first_note = current_note->next; + glyph->u.notes.glyph_type = G_PORRECTUS_NO_BAR; gregoriotex_determine_number_and_type(glyph, element, &type, >ype, &glyph_number); // TODO : fusion functions fprintf(f, "\\greglyph{\\char %d}{%c}{%c}{%d}", glyph_number, - glyph->first_note->pitch, next_note_pitch, type); + glyph->u.notes.first_note->u.note.pitch, next_note_pitch, + type); gregoriotex_write_signs(f, gtype, glyph, element, - glyph->first_note); - glyph->glyph_type = G_TORCULUS_RESUPINUS; - glyph->first_note = current_note; + glyph->u.notes.first_note); + glyph->u.notes.glyph_type = G_TORCULUS_RESUPINUS; + glyph->u.notes.first_note = current_note; } else { gregoriotex_determine_number_and_type(glyph, element, &type, >ype, &glyph_number); fprintf(f, "\\greglyph{\\char %d}{%c}{%c}{%d}", glyph_number, - glyph->first_note->pitch, next_note_pitch, type); + glyph->u.notes.first_note->u.note.pitch, next_note_pitch, + type); gregoriotex_write_signs(f, gtype, glyph, element, - glyph->first_note); + glyph->u.notes.first_note); break; } } @@ -1669,7 +1704,7 @@ gregoriotex_write_signs(FILE *f, char type, gregorio_note *current_note = note; while (current_note) { // we start by the additional lines - if (current_note->pitch < 'c') { + if (current_note->u.note.pitch < 'c') { if (found == 0) { found = 1; fprintf(f, "%%\n{%%\n"); @@ -1678,7 +1713,7 @@ gregoriotex_write_signs(FILE *f, char type, TT_BOTTOM, current_note); status->bottom_line = 1; } - if (current_note->pitch > 'k') { + if (current_note->u.note.pitch > 'k') { if (found == 0) { found = 1; fprintf(f, "%%\n{%%\n"); @@ -1748,10 +1783,10 @@ gregoriotex_write_signs(FILE *f, char type, } } // write_rare also writes the vepisemus - if (current_note->rare_sign) { + if (current_note->special_sign) { _found(); gregoriotex_write_rare(f, glyph, i, type, - current_note, current_note->rare_sign); + current_note, current_note->special_sign); } if (current_note->signs != _NO_SIGN) { _found(); @@ -1760,8 +1795,8 @@ gregoriotex_write_signs(FILE *f, char type, case _V_EPISEMUS: case _V_EPISEMUS_PUNCTUM_MORA: case _V_EPISEMUS_AUCTUM_DUPLEX: - if (current_note->rare_sign != _ICTUS_A - && current_note->rare_sign != _ICTUS_T) { + if (current_note->special_sign != _ICTUS_A + && current_note->special_sign != _ICTUS_T) { gregoriotex_write_vepisemus(f, glyph, i, type, current_note); } break; @@ -1769,7 +1804,7 @@ gregoriotex_write_signs(FILE *f, char type, break; } // why is this if there?... - if (!current_note->rare_sign) { + if (!current_note->special_sign) { if (block_hepisemus == 2) { block_hepisemus = 0; } @@ -1819,8 +1854,7 @@ gregoriotex_write_choral_sign(FILE *f, // a temp value char kind_of_pes = 0; gregorio_note *tmpnote = NULL; - - switch (glyph->glyph_type) { + switch (glyph->u.notes.glyph_type) { case G_FLEXUS: case G_TORCULUS: case G_TORCULUS_LIQUESCENS: @@ -1837,7 +1871,7 @@ gregoriotex_write_choral_sign(FILE *f, break; } kind_of_pes = 1; - if (current_note->shape != S_QUILISMA) { + if (current_note->u.note.shape != S_QUILISMA) { low_sign = 1; } break; @@ -1853,16 +1887,18 @@ gregoriotex_write_choral_sign(FILE *f, if (low_sign == 0) { // let's cheat a little - current_note->h_episemus_top_note = current_note->pitch; + current_note->h_episemus_top_note = current_note->u.note.pitch; gregoriotex_find_sign_number(glyph, i, type, TT_H_EPISEMUS, current_note, &number, &height, &bottom); - if (is_on_a_line(current_note->pitch)) { + if (is_on_a_line(current_note->u.note.pitch)) { fprintf(f, "\\grehighchoralsign{%c}{%s}{%d}%%\n", - current_note->pitch, current_note->choral_sign, number); + current_note->u.note.pitch, current_note->choral_sign, + number); } else { fprintf(f, "\\grehighchoralsign{%c}{%s}{%d}%%\n", - current_note->pitch + 2, current_note->choral_sign, number); + current_note->u.note.pitch + 2, current_note->choral_sign, + number); } if (simple_htype(current_note->h_episemus_type) != H_NO_EPISEMUS) { tmpnote = current_note; @@ -1897,11 +1933,12 @@ gregoriotex_write_choral_sign(FILE *f, } else { // very approximative euristic, some things may have to be adapted // here... - if (is_on_a_line(current_note->pitch)) { + if (is_on_a_line(current_note->u.note.pitch)) { if (kind_of_pes == 1 - && current_note->pitch - current_note->next->pitch == -1) { + && current_note->u.note.pitch - + current_note->next->u.note.pitch == -1) { fprintf(f, "\\grelowchoralsign{%c}{%s}{1}%%\n", - current_note->pitch, current_note->choral_sign); + current_note->u.note.pitch, current_note->choral_sign); return; } if (current_note->previous @@ -1909,13 +1946,13 @@ gregoriotex_write_choral_sign(FILE *f, || current_note->previous->signs == _V_EPISEMUS_PUNCTUM_MORA)) { fprintf(f, "\\grelowchoralsign{%c}{%s}{1}%%\n", - current_note->pitch, current_note->choral_sign); + current_note->u.note.pitch, current_note->choral_sign); return; } } fprintf(f, "\\grelowchoralsign{%c}{%s}{0}%%\n", - current_note->pitch, current_note->choral_sign); + current_note->u.note.pitch, current_note->choral_sign); } } @@ -1929,7 +1966,7 @@ gregoriotex_write_choral_sign(FILE *f, */ void gregoriotex_write_auctum_duplex(FILE *f, gregorio_note *current_note) { - char pitch = current_note->pitch; + char pitch = current_note->u.note.pitch; char previous_pitch = 0; // second_pitch is the second argument of the \augmentumduplex macro, // that's @@ -1940,11 +1977,13 @@ void gregoriotex_write_auctum_duplex(FILE *f, gregorio_note *current_note) // of a podatus or a porrectus or a torculus resupinus unsigned char special_punctum = 0; if (current_note->previous) { - if (current_note->previous->pitch - current_note->pitch == -1 - || current_note->previous->pitch - current_note->pitch == 1) { + if (current_note->previous->u.note.pitch - current_note->u.note.pitch == + -1 + || current_note->previous->u.note.pitch - + current_note->u.note.pitch == 1) { special_punctum = 1; } - second_pitch = current_note->previous->pitch; + second_pitch = current_note->previous->u.note.pitch; previous_pitch = second_pitch; } @@ -1992,7 +2031,7 @@ gregoriotex_write_punctum_mora(FILE *f, // 0 if space is normal, 1 if there should be no space after a punctum unsigned char no_space = 0; // the pitch where to set the punctum - char pitch = current_note->pitch; + char pitch = current_note->u.note.pitch; // a variable to know if we are on a punctum inclinatum or not unsigned char punctum_inclinatum = 0; // a temp variable @@ -2001,58 +2040,66 @@ gregoriotex_write_punctum_mora(FILE *f, // is // at a strange place: if (type == T_ONE_NOTE_TRF) { - fprintf(f, "\\grepunctummora{%c}{1}{0}{0}%%\n", current_note->pitch); + fprintf(f, "\\grepunctummora{%c}{1}{0}{0}%%\n", + current_note->u.note.pitch); } // we go into this switch only if it is the note before the last note if (current_note->next) { - switch (glyph->glyph_type) { + switch (glyph->u.notes.glyph_type) { case G_FLEXUS: case G_TORCULUS: case G_TORCULUS_RESUPINUS_FLEXUS: case G_PORRECTUS_FLEXUS: - if (glyph->liquescentia != L_DEMINUTUS - && glyph->liquescentia != L_DEMINUTUS_INITIO_DEBILIS) { + if (glyph->u.notes.liquescentia != L_DEMINUTUS + && glyph->u.notes.liquescentia != L_DEMINUTUS_INITIO_DEBILIS) { shift_before = 1; } break; case G_PES: - if ((current_note->shape != S_PUNCTUM - && current_note->shape != S_QUILISMA) - || glyph->liquescentia == L_AUCTUS_DESCENDENS - || glyph->liquescentia == L_AUCTUS_ASCENDENS - || glyph->liquescentia == L_AUCTUS_ASCENDENS_INITIO_DEBILIS - || glyph->liquescentia == L_AUCTUS_DESCENDENS_INITIO_DEBILIS) { + if ((current_note->u.note.shape != S_PUNCTUM + && current_note->u.note.shape != S_QUILISMA) + || glyph->u.notes.liquescentia == L_AUCTUS_DESCENDENS + || glyph->u.notes.liquescentia == L_AUCTUS_ASCENDENS + || glyph->u.notes.liquescentia == + L_AUCTUS_ASCENDENS_INITIO_DEBILIS + || glyph->u.notes.liquescentia == + L_AUCTUS_DESCENDENS_INITIO_DEBILIS) { shift_before = 1; // fine tuning - if (current_note->next->pitch - current_note->pitch == 1) { - if (is_on_a_line(current_note->pitch)) { + if (current_note->next->u.note.pitch - + current_note->u.note.pitch == 1) { + if (is_on_a_line(current_note->u.note.pitch)) { special_punctum = 1; } else { - pitch = current_note->pitch - 1; + pitch = current_note->u.note.pitch - 1; } } } else { // case for f.g - if (current_note->next->pitch - current_note->pitch == 1) { + if (current_note->next->u.note.pitch - + current_note->u.note.pitch == 1) { special_punctum = 1; } } break; case G_PES_QUADRATUM: shift_before = 1; - if (current_note->next->pitch - current_note->pitch == 1) { - if (is_on_a_line(current_note->pitch)) { + if (current_note->next->u.note.pitch - current_note->u.note.pitch == + 1) { + if (is_on_a_line(current_note->u.note.pitch)) { special_punctum = 1; } else { - pitch = current_note->pitch - 1; + pitch = current_note->u.note.pitch - 1; } } break; case G_PORRECTUS: case G_TORCULUS_RESUPINUS: // this case is only for the note before the previous note - if ((current_note->next->pitch - current_note->pitch == -1 - || current_note->next->pitch - current_note->pitch == 1) + if ((current_note->next->u.note.pitch - + current_note->u.note.pitch == -1 + || current_note->next->u.note.pitch - + current_note->u.note.pitch == 1) && !(current_note->next->next)) special_punctum = 1; break; @@ -2061,7 +2108,7 @@ gregoriotex_write_punctum_mora(FILE *f, } } // we enter here in any case - switch (glyph->glyph_type) { + switch (glyph->u.notes.glyph_type) { case G_TRIGONUS: case G_PUNCTA_INCLINATA: case G_2_PUNCTA_INCLINATA_DESCENDENS: @@ -2075,18 +2122,19 @@ gregoriotex_write_punctum_mora(FILE *f, default: break; } - if (current_note->shape == S_PUNCTUM_INCLINATUM) { + if (current_note->u.note.shape == S_PUNCTUM_INCLINATUM) { punctum_inclinatum = 1; } - if (current_note->shape == S_PUNCTUM_INCLINATUM_DEMINUTUS) { + if (current_note->u.note.shape == S_PUNCTUM_INCLINATUM_DEMINUTUS) { punctum_inclinatum = 1; } // when the punctum mora is on a note on a line, and the prior note is on // the space immediately above, the dot is placed on the space below the // line instead if (current_note->previous - && (current_note->previous->pitch - current_note->pitch == 1) - && is_on_a_line(current_note->pitch) + && (current_note->previous->u.note.pitch - current_note->u.note.pitch == + 1) + && is_on_a_line(current_note->u.note.pitch) && (current_note->previous->signs == _PUNCTUM_MORA || current_note->previous->signs == _V_EPISEMUS_PUNCTUM_MORA || current_note->previous->choral_sign)) { @@ -2094,8 +2142,9 @@ gregoriotex_write_punctum_mora(FILE *f, } if (shift_before == 1) { - if (current_note->next->pitch - current_note->pitch == -1 - || current_note->next->pitch - current_note->pitch == 1) { + if (current_note->next->u.note.pitch - current_note->u.note.pitch == -1 + || current_note->next->u.note.pitch - current_note->u.note.pitch == + 1) { fprintf(f, "\\grepunctummora{%c}{3}{%d}{%d}%%\n", pitch, special_punctum, punctum_inclinatum); } else { @@ -2112,13 +2161,13 @@ gregoriotex_write_punctum_mora(FILE *f, // You'll all have understood, this case is quite rare... but when it // appears, we pass 1 as a second argument of \punctummora so that it // removes the space introduced by the punctummora. - if (glyph->glyph_type == G_PODATUS && glyph->next + if (glyph->u.notes.glyph_type == G_PODATUS && glyph->next && glyph->next->type == GRE_SPACE - && glyph->next->glyph_type == SP_ZERO_WIDTH && current_note->next && glyph->next->next && glyph->next->next->type == GRE_GLYPH - && glyph->next->next->first_note - && (glyph->next->next->first_note->pitch - current_note->pitch > 1)) { + && glyph->next->next->u.notes.first_note + && (glyph->next->next->u.notes.first_note->u.note.pitch - + current_note->u.note.pitch > 1)) { fprintf(f, "\\grepunctummora{%c}{1}{%d}{%d}%%\n", pitch, special_punctum, punctum_inclinatum); return; @@ -2194,9 +2243,10 @@ gregoriotex_write_hepisemus(FILE *f, if (simple_htype(current_note->h_episemus_type) != H_NO_EPISEMUS && (!current_note->next - || current_note->next->shape == S_PUNCTUM_INCLINATUM - || current_note->next->shape == S_PUNCTUM_INCLINATUM_DEMINUTUS - || current_note->next->shape == S_PUNCTUM_INCLINATUM_AUCTUS) + || current_note->next->u.note.shape == S_PUNCTUM_INCLINATUM + || current_note->next->u.note.shape == + S_PUNCTUM_INCLINATUM_DEMINUTUS + || current_note->next->u.note.shape == S_PUNCTUM_INCLINATUM_AUCTUS) && (!current_note->previous || simple_htype(current_note->previous->h_episemus_type) == H_NO_EPISEMUS) && bottom == 0 && next_height != -1) { @@ -2219,7 +2269,7 @@ gregoriotex_write_hepisemus(FILE *f, } if (current_note->next) { - ambitus = current_note->pitch - current_note->next->pitch; + ambitus = current_note->u.note.pitch - current_note->next->u.note.pitch; } if (has_bottom(current_note->h_episemus_type)) { fprintf(f, "\\grehepisemusbottom{%c}{%d}{%d}%%\n", @@ -2256,11 +2306,10 @@ gregoriotex_find_next_hepisemus_height(gregorio_glyph *glyph, int type = 0; char gtype = 0; unsigned int glyph_number = 0; - - if (note && note->shape == S_PUNCTUM_INCLINATUM && note->next && - (note->next->shape == S_PUNCTUM_INCLINATUM - || note->next->shape == S_PUNCTUM_INCLINATUM_DEMINUTUS - || note->next->shape == S_PUNCTUM_INCLINATUM_AUCTUS) + if (note && note->u.note.shape == S_PUNCTUM_INCLINATUM && note->next && + (note->next->u.note.shape == S_PUNCTUM_INCLINATUM + || note->next->u.note.shape == S_PUNCTUM_INCLINATUM_DEMINUTUS + || note->next->u.note.shape == S_PUNCTUM_INCLINATUM_AUCTUS) && simple_htype(note->next->h_episemus_type) != H_NO_EPISEMUS) { return note->next->h_episemus_top_note + 1; } @@ -2272,8 +2321,8 @@ gregoriotex_find_next_hepisemus_height(gregorio_glyph *glyph, glyph = glyph->next; } glyph = glyph->next; - note = glyph->first_note; - if (glyph->glyph_type == G_PES) { + note = glyph->u.notes.first_note; + if (glyph->u.notes.glyph_type == G_PES) { note = note->next; i = 2; gtype = T_PES; @@ -2300,21 +2349,21 @@ gregoriotex_find_next_hepisemus_height(gregorio_glyph *glyph, return -1; } if (element->type == GRE_SPACE - && (element->element_type == SP_NEUMATIC_CUT - || element->element_type == SP_LARGER_SPACE - || element->element_type == SP_NEUMATIC_CUT_NB - || element->element_type == SP_LARGER_SPACE_NB)) { + && (element->u.misc.unpitched.info.space == SP_NEUMATIC_CUT + || element->u.misc.unpitched.info.space == SP_LARGER_SPACE + || element->u.misc.unpitched.info.space == SP_NEUMATIC_CUT_NB + || element->u.misc.unpitched.info.space == SP_LARGER_SPACE_NB)) { element = element->next; } if (!element || element->type != GRE_ELEMENT) { return -1; } - glyph = element->first_glyph; - if (!glyph || !glyph->first_note) { + glyph = element->u.glyphs.first_glyph; + if (!glyph || !glyph->u.notes.first_note) { return -1; } - note = glyph->first_note; - if (glyph->glyph_type == G_PES) { + note = glyph->u.notes.first_note; + if (glyph->u.notes.glyph_type == G_PES) { note = note->next; i = 2; gtype = T_PES; @@ -2368,8 +2417,8 @@ gregoriotex_write_additional_line(FILE *f, i = HEPISEMUS_FIRST_TWO; } if (i == 2) { - if (current_note->previous->pitch > 'b' - && current_note->previous->pitch < 'l') { + if (current_note->previous->u.note.pitch > 'b' + && current_note->previous->u.note.pitch < 'l') { i = HEPISEMUS_FIRST_TWO; } else { return; @@ -2377,7 +2426,7 @@ gregoriotex_write_additional_line(FILE *f, } if (i == 3) { if (bottom_or_top == TT_BOTTOM - || current_note->previous->pitch > 'k') { + || current_note->previous->u.note.pitch > 'k') { // we don't need to add twice the same line return; } @@ -2388,7 +2437,7 @@ gregoriotex_write_additional_line(FILE *f, i = HEPISEMUS_FIRST_TWO; } if (i == 3) { - if (current_note->previous->pitch > 'b') { + if (current_note->previous->u.note.pitch > 'b') { i = HEPISEMUS_FIRST_TWO; } else { return; @@ -2396,7 +2445,7 @@ gregoriotex_write_additional_line(FILE *f, } if (i == 4) { if (bottom_or_top == TT_BOTTOM - || current_note->previous->pitch > 'k') { + || current_note->previous->u.note.pitch > 'k') { // we don't need to add twice the same line return; } @@ -2414,10 +2463,13 @@ gregoriotex_write_additional_line(FILE *f, // one // but it may be tricky sometimes, because of the previous patch if (current_note->previous && - current_note->previous->pitch > current_note->pitch) { - ambitus = current_note->previous->pitch - current_note->pitch; + current_note->previous->u.note.pitch > current_note->u.note.pitch) { + ambitus = + current_note->previous->u.note.pitch - + current_note->u.note.pitch; } else { - ambitus = current_note->pitch - current_note->next->pitch; + ambitus = + current_note->u.note.pitch - current_note->next->u.note.pitch; } } fprintf(f, "\\greadditionalline{%d}{%d}{%d}%%\n", number, ambitus, @@ -2439,11 +2491,10 @@ gregoriotex_write_vepisemus(FILE *f, char height = 0; char number = 0; - gregoriotex_find_sign_number(current_glyph, i, type, TT_V_EPISEMUS, current_note, &number, &height, NULL); - if (current_note->pitch == 'a') { + if (current_note->u.note.pitch == 'a') { height = 'z'; } fprintf(f, "\\grevepisemus{%c}{%d}%%\n", height, number); @@ -2471,22 +2522,24 @@ gregoriotex_write_rare(FILE *f, switch (rare) { case _ACCENTUS: - fprintf(f, "\\greaccentus{%c}{%d}%%\n", current_note->pitch, number); + fprintf(f, "\\greaccentus{%c}{%d}%%\n", current_note->u.note.pitch, + number); break; case _ACCENTUS_REVERSUS: - fprintf(f, "\\grereversedaccentus{%c}{%d}%%\n", current_note->pitch, - number); + fprintf(f, "\\grereversedaccentus{%c}{%d}%%\n", + current_note->u.note.pitch, number); break; case _CIRCULUS: - fprintf(f, "\\grecirculus{%c}{%d}%%\n", current_note->pitch, number); + fprintf(f, "\\grecirculus{%c}{%d}%%\n", current_note->u.note.pitch, + number); break; case _SEMI_CIRCULUS: - fprintf(f, "\\gresemicirculus{%c}{%d}%%\n", current_note->pitch, + fprintf(f, "\\gresemicirculus{%c}{%d}%%\n", current_note->u.note.pitch, number); break; case _SEMI_CIRCULUS_REVERSUS: fprintf(f, "\\grereversedsemicirculus{%c}{%d}%%\n", - current_note->pitch, number); + current_note->u.note.pitch, number); break; // the cases of the bar signs are dealt in another function (write_bar) case _ICTUS_A: @@ -2522,12 +2575,14 @@ static inline void number_note_before_last_note(gregorio_glyph *current_glyph, gregorio_note *current_note, char *number) { - if ((current_glyph->liquescentia == L_DEMINUTUS_INITIO_DEBILIS - || current_glyph->liquescentia == L_DEMINUTUS) && current_note->next) { + if ((current_glyph->u.notes.liquescentia == L_DEMINUTUS_INITIO_DEBILIS + || current_glyph->u.notes.liquescentia == L_DEMINUTUS) + && current_note->next) { *number = 3; } else { - if ((current_note->pitch - current_note->next->pitch) == 1 - || (current_note->pitch - current_note->next->pitch) == -1) { + if ((current_note->u.note.pitch - current_note->next->u.note.pitch) == 1 + || (current_note->u.note.pitch - + current_note->next->u.note.pitch) == -1) { *number = 17; } else { *number = 2; @@ -2540,8 +2595,8 @@ static inline void number_note_before_last_note(gregorio_glyph *current_glyph, static inline void number_last_note(gregorio_glyph *current_glyph, char *number, char num) { - if (current_glyph->liquescentia == L_DEMINUTUS_INITIO_DEBILIS - || current_glyph->liquescentia == L_DEMINUTUS) { + if (current_glyph->u.notes.liquescentia == L_DEMINUTUS_INITIO_DEBILIS + || current_glyph->u.notes.liquescentia == L_DEMINUTUS) { /* * may seem strange, but it is unlogical to typeset a small horizontal * episemus at the end of a flexus deminutus @@ -2558,7 +2613,7 @@ static inline void normal_height(char sign_type, gregorio_note *current_note, if (sign_type == TT_H_EPISEMUS) { *height = current_note->h_episemus_top_note + 1; } else { - *height = current_note->pitch - 1; + *height = current_note->u.note.pitch - 1; } } @@ -2570,9 +2625,9 @@ static inline void normal_height_long_first(char sign_type, *height = current_note->h_episemus_top_note + 1; } else { if (sign_type == TT_V_EPISEMUS) { - *height = current_note->pitch - 2; + *height = current_note->u.note.pitch - 2; } else { - *height = current_note->pitch - 1; + *height = current_note->u.note.pitch - 1; } } } @@ -2586,19 +2641,21 @@ static inline void normal_height_top(char sign_type, *height = current_note->h_episemus_top_note + 1; } else { if (current_note->previous - && current_note->pitch - current_note->previous->pitch > 2) { + && current_note->u.note.pitch - + current_note->previous->u.note.pitch > 2) { /* * an exceptional case, which may be too particular: marking a * salicus starting with an interval of a 5th... */ if (sign_type == TT_V_EPISEMUS - && current_note->pitch - current_note->previous->pitch == 4) { - *height = current_note->pitch + 2; + && current_note->u.note.pitch - + current_note->previous->u.note.pitch == 4) { + *height = current_note->u.note.pitch + 2; } else { - *height = current_note->pitch - 1; + *height = current_note->u.note.pitch - 1; } } else { - *height = current_note->pitch + 2; + *height = current_note->u.note.pitch + 2; } } } @@ -2611,11 +2668,12 @@ static inline void height_layered_notes(char sign_type, if (sign_type == TT_H_EPISEMUS) { *height = current_note->h_episemus_top_note + 1; } else { - if ((current_note->pitch - current_note->next->pitch) == 1 - || (current_note->pitch - current_note->next->pitch) == -1) { - *height = current_note->pitch + 2; + if ((current_note->u.note.pitch - current_note->next->u.note.pitch) == 1 + || (current_note->u.note.pitch - + current_note->next->u.note.pitch) == -1) { + *height = current_note->u.note.pitch + 2; } else { - *height = current_note->pitch - 1; + *height = current_note->u.note.pitch - 1; } } } @@ -2638,7 +2696,7 @@ static inline void normal_height_bottom(char sign_type, && (!current_note->next || simple_htype(current_note->next->h_episemus_type) == H_NO_EPISEMUS)) { - *height = current_note->pitch - 1; + *height = current_note->u.note.pitch - 1; if (bottom) { *bottom = 1; } @@ -2646,7 +2704,7 @@ static inline void normal_height_bottom(char sign_type, *height = current_note->h_episemus_top_note + 1; } } else { - *height = current_note->pitch - 1; + *height = current_note->u.note.pitch - 1; } } @@ -2657,12 +2715,12 @@ static inline void normal_height_bottom_pes(char sign_type, char *height, char *bottom) { if (sign_type == TT_H_EPISEMUS) { - *height = current_note->pitch - 1; + *height = current_note->u.note.pitch - 1; if (bottom) { *bottom = 1; } } else { - *height = current_note->pitch - 1; + *height = current_note->u.note.pitch - 1; } } @@ -2683,10 +2741,10 @@ gregoriotex_find_sign_number(gregorio_glyph *current_glyph, * in the case of a pes, we put the episemus just under the bottom note */ if (i == 1) { - if (current_glyph->liquescentia >= L_INITIO_DEBILIS) { + if (current_glyph->u.notes.liquescentia >= L_INITIO_DEBILIS) { *number = 1; } else { - if (current_note->shape == S_QUILISMA) { + if (current_note->u.note.shape == S_QUILISMA) { *number = 15; } else { *number = 0; @@ -2697,8 +2755,9 @@ gregoriotex_find_sign_number(gregorio_glyph *current_glyph, /* * i=2 */ - if (current_glyph->liquescentia == L_DEMINUTUS_INITIO_DEBILIS - || current_glyph->liquescentia == L_DEMINUTUS) { + if (current_glyph->u.notes.liquescentia == + L_DEMINUTUS_INITIO_DEBILIS + || current_glyph->u.notes.liquescentia == L_DEMINUTUS) { *number = 1; } else { *number = 18; @@ -2710,13 +2769,13 @@ gregoriotex_find_sign_number(gregorio_glyph *current_glyph, case T_PESQUASSUS: case T_PESQUILISMAQUADRATUM: if (i == 1) { - if (current_glyph->liquescentia >= L_INITIO_DEBILIS) { + if (current_glyph->u.notes.liquescentia >= L_INITIO_DEBILIS) { *number = 7; } else { - if (current_note->shape == S_ORISCUS) { + if (current_note->u.note.shape == S_ORISCUS) { *number = 19; } - if (current_note->shape == S_QUILISMA) { + if (current_note->u.note.shape == S_QUILISMA) { *number = 20; } else { *number = 6; @@ -2727,8 +2786,9 @@ gregoriotex_find_sign_number(gregorio_glyph *current_glyph, /* * i=2 */ - if (current_glyph->liquescentia == L_DEMINUTUS_INITIO_DEBILIS - || current_glyph->liquescentia == L_DEMINUTUS) { + if (current_glyph->u.notes.liquescentia == + L_DEMINUTUS_INITIO_DEBILIS + || current_glyph->u.notes.liquescentia == L_DEMINUTUS) { *number = 7; } else { *number = 0; @@ -2742,8 +2802,9 @@ gregoriotex_find_sign_number(gregorio_glyph *current_glyph, switch (i) { case 1: number_note_before_last_note(current_glyph, current_note, number); - if (current_glyph->liquescentia == L_DEMINUTUS_INITIO_DEBILIS - || current_glyph->liquescentia == L_DEMINUTUS) { + if (current_glyph->u.notes.liquescentia == + L_DEMINUTUS_INITIO_DEBILIS + || current_glyph->u.notes.liquescentia == L_DEMINUTUS) { height_layered_notes(sign_type, current_note, height); } else { normal_height(sign_type, current_note, height); @@ -2773,8 +2834,9 @@ gregoriotex_find_sign_number(gregorio_glyph *current_glyph, normal_height_long_first(sign_type, current_note, height); break; case 2: - if (current_glyph->liquescentia == L_DEMINUTUS_INITIO_DEBILIS - || current_glyph->liquescentia == L_DEMINUTUS) { + if (current_glyph->u.notes.liquescentia == + L_DEMINUTUS_INITIO_DEBILIS + || current_glyph->u.notes.liquescentia == L_DEMINUTUS) { *number = 5; } else { *number = 4; @@ -2782,19 +2844,22 @@ gregoriotex_find_sign_number(gregorio_glyph *current_glyph, normal_height_bottom(sign_type, current_note, height, bottom); break; case 3: - if (current_note->pitch - current_note->next->pitch != 1) { + if (current_note->u.note.pitch - current_note->next->u.note.pitch != + 1) { number_note_before_last_note(current_glyph, current_note, number); } - if ((current_glyph->liquescentia == L_DEMINUTUS_INITIO_DEBILIS - || current_glyph->liquescentia == L_DEMINUTUS) + if ((current_glyph->u.notes.liquescentia == + L_DEMINUTUS_INITIO_DEBILIS + || current_glyph->u.notes.liquescentia == L_DEMINUTUS) && current_note->next) { *number = 3; } else { *number = 2; } - if (current_glyph->liquescentia == L_DEMINUTUS_INITIO_DEBILIS - || current_glyph->liquescentia == L_DEMINUTUS) { + if (current_glyph->u.notes.liquescentia == + L_DEMINUTUS_INITIO_DEBILIS + || current_glyph->u.notes.liquescentia == L_DEMINUTUS) { height_layered_notes(sign_type, current_note, height); } else { normal_height(sign_type, current_note, height); @@ -2821,7 +2886,7 @@ gregoriotex_find_sign_number(gregorio_glyph *current_glyph, normal_height(sign_type, current_note, height); break; case 1: - if (current_glyph->liquescentia >= L_INITIO_DEBILIS) { + if (current_glyph->u.notes.liquescentia >= L_INITIO_DEBILIS) { *number = 7; } else { *number = 6; @@ -2829,10 +2894,11 @@ gregoriotex_find_sign_number(gregorio_glyph *current_glyph, normal_height_bottom(sign_type, current_note, height, bottom); break; case 2: - if (current_glyph->liquescentia >= L_INITIO_DEBILIS) { + if (current_glyph->u.notes.liquescentia >= L_INITIO_DEBILIS) { *number = 23; } else { - if (current_note->pitch - current_note->previous->pitch == 1) { + if (current_note->u.note.pitch - + current_note->previous->u.note.pitch == 1) { *number = 22; } else { *number = 21; @@ -2846,8 +2912,9 @@ gregoriotex_find_sign_number(gregorio_glyph *current_glyph, // in the current fonts the third note of the torculus resupinus // is v aligned with the last note number_last_note(current_glyph, number, 18); - if (current_glyph->liquescentia == L_DEMINUTUS_INITIO_DEBILIS - || current_glyph->liquescentia == L_DEMINUTUS) { + if (current_glyph->u.notes.liquescentia == + L_DEMINUTUS_INITIO_DEBILIS + || current_glyph->u.notes.liquescentia == L_DEMINUTUS) { height_layered_notes(sign_type, current_note, height); } else { normal_height_bottom(sign_type, current_note, height, bottom); @@ -2878,9 +2945,9 @@ gregoriotex_find_sign_number(gregorio_glyph *current_glyph, normal_height_long_first(sign_type, current_note, height); break; case 2: - if ((current_glyph->liquescentia == + if ((current_glyph->u.notes.liquescentia == L_DEMINUTUS_INITIO_DEBILIS - || current_glyph->liquescentia == L_DEMINUTUS) + || current_glyph->u.notes.liquescentia == L_DEMINUTUS) && current_note->next) { *number = 3; } else { @@ -2897,7 +2964,7 @@ gregoriotex_find_sign_number(gregorio_glyph *current_glyph, case T_SCANDICUS: switch (i) { case 1: - if (current_glyph->liquescentia >= L_INITIO_DEBILIS) { + if (current_glyph->u.notes.liquescentia >= L_INITIO_DEBILIS) { *number = 7; } else { *number = 6; @@ -2935,7 +3002,7 @@ gregoriotex_find_sign_number(gregorio_glyph *current_glyph, case T_TORCULUS_QUILISMA: switch (i) { case 1: - if (current_glyph->liquescentia >= L_INITIO_DEBILIS) { + if (current_glyph->u.notes.liquescentia >= L_INITIO_DEBILIS) { *number = 7; } else { if (type == T_TORCULUS_QUILISMA) { @@ -2948,8 +3015,9 @@ gregoriotex_find_sign_number(gregorio_glyph *current_glyph, break; case 2: number_note_before_last_note(current_glyph, current_note, number); - if (current_glyph->liquescentia == L_DEMINUTUS_INITIO_DEBILIS - || current_glyph->liquescentia == L_DEMINUTUS) { + if (current_glyph->u.notes.liquescentia == + L_DEMINUTUS_INITIO_DEBILIS + || current_glyph->u.notes.liquescentia == L_DEMINUTUS) { height_layered_notes(sign_type, current_note, height); } else { normal_height(sign_type, current_note, height); @@ -2963,7 +3031,7 @@ gregoriotex_find_sign_number(gregorio_glyph *current_glyph, break; default: /* case T_ONE_NOTE */ normal_height(sign_type, current_note, height); - switch (current_note->shape) { + switch (current_note->u.note.shape) { case S_PUNCTUM_INCLINATUM_DEMINUTUS: *number = 13; break; @@ -3026,9 +3094,9 @@ gregoriotex_find_sign_number(gregorio_glyph *current_glyph, */ unsigned int -gregoriotex_determine_liquescentia_number(unsigned int - factor, - unsigned char type, char liquescentia) +gregoriotex_determine_liquescentia_number(unsigned int factor, + gregorio_liquescentia type, + gregorio_liquescentia liquescentia) { if (liquescentia == L_AUCTA) { liquescentia = L_AUCTUS_ASCENDENS; @@ -3111,10 +3179,10 @@ gregoriotex_determine_liquescentia_number(unsigned int {\ if (glyph->type == GRE_GLYPH)\ {\ - note = glyph->first_note;\ + note = glyph->u.notes.first_note;\ while (note)\ {\ - if (note->pitch < 'c')\ + if (note->u.note.pitch < 'c')\ {\ return 1;\ }\ @@ -3145,14 +3213,15 @@ gregoriotex_is_long(char pitch, gregorio_glyph *current_glyph, // we first look forward to see if there is a note underneath c whileglyph(next); if (element && element->type == GRE_SPACE - && (element->element_type == SP_NEUMATIC_CUT - || element->element_type == SP_LARGER_SPACE - || element->element_type == SP_NEUMATIC_CUT_NB - || element->element_type == SP_LARGER_SPACE_NB)) { + && (element->u.misc.unpitched.info.space == SP_NEUMATIC_CUT + || element->u.misc.unpitched.info.space == SP_LARGER_SPACE + || element->u.misc.unpitched.info.space == SP_NEUMATIC_CUT_NB + || element->u.misc.unpitched.info.space == + SP_LARGER_SPACE_NB)) { element = element->next; } if (element && element->type == GRE_ELEMENT) { - glyph = element->first_glyph; + glyph = element->u.glyphs.first_glyph; whileglyph(next); } // and now something completely different @@ -3160,14 +3229,15 @@ gregoriotex_is_long(char pitch, gregorio_glyph *current_glyph, element = current_element->previous; whileglyph(previous); if (element && element->type == GRE_SPACE - && (element->element_type == SP_NEUMATIC_CUT - || element->element_type == SP_LARGER_SPACE - || element->element_type == SP_NEUMATIC_CUT_NB - || element->element_type == SP_LARGER_SPACE_NB)) { + && (element->u.misc.unpitched.info.space == SP_NEUMATIC_CUT + || element->u.misc.unpitched.info.space == SP_LARGER_SPACE + || element->u.misc.unpitched.info.space == SP_NEUMATIC_CUT_NB + || element->u.misc.unpitched.info.space == + SP_LARGER_SPACE_NB)) { element = element->previous; } if (element && element->type == GRE_ELEMENT) { - glyph = element->first_glyph; + glyph = element->u.glyphs.first_glyph; whileglyph(next); } return 0; @@ -3181,9 +3251,10 @@ gregoriotex_is_long(char pitch, gregorio_glyph *current_glyph, // very basic, it is only the global dimensions : torculus, one_note, etc. void - gregoriotex_determine_number_and_type - (gregorio_glyph *glyph, gregorio_element *element, int *type, char *gtype, - unsigned int *glyph_number) { +gregoriotex_determine_number_and_type(gregorio_glyph *glyph, + gregorio_element *element, int *type, + char *gtype, unsigned int *glyph_number) +{ unsigned int temp = 0; char pitch = 0; char liquescentia; @@ -3193,13 +3264,13 @@ void "gregoriotex_determine_number_and_type", ERROR, 0); return; } - if (!glyph->first_note) { + if (!glyph->u.notes.first_note) { gregorio_message(_ ("called with a glyph that has no note"), "gregorio_tex_determine_number_and_type", ERROR, 0); return; } - liquescentia = glyph->liquescentia; + liquescentia = glyph->u.notes.liquescentia; /* * commented, but must be there for the font gregoria (as there is no auctus * descendens). TODO : having a variable telling the font if (liquescentia == @@ -3208,19 +3279,21 @@ void * = L_AUCTUS_DESCENDENS_INITIO_DEBILIS; } */ - switch (glyph->glyph_type) { + switch (glyph->u.notes.glyph_type) { case G_PODATUS: - pitch = glyph->first_note->next->pitch; - switch (glyph->first_note->shape) { + pitch = glyph->u.notes.first_note->next->u.note.pitch; + switch (glyph->u.notes.first_note->u.note.shape) { case S_QUILISMA: *type = AT_QUILISMA; // the next if is because we made the choice that AUCTUS shapes // look // like pes quadratum. - if (glyph->liquescentia == L_AUCTUS_ASCENDENS - || glyph->liquescentia == L_AUCTUS_DESCENDENS - || glyph->liquescentia == L_AUCTUS_DESCENDENS_INITIO_DEBILIS - || glyph->liquescentia == L_AUCTUS_ASCENDENS_INITIO_DEBILIS) { + if (glyph->u.notes.liquescentia == L_AUCTUS_ASCENDENS + || glyph->u.notes.liquescentia == L_AUCTUS_DESCENDENS + || glyph->u.notes.liquescentia == + L_AUCTUS_DESCENDENS_INITIO_DEBILIS + || glyph->u.notes.liquescentia == + L_AUCTUS_ASCENDENS_INITIO_DEBILIS) { *gtype = T_PESQUILISMAQUADRATUM; } else { *gtype = T_PESQUILISMA; @@ -3229,12 +3302,13 @@ void TYPE_FACTOR * (*gtype) + gregoriotex_determine_liquescentia_number(S_LIQ_FACTOR, L_NO_INITIO, - glyph->liquescentia); + glyph->u. + notes.liquescentia); break; case S_ORISCUS: *type = AT_ORISCUS; // TODO: we could factorize this code - if (glyph->liquescentia == L_NO_LIQUESCENTIA + if (glyph->u.notes.liquescentia == L_NO_LIQUESCENTIA && gregoriotex_is_long(pitch, glyph, element) == 1) { *gtype = T_PESQUASSUS_LONGQUEUE; } else { @@ -3244,14 +3318,17 @@ void TYPE_FACTOR * (*gtype) + gregoriotex_determine_liquescentia_number(S_LIQ_FACTOR, L_NO_INITIO, - glyph->liquescentia); + glyph->u. + notes.liquescentia); break; default: *type = AT_ONE_NOTE; - if (glyph->liquescentia == L_AUCTUS_ASCENDENS - || glyph->liquescentia == L_AUCTUS_DESCENDENS - || glyph->liquescentia == L_AUCTUS_DESCENDENS_INITIO_DEBILIS - || glyph->liquescentia == L_AUCTUS_ASCENDENS_INITIO_DEBILIS) { + if (glyph->u.notes.liquescentia == L_AUCTUS_ASCENDENS + || glyph->u.notes.liquescentia == L_AUCTUS_DESCENDENS + || glyph->u.notes.liquescentia == + L_AUCTUS_DESCENDENS_INITIO_DEBILIS + || glyph->u.notes.liquescentia == + L_AUCTUS_ASCENDENS_INITIO_DEBILIS) { *gtype = T_PESQUADRATUM; } else { *gtype = T_PES; @@ -3260,16 +3337,17 @@ void TYPE_FACTOR * (*gtype) + gregoriotex_determine_liquescentia_number(S_LIQ_FACTOR, L_ALL, - glyph->liquescentia); + glyph->u. + notes.liquescentia); break; } break; case G_PES_QUADRATUM: - pitch = glyph->first_note->next->pitch; - switch (glyph->first_note->shape) { + pitch = glyph->u.notes.first_note->next->u.note.pitch; + switch (glyph->u.notes.first_note->u.note.shape) { case S_QUILISMA: *type = AT_QUILISMA; - if (glyph->liquescentia == L_NO_LIQUESCENTIA + if (glyph->u.notes.liquescentia == L_NO_LIQUESCENTIA && gregoriotex_is_long(pitch, glyph, element) == 1) { *gtype = T_PESQUILISMAQUADRATUM_LONGQUEUE; } else { @@ -3279,11 +3357,12 @@ void TYPE_FACTOR * (*gtype) + gregoriotex_determine_liquescentia_number(S_LIQ_FACTOR, L_NO_INITIO, - glyph->liquescentia); + glyph->u. + notes.liquescentia); break; case S_ORISCUS: *type = AT_ORISCUS; - if (glyph->liquescentia == L_NO_LIQUESCENTIA + if (glyph->u.notes.liquescentia == L_NO_LIQUESCENTIA && gregoriotex_is_long(pitch, glyph, element) == 1) { *gtype = T_PESQUASSUS_LONGQUEUE; } else { @@ -3293,11 +3372,12 @@ void TYPE_FACTOR * (*gtype) + gregoriotex_determine_liquescentia_number(S_LIQ_FACTOR, L_NO_INITIO, - glyph->liquescentia); + glyph->u. + notes.liquescentia); break; default: *type = AT_ONE_NOTE; - if (glyph->liquescentia == L_NO_LIQUESCENTIA + if (glyph->u.notes.liquescentia == L_NO_LIQUESCENTIA && gregoriotex_is_long(pitch, glyph, element) == 1) { *gtype = T_PESQUADRATUM_LONGQUEUE; } else { @@ -3307,28 +3387,30 @@ void TYPE_FACTOR * (*gtype) + gregoriotex_determine_liquescentia_number(S_LIQ_FACTOR, L_ALL, - glyph->liquescentia); + glyph->u. + notes.liquescentia); break; } break; case G_FLEXA: - pitch = glyph->first_note->pitch; - if (glyph->liquescentia == L_DEMINUTUS) { + pitch = glyph->u.notes.first_note->u.note.pitch; + if (glyph->u.notes.liquescentia == L_DEMINUTUS) { *type = AT_FLEXUS_DEMINUTUS; } else { - if (pitch - glyph->first_note->next->pitch == 1) { + if (pitch - glyph->u.notes.first_note->next->u.note.pitch == 1) { *type = AT_FLEXUS_1; } else { *type = AT_FLEXUS; } } - if (glyph->first_note->shape == S_ORISCUS) { + if (glyph->u.notes.first_note->u.note.shape == S_ORISCUS) { *gtype = T_FLEXUS_ORISCUS; temp = TYPE_FACTOR * T_FLEXUS_ORISCUS + gregoriotex_determine_liquescentia_number(S_LIQ_FACTOR, L_NO_INITIO, - glyph->liquescentia); + glyph->u. + notes.liquescentia); } else { if (is_short(pitch, glyph, element)) { *gtype = T_FLEXUS; @@ -3336,44 +3418,49 @@ void TYPE_FACTOR * T_FLEXUS + gregoriotex_determine_liquescentia_number(S_LIQ_FACTOR, L_NO_INITIO, - glyph->liquescentia); + glyph->u.notes. + liquescentia); } else { *gtype = T_FLEXUS_LONGQUEUE; temp = TYPE_FACTOR * T_FLEXUS_LONGQUEUE + gregoriotex_determine_liquescentia_number(S_LIQ_FACTOR, L_NO_INITIO, - glyph->liquescentia); + glyph->u.notes. + liquescentia); } } break; case G_TORCULUS: - if (glyph->first_note->shape == S_QUILISMA) { + if (glyph->u.notes.first_note->u.note.shape == S_QUILISMA) { *type = AT_QUILISMA; *gtype = T_TORCULUS_QUILISMA; temp = TYPE_FACTOR * T_TORCULUS_QUILISMA + gregoriotex_determine_liquescentia_number(L_LIQ_FACTOR, L_NO_INITIO, - glyph->liquescentia); + glyph->u. + notes.liquescentia); } else { *type = AT_ONE_NOTE; *gtype = T_TORCULUS; temp = TYPE_FACTOR * T_TORCULUS + gregoriotex_determine_liquescentia_number(L_LIQ_FACTOR, L_ALL, - glyph->liquescentia); + glyph->u. + notes.liquescentia); } break; case G_TORCULUS_LIQUESCENS: - if (glyph->first_note->shape == S_QUILISMA) { + if (glyph->u.notes.first_note->u.note.shape == S_QUILISMA) { *type = AT_QUILISMA; *gtype = T_TORCULUS_LIQUESCENS_QUILISMA; temp = TYPE_FACTOR * T_TORCULUS_LIQUESCENS_QUILISMA + gregoriotex_determine_liquescentia_number(L_LIQ_FACTOR, L_ONLY_DEMINUTUS, - glyph->liquescentia); + glyph->u. + notes.liquescentia); } else { *type = AT_ONE_NOTE; *gtype = T_TORCULUS_LIQUESCENS; @@ -3381,7 +3468,8 @@ void TYPE_FACTOR * T_TORCULUS_LIQUESCENS + gregoriotex_determine_liquescentia_number(L_LIQ_FACTOR, L_ONLY_DEMINUTUS, - glyph->liquescentia); + glyph->u. + notes.liquescentia); } break; case G_TORCULUS_RESUPINUS_FLEXUS: @@ -3397,7 +3485,8 @@ void TYPE_FACTOR * T_PORRECTUS + gregoriotex_determine_liquescentia_number(L_LIQ_FACTOR, L_NO_INITIO, - glyph->liquescentia); + glyph->u. + notes.liquescentia); break; case G_TORCULUS_RESUPINUS: *type = AT_ONE_NOTE; @@ -3406,7 +3495,8 @@ void TYPE_FACTOR * T_TORCULUS_RESUPINUS + gregoriotex_determine_liquescentia_number(L_LIQ_FACTOR, L_ALL, - glyph->liquescentia); + glyph->u. + notes.liquescentia); break; case G_PORRECTUS_FLEXUS: *type = AT_PORRECTUS; @@ -3415,7 +3505,8 @@ void TYPE_FACTOR * T_PORRECTUSFLEXUS + gregoriotex_determine_liquescentia_number(L_LIQ_FACTOR, L_NO_INITIO, - glyph->liquescentia); + glyph->u. + notes.liquescentia); break; case G_PORRECTUS_NO_BAR: *type = AT_PORRECTUS; @@ -3424,7 +3515,8 @@ void TYPE_FACTOR * T_PORRECTUS_NOBAR + gregoriotex_determine_liquescentia_number(L_LIQ_FACTOR, L_NO_INITIO, - glyph->liquescentia); + glyph->u. + notes.liquescentia); break; case G_PORRECTUS_FLEXUS_NO_BAR: *type = AT_PORRECTUS; @@ -3433,12 +3525,13 @@ void TYPE_FACTOR * T_PORRECTUSFLEXUS_NOBAR + gregoriotex_determine_liquescentia_number(L_LIQ_FACTOR, L_NO_INITIO, - glyph->liquescentia); + glyph->u. + notes.liquescentia); break; case G_ANCUS: - if (glyph->liquescentia == L_DEMINUTUS - || glyph->liquescentia == L_DEMINUTUS_INITIO_DEBILIS) { - if (pitch - glyph->first_note->next->pitch == 1) { + if (glyph->u.notes.liquescentia == L_DEMINUTUS + || glyph->u.notes.liquescentia == L_DEMINUTUS_INITIO_DEBILIS) { + if (pitch - glyph->u.notes.first_note->next->u.note.pitch == 1) { *type = AT_FLEXUS_1; } else { *type = AT_FLEXUS; @@ -3448,13 +3541,15 @@ void temp = TYPE_FACTOR * T_ANCUS + gregoriotex_determine_liquescentia_number(S_LIQ_FACTOR, L_ONLY_DEMINUTUS, - glyph->liquescentia); + glyph->u.notes. + liquescentia); } else { *gtype = T_ANCUS_LONGQUEUE; temp = TYPE_FACTOR * T_ANCUS_LONGQUEUE + gregoriotex_determine_liquescentia_number(S_LIQ_FACTOR, L_ONLY_DEMINUTUS, - glyph->liquescentia); + glyph->u.notes. + liquescentia); } } else { // TODO... @@ -3467,11 +3562,12 @@ void temp = TYPE_FACTOR * T_SCANDICUS + gregoriotex_determine_liquescentia_number(S_LIQ_FACTOR, L_NO_INITIO, - glyph->liquescentia); + glyph->u. + notes.liquescentia); break; case G_SALICUS: *type = AT_ONE_NOTE; - pitch = glyph->first_note->next->next->pitch; + pitch = glyph->u.notes.first_note->next->next->u.note.pitch; if (gregoriotex_is_long(pitch, glyph, element) == 1) { *gtype = T_SALICUS_LONGQUEUE; } else { @@ -3480,7 +3576,8 @@ void temp = TYPE_FACTOR * (*gtype) + gregoriotex_determine_liquescentia_number(S_LIQ_FACTOR, L_NO_INITIO, - glyph->liquescentia); + glyph->u. + notes.liquescentia); break; case G_ONE_NOTE: case G_PUNCTUM_INCLINATUM: @@ -3516,7 +3613,7 @@ void *glyph_number = gregoriotex_determine_interval(glyph); *glyph_number = temp + (*glyph_number) + GLYPH_NUMBERING_START; // we change to the original liquescentia - glyph->liquescentia = liquescentia; + glyph->u.notes.liquescentia = liquescentia; // we fix *type with initio_debilis if (*type == AT_ONE_NOTE) { if (is_initio_debilis(liquescentia)) { @@ -3539,18 +3636,18 @@ unsigned int gregoriotex_determine_interval(gregorio_glyph *glyph) "gregoriotex_determine_interval", ERROR, 0); return 0; } - if (!glyph->first_note) { + if (!glyph->u.notes.first_note) { gregorio_message(_ ("called with a glyph that have no note"), "gregoriotex_determine_interval", ERROR, 0); return 0; } - current_note = glyph->first_note; + current_note = glyph->u.notes.first_note; if (!current_note->next) { return 0; } - first = current_note->pitch; - second = current_note->next->pitch; + first = current_note->u.note.pitch; + second = current_note->next->u.note.pitch; if (first < second) { current = second - first; } else { @@ -3560,8 +3657,8 @@ unsigned int gregoriotex_determine_interval(gregorio_glyph *glyph) if (!current_note->next) { return current; } - first = current_note->pitch; - second = current_note->next->pitch; + first = current_note->u.note.pitch; + second = current_note->next->u.note.pitch; if (first < second) { current = 5 * (second - first) + current; } else { @@ -3571,8 +3668,8 @@ unsigned int gregoriotex_determine_interval(gregorio_glyph *glyph) if (!current_note->next) { return current; } - first = current_note->pitch; - second = current_note->next->pitch; + first = current_note->u.note.pitch; + second = current_note->next->u.note.pitch; if (first < second) { current = 25 * (second - first) + current; } else { @@ -3657,7 +3754,7 @@ gregoriotex_write_note(FILE *f, gregorio_note *note, char next_note_pitch) { unsigned int glyph_number; - unsigned int initial_shape = note->shape; + unsigned int initial_shape = note->u.note.shape; char temp; // type in the sense of GregorioTeX alignment type int type = AT_ONE_NOTE; @@ -3667,30 +3764,31 @@ gregoriotex_write_note(FILE *f, gregorio_note *note, "gregoriotex_write_note", ERROR, 0); return; } - if (note->shape == S_PUNCTUM && note->liquescentia != L_NO_LIQUESCENTIA) { - switch (note->liquescentia) { + if (note->u.note.shape == S_PUNCTUM + && note->u.note.liquescentia != L_NO_LIQUESCENTIA) { + switch (note->u.note.liquescentia) { case L_AUCTUS_ASCENDENS: - note->shape = S_PUNCTUM_AUCTUS_ASCENDENS; + note->u.note.shape = S_PUNCTUM_AUCTUS_ASCENDENS; break; case L_AUCTUS_DESCENDENS: case L_AUCTA: - note->shape = S_PUNCTUM_AUCTUS_DESCENDENS; + note->u.note.shape = S_PUNCTUM_AUCTUS_DESCENDENS; break; case L_DEMINUTUS: case L_INITIO_DEBILIS: - note->shape = S_PUNCTUM_DEMINUTUS; + note->u.note.shape = S_PUNCTUM_DEMINUTUS; default: break; } } gregoriotex_determine_note_number_and_type(note, glyph, element, &type, &glyph_number); - note->shape = initial_shape; + note->u.note.shape = initial_shape; // special things for puncta inclinata - if (note->shape == S_PUNCTUM_INCLINATUM) { + if (note->u.note.shape == S_PUNCTUM_INCLINATUM) { if (note->previous) { // means that it is the first note of the puncta inclinata sequence - temp = note->previous->pitch - note->pitch; + temp = note->previous->u.note.pitch - note->u.note.pitch; // if (temp < -1 || temp > 1) switch (temp) // we switch on the range of the inclinata { @@ -3716,16 +3814,16 @@ gregoriotex_write_note(FILE *f, gregorio_note *note, } } } - if (note->shape == S_PUNCTUM_INCLINATUM_DEMINUTUS) { + if (note->u.note.shape == S_PUNCTUM_INCLINATUM_DEMINUTUS) { if (note->previous) { // means that it is the first note of the puncta inclinata sequence - temp = note->previous->pitch - note->pitch; + temp = note->previous->u.note.pitch - note->u.note.pitch; if (temp < -2 || temp > 2) { fprintf(f, "\\greendofglyph{11}%%\n"); } else { if (note->previous - && note->previous->shape == S_PUNCTUM_INCLINATUM_DEMINUTUS) - { + && note->previous->u.note.shape == + S_PUNCTUM_INCLINATUM_DEMINUTUS) { if (temp < -1 || temp > 1) // really if the ambitus = 3rd at this point { @@ -3740,10 +3838,10 @@ gregoriotex_write_note(FILE *f, gregorio_note *note, } } } - if (note->shape == S_PUNCTUM_INCLINATUM_AUCTUS) { + if (note->u.note.shape == S_PUNCTUM_INCLINATUM_AUCTUS) { if (note->previous) { // means that it is the first note of the puncta inclinata sequence - temp = note->previous->pitch - note->pitch; + temp = note->previous->u.note.pitch - note->u.note.pitch; if (temp < -1 || temp > 1) { fprintf(f, "\\greendofglyph{1}%%\n"); } else { @@ -3752,22 +3850,22 @@ gregoriotex_write_note(FILE *f, gregorio_note *note, } } } - switch (note->shape) { + switch (note->u.note.shape) { case S_PUNCTUM_CAVUM: - fprintf(f, "\\grepunctumcavum{%c}{%c}{%d}", note->pitch, + fprintf(f, "\\grepunctumcavum{%c}{%c}{%d}", note->u.note.pitch, next_note_pitch, type); break; case S_LINEA_PUNCTUM_CAVUM: - fprintf(f, "\\grelineapunctumcavum{%c}{%c}{%d}", note->pitch, + fprintf(f, "\\grelineapunctumcavum{%c}{%c}{%d}", note->u.note.pitch, next_note_pitch, type); break; case S_LINEA: - fprintf(f, "\\grelinea{%c}{%c}{%d}", note->pitch, next_note_pitch, - type); + fprintf(f, "\\grelinea{%c}{%c}{%d}", note->u.note.pitch, + next_note_pitch, type); break; default: fprintf(f, "\\greglyph{\\char %d}{%c}{%c}{%d}", - glyph_number, note->pitch, next_note_pitch, type); + glyph_number, note->u.note.pitch, next_note_pitch, type); break; } } @@ -3785,7 +3883,7 @@ void } *type = AT_ONE_NOTE; - switch (note->shape) { + switch (note->u.note.shape) { case S_PUNCTUM_INCLINATUM: *glyph_number = 19; *type = AT_PUNCTUM_INCLINATUM; @@ -3821,21 +3919,21 @@ void *glyph_number = 36; break; case S_VIRGA: - if (is_short(note->pitch, glyph, element)) { + if (is_short(note->u.note.pitch, glyph, element)) { *glyph_number = 23; } else { *glyph_number = 22; } break; case S_VIRGA_REVERSA: - if (note->liquescentia == L_AUCTUS_DESCENDENS) { - if (is_short(note->pitch, glyph, element)) { + if (note->u.note.liquescentia == L_AUCTUS_DESCENDENS) { + if (is_short(note->u.note.pitch, glyph, element)) { *glyph_number = 92; } else { *glyph_number = 93; } } else { - if (is_short(note->pitch, glyph, element)) { + if (is_short(note->u.note.pitch, glyph, element)) { *glyph_number = 25; } else { *glyph_number = 24; @@ -3859,7 +3957,7 @@ void *glyph_number = 26; break; case S_STROPHA: - if (glyph->liquescentia == L_AUCTA) { + if (glyph->u.notes.liquescentia == L_AUCTA) { *glyph_number = 21; } else { *glyph_number = 20; @@ -3899,7 +3997,7 @@ int gregoriotex_syllable_first_type(gregorio_syllable *syllable) element = syllable->elements[0]; while (element) { if (element->type == GRE_BAR) { - switch (element->element_type) { + switch (element->u.misc.unpitched.info.bar) { case B_NO_BAR: case B_VIRGULA: type = 10; @@ -3924,8 +4022,8 @@ int gregoriotex_syllable_first_type(gregorio_syllable *syllable) } return type; } - if (element->type == GRE_ELEMENT && element->first_glyph) { - glyph = element->first_glyph; + if (element->type == GRE_ELEMENT && element->u.glyphs.first_glyph) { + glyph = element->u.glyphs.first_glyph; while (glyph) { if (glyph->type == GRE_FLAT && alteration == 0) { alteration = 20; @@ -3936,8 +4034,8 @@ int gregoriotex_syllable_first_type(gregorio_syllable *syllable) if (glyph->type == GRE_SHARP && alteration == 0) { alteration = 60; } - if (glyph->type == GRE_GLYPH && glyph->first_note) { - switch (glyph->glyph_type) { + if (glyph->type == GRE_GLYPH && glyph->u.notes.first_note) { + switch (glyph->u.notes.glyph_type) { case G_TRIGONUS: case G_PUNCTA_INCLINATA: case G_2_PUNCTA_INCLINATA_DESCENDENS: @@ -3960,7 +4058,8 @@ int gregoriotex_syllable_first_type(gregorio_syllable *syllable) case G_BIVIRGA: case G_TRIVIRGA: gregoriotex_determine_note_number_and_type - (glyph->first_note, glyph, element, &type, &number); + (glyph->u.notes.first_note, glyph, element, &type, + &number); break; default: gregoriotex_determine_number_and_type diff --git a/src/gregoriotex/gregoriotex.h b/src/gregoriotex/gregoriotex.h index 6ff4ede9a..65c74a900 100644 --- a/src/gregoriotex/gregoriotex.h +++ b/src/gregoriotex/gregoriotex.h @@ -187,9 +187,11 @@ void gtex_write_special_char(FILE *f, grewchar *special_char); void gtex_write_verb(FILE *f, grewchar *verb_str); void gtex_print_char(FILE *f, grewchar to_print); -unsigned int gregoriotex_determine_liquescentia_number(unsigned int factor, - unsigned char type, - char liquescentia); +unsigned int +gregoriotex_determine_liquescentia_number(unsigned int factor, + gregorio_liquescentia + type, + gregorio_liquescentia liquescentia); void gregoriotex_write_vepisemus(FILE *f, gregorio_glyph *current_glyph, int i, char type, gregorio_note *current_note); void gregoriotex_write_choral_sign(FILE *f, gregorio_glyph *glyph, char type, diff --git a/src/struct.c b/src/struct.c index a6e87a52a..2ef3f0642 100644 --- a/src/struct.c +++ b/src/struct.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "struct.h" #include "unicode.h" #include "messages.h" @@ -57,62 +58,109 @@ static inline char max(char a, char b) return a > b ? a : b; } +static gregorio_note *create_and_link_note(gregorio_note **current_note) +{ + gregorio_note *note = calloc(1, sizeof(gregorio_note)); + if (!note) { + gregorio_message(_("error in memory allocation"), + "create_and_link_note", FATAL_ERROR, 0); + return NULL; + } + + note->previous = *current_note; + note->next = NULL; + if (*current_note) { + (*current_note)->next = note; + } + *current_note = note; + + return note; +} + void gregorio_add_note(gregorio_note **current_note, char pitch, - gregorio_shape shape, char signs, char liquescentia, - char h_episemus_type) + gregorio_shape shape, gregorio_sign signs, + gregorio_liquescentia liquescentia, char h_episemus_type) +{ + gregorio_note *element = create_and_link_note(current_note); + if (element) { + element->type = GRE_NOTE; + element->u.note.pitch = pitch; + element->u.note.shape = shape; + element->signs = signs; + element->special_sign = _NO_SIGN; + element->u.note.liquescentia = liquescentia; + element->h_episemus_type = H_NO_EPISEMUS; + element->h_episemus_top_note = 0; + element->h_episemus_bottom_note = 0; + element->texverb = NULL; + element->choral_sign = NULL; + gregorio_mix_h_episemus(element, h_episemus_type); + } +} + +void +gregorio_add_end_of_line_as_note(gregorio_note **current_note, + gregorio_type sub_type) { + gregorio_note *element = create_and_link_note(current_note); + if (element) { + element->type = GRE_END_OF_LINE; + element->u.other.sub_type = sub_type; + } +} - gregorio_note *element = malloc(sizeof(gregorio_note)); - if (!element) { - gregorio_message(_("error in memory allocation"), - "add_note", FATAL_ERROR, 0); - return; +void gregorio_add_custo_as_note(gregorio_note **current_note) +{ + gregorio_note *element = create_and_link_note(current_note); + if (element) { + element->type = GRE_CUSTO; } - element->type = GRE_NOTE; - element->pitch = pitch; - element->shape = shape; - element->signs = signs; - element->rare_sign = _NO_SIGN; - element->liquescentia = liquescentia; - element->previous = *current_note; - element->h_episemus_type = H_NO_EPISEMUS; - element->h_episemus_top_note = 0; - element->h_episemus_bottom_note = 0; - element->next = NULL; - element->texverb = NULL; - element->choral_sign = NULL; - if (*current_note) { - (*current_note)->next = element; +} + +void +gregorio_add_clef_change_as_note(gregorio_note **current_note, + gregorio_type type, char clef_line) +{ + gregorio_note *element = create_and_link_note(current_note); + assert(type == GRE_C_KEY_CHANGE || type == GRE_F_KEY_CHANGE + || type == GRE_C_KEY_CHANGE_FLATED + || type == GRE_F_KEY_CHANGE_FLATED); + if (element) { + element->type = type; + element->u.note.pitch = clef_line; + } +} + +void gregorio_add_bar_as_note(gregorio_note **current_note, gregorio_bar bar) +{ + gregorio_note *element = create_and_link_note(current_note); + if (element) { + element->type = GRE_BAR; + element->u.other.bar = bar; } - *current_note = element; - gregorio_mix_h_episemus(*current_note, h_episemus_type); } void -gregorio_add_special_as_note(gregorio_note **current_note, gregorio_type type, - char pitch) +gregorio_add_alteration_as_note(gregorio_note **current_note, + gregorio_type type, char pitch) { - gregorio_note *element = malloc(sizeof(gregorio_note)); - if (!element) { - gregorio_message(_("error in memory allocation"), - "add_special_as_note", FATAL_ERROR, 0); - return; + gregorio_note *element = create_and_link_note(current_note); + assert(type == GRE_FLAT || type == GRE_SHARP || type == GRE_NATURAL); + if (element) { + element->type = type; + element->u.note.pitch = pitch; } - element->type = type; - element->pitch = pitch; - element->signs = _NO_SIGN; - element->previous = *current_note; - element->next = NULL; - element->texverb = NULL; - element->h_episemus_type = H_NO_EPISEMUS; - element->h_episemus_top_note = 0; - element->h_episemus_bottom_note = 0; - element->choral_sign = NULL; - if (*current_note) { - (*current_note)->next = element; +} + +void +gregorio_add_space_as_note(gregorio_note **current_note, gregorio_space space) +{ + gregorio_note *element = create_and_link_note(current_note); + if (element) { + element->type = GRE_SPACE; + element->u.other.space = space; } - *current_note = element; } void @@ -123,51 +171,21 @@ gregorio_add_texverb_as_note(gregorio_note **current_note, char *str, if (str == NULL) { return; } - element = malloc(sizeof(gregorio_note)); - if (!element) { - gregorio_message(_("error in memory allocation"), - "add_special_as_note", FATAL_ERROR, 0); - return; + element = create_and_link_note(current_note); + assert(type == GRE_TEXVERB_GLYPH || type == GRE_TEXVERB_ELEMENT); + if (element) { + element->type = type; + element->texverb = str; } - element->type = type; - element->pitch = 0; - element->signs = _NO_SIGN; - element->previous = *current_note; - element->h_episemus_type = H_NO_EPISEMUS; - element->h_episemus_top_note = 0; - element->h_episemus_bottom_note = 0; - element->next = NULL; - element->texverb = str; - element->choral_sign = NULL; - if (*current_note) { - (*current_note)->next = element; - } - *current_note = element; } -void gregorio_add_nlba_as_note(gregorio_note **current_note, char type) +void gregorio_add_nlba_as_note(gregorio_note **current_note, gregorio_nlba type) { - gregorio_note *element; - element = malloc(sizeof(gregorio_note)); - if (!element) { - gregorio_message(_("error in memory allocation"), - "add_special_as_note", FATAL_ERROR, 0); - return; - } - element->type = GRE_NLBA; - element->pitch = type; - element->signs = _NO_SIGN; - element->previous = *current_note; - element->h_episemus_type = H_NO_EPISEMUS; - element->h_episemus_top_note = 0; - element->h_episemus_bottom_note = 0; - element->next = NULL; - element->texverb = NULL; - element->choral_sign = NULL; - if (*current_note) { - (*current_note)->next = element; + gregorio_note *element = create_and_link_note(current_note); + if (element) { + element->type = GRE_NLBA; + element->u.other.nlba = type; } - *current_note = element; } void gregorio_add_texverb_to_note(gregorio_note **current_note, char *str) @@ -182,10 +200,7 @@ void gregorio_add_texverb_to_note(gregorio_note **current_note, char *str) if ((*current_note)->texverb) { len = strlen((*current_note)->texverb) + strlen(str) + 1; res = malloc(len * sizeof(char)); - len = strlen((*current_note)->texverb); - for (i = 0; i <= len; i++) { - res[i] = ((*current_note)->texverb)[i]; - } + strcpy(res, (*current_note)->texverb); strcat(res, str); free((*current_note)->texverb); (*current_note)->texverb = res; @@ -202,13 +217,13 @@ void gregorio_add_cs_to_note(gregorio_note **current_note, char *str) } } -void gregorio_add_special_sign(gregorio_note *note, char sign) +void gregorio_add_special_sign(gregorio_note *note, gregorio_sign sign) { if (!note) { // error return; } - note->rare_sign = sign; + note->special_sign = sign; } void gregorio_set_signs(gregorio_note *note, char signs) @@ -223,38 +238,35 @@ void gregorio_set_signs(gregorio_note *note, char signs) void gregorio_change_shape(gregorio_note *note, gregorio_shape shape) { if (!note || note->type != GRE_NOTE) { - gregorio_message(_ - ("trying to change the shape of something that is not a note"), - "change_shape", ERROR, 0); + gregorio_message(_("trying to change the shape of something that is " + "not a note"), "change_shape", ERROR, 0); return; } - note->shape = shape; - if (note->shape == S_STROPHA || note->shape == S_DISTROPHA - || note->shape == S_TRISTROPHA) { - switch (note->liquescentia) { + note->u.note.shape = shape; + if (shape == S_STROPHA || shape == S_DISTROPHA || shape == S_TRISTROPHA) { + switch (note->u.note.liquescentia) { case L_AUCTUS_ASCENDENS: case L_AUCTUS_DESCENDENS: - note->liquescentia = L_AUCTA; + note->u.note.liquescentia = L_AUCTA; break; case L_AUCTUS_ASCENDENS_INITIO_DEBILIS: case L_AUCTUS_DESCENDENS_INITIO_DEBILIS: - note->liquescentia = L_AUCTA_INITIO_DEBILIS; + note->u.note.liquescentia = L_AUCTA_INITIO_DEBILIS; break; default: break; } - } - if (note->shape == S_ORISCUS) { - switch (note->liquescentia) { + } else if (shape == S_ORISCUS) { + switch (note->u.note.liquescentia) { case L_AUCTUS_ASCENDENS: case L_AUCTUS_DESCENDENS: case L_AUCTUS_ASCENDENS_INITIO_DEBILIS: case L_AUCTUS_DESCENDENS_INITIO_DEBILIS: - note->shape = S_ORISCUS_AUCTUS; + note->u.note.shape = S_ORISCUS_AUCTUS; break; case L_DEMINUTUS: case L_DEMINUTUS_INITIO_DEBILIS: - note->shape = S_ORISCUS_DEMINUTUS; + note->u.note.shape = S_ORISCUS_DEMINUTUS; break; default: break; @@ -262,58 +274,57 @@ void gregorio_change_shape(gregorio_note *note, gregorio_shape shape) } } -void gregorio_add_liquescentia(gregorio_note *note, char liq) +void gregorio_add_liquescentia(gregorio_note *note, gregorio_liquescentia liq) { if (!note || note->type != GRE_NOTE) { - gregorio_message(_ - ("trying to make a liquescence on something that is not a note"), - "add_liquescentia", ERROR, 0); + gregorio_message(_("trying to make a liquescence on something that " + "is not a note"), "add_liquescentia", ERROR, 0); return; } if (is_initio_debilis(liq)) { switch (liq) { case L_DEMINUTUS: - note->liquescentia = L_DEMINUTUS_INITIO_DEBILIS; + note->u.note.liquescentia = L_DEMINUTUS_INITIO_DEBILIS; break; case L_AUCTUS_ASCENDENS: - note->liquescentia = L_AUCTUS_ASCENDENS_INITIO_DEBILIS; + note->u.note.liquescentia = L_AUCTUS_ASCENDENS_INITIO_DEBILIS; break; case L_AUCTUS_DESCENDENS: - note->liquescentia = L_AUCTUS_DESCENDENS_INITIO_DEBILIS; + note->u.note.liquescentia = L_AUCTUS_DESCENDENS_INITIO_DEBILIS; break; case L_AUCTA: - note->liquescentia = L_AUCTA_INITIO_DEBILIS; + note->u.note.liquescentia = L_AUCTA_INITIO_DEBILIS; break; } } else { - note->liquescentia = liq; + note->u.note.liquescentia = liq; } - if (note->shape == S_STROPHA || note->shape == S_DISTROPHA - || note->shape == S_TRISTROPHA) { - switch (note->liquescentia) { + if (note->u.note.shape == S_STROPHA || note->u.note.shape == S_DISTROPHA + || note->u.note.shape == S_TRISTROPHA) { + switch (note->u.note.liquescentia) { case L_AUCTUS_ASCENDENS: case L_AUCTUS_DESCENDENS: - note->liquescentia = L_AUCTA; + note->u.note.liquescentia = L_AUCTA; break; case L_AUCTUS_ASCENDENS_INITIO_DEBILIS: case L_AUCTUS_DESCENDENS_INITIO_DEBILIS: - note->liquescentia = L_AUCTA_INITIO_DEBILIS; + note->u.note.liquescentia = L_AUCTA_INITIO_DEBILIS; break; default: break; } } - if (note->shape == S_ORISCUS) { - switch (note->liquescentia) { + if (note->u.note.shape == S_ORISCUS) { + switch (note->u.note.liquescentia) { case L_AUCTUS_ASCENDENS: case L_AUCTUS_DESCENDENS: case L_AUCTUS_ASCENDENS_INITIO_DEBILIS: case L_AUCTUS_DESCENDENS_INITIO_DEBILIS: - note->shape = S_ORISCUS_AUCTUS; + note->u.note.shape = S_ORISCUS_AUCTUS; break; case L_DEMINUTUS: case L_DEMINUTUS_INITIO_DEBILIS: - note->shape = S_ORISCUS_DEMINUTUS; + note->u.note.shape = S_ORISCUS_DEMINUTUS; break; default: break; @@ -322,13 +333,12 @@ void gregorio_add_liquescentia(gregorio_note *note, char liq) } void -gregorio_add_h_episemus(gregorio_note *note, unsigned char type, +gregorio_add_h_episemus(gregorio_note *note, gregorio_h_episemus type, unsigned int *nbof_isolated_episemus) { if (!note || (note->type != GRE_NOTE && note->type != GRE_BAR)) { - gregorio_message(_ - ("trying to add an horizontal episemus on something that is not a note"), - "add_h_episemus", ERROR, 0); + gregorio_message(_("trying to add an horizontal episemus on something " + "that is not a note"), "add_h_episemus", ERROR, 0); return; } if (!nbof_isolated_episemus) { @@ -351,12 +361,11 @@ gregorio_add_h_episemus(gregorio_note *note, unsigned char type, } // a helper function -void gregorio_set_h_episemus(gregorio_note *note, unsigned char type) +void gregorio_set_h_episemus(gregorio_note *note, gregorio_h_episemus type) { if (!note || (note->type != GRE_NOTE && note->type != GRE_BAR)) { - gregorio_message(_ - ("trying to add an horizontal episemus on something that is not a note"), - "set_h_episemus", ERROR, 0); + gregorio_message(_("trying to add an horizontal episemus on something " + "that is not a note"), "set_h_episemus", ERROR, 0); return; } if (type == H_BOTTOM) { @@ -366,7 +375,7 @@ void gregorio_set_h_episemus(gregorio_note *note, unsigned char type) } } -void gregorio_add_sign(gregorio_note *note, char sign) +void gregorio_add_sign(gregorio_note *note, gregorio_sign sign) { if (!note) { // error @@ -423,11 +432,16 @@ void gregorio_go_to_first_note(gregorio_note **note) *note = tmp; } +static inline void free_one_note(gregorio_note *note) +{ + free(note->texverb); + free(note->choral_sign); + free(note); +} + void gregorio_free_one_note(gregorio_note **note) { gregorio_note *next = NULL; - free((*note)->texverb); - free((*note)->choral_sign); if (!note || !*note) { return; } @@ -438,7 +452,7 @@ void gregorio_free_one_note(gregorio_note **note) if ((*note)->previous) { (*note)->previous->next = NULL; } - free(*note); + free_one_note(*note); *note = next; } @@ -447,56 +461,80 @@ void gregorio_free_notes(gregorio_note **note) gregorio_note *tmp; while (*note) { tmp = (*note)->next; - free(*note); + free_one_note(*note); *note = tmp; } } -void -gregorio_add_glyph(gregorio_glyph **current_glyph, char type, - gregorio_note *first_note, char liquescentia) +static gregorio_glyph *create_and_link_glyph(gregorio_glyph **current_glyph) { - gregorio_glyph *next_glyph = malloc(sizeof(gregorio_glyph)); - if (!next_glyph) { + gregorio_glyph *glyph = calloc(1, sizeof(gregorio_glyph)); + if (!glyph) { gregorio_message(_("error in memory allocation"), - "add_glyph", FATAL_ERROR, 0); - return; + "create_and_link_glyph", FATAL_ERROR, 0); + return NULL; } - next_glyph->type = GRE_GLYPH; - next_glyph->glyph_type = type; - next_glyph->liquescentia = liquescentia; - next_glyph->first_note = first_note; - next_glyph->next = NULL; - next_glyph->texverb = NULL; - next_glyph->previous = *current_glyph; + + glyph->previous = *current_glyph; + glyph->next = NULL; if (*current_glyph) { - (*current_glyph)->next = next_glyph; + (*current_glyph)->next = glyph; } - *current_glyph = next_glyph; + *current_glyph = glyph; + + return glyph; } void -gregorio_add_special_as_glyph(gregorio_glyph **current_glyph, - gregorio_type type, char pitch, - char additional_infos, char *texverb) +gregorio_add_glyph(gregorio_glyph **current_glyph, gregorio_glyph_type type, + gregorio_note *first_note, + gregorio_liquescentia liquescentia) { - gregorio_glyph *next_glyph = malloc(sizeof(gregorio_glyph)); - if (!next_glyph) { - gregorio_message(_("error in memory allocation"), - "add_special_as_glyph", FATAL_ERROR, 0); - return; + gregorio_glyph *next_glyph = create_and_link_glyph(current_glyph); + if (next_glyph) { + next_glyph->type = GRE_GLYPH; + next_glyph->u.notes.glyph_type = type; + next_glyph->u.notes.liquescentia = liquescentia; + next_glyph->u.notes.first_note = first_note; } - next_glyph->type = type; - next_glyph->glyph_type = pitch; - next_glyph->liquescentia = additional_infos; - next_glyph->first_note = NULL; - next_glyph->next = NULL; - next_glyph->texverb = texverb; - next_glyph->previous = *current_glyph; - if (*current_glyph) { - (*current_glyph)->next = next_glyph; +} + +void +gregorio_add_pitched_element_as_glyph(gregorio_glyph **current_glyph, + gregorio_type type, char pitch, + bool flatted_key, char *texverb) +{ + gregorio_glyph *next_glyph = create_and_link_glyph(current_glyph); + assert(type == GRE_C_KEY_CHANGE || type == GRE_F_KEY_CHANGE + || type == GRE_C_KEY_CHANGE_FLATED || type == GRE_F_KEY_CHANGE_FLATED + || type == GRE_CUSTO || type == GRE_FLAT || type == GRE_NATURAL + || type == GRE_SHARP); + if (next_glyph) { + next_glyph->type = type; + next_glyph->u.misc.pitched.pitch = pitch; + next_glyph->u.misc.pitched.flatted_key = flatted_key; + next_glyph->texverb = texverb; + } +} + +void +gregorio_add_unpitched_element_as_glyph(gregorio_glyph **current_glyph, + gregorio_type type, + gregorio_extra_info info, + gregorio_sign sign, char *texverb) +{ + gregorio_glyph *next_glyph = create_and_link_glyph(current_glyph); + assert(type != GRE_NOTE && type != GRE_GLYPH && type != GRE_ELEMENT + && type != GRE_C_KEY_CHANGE && type != GRE_F_KEY_CHANGE + && type != GRE_C_KEY_CHANGE_FLATED && type != GRE_F_KEY_CHANGE_FLATED + && type != GRE_CUSTO && type != GRE_FLAT && type != GRE_NATURAL + && type != GRE_SHARP); + if (next_glyph) { + next_glyph->type = type; + next_glyph->u.misc.unpitched.info = info; + next_glyph->u.misc.unpitched.special_sign = sign; + next_glyph->texverb = texverb; } - *current_glyph = next_glyph; } void gregorio_go_to_first_glyph(gregorio_glyph **glyph) @@ -512,6 +550,15 @@ void gregorio_go_to_first_glyph(gregorio_glyph **glyph) *glyph = tmp; } +static inline void free_one_glyph(gregorio_glyph *glyph) +{ + free(glyph->texverb); + if (glyph->type == GRE_GLYPH) { + gregorio_free_notes(&glyph->u.notes.first_note); + } + free(glyph); +} + void gregorio_free_one_glyph(gregorio_glyph **glyph) { gregorio_glyph *next = NULL; @@ -525,9 +572,7 @@ void gregorio_free_one_glyph(gregorio_glyph **glyph) if ((*glyph)->previous) { (*glyph)->previous->next = NULL; } - free((*glyph)->texverb); - gregorio_free_notes(&(*glyph)->first_note); - free(*glyph); + free_one_glyph(*glyph); *glyph = next; } @@ -539,69 +584,78 @@ void gregorio_free_glyphs(gregorio_glyph **glyph) } while (*glyph) { next_glyph = (*glyph)->next; - gregorio_free_notes(&(*glyph)->first_note); - free(*glyph); + free_one_glyph(*glyph); *glyph = next_glyph; } } -void -gregorio_add_element(gregorio_element **current_element, - gregorio_glyph *first_glyph) +static gregorio_element *create_and_link_element(gregorio_element + **current_element) { - gregorio_element *next = malloc(sizeof(gregorio_element)); - if (!next) { + gregorio_element *element = calloc(1, sizeof(gregorio_element)); + if (!element) { gregorio_message(_("error in memory allocation"), - "add_element", FATAL_ERROR, 0); - return; + "create_and_link_element", FATAL_ERROR, 0); + return NULL; } - next->type = GRE_ELEMENT; - next->element_type = 0; - next->additional_infos = 0; - next->first_glyph = first_glyph; - next->previous = *current_element; - next->next = NULL; - next->texverb = NULL; + + element->previous = *current_element; + element->next = NULL; if (*current_element) { - (*current_element)->next = next; + (*current_element)->next = element; } - *current_element = next; + *current_element = element; + + return element; } void -gregorio_add_special_as_element(gregorio_element **current_element, - gregorio_type type, char pitch, - char additional_infos, char *texverb) +gregorio_add_element(gregorio_element **current_element, + gregorio_glyph *first_glyph) { - gregorio_element *special = malloc(sizeof(gregorio_element)); - if (!special) { - gregorio_message(_("error in memory allocation"), - "add_special_as_element", FATAL_ERROR, 0); - return; + gregorio_element *next = create_and_link_element(current_element); + if (next) { + next->type = GRE_ELEMENT; + next->u.glyphs.first_glyph = first_glyph; } - special->type = type; - special->element_type = pitch; - special->additional_infos = additional_infos; - special->first_glyph = NULL; - special->next = NULL; - special->texverb = texverb; - special->previous = *current_element; - if (*current_element) { - (*current_element)->next = special; +} + +void +gregorio_add_misc_element(gregorio_element **current_element, + gregorio_type type, gregorio_misc_element_info info, + char *texverb) +{ + gregorio_element *special = create_and_link_element(current_element); + if (special) { + special->type = type; + special->u.misc = info; + special->texverb = texverb; + } +} + +static inline void free_one_element(gregorio_element *element) +{ + free(element->texverb); + if (element->type == GRE_ELEMENT) { + gregorio_free_glyphs(&element->u.glyphs.first_glyph); } - *current_element = special; + free(element); } void gregorio_free_one_element(gregorio_element **element) { - gregorio_element *next; + gregorio_element *next = NULL; if (!element || !*element) { return; } - free((*element)->texverb); - next = (*element)->next; - gregorio_free_glyphs(&(*element)->first_glyph); - free(*element); + if ((*element)->next) { + (*element)->next->previous = NULL; + next = (*element)->next; + } + if ((*element)->previous) { + (*element)->previous->next = NULL; + } + free_one_element(*element); *element = next; } @@ -613,8 +667,7 @@ void gregorio_free_elements(gregorio_element **element) } while (*element) { next = (*element)->next; - gregorio_free_glyphs(&(*element)->first_glyph); - free(*element); + free_one_element(*element); *element = next; } } @@ -650,7 +703,7 @@ gregorio_add_character(gregorio_character **current_character, grewchar wcharacter) { gregorio_character *element = - (gregorio_character *) malloc(sizeof(gregorio_character)); + (gregorio_character *) calloc(1, sizeof(gregorio_character)); if (!element) { gregorio_message(_("error in memory allocation"), "gregorio_add_character", FATAL_ERROR, 0); @@ -702,7 +755,7 @@ gregorio_begin_style(gregorio_character **current_character, grestyle_style style) { gregorio_character *element = - (gregorio_character *) malloc(sizeof(gregorio_character)); + (gregorio_character *) calloc(1, sizeof(gregorio_character)); if (!element) { gregorio_message(_("error in memory allocation"), "add_note", FATAL_ERROR, 0); @@ -723,7 +776,7 @@ void gregorio_end_style(gregorio_character **current_character, grestyle_style style) { gregorio_character *element = - (gregorio_character *) malloc(sizeof(gregorio_character)); + (gregorio_character *) calloc(1, sizeof(gregorio_character)); if (!element) { gregorio_message(_("error in memory allocation"), "add_note", FATAL_ERROR, 0); @@ -756,14 +809,14 @@ gregorio_add_syllable(gregorio_syllable **current_syllable, gregorio_message(_("too many voices"), "add_syllable", FATAL_ERROR, 0); return; } - next = malloc(sizeof(gregorio_syllable)); + next = calloc(1, sizeof(gregorio_syllable)); if (!next) { gregorio_message(_("error in memory allocation"), "add_syllable", FATAL_ERROR, 0); return; } next->type = GRE_SYLLABLE; - next->additional_infos = 0; + next->special_sign = _NO_SIGN; next->position = position; next->no_linebreak_area = no_linebreak_area; next->text = first_character; @@ -831,7 +884,7 @@ void gregorio_free_syllables(gregorio_syllable **syllable, int number_of_voices) gregorio_score *gregorio_new_score(void) { - gregorio_score *new_score = malloc(sizeof(gregorio_score)); + gregorio_score *new_score = calloc(1, sizeof(gregorio_score)); new_score->first_syllable = NULL; new_score->number_of_voices = 1; new_score->name = NULL; @@ -1020,9 +1073,9 @@ void gregorio_set_score_user_notes(gregorio_score *score, char *user_notes) void gregorio_add_voice_info(gregorio_voice_info **current_voice_info) { int annotation_num; - gregorio_voice_info *next = malloc(sizeof(gregorio_voice_info)); + gregorio_voice_info *next = calloc(1, sizeof(gregorio_voice_info)); next->initial_key = NO_KEY; - next->flatted_key = NO_FLAT_KEY; + next->flatted_key = false; for (annotation_num = 0; annotation_num < NUM_ANNOTATIONS; ++annotation_num) { next->annotation[annotation_num] = NULL; } @@ -1294,7 +1347,7 @@ void gregorio_activate_isolated_h_episemus(gregorio_note *current_note, int n) * we make the first iteration by hand,in the case where something would be * in highest_pitch */ - top_note = current_note->pitch; + top_note = current_note->u.note.pitch; tmp = tmp->previous; if (!tmp) { // case of b___ @@ -1303,12 +1356,12 @@ void gregorio_activate_isolated_h_episemus(gregorio_note *current_note, int n) "activate_h_isolated_episemus", WARNING, 0); return; } - top_note = max(top_note, tmp->pitch); + top_note = max(top_note, tmp->u.note.pitch); for (i = 0; i < n - 1; i++) { - top_note = max(top_note, tmp->pitch); + top_note = max(top_note, tmp->u.note.pitch); if (tmp->previous && tmp->previous->type == GRE_NOTE) { tmp = tmp->previous; - top_note = max(top_note, tmp->pitch); + top_note = max(top_note, tmp->u.note.pitch); } else { gregorio_message(_ ("found more horizontal episemus than notes able to be under"), @@ -1320,7 +1373,7 @@ void gregorio_activate_isolated_h_episemus(gregorio_note *current_note, int n) // the top note. TODO: we should consider also the next note, but we cannot // do it at this stage. if (tmp->previous && tmp->previous->type == GRE_NOTE) { - top_note = max(top_note, tmp->previous->pitch); + top_note = max(top_note, tmp->previous->u.note.pitch); } while (tmp) { gregorio_set_h_episemus(tmp, H_MULTI); @@ -1382,12 +1435,13 @@ void gregorio_determine_good_bottom_notes(gregorio_note *current_note) return; } prev_note = current_note->previous; - current_note->h_episemus_bottom_note = current_note->pitch; + if (current_note->type == GRE_NOTE) { + current_note->h_episemus_bottom_note = current_note->u.note.pitch; + } if (!prev_note) { return; } - if (prev_note->type == GRE_SPACE && prev_note->pitch == SP_ZERO_WIDTH - && prev_note->previous) { + if (prev_note->type == GRE_SPACE && prev_note->previous) { prev_note = prev_note->previous; if (!prev_note || !has_bottom(prev_note->h_episemus_type)) { return; @@ -1404,9 +1458,7 @@ void gregorio_determine_good_bottom_notes(gregorio_note *current_note) bottom_note = current_note->h_episemus_bottom_note; while (prev_note) { if (!has_bottom(prev_note->h_episemus_type)) { - if (prev_note->type == GRE_SPACE - && prev_note->pitch == SP_ZERO_WIDTH - && prev_note->previous) { + if (prev_note->type == GRE_SPACE && prev_note->previous) { prev_note = prev_note->previous; continue; } else { @@ -1446,10 +1498,14 @@ void gregorio_mix_h_episemus(gregorio_note *current_note, unsigned char type) current_note->h_episemus_top_note = 0; } else { if (prev_note && prev_note->type == GRE_NOTE) { - current_note->h_episemus_top_note = - max(prev_note->pitch, current_note->pitch); - } else { - current_note->h_episemus_top_note = current_note->pitch; + if (current_note->type == GRE_NOTE) { + current_note->h_episemus_top_note = + max(prev_note->u.note.pitch, current_note->u.note.pitch); + } else { + current_note->h_episemus_top_note = prev_note->u.note.pitch; + } + } else if (current_note->type == GRE_NOTE) { + current_note->h_episemus_top_note = current_note->u.note.pitch; } if (!prev_note || prev_note->type != GRE_NOTE || simple_htype(prev_note->h_episemus_type) == H_NO_EPISEMUS) { @@ -1708,8 +1764,9 @@ char if (glyph) { glyph = glyph->next; while (glyph) { - if (glyph->type == GRE_GLYPH && glyph->first_note) { - return glyph->first_note->pitch; + if (glyph->type == GRE_GLYPH && glyph->u.notes.first_note) { + assert(glyph->u.notes.first_note->type == GRE_NOTE); + return glyph->u.notes.first_note->u.note.pitch; } glyph = glyph->next; } @@ -1717,11 +1774,12 @@ char // then we do the same with the elements element = element->next; while (element) { - if (element->type == GRE_ELEMENT && element->first_glyph) { - glyph = element->first_glyph; + if (element->type == GRE_ELEMENT && element->u.glyphs.first_glyph) { + glyph = element->u.glyphs.first_glyph; while (glyph) { - if (glyph->type == GRE_GLYPH && glyph->first_note) { - return glyph->first_note->pitch; + if (glyph->type == GRE_GLYPH && glyph->u.notes.first_note) { + assert(glyph->u.notes.first_note->type == GRE_NOTE); + return glyph->u.notes.first_note->u.note.pitch; } glyph = glyph->next; } @@ -1756,10 +1814,10 @@ gregorio_glyph *gregorio_first_glyph(gregorio_syllable *syllable) } element = syllable->elements[0]; while (element) { - if (element->type == GRE_ELEMENT && element->first_glyph) { - glyph = element->first_glyph; + if (element->type == GRE_ELEMENT && element->u.glyphs.first_glyph) { + glyph = element->u.glyphs.first_glyph; while (glyph) { - if (glyph->type == GRE_GLYPH && glyph->first_note) { + if (glyph->type == GRE_GLYPH && glyph->u.notes.first_note) { return glyph; } glyph = glyph->next; @@ -1777,7 +1835,8 @@ char gregorio_syllable_first_note(gregorio_syllable *syllable) if (glyph == NULL) { return 0; } else { - return glyph->first_note->pitch; + assert(glyph->u.notes.first_note->type == GRE_NOTE); + return glyph->u.notes.first_note->u.note.pitch; } } @@ -1861,32 +1920,24 @@ void gregorio_fix_initial_keys(gregorio_score *score, int default_key) } if (element->type == GRE_C_KEY_CHANGE) { clef = - gregorio_calculate_new_key(C_KEY, element->element_type - 48); + gregorio_calculate_new_key(C_KEY, + element->u.misc.pitched.pitch - '0'); voice_info->initial_key = clef; - if (element->additional_infos == FLAT_KEY) { - voice_info->flatted_key = FLAT_KEY; - } + voice_info->flatted_key = element->u.misc.pitched.flatted_key; gregorio_free_one_element(&(score->first_syllable->elements[i])); - voice_info = voice_info->next_voice_info; - snprintf(error, 80, - _ - ("in voice %d the first element is a key definition, considered as initial key"), + snprintf(error, 80, _("in voice %d the first element is a key " + "definition, considered as initial key"), i + 1); gregorio_message(error, "gregorio_fix_initial_keys", VERBOSE, 0); - - continue; - } - if (element->type == GRE_F_KEY_CHANGE) { + } else if (element->type == GRE_F_KEY_CHANGE) { clef = - gregorio_calculate_new_key(F_KEY, element->element_type - 48); + gregorio_calculate_new_key(F_KEY, + element->u.misc.pitched.pitch - '0'); voice_info->initial_key = clef; - if (element->additional_infos == FLAT_KEY) { - voice_info->flatted_key = FLAT_KEY; - } + voice_info->flatted_key = element->u.misc.pitched.flatted_key; gregorio_free_one_element(&(score->first_syllable->elements[i])); - snprintf(error, 80, - _ - ("in voice %d the first element is a key definition, considered as initial key"), + snprintf(error, 80, _("in voice %d the first element is a key " + "definition, considered as initial key"), i + 1); gregorio_message(error, "gregorio_fix_initial_keys", VERBOSE, 0); } diff --git a/src/struct.h b/src/struct.h index 29c311468..96ef81248 100644 --- a/src/struct.h +++ b/src/struct.h @@ -109,113 +109,149 @@ typedef enum gregorio_shape { S_LINEA, } gregorio_shape; -/* - * ! We start with the most precise structure, the note structure. The - * note is always a real note (we'll see that glyphs and elements can be - * other things). - */ -typedef struct gregorio_note { - // we have seen that notes are always real notes, that is to say - // GRE_NOTE. the type is always that in the final structure. But there - // is however this field in the structure because of the temporary - // states that can appear in the determination, where notes can be - // other things. This is the case for example in gabc reading. - ENUM_BITFIELD(gregorio_type) type:8; - // then two pointer to other notes, to make a chained list. - struct gregorio_note *previous; - struct gregorio_note *next; - // / the pitch is the height of the note on the score, that is to say - // the letter it is represented by in gabc. - char pitch; - // shape is the shape of the note... if you want to know the different - // possible shapes, see above. - ENUM_BITFIELD(gregorio_shape) shape:8; - // signs is the signs on the notes, see below for all possible values - char signs; - // rare_sign is the sign we sometimes encounter on punctum cavum, like - // accentus, semi-circulus, etc. can also be the ictus - char rare_sign; - // choral sign is a letter that appears next to a note in some choral - // scores - // we put it as char* because sometimes two letters appear - char *choral_sign; - // liquescentia is the liquescence on the note, it is not really used - // in the final score, but it is, like type, used in the determination - // of glyphs. - char liquescentia; - // h_episemus_type is the type of horizontal episemus, possible values - // are H_ALONE for an isolated horizontal episemus, H_MULTI_BEGINNING - // if the note is the first note of an episemus on several notes, - // H_MULTI_MIDDLE if it is inside an episemus on several notes. I let - // you guess what could be the use of H_MULTI_END. Other values are - // temporary values used in determination, they must not appear in the - // final structure. - unsigned char h_episemus_type; - // h_episemus_top_note is the highest pitch of the notes that are - // under the same horizontal episemus of the note. If the note is not - // under an episemus, it is 0. - char h_episemus_top_note; - // same for bottom_note - char h_episemus_bottom_note; - // a string containing a possible TeX verbatim; necessary during - // structure generation. - char *texverb; -} gregorio_note; +// the different kind of bars -/* - * ! @brief The gregorio glyph structure Unlike gregorio_note, - * gregorio_glyph can be other things besides \c GRE_GLYPH: it can also be - * \c GRE_FLAT, \c GRE_NATURAL or \c GRE_SPACE - */ -typedef struct gregorio_glyph { - // type can have the values explained in the comment just above. - ENUM_BITFIELD(gregorio_type) type:8; - // two pointer to make a chained list - struct gregorio_glyph *previous; - struct gregorio_glyph *next; - // in the case of a GRE_GLYPH, glyph_type is the type of the glyph - // (porrectus, pes, etc.), they are all listed below. If it is a - // GRE_FLAT or a GRE_NATURAL, it is the height of the flat or natural - // that will be represented. If it is GRE_SPACE, it is the kind of - // space it is (they are listed below). As a matter of fact, a - // GRE_SPACE in a gregorio_glyph can have only one value: - // SP_ZERO_WIDTH, as other spaces would break the glyphs into - // different elements. - char glyph_type; - // liquescentia is really used, because that will determine the shape - // we will have to use. - // it may also contain additional informations (a bit hacky) - char liquescentia; - // a pointer to a (chained list of) gregorio_notes, the first of the - // glyph. - struct gregorio_note *first_note; - // a string containing a possible TeX verbatim; necessary during - // structure generation. - char *texverb; -} gregorio_glyph; +typedef enum gregorio_bar { + B_NO_BAR = 0, + B_VIRGULA, + B_DIVISIO_MINIMA, + B_DIVISIO_MINOR, + B_DIVISIO_MAIOR, + B_DIVISIO_FINALIS, + B_DIVISIO_MINOR_D1, + B_DIVISIO_MINOR_D2, + B_DIVISIO_MINOR_D3, + B_DIVISIO_MINOR_D4, + B_DIVISIO_MINOR_D5, + B_DIVISIO_MINOR_D6, +} gregorio_bar; -typedef struct gregorio_element { - // type can have the values GRE_ELEMENT, GRE_BAR, GRE_C_KEY_CHANGE, - // GRE_F_KEY_CHANGE, GRE_END_OF_LINE, GRE_SPACE, GRE_TEXVERB_ELEMENT - // or GRE_NLBA - ENUM_BITFIELD(gregorio_type) type:8; - // pointers to the next and previous elements. - struct gregorio_element *previous; - struct gregorio_element *next; - // in the case of a GRE_ELEMENT, element_type is the kind of element - // it is (but it is very blur.. don't watch this value). In the case - // of a GRE_BAR it is the type of bar (listed below). If it is - // GRE_*_KEY_CHANGE, it is 0. If it is GRE_SPACE, it is the kind of - // space (it can't be SP_ZERO_WIDTH). - char element_type; - // contain additional informations, like for example bar signs, or if - // the key has a flat or not - char additional_infos; - // a pointer to the first glyph of the element. - struct gregorio_glyph *first_glyph; - // a string containing a possible TeX verbatim. - char *texverb; -} gregorio_element; +// definition of the signs. You can notice that the values are made so +// that if you wan to add a vertical episemus to a note, you juste +// make note->signs+=_V_EPISEMUS, so please don't change the value as +// this tricky is used. + +typedef enum gregorio_sign { + _NO_SIGN = 0, + _PUNCTUM_MORA = 1, + _AUCTUM_DUPLEX = 2, + _V_EPISEMUS = 5, + _V_EPISEMUS_PUNCTUM_MORA = 6, + _V_EPISEMUS_AUCTUM_DUPLEX = 7, + // more rare signs, for now they can't be used with the others + _ACCENTUS = 8, + _ACCENTUS_REVERSUS = 9, + _CIRCULUS = 10, + _SEMI_CIRCULUS = 11, + _SEMI_CIRCULUS_REVERSUS = 12, + _ICTUS_A = 13, + _ICTUS_T = 14, + // signs of a bar + _V_EPISEMUS_ICTUS_A = 15, + _V_EPISEMUS_ICTUS_T = 16, + _V_EPISEMUS_H_EPISEMUS = 17, + _V_EPISEMUS_H_EPISEMUS_ICTUS_A = 18, + _V_EPISEMUS_H_EPISEMUS_ICTUS_T = 19, + _H_EPISEMUS_ICTUS_A = 20, + _H_EPISEMUS_ICTUS_T = 21, + _H_EPISEMUS = 22, +} gregorio_sign; + +// the different spaces + +typedef enum gregorio_space { + SP_DEFAULT = 1, + SP_NO_SPACE, + SP_ZERO_WIDTH, + SP_NEUMATIC_CUT, + SP_LARGER_SPACE, + SP_GLYPH_SPACE, + SP_NEUMATIC_CUT_NB, + SP_LARGER_SPACE_NB, + SP_GLYPH_SPACE_NB, +} gregorio_space; + +// the different liquescences, like for the signs, have special +// values: to say that something is initio_debilis, just do +// glyph->liquescentia+=L_INITIO_DEBILIS. So don't change the value, +// the tricky is much used + +typedef enum gregorio_liquescentia { + L_NO_LIQUESCENTIA = 0, + L_DEMINUTUS = 1, + L_AUCTUS_ASCENDENS = 2, + L_AUCTUS_DESCENDENS = 3, + L_AUCTA = 4, + L_INITIO_DEBILIS = 5, + L_DEMINUTUS_INITIO_DEBILIS = 6, + L_AUCTUS_ASCENDENS_INITIO_DEBILIS = 7, + L_AUCTUS_DESCENDENS_INITIO_DEBILIS = 8, + L_AUCTA_INITIO_DEBILIS = 9, +} gregorio_liquescentia; + +typedef enum gregorio_h_episemus { + H_NO_EPISEMUS = 0, + H_ONE = 1, + H_ALONE = 2, + H_MULTI = 3, + H_MULTI_BEGINNING = 4, + H_MULTI_MIDDLE = 5, + H_MULTI_END = 6, + H_UNDETERMINED = 7, + // this H_EPISEMUS can be mixed with another one: + H_BOTTOM = 16, +} gregorio_h_episemus; + +// The different types of glyph + +#define G_NO_GLYPH G_UNDETERMINED +#define G_PES G_PODATUS +#define G_FLEXUS G_FLEXA +typedef enum gregorio_glyph_type { + G_PUNCTUM_INCLINATUM = 1, + G_2_PUNCTA_INCLINATA_DESCENDENS, + G_3_PUNCTA_INCLINATA_DESCENDENS, + G_4_PUNCTA_INCLINATA_DESCENDENS, + G_5_PUNCTA_INCLINATA_DESCENDENS, + G_2_PUNCTA_INCLINATA_ASCENDENS, + G_3_PUNCTA_INCLINATA_ASCENDENS, + G_4_PUNCTA_INCLINATA_ASCENDENS, + G_5_PUNCTA_INCLINATA_ASCENDENS, + G_TRIGONUS, + G_PUNCTA_INCLINATA, + // !!! DO NOT CHANGE THE ENUM ORDERING BEFORE THIS LINE !!! + G_UNDETERMINED, + G_VIRGA, + G_STROPHA, + G_STROPHA_AUCTA, + G_PUNCTUM, + G_PODATUS, + G_PES_QUADRATUM, + G_FLEXA, + G_TORCULUS, + G_TORCULUS_RESUPINUS, + G_TORCULUS_RESUPINUS_FLEXUS, + G_PORRECTUS, + G_PORRECTUS_FLEXUS, + G_BIVIRGA, + G_TRIVIRGA, + G_DISTROPHA, + G_DISTROPHA_AUCTA, + G_TRISTROPHA, + G_TRISTROPHA_AUCTA, + G_PES_QUADRATUM_FIRST_PART, + G_SCANDICUS, + G_PES_QUILISMA_QUADRATUM_FIRST_PART, + G_PES_ORISCUS_QUADRATUM_FIRST_PART, + G_ANCUS, + G_ONE_NOTE, + G_PUNCTA_ASCENDENS, + G_PUNCTA_DESCENDENS, + G_VIRGA_REVERSA, + G_SALICUS, + G_SALICUS_FIRST_PART, + G_TORCULUS_LIQUESCENS, +} gregorio_glyph_type; /* * @@ -279,6 +315,166 @@ typedef enum gregorio_word_position { WORD_ONE_SYLLABLE, } gregorio_word_position; +// the centering schemes for gabc: +typedef enum gregorio_lyric_centering { + SCHEME_LATINE = 1, + SCHEME_ENGLISH, +} gregorio_lyric_centering; + +typedef struct gregorio_extra_info { + // the sub-type of GRE_END_OF_LINE + ENUM_BITFIELD(gregorio_type) sub_type:8; + ENUM_BITFIELD(gregorio_bar) bar:8; + ENUM_BITFIELD(gregorio_space) space:8; + ENUM_BITFIELD(gregorio_nlba) nlba:8; +} gregorio_extra_info; + +typedef union gregorio_misc_element_info { + // pitched is used for GRE_CUSTO, GRE_FLAT, GRE_SHARP, GRE_NATURAL, + // GRE_C_KEY_CHANGE, GRE_F_KEY_CHANGE, GRE_C_KEY_CHANGE_FLATED, and + // GRE_F_KEY_CHANGE_FLATED + struct { + // The pitch of the glyph for GRE_FLAT, GRE_NATURAL, GRE_SHARP. + // If a clef change, pitch will be a number indicating the line of + // the clef. + char pitch; + // boolean indicating a clef with a B-flat + bool flatted_key:1; + } pitched; + // unpitched is used for everything else + struct { + struct gregorio_extra_info info; + // an element might carry a sign. + ENUM_BITFIELD(gregorio_sign) special_sign:8; + } unpitched; +} gregorio_misc_element_info; + +/* + * ! We start with the most precise structure, the note structure. The + * note is always a real note (we'll see that glyphs and elements can be + * other things). + */ +typedef struct gregorio_note { + // then two pointer to other notes, to make a chained list. + struct gregorio_note *previous; + struct gregorio_note *next; + // choral sign is a letter that appears next to a note in some choral + // scores we put it as char* because sometimes two letters appear + char *choral_sign; + // a string containing a possible TeX verbatim; necessary during + // structure generation. + char *texverb; + union { + // note is used for GRE_NOTE, GRE_FLAT, GRE_SHARP, GRE_NATURAL, + // GRE_C_KEY_CHANGE, GRE_F_KEY_CHANGE, GRE_C_KEY_CHANGE_FLATED, and + // GRE_F_KEY_CHANGE_FLATED + struct { + // the pitch is the height of the note on the score, that is to + // say the letter it is represented by in gabc. If a clef + // change, pitch will be a number indicating the line of the clef. + char pitch; + // shape is the shape of the note... if you want to know the + // different possible shapes, see above. + ENUM_BITFIELD(gregorio_shape) shape:8; + // liquescentia is the liquescence on the note, it is not really + // used in the final score, but it is, like type, used in the + // determination of glyphs. + ENUM_BITFIELD(gregorio_liquescentia) liquescentia:8; + } note; + // other is used for everything else + struct gregorio_extra_info other; + } u; + + //// characters go to the end for structure alignment + + // we have seen that notes are always real notes, that is to say + // GRE_NOTE. the type is always that in the final structure. But there + // is however this field in the structure because of the temporary + // states that can appear in the determination, where notes can be + // other things. This is the case for example in gabc reading. + ENUM_BITFIELD(gregorio_type) type:8; + // signs is the signs on the notes, see above for all possible values + ENUM_BITFIELD(gregorio_sign) signs:8; + // special_sign is the sign we sometimes encounter on punctum cavum, like + // accentus, semi-circulus, etc. can also be the ictus + // h_episemus_type is the type of horizontal episemus, possible values + // are H_ALONE for an isolated horizontal episemus, H_MULTI_BEGINNING + // if the note is the first note of an episemus on several notes, + // H_MULTI_MIDDLE if it is inside an episemus on several notes. I let + // you guess what could be the use of H_MULTI_END. Other values are + // temporary values used in determination, they must not appear in the + // final structure. + ENUM_BITFIELD(gregorio_h_episemus) h_episemus_type; + // h_episemus_top_note is the highest pitch of the notes that are + // under the same horizontal episemus of the note. If the note is not + // under an episemus, it is 0. + char h_episemus_top_note; + // same for bottom_note + char h_episemus_bottom_note; + ENUM_BITFIELD(gregorio_sign) special_sign:8; +} gregorio_note; + +/* + * ! @brief The gregorio glyph structure Unlike gregorio_note, + * gregorio_glyph can be other things besides \c GRE_GLYPH: it can also be + * \c GRE_FLAT, \c GRE_NATURAL or \c GRE_SPACE + */ +typedef struct gregorio_glyph { + // two pointer to make a chained list + struct gregorio_glyph *previous; + struct gregorio_glyph *next; + // a string containing a possible TeX verbatim; necessary during structure + // generation. + char *texverb; + union { + // glyph is used for GRE_GLYPH + struct { + // a pointer to a (chained list of) gregorio_notes, the first of + // the glyph. + struct gregorio_note *first_note; + // The glyph type for a GRE_GLYPH (porrectus, pes, etc.). They + // are all listed above. + ENUM_BITFIELD(gregorio_glyph_type) glyph_type:8; + // liquescentia is really used, because that will determine the + // shape we will have to use. + ENUM_BITFIELD(gregorio_liquescentia) liquescentia:8; + } notes; + union gregorio_misc_element_info misc; + } u; + + //// characters go to the end for structure alignment + + // type can have the values explained in the comment just above. + ENUM_BITFIELD(gregorio_type) type:8; + + // There is no additional parameter for GRE_SPACE in a gregorio_glyph + // because gregorio_space in this case can have only one value: + // SP_ZERO_WIDTH, as other spaces would break the glyphs into + // different elements. +} gregorio_glyph; + +typedef struct gregorio_element { + // pointers to the next and previous elements. + struct gregorio_element *previous; + struct gregorio_element *next; + // a string containing a possible TeX verbatim; necessary during structure + // generation. + char *texverb; + union { + // element is used for GRE_ELEMENT + struct { + // a pointer to the first glyph of the element. + struct gregorio_glyph *first_glyph; + } glyphs; + union gregorio_misc_element_info misc; + } u; + + // type can have the values GRE_ELEMENT, GRE_BAR, GRE_C_KEY_CHANGE, + // GRE_F_KEY_CHANGE, GRE_END_OF_LINE, GRE_SPACE, GRE_TEXVERB_ELEMENT + // or GRE_NLBA + ENUM_BITFIELD(gregorio_type) type:8; +} gregorio_element; + /* * * gregorio_characters are a bit specials. As there can be styles in the @@ -308,7 +504,7 @@ typedef enum gregorio_word_position { typedef struct gregorio_style { ENUM_BITFIELD(grestyle_style) style:8; - ENUM_BITFIELD(grestyle_type) type:8; + ENUM_BITFIELD(grestyle_type) type:8; } gregorio_style; /* @@ -349,13 +545,13 @@ typedef struct gregorio_syllable { // position is WORD_BEGINNING for the beginning of a multi-syllable // word, WORD_ONE_SYLLABLE for syllable that are alone in their word, // and i let you gess what are WORD_MIDDLE and WORD_END. - ENUM_BITFIELD(gregorio_word_position) position:8; + ENUM_BITFIELD(gregorio_word_position) position:8; // again, an additional field to put some signs or other things... - char additional_infos; + ENUM_BITFIELD(gregorio_sign) special_sign:8; // type of translation (with center beginning or only center end) - ENUM_BITFIELD(gregorio_tr_centering) translation_type; + ENUM_BITFIELD(gregorio_tr_centering) translation_type:8; // beginning or end of area without linebreak? - ENUM_BITFIELD(gregorio_nlba) no_linebreak_area:8; + ENUM_BITFIELD(gregorio_nlba) no_linebreak_area:8; // pointer to a gregorio_text structure corresponding to the text. struct gregorio_character *text; // pointer to a gregorio_text structure corresponding to the @@ -456,13 +652,13 @@ typedef struct gregorio_voice_info { // special representation for the key. See comments on // src/struct-utils.c for further reading. int initial_key; - char flatted_key; // There is one annotation for each line above the initial letter char *annotation[NUM_ANNOTATIONS]; // See source_info above for comments about the move of author etc. char *style; char *virgula_position; struct gregorio_voice_info *next_voice_info; + bool flatted_key; } gregorio_voice_info; gregorio_score *gregorio_new_score(void); @@ -475,10 +671,11 @@ void gregorio_mix_h_episemus(gregorio_note *current_note, unsigned char type); gregorio_shape gregorio_det_shape(char pitch); void gregorio_add_note(gregorio_note **current_note, char pitch, - gregorio_shape shape, char signs, char liquescentia, - char h_episemus); -void gregorio_add_glyph(gregorio_glyph **current_glyph, char type, - gregorio_note *first_note, char liquescentia); + gregorio_shape shape, gregorio_sign signs, + gregorio_liquescentia liquescentia, char h_episemus); +void gregorio_add_glyph(gregorio_glyph **current_glyph, gregorio_glyph_type type, + gregorio_note *first_note, + gregorio_liquescentia liquescentia); void gregorio_add_element(gregorio_element **current_element, gregorio_glyph *first_glyph); void gregorio_add_syllable(gregorio_syllable **current_syllable, @@ -492,13 +689,14 @@ void gregorio_add_syllable(gregorio_syllable **current_syllable, gregorio_nlba no_linebreak_area); void gregorio_set_signs(gregorio_note *current_note, char signs); -void gregorio_add_special_sign(gregorio_note *current_note, char sign); +void gregorio_add_special_sign(gregorio_note *current_note, gregorio_sign sign); void gregorio_change_shape(gregorio_note *note, gregorio_shape shape); -void gregorio_add_h_episemus(gregorio_note *note, unsigned char type, +void gregorio_add_h_episemus(gregorio_note *note, gregorio_h_episemus type, unsigned int *nbof_isolated_episemus); -void gregorio_set_h_episemus(gregorio_note *note, unsigned char type); -void gregorio_add_sign(gregorio_note *note, char sign); -void gregorio_add_liquescentia(gregorio_note *note, char liquescentia); +void gregorio_set_h_episemus(gregorio_note *note, gregorio_h_episemus type); +void gregorio_add_sign(gregorio_note *note, gregorio_sign sign); +void gregorio_add_liquescentia(gregorio_note *note, + gregorio_liquescentia liquescentia); void gregorio_add_voice_info(gregorio_voice_info **current_voice_info); @@ -522,19 +720,34 @@ void gregorio_go_to_first_character(gregorio_character **character); void gregorio_add_text(char *mbcharacters, gregorio_character **current_character); -void gregorio_add_special_as_glyph(gregorio_glyph **current_glyph, - gregorio_type type, char pitch, - char additional_infos, char *texverb); -void gregorio_add_special_as_note(gregorio_note **current_note, - gregorio_type type, char pitch); +void gregorio_add_pitched_element_as_glyph(gregorio_glyph **current_glyph, + gregorio_type type, char pitch, + bool flatted_key, char *texverb); +void gregorio_add_unpitched_element_as_glyph(gregorio_glyph **current_glyph, + gregorio_type type, + gregorio_extra_info info, + gregorio_sign sign, char *texverb); + +void gregorio_add_end_of_line_as_note(gregorio_note **current_note, + gregorio_type sub_type); +void gregorio_add_custo_as_note(gregorio_note **current_note); +void gregorio_add_clef_change_as_note(gregorio_note **current_note, + gregorio_type type, char clef_line); +void gregorio_add_bar_as_note(gregorio_note **current_note, gregorio_bar bar); +void gregorio_add_alteration_as_note(gregorio_note **current_note, + gregorio_type type, char pitch); +void gregorio_add_space_as_note(gregorio_note **current_note, + gregorio_space space); +// void gregorio_add_special_as_note(gregorio_note **current_note, +// gregorio_type type, char pitch); void gregorio_add_texverb_as_note(gregorio_note **current_note, char *str, gregorio_type type); -void gregorio_add_nlba_as_note(gregorio_note **current_note, char type); +void gregorio_add_nlba_as_note(gregorio_note **current_note, gregorio_nlba type); void gregorio_add_texverb_to_note(gregorio_note **current_note, char *str); void gregorio_add_cs_to_note(gregorio_note **current_note, char *str); -void gregorio_add_special_as_element(gregorio_element **current_element, - gregorio_type type, char pitch, - char additional_infos, char *texverb); +void gregorio_add_misc_element(gregorio_element **current_element, + gregorio_type type, + gregorio_misc_element_info info, char *texverb); void gregorio_determine_good_top_notes(gregorio_note *current_note); void gregorio_determine_good_bottom_notes(gregorio_note *current_note); @@ -582,8 +795,6 @@ void gregorio_set_voice_style(gregorio_voice_info *voice_info, char *style); void gregorio_set_voice_virgula_position(gregorio_voice_info *voice_info, char *virgula_position); -void gregorio_set_voice_annotation(gregorio_voice_info *voice_info, - char *annotation); void gregorio_fix_initial_keys(gregorio_score *score, int default_key); @@ -616,8 +827,8 @@ gregorio_set_octave_and_step_from_pitch(char *step, #define F_KEY 'f' #define NO_KEY -5 #define DEFAULT_KEY 5 -#define FLAT_KEY 25 -#define NO_FLAT_KEY 0 +//#define FLAT_KEY 25 +//#define NO_FLAT_KEY 0 #define MONOPHONY 0 @@ -633,46 +844,6 @@ gregorio_set_octave_and_step_from_pitch(char *step, #define USELESS_VALUE 0 -// definition of the signs. You can notice that the values are made so -// that if you wan to add a vertical episemus to a note, you juste -// make note->signs+=_V_EPISEMUS, so please don't change the value as -// this tricky is used. - -#define _NO_SIGN 0 -#define _PUNCTUM_MORA 1 -#define _AUCTUM_DUPLEX 2 -#define _V_EPISEMUS 5 -#define _V_EPISEMUS_PUNCTUM_MORA 6 -#define _V_EPISEMUS_AUCTUM_DUPLEX 7 -// more rare signs, for now they can't be used with the others -#define _ACCENTUS 8 -#define _ACCENTUS_REVERSUS 9 -#define _CIRCULUS 10 -#define _SEMI_CIRCULUS 11 -#define _SEMI_CIRCULUS_REVERSUS 12 -#define _ICTUS_A 13 -#define _ICTUS_T 14 -// signs of a bar -#define _V_EPISEMUS_ICTUS_A 15 -#define _V_EPISEMUS_ICTUS_T 16 -#define _V_EPISEMUS_H_EPISEMUS 17 -#define _V_EPISEMUS_H_EPISEMUS_ICTUS_A 18 -#define _V_EPISEMUS_H_EPISEMUS_ICTUS_T 19 -#define _H_EPISEMUS_ICTUS_A 20 -#define _H_EPISEMUS_ICTUS_T 21 -#define _H_EPISEMUS 22 - -#define H_NO_EPISEMUS 0 -#define H_ONE 1 -#define H_ALONE 2 -#define H_MULTI 3 -#define H_MULTI_BEGINNING 4 -#define H_MULTI_MIDDLE 5 -#define H_MULTI_END 6 -#define H_UNDETERMINED 7 -// this H_EPISEMUS can be mixed with another one: -#define H_BOTTOM 16 - inline unsigned char simple_htype(unsigned char h) { return h & (255 - H_BOTTOM); @@ -688,102 +859,11 @@ inline bool is_multi(unsigned char h_episemus) return (simple_htype(h_episemus)) > H_ALONE; } -// the different kind of bars - -#define B_NO_BAR 0 -#define B_VIRGULA 1 -#define B_DIVISIO_MINIMA 2 -#define B_DIVISIO_MINOR 3 -#define B_DIVISIO_MAIOR 4 -#define B_DIVISIO_FINALIS 5 -#define B_DIVISIO_MINOR_D1 6 -#define B_DIVISIO_MINOR_D2 7 -#define B_DIVISIO_MINOR_D3 8 -#define B_DIVISIO_MINOR_D4 9 -#define B_DIVISIO_MINOR_D5 10 -#define B_DIVISIO_MINOR_D6 11 - -// The different types of glyph - -#define G_PUNCTUM_INCLINATUM 1 -#define G_2_PUNCTA_INCLINATA_DESCENDENS 2 -#define G_3_PUNCTA_INCLINATA_DESCENDENS 3 -#define G_4_PUNCTA_INCLINATA_DESCENDENS 4 -#define G_5_PUNCTA_INCLINATA_DESCENDENS 5 -#define G_2_PUNCTA_INCLINATA_ASCENDENS 6 -#define G_3_PUNCTA_INCLINATA_ASCENDENS 7 -#define G_4_PUNCTA_INCLINATA_ASCENDENS 8 -#define G_5_PUNCTA_INCLINATA_ASCENDENS 9 -#define G_TRIGONUS 10 -#define G_PUNCTA_INCLINATA 11 -#define G_NO_GLYPH G_UNDETERMINED -#define G_UNDETERMINED 12 -#define G_VIRGA 13 -#define G_STROPHA 14 -#define G_STROPHA_AUCTA 15 -#define G_PUNCTUM 16 -#define G_PES G_PODATUS -#define G_PODATUS 17 -#define G_PES_QUADRATUM 18 -#define G_FLEXA 19 -#define G_FLEXUS G_FLEXA -#define G_TORCULUS 20 -#define G_TORCULUS_RESUPINUS 21 -#define G_TORCULUS_RESUPINUS_FLEXUS 22 -#define G_PORRECTUS 23 -#define G_PORRECTUS_FLEXUS 24 -#define G_BIVIRGA 25 -#define G_TRIVIRGA 26 -#define G_DISTROPHA 27 -#define G_DISTROPHA_AUCTA 28 -#define G_TRISTROPHA 29 -#define G_TRISTROPHA_AUCTA 30 -#define G_PES_QUADRATUM_FIRST_PART 31 -#define G_SCANDICUS 32 -#define G_PES_QUILISMA_QUADRATUM_FIRST_PART 33 -#define G_PES_ORISCUS_QUADRATUM_FIRST_PART 38 -#define G_ANCUS 34 -#define G_ONE_NOTE 36 -#define G_PUNCTA_ASCENDENS 34 -#define G_PUNCTA_DESCENDENS 35 -#define G_VIRGA_REVERSA 37 -#define G_SALICUS 39 -#define G_SALICUS_FIRST_PART 40 -#define G_TORCULUS_LIQUESCENS 41 - inline bool is_puncta_inclinata(char glyph) { return glyph <= G_5_PUNCTA_INCLINATA_ASCENDENS; } -// the different spaces - -#define SP_DEFAULT '1' -#define SP_NO_SPACE '2' -#define SP_ZERO_WIDTH '3' -#define SP_NEUMATIC_CUT '4' -#define SP_LARGER_SPACE '5' -#define SP_GLYPH_SPACE '6' -#define SP_NEUMATIC_CUT_NB '7' -#define SP_LARGER_SPACE_NB '8' -#define SP_GLYPH_SPACE_NB '9' - -// the different liquescences, like for the signs, have special -// values: to say that something is initio_debilis, just do -// glyph->liquescentia+=L_INITIO_DEBILIS. So don't change the value, -// the tricky is much used - -#define L_NO_LIQUESCENTIA 0 -#define L_DEMINUTUS 1 -#define L_AUCTUS_ASCENDENS 2 -#define L_AUCTUS_DESCENDENS 3 -#define L_AUCTA 4 -#define L_INITIO_DEBILIS 5 -#define L_DEMINUTUS_INITIO_DEBILIS 6 -#define L_AUCTUS_ASCENDENS_INITIO_DEBILIS 7 -#define L_AUCTUS_DESCENDENS_INITIO_DEBILIS 8 -#define L_AUCTA_INITIO_DEBILIS 9 - #define IS_INITIO_DEBILIS 5 #define NO_INITIO_DEBILIS 0 @@ -800,12 +880,6 @@ inline bool is_initio_debilis(char liquescentia) return liquescentia >= L_INITIO_DEBILIS; } -// the centering schemes for gabc: -typedef enum gregorio_lyric_centering { - SCHEME_LATINE = 1, - SCHEME_ENGLISH, -} gregorio_lyric_centering; - #define SCHEME_DEFAULT SCHEME_LATINE void gregorio_add_character(gregorio_character **current_character, From d21c604dc5fa111d6c4f62430ccd0310a8074f50 Mon Sep 17 00:00:00 2001 From: "Henry So, Jr." Date: Wed, 1 Apr 2015 01:51:27 -0400 Subject: [PATCH 2/3] Added missing GRE_ALT check to texverb-as-note assertion. --- src/struct.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/struct.c b/src/struct.c index 2ef3f0642..71377791b 100644 --- a/src/struct.c +++ b/src/struct.c @@ -172,7 +172,8 @@ gregorio_add_texverb_as_note(gregorio_note **current_note, char *str, return; } element = create_and_link_note(current_note); - assert(type == GRE_TEXVERB_GLYPH || type == GRE_TEXVERB_ELEMENT); + assert(type == GRE_TEXVERB_GLYPH || type == GRE_TEXVERB_ELEMENT + || type == GRE_ALT); if (element) { element->type = type; element->texverb = str; From 2722891f38b683a4498b609d7e7ed89263c0a4a0 Mon Sep 17 00:00:00 2001 From: "Henry So, Jr." Date: Wed, 1 Apr 2015 01:51:57 -0400 Subject: [PATCH 3/3] Switched to use '0' instead of 48. --- src/gabc/gabc-notes-determination.l | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/gabc/gabc-notes-determination.l b/src/gabc/gabc-notes-determination.l index 9c3f0ea9a..ffa9392df 100644 --- a/src/gabc/gabc-notes-determination.l +++ b/src/gabc/gabc-notes-determination.l @@ -46,7 +46,7 @@ static inline void error() { char *tempstr = malloc(71 * sizeof(char)); snprintf(tempstr, 70, _("undefined macro used: m%d"), - gabc_notes_determination_text[3] - 48); + gabc_notes_determination_text[3] - '0'); gregorio_message(tempstr, "gabc_notes_determination", ERROR, 0); } %} @@ -90,41 +90,41 @@ static inline void error() BEGIN(choralsign); } \[ob:[01]; { - char_for_brace = gabc_notes_determination_text[4]-48; + char_for_brace = gabc_notes_determination_text[4]-'0'; BEGIN(overbrace); } \[ocb:[01]; { - char_for_brace = gabc_notes_determination_text[5]-48; + char_for_brace = gabc_notes_determination_text[5]-'0'; BEGIN(overcurlybrace); } \[ocba:[01]; { - char_for_brace = gabc_notes_determination_text[6]-48; + char_for_brace = gabc_notes_determination_text[6]-'0'; BEGIN(overcurlyaccentusbrace); } \[nm[1-9]\] { - if (notesmacros[gabc_notes_determination_text[3]-48]) { + if (notesmacros[gabc_notes_determination_text[3]-'0']) { gregorio_add_texverb_to_note(¤t_note, - strdup(notesmacros[gabc_notes_determination_text[3]-48])); + strdup(notesmacros[gabc_notes_determination_text[3]-'0'])); } else error(); } \[gm[1-9]\] { - if (notesmacros[gabc_notes_determination_text[3]-48]) { + if (notesmacros[gabc_notes_determination_text[3]-'0']) { gregorio_add_texverb_as_note(¤t_note, - strdup(notesmacros[gabc_notes_determination_text[3]-48]), + strdup(notesmacros[gabc_notes_determination_text[3]-'0']), GRE_TEXVERB_GLYPH); } else error(); } \[em[1-9]\] { - if (notesmacros[gabc_notes_determination_text[3]-48]) { + if (notesmacros[gabc_notes_determination_text[3]-'0']) { gregorio_add_texverb_as_note(¤t_note, - strdup(notesmacros[gabc_notes_determination_text[3]-48]), + strdup(notesmacros[gabc_notes_determination_text[3]-'0']), GRE_TEXVERB_ELEMENT); } else error(); } \[altm[1-9]\] { - if (notesmacros[gabc_notes_determination_text[5]-48]) { + if (notesmacros[gabc_notes_determination_text[5]-'0']) { gregorio_add_texverb_as_note(¤t_note, - strdup(notesmacros[gabc_notes_determination_text[5]-48]), + strdup(notesmacros[gabc_notes_determination_text[5]-'0']), GRE_TEXVERB_ELEMENT); } else error(); }