Пример #1
0
static void gabc_write_bar(FILE *f, gregorio_bar type)
{
    switch (type) {
    case B_VIRGULA:
        fprintf(f, "`");
        break;
    case B_DIVISIO_MINIMA:
        fprintf(f, ",");
        break;
    case B_DIVISIO_MINOR:
        fprintf(f, ";");
        break;
    case B_DIVISIO_MAIOR:
        fprintf(f, ":");
        break;
    case B_DIVISIO_FINALIS:
        fprintf(f, "::");
        break;
    case B_DIVISIO_MINOR_D1:
        fprintf(f, ";1");
        break;
    case B_DIVISIO_MINOR_D2:
        fprintf(f, ";2");
        break;
    case B_DIVISIO_MINOR_D3:
        fprintf(f, ";3");
        break;
    case B_DIVISIO_MINOR_D4:
        fprintf(f, ";4");
        break;
    case B_DIVISIO_MINOR_D5:
        fprintf(f, ";5");
        break;
    case B_DIVISIO_MINOR_D6:
        fprintf(f, ";6");
        break;
    case B_DIVISIO_MINOR_D7:
        fprintf(f, ";7");
        break;
    case B_DIVISIO_MINOR_D8:
        fprintf(f, ";8");
        break;
    default:
        /* not reachable unless there's a programming error */
        /* LCOV_EXCL_START */
        unsupported("gabc_write_bar", __LINE__, "bar type",
                gregorio_bar_to_string(type));
        break;
        /* LCOV_EXCL_STOP */
    }
}
Пример #2
0
void dump_write_score(FILE *f, gregorio_score *score)
{
    gregorio_voice_info *voice_info = score->first_voice_info;
    int i;
    int annotation_num;
    gregorio_syllable *syllable;
    gregorio_header *header;

    if (!f) {
        gregorio_message(_("call with NULL file"), "gregoriotex_write_score",
                VERBOSITY_ERROR, 0);
        return;
    }
    fprintf(f,
            "=====================================================================\n"
            " SCORE INFOS\n"
            "=====================================================================\n");
    if (score->number_of_voices) {
        fprintf(f, "   number_of_voices          %d\n",
                score->number_of_voices);
    }
    if (score->name) {
        fprintf(f, "   name                      %s\n", score->name);
    }
    if (score->gabc_copyright) {
        fprintf(f, "   gabc_copyright            %s\n", score->gabc_copyright);
    }
    if (score->score_copyright) {
        fprintf(f, "   score_copyright           %s\n", score->score_copyright);
    }
    if (score->author) {
        fprintf(f, "   author                    %s\n", score->author);
    }
    if (score->mode) {
        fprintf(f, "   mode                      %s\n", score->mode);
    }
    if (score->mode_modifier) {
        fprintf(f, "   mode_modifier             %s\n", score->mode_modifier);
    }
    if (score->mode_differentia) {
        fprintf(f, "   mode_differentia          %s\n", score->mode_differentia);
    }
    if (score->staff_lines != 4) {
        fprintf(f, "   staff_lines               %d\n", (int)score->staff_lines);
    }
    if (score->nabc_lines) {
        fprintf(f, "   nabc_lines                %d\n", (int)score->nabc_lines);
    }
    if (score->legacy_oriscus_orientation) {
        fprintf(f, "   oriscus-orientation       legacy\n");
    }
    fprintf(f, "\n\n"
            "=====================================================================\n"
            " HEADERS\n"
            "=====================================================================\n");
    for (header = score->headers; header; header = header->next) {
        fprintf(f, "   %-25s %s\n", header->name, header->value);
    }
    fprintf(f, "\n\n"
            "=====================================================================\n"
            " VOICES INFOS\n"
            "=====================================================================\n");
    for (i = 0; i < score->number_of_voices; i++) {
        fprintf(f, "  Voice %d\n", i + 1);
        if (voice_info->initial_clef.line) {
            fprintf(f, "   initial_key               %d (%c%d)\n",
                    gregorio_calculate_new_key(voice_info->initial_clef),
                    gregorio_clef_to_char(voice_info->initial_clef.clef),
                    voice_info->initial_clef.line);
            if (voice_info->initial_clef.flatted) {
                fprintf(f, "   flatted_key               true\n");
            }
            if (voice_info->initial_clef.secondary_line) {
                fprintf(f, "     secondary_clef          %c%d\n",
                        gregorio_clef_to_char(
                            voice_info->initial_clef.secondary_clef),
                        voice_info->initial_clef.secondary_line);
                if (voice_info->initial_clef.secondary_flatted) {
                    fprintf(f, "     secondary_flatted_key   true\n");
                }
            }
        }
        for (annotation_num = 0; annotation_num < MAX_ANNOTATIONS;
             ++annotation_num) {
            if (score->annotation[annotation_num]) {
                fprintf(f, "   annotation                %s\n",
                        score->annotation[annotation_num]);
            }
        }
        voice_info = voice_info->next_voice_info;
    }
    fprintf(f, "\n\n"
            "=====================================================================\n"
            " SCORE\n"
            "=====================================================================\n");
    for (syllable = score->first_syllable; syllable;
            syllable = syllable->next_syllable) {
        gregorio_element *element;
        if (syllable->type) {
            fprintf(f, "   type                      %d (%s)\n",
                    syllable->type, gregorio_type_to_string(syllable->type));
        }
        if (syllable->position) {
            fprintf(f, "   position                  %d (%s)\n",
                    syllable->position,
                    gregorio_word_position_to_string(syllable->position));
        }
        if (syllable->special_sign) {
            fprintf(f, "   special sign                       %s\n",
                    gregorio_sign_to_string(syllable->special_sign));
        }
        if (syllable->no_linebreak_area != NLBA_NORMAL) {
            fprintf(f, "   no line break area        %s\n",
                    gregorio_nlba_to_string(syllable->no_linebreak_area));
        }
        if (syllable->text) {
            if (syllable->translation) {
                fprintf(f, "\n  Text\n");
            }
            dump_write_characters(f, syllable->text);
        }
        if ((syllable->translation
             && syllable->translation_type != TR_WITH_CENTER_END)
            || syllable->translation_type == TR_WITH_CENTER_END) {
            fprintf(f, "\n  Translation type             %s",
                    gregorio_tr_centering_to_string
                    (syllable->translation_type));
            if (syllable->translation_type == TR_WITH_CENTER_END) {
                fprintf(f, "\n");
            }
        }
        if (syllable->translation) {
            fprintf(f, "\n  Translation\n");
            dump_write_characters(f, syllable->translation);
        }
        if (syllable->abovelinestext) {
            fprintf(f, "\n  Abovelinestext\n    %s", syllable->abovelinestext);
        }
        for (element = *syllable->elements; element; element = element->next) {
            gregorio_glyph *glyph;
            fprintf(f, "---------------------------------------------------------------------\n");
            if (element->type) {
                fprintf(f, "     type                    %d (%s)\n",
                        element->type, gregorio_type_to_string(element->type));
            }
            switch (element->type) {
            case GRE_CUSTOS:
                if (element->u.misc.pitched.pitch) {
                    fprintf(f, "     pitch                   %s\n",
                            dump_pitch(element->u.misc.pitched.pitch,
                                score->highest_pitch));
                }
                if (element->u.misc.pitched.force_pitch) {
                    fprintf(f, "     force_pitch             true\n");
                }
                break;
            case GRE_SPACE:
                if (element->u.misc.unpitched.info.space) {
                    char *factor = element->u.misc.unpitched.info.
                            ad_hoc_space_factor;
                    fprintf(f, "     space                   %d (%s)%s%s\n",
                            element->u.misc.unpitched.info.space,
                            gregorio_space_to_string(
                                element->u.misc.unpitched.info.space),
                            factor? " x " : "", factor? factor : "");
                }
                break;
            case GRE_TEXVERB_ELEMENT:
                fprintf(f, "     TeX string              \"%s\"\n",
                        element->texverb);
                break;
            case GRE_NLBA:
                fprintf(f, "     nlba                    %d (%s)\n",
                        element->u.misc.unpitched.info.nlba,
                        gregorio_nlba_to_string(element->u.misc.unpitched.info.
                            nlba));
                break;
            case GRE_ALT:
                fprintf(f, "     Above lines text        \"%s\"\n",
                        element->texverb);
                break;
            case GRE_BAR:
                if (element->u.misc.unpitched.info.bar) {
                    fprintf(f, "     bar                     %d (%s)\n",
                            element->u.misc.unpitched.info.bar,
                            gregorio_bar_to_string(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,
                                gregorio_sign_to_string(element->
                                        u.misc.unpitched.special_sign));
                    }
                }
                break;
            case GRE_CLEF:
                if (element->u.misc.clef.line) {
                    fprintf(f, "     clef                    %d (%c%d)\n",
                            gregorio_calculate_new_key(element->u.misc.clef),
                            gregorio_clef_to_char(element->u.misc.clef.clef),
                            element->u.misc.clef.line);
                    if (element->u.misc.clef.flatted) {
                        fprintf(f, "     flatted_key             true\n");
                    }
                    if (element->u.misc.clef.secondary_line) {
                        fprintf(f, "     secondary_clef          %c%d\n",
                                gregorio_clef_to_char(
                                    element->u.misc.clef.secondary_clef),
                                element->u.misc.clef.secondary_line);
                        if (element->u.misc.clef.secondary_flatted) {
                            fprintf(f, "     secondary_flatted_key   true\n");
                        }
                    }
                }
                break;
            case GRE_END_OF_LINE:
                if (element->u.misc.unpitched.info.eol_ragged) {
                    fprintf(f, "         ragged                 true\n");
                }
                if (element->u.misc.unpitched.info.eol_forces_custos) {
                    fprintf(f, "         forces custos          %s\n",
                            dump_bool(element
                                ->u.misc.unpitched.info.eol_forces_custos_on));
                }
                break;
            case GRE_ELEMENT:
                for (glyph = element->u.first_glyph; glyph;
                        glyph = glyph->next) {
                    gregorio_note *note;
                    fprintf(f, "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n");
                    if (glyph->type) {
                        fprintf(f, "       type                  %d (%s)\n",
                                glyph->type, gregorio_type_to_string(glyph->
                                                                     type));
                    }
                    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,
                                gregorio_space_to_string(glyph->u.misc.
                                                         unpitched.info.space));
                        break;

                    case GRE_BAR:
                        fprintf(f, "       glyph_type            %d (%s)\n",
                                glyph->u.misc.unpitched.info.bar,
                                gregorio_bar_to_string(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,
                                    gregorio_sign_to_string(glyph->
                                            u.misc.unpitched.special_sign));
                        }
                        break;

                    case GRE_GLYPH:
                        fprintf(f, "       glyph_type            %d (%s)\n",
                                glyph->u.notes.glyph_type,
                                gregorio_glyph_type_to_string(glyph->u.notes.
                                                              glyph_type));
                        if (glyph->u.notes.liquescentia) {
                            fprintf(f, "       liquescentia          %d (%s)\n",
                                    glyph->u.notes.liquescentia,
                                    gregorio_liquescentia_to_string(
                                            glyph->u.notes.liquescentia));
                        }
                        break;

                    default:
                        fprintf(f, "       !!! UNKNOWN !!!       !!!\n");
                        break;
                    }
                    if (glyph->type == GRE_GLYPH) {
                        for (note = glyph->u.notes.first_note; note;
                                note = note->next) {
                            fprintf(f, "-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  \n");
                            if (note->type) {
                                fprintf(f, "         type                   %d (%s)\n",
                                        note->type,
                                        gregorio_type_to_string(note->type));
                            }
                            switch (note->type) {
                            case GRE_NOTE:
                                if (note->u.note.pitch) {
                                    fprintf(f, "         pitch                  %s\n",
                                            dump_pitch(note->u.note.pitch,
                                                score->highest_pitch));
                                }
                                if (note->u.note.shape) {
                                    fprintf(f, "         shape                  %d (%s)\n",
                                            note->u.note.shape,
                                            gregorio_shape_to_string(
                                                    note->u.note.shape));
                                }
                                if (note->u.note.liquescentia) {
                                    fprintf(f, "         liquescentia           %d (%s)\n",
                                            note->u.note.liquescentia,
                                            gregorio_liquescentia_to_string(
                                                    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,
                                        gregorio_sign_to_string(note->signs));
                            }
                            if (note->signs & _V_EPISEMA && note->v_episema_height) {
                                if (note->v_episema_height < note->u.note.pitch) {
                                    fprintf(f, "         v episema forced       BELOW\n");
                                }
                                else {
                                    fprintf(f, "         v episema forced       ABOVE\n");
                                }
                            }
                            if ((note->signs == _PUNCTUM_MORA
                                        || note->signs == _V_EPISEMA_PUNCTUM_MORA)
                                    && note->mora_vposition) {
                                fprintf(f, "         mora vposition         %s\n",
                                        gregorio_vposition_to_string(note->
                                                mora_vposition));
                            }
                            if (note->special_sign) {
                                fprintf(f, "         special sign           %d (%s)\n",
                                        note->special_sign,
                                        gregorio_sign_to_string(
                                                note->special_sign));
                            }
                            if (note->h_episema_above == HEPISEMA_AUTO
                                    && note->h_episema_below == HEPISEMA_AUTO) {
                                fprintf(f, "         auto hepisema size     %d (%s)\n",
                                        note->h_episema_above_size,
                                        grehepisema_size_to_string(note->
                                                h_episema_above_size));
                                fprintf(f, "         auto hepisema bridge   %s\n",
                                        dump_bool(note->h_episema_above_connect));
                            }
                            else {
                                if (note->h_episema_above == HEPISEMA_FORCED) {
                                    fprintf(f, "         above hepisema size    %d (%s)\n",
                                            note->h_episema_above_size,
                                            grehepisema_size_to_string(note->
                                                    h_episema_above_size));
                                    fprintf(f, "         above hepisema bridge  %s\n",
                                            dump_bool(note->h_episema_above_connect));
                                }
                                if (note->h_episema_below == HEPISEMA_FORCED) {
                                    fprintf(f, "         below hepisema size    %d (%s)\n",
                                            note->h_episema_below_size,
                                            grehepisema_size_to_string(note->
                                                    h_episema_below_size));
                                    fprintf(f, "         below hepisema bridge  %s\n",
                                            dump_bool(note->h_episema_below_connect));
                                }
                            }
                            if (note->explicit_high_ledger_line) {
                                fprintf(f, "         explicit high line     %s\n",
                                        dump_bool(note->supposed_high_ledger_line));
                            }
                            if (note->explicit_low_ledger_line) {
                                fprintf(f, "         explicit low line      %s\n",
                                        dump_bool(note->supposed_low_ledger_line));
                            }
                        }
                    }
                }
                break;

            default:
                /* do nothing */
                break;
            }
            if (element->nabc_lines) {
                fprintf(f, "     nabc_lines              %d\n",
                        (int)element->nabc_lines);
            }
            if (element->nabc_lines && element->nabc) {
                for (i = 0; i < (int)element->nabc_lines; i++) {
                    if (element->nabc[i]) {
                        fprintf(f, "     nabc_line %d             \"%s\"\n",
                                (int)(i+1), element->nabc[i]);
                    }
                }
            }
        }
        fprintf(f, "=====================================================================\n");
    }
}