Skip to content

Commit

Permalink
Implemented [shape:] hints in gabc and [shape:stroke] for the flexus.
Browse files Browse the repository at this point in the history
Part of the implementation for #1558
  • Loading branch information
henryso committed Feb 5, 2022
1 parent cb5b46d commit 80afafc
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ indent_size = 2
charset = utf-8
trim_trailing_whitespace = true

[*.{py,c,h}]
[*.{py,c,h,l,y}]
indent_size = 4
13 changes: 13 additions & 0 deletions doc/Gabc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,19 @@ \subsubsection{Neume Spacing}\label{neumespacing}
space, makes the space that follows a non-breaking space \\
\end{tabularx}

\subsubsection{Shape Hints}

In some cases, an alternate form of a shape is desired. To do this, put a
\texttt{[shape:}\textit{hint}\texttt{]} after the figure that needs to be
altered. The available alternate form hints are as follows:

\begin{tabularx}{\textwidth}{l|X}
\textit{hint} & Description \\
\hline
\texttt{stroke} & Render a clivis/flexus as a stroke (like in a porrectus)
rather than as two notes \\
\end{tabularx}

\subsubsection{Additional Symbols}

Puncta mora, episemata, and other symbols may also be added to a note by
Expand Down
16 changes: 10 additions & 6 deletions src/dump/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
* Copyright (C) 2007-2021 The Gregorio Project (see CONTRIBUTORS.md)
*
* This file is part of Gregorio.
*
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "config.h"
Expand Down Expand Up @@ -424,9 +424,13 @@ void dump_write_score(FILE *f, gregorio_score *score)
gregorio_texverb(note->texverb));
}
if (note->choral_sign) {
fprintf(f, " Choral Sign \"%s\"\n",
fprintf(f, " choral sign \"%s\"\n",
note->choral_sign);
}
if (note->shape_hint) {
fprintf(f, " shape hint \"%s\"\n",
note->shape_hint);
}
if (note->signs) {
fprintf(f, " signs %d (%s)\n",
note->signs,
Expand Down
14 changes: 11 additions & 3 deletions src/gabc/gabc-notes-determination.l
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,7 @@ void gabc_det_notes_finish(void)
%x overledger overledger2
%x underledger underledger2
%x endledger
%x shapehint

%%
<INITIAL>\% {
Expand Down Expand Up @@ -1021,11 +1022,11 @@ void gabc_det_notes_finish(void)
gregorio_add_texverb_to_note(current_note, gabc_unescape(tempstr));
}
<choralsign>(\$.|[^\]])+ {
gregorio_add_cs_to_note(&current_note,
gregorio_add_cs_to_note(current_note,
gabc_unescape(gabc_notes_determination_text), false);
}
<choralnabc>(\$.|[^\]])+ {
gregorio_add_cs_to_note(&current_note,
gregorio_add_cs_to_note(current_note,
gabc_unescape(gabc_notes_determination_text), true);
}
<texverbnote>(\$.|[^\]])+ {
Expand Down Expand Up @@ -1109,7 +1110,14 @@ void gabc_det_notes_finish(void)
add_variable_ledger(SO_UNDER, gabc_notes_determination_text);
BEGIN(endledger);
}
<texverbnote,texverbglyph,texverbelement,choralsign,choralnabc,alt,overcurlyaccentusbrace,overcurlybrace,overbrace,underbrace,space,nbspace,endledger>\] {
<INITIAL>\[shape: {
BEGIN(shapehint);
}
<shapehint>(\$.|[^\]])+ {
gregorio_add_shape_hint_to_note(current_note,
gabc_unescape(gabc_notes_determination_text));
}
<texverbnote,texverbglyph,texverbelement,choralsign,choralnabc,alt,overcurlyaccentusbrace,overcurlybrace,overbrace,underbrace,space,nbspace,endledger,shapehint>\] {
BEGIN(INITIAL);
}
<INITIAL>\[[ou]slur:[012];[^,]+,[^\]]+\] {
Expand Down
12 changes: 6 additions & 6 deletions src/gabc/gabc-score-determination.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
* Copyright (C) 2016-2021 The Gregorio Project (see CONTRIBUTORS.md)
*
* This file is part of Gregorio.
*
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/

Expand Down Expand Up @@ -662,8 +662,8 @@ char *gabc_unescape(const char *const string)
{
/*
* in this context, unescape means to discard any special meaning of a
* character that follows a backslash. Thus backslash-{something} is
* reduced to {something}
* character that follows a dollar sign. Thus $-{something} is reduced
* to {something}
*/
char *result, *to;
const char *from = string;
Expand Down
86 changes: 46 additions & 40 deletions src/gabc/gabc-write.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
* Copyright (C) 2006-2021 The Gregorio Project (see CONTRIBUTORS.md)
*
* This file is part of Gregorio.
*
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* This is a simple and easyly understandable output module. If you want to
* write a module, you can consider it as a model.
*/
Expand Down Expand Up @@ -64,7 +64,7 @@ static __inline void unsupported(const char *fn, const int line,
/* LCOV_EXCL_STOP */

/*
* Output one attribute, allowing for multi-line values
* Output one attribute, allowing for multi-line values
*/
static void gabc_write_str_attribute(FILE *f, const char *name,
const char *attr)
Expand All @@ -75,13 +75,13 @@ static void gabc_write_str_attribute(FILE *f, const char *name,
}

/*
*
*
* Then we start the functions made to write the text of the syllable. See
* comments on struct.h and struct-utils.c to understand more deeply.
*
*
* This first function will be called each time we will encounter a
* gregorio_character which is the beginning of a style.
*
*
*/

static void gabc_write_begin(FILE *f, grestyle_style style)
Expand Down Expand Up @@ -133,9 +133,9 @@ static void gabc_write_begin(FILE *f, grestyle_style style)
}

/*
*
*
* This function is about the same but for ends of styles.
*
*
*/

static void gabc_write_end(FILE *f, grestyle_style style)
Expand Down Expand Up @@ -189,11 +189,11 @@ static void gabc_write_end(FILE *f, grestyle_style style)
}

/*
*
*
* The function called when we will encounter a character. There may be other
* representations of the character (for example for Omega), so it is necessary
* representations of the character (for example for Omega), so it is necessary
* to have such a function defined in each module.
*
*
*/

static void gabc_print_char(FILE *f, const grewchar to_print)
Expand Down Expand Up @@ -263,11 +263,11 @@ static void gabc_print_string(FILE *f, const char *first_char)
}

/*
*
*
* This function writes the special chars. As the specials chars are
* represented simply in gabc, this function is very simple, but for TeX output
* represented simply in gabc, this function is very simple, but for TeX output
* modules, this may be.. a little more difficult.
*
*
*/
static void gabc_write_special_char(FILE *f, const grewchar *first_char)
{
Expand All @@ -277,10 +277,10 @@ static void gabc_write_special_char(FILE *f, const grewchar *first_char)
}

/*
*
*
* This functions writes verbatim output... but as the previous one it is very
* simple.
*
*
*/
static void gabc_write_verb(FILE *f, const grewchar *first_char)
{
Expand All @@ -295,10 +295,10 @@ static void gabc_write_verb(FILE *f, const grewchar *first_char)
}

/*
*
*
* Quite important: the function that writes the liquescentia. It is called at
* the end of the function that writes one glyph.
*
*
*/

static void gabc_write_end_liquescentia(FILE *f, char liquescentia)
Expand All @@ -317,9 +317,9 @@ static void gabc_write_end_liquescentia(FILE *f, char liquescentia)
}

/*
*
*
* The function that writes a key change... quite simple.
*
*
*/

static void gabc_write_clef(FILE *f, gregorio_clef_info clef)
Expand All @@ -333,9 +333,9 @@ static void gabc_write_clef(FILE *f, gregorio_clef_info clef)
}

/*
*
*
* The function that writes spaces, called when we encounter one.
*
*
*/

static void gabc_write_space(FILE *f, gregorio_space type, char *factor,
Expand Down Expand Up @@ -382,9 +382,9 @@ static void gabc_write_space(FILE *f, gregorio_space type, char *factor,
}

/*
*
*
* A function to write a bar.
*
*
*/

static void gabc_write_bar(FILE *f, gregorio_bar type)
Expand Down Expand Up @@ -583,9 +583,9 @@ typedef struct glyph_context {
} glyph_context;

/*
*
*
* The function that writes one gregorio_note.
*
*
*/

static void gabc_write_gregorio_note(FILE *f, gregorio_note *note,
Expand Down Expand Up @@ -778,6 +778,12 @@ static void gabc_write_gregorio_note(FILE *f, gregorio_note *note,
gabc_print_string(f, gregorio_texverb(note->texverb));
fprintf(f, "]");
}
if (note->choral_sign) {
fprintf(f, "[cs:%s]", note->choral_sign);
}
if (note->shape_hint) {
fprintf(f, "[shape:%s]", note->shape_hint);
}
}

static void get_next_hepisema_adjustments(unsigned short *adjustment_index,
Expand Down Expand Up @@ -916,11 +922,11 @@ static __inline void close_hepisema_adjustment(FILE *const f,
}

/*
*
*
* The function that writes one glyph. If it is really a glyph (meaning not a
* space or an alteration), we just do like always, a loop on the notes and a
* call to the function that writes one note on each of them.
*
*
*/

static void gabc_write_gregorio_glyph(FILE *f, gregorio_glyph *glyph,
Expand Down Expand Up @@ -1018,12 +1024,12 @@ static void gabc_write_gregorio_glyph(FILE *f, gregorio_glyph *glyph,
}

/*
*
* To write an element, first we check the type of the element (if it is a bar,
*
* To write an element, first we check the type of the element (if it is a bar,
* etc.), and if it is really an element, we make a loop on the list of glyphs
* inside the neume, and for each of them we call the function that will write
* one glyph.
*
*
*/

static void gabc_write_gregorio_element(FILE *f, gregorio_element *element,
Expand Down Expand Up @@ -1115,11 +1121,11 @@ static void gabc_write_gregorio_element(FILE *f, gregorio_element *element,
}

/*
*
*
* Here is defined the function that will write the list of gregorio_elements.
* It is very simple: it makes a loop in which it calls a function that writes
* one element.
*
*
*/

static bool gabc_write_gregorio_elements(FILE *f, gregorio_element *element,
Expand All @@ -1146,9 +1152,9 @@ static bool gabc_write_gregorio_elements(FILE *f, gregorio_element *element,
}

/*
*
*
* Here it goes, we are writing a gregorio_syllable.
*
*
*/

static void gabc_write_gregorio_syllable(FILE *f, gregorio_syllable *syllable,
Expand Down Expand Up @@ -1208,10 +1214,10 @@ static void gabc_write_gregorio_syllable(FILE *f, gregorio_syllable *syllable,
}

/*
*
*
* This is the top function, the one called when we want to write a
* gregorio_score in gabc.
*
*
*/

void gabc_write_score(FILE *f, gregorio_score *score)
Expand Down
Loading

0 comments on commit 80afafc

Please sign in to comment.