Skip to content

Commit

Permalink
Considered automatic custos when setting the next custos.
Browse files Browse the repository at this point in the history
Recomputed the next custos if the clef change discretionary is printed.
Fixes gregorio-project#569.
  • Loading branch information
henryso committed Aug 20, 2015
1 parent 9f16cc0 commit 88649c6
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 31 deletions.
10 changes: 9 additions & 1 deletion doc/Command_Index_gregorio.tex
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ \section{Gregorio Controls}
\#1 & \TeX{} code & The \TeX{} code to use when long stems are not forced.\\
\end{argtable}

\macroname{\textbackslash GreCusto}{\#1}{gregoriotex-signs.tex}
\macroname{\textbackslash GreCustos}{\#1}{gregoriotex-signs.tex}
Typesets a custos.

\begin{argtable}
Expand Down Expand Up @@ -502,6 +502,14 @@ \section{Gregorio Controls}
\macroname{\textbackslash GreNewParLine}{}{gregoriotex-main.tex}
Same as \verb=\GreNewLine= except line is not justified.

\macroname{\textbackslash GreNextCustos}{\#1}{gregoriotex-signs.tex}
Sets the pitch to use for the next custos if it were to happen at the point
where this macro is called.

\begin{argtable}
\#1 & integer & Height number of the custos.\\
\end{argtable}

\macroname{\textbackslash GreNoInitial}{}{gregoriotex-main.tex}
Macro called when no initial is being set.

Expand Down
7 changes: 5 additions & 2 deletions src/gregoriotex/gregoriotex-write.c
Original file line number Diff line number Diff line change
Expand Up @@ -2985,8 +2985,11 @@ static void gregoriotex_write_syllable(FILE *f, gregorio_syllable *syllable,
* We don't print custos before a bar at the end of a line
*/
/* we also print an unbreakable larger space before the custo */
fprintf(f, "\\GreEndOfElement{1}{1}%%\n\\GreCusto{%d}%%\n",
pitch_value(element->u.misc.pitched.pitch));
fprintf(f, "\\GreEndOfElement{1}{1}%%\n\\GreCustos{%d}"
"\\GreNextCustos{%d}%%\n",
pitch_value(element->u.misc.pitched.pitch),
pitch_value(gregorio_determine_next_pitch(syllable,
element, NULL)));
}
break;

Expand Down
41 changes: 17 additions & 24 deletions src/struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -1479,51 +1479,41 @@ void gregorio_det_step_and_line_from_key(int key, char *step, int *line)
}
}

static gregorio_glyph *gregorio_first_glyph(gregorio_syllable *syllable)
static signed char gregorio_syllable_first_note(gregorio_syllable *syllable)
{
gregorio_glyph *glyph;
gregorio_element *element;
gregorio_glyph *glyph;
if (!syllable) {
gregorio_message(_("called with a NULL argument"),
"gregorio_first_glyph", VERBOSITY_ERROR, 0);
"gregorio_syllable_first_note", VERBOSITY_ERROR, 0);
}
element = syllable->elements[0];
while (element) {
if (element->type == GRE_CUSTO) {
return element->u.misc.pitched.pitch;
}
if (element->type == GRE_ELEMENT && element->u.first_glyph) {
glyph = element->u.first_glyph;
while (glyph) {
if ((glyph->type == GRE_GLYPH
|| glyph->type == GRE_MANUAL_CUSTOS)
&& glyph->u.notes.first_note) {
return glyph;
if (glyph->type == GRE_MANUAL_CUSTOS) {
return glyph->u.misc.pitched.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;
}
}
element = element->next;
}
return NULL;
}

static signed char gregorio_syllable_first_note(gregorio_syllable *syllable)
{
gregorio_glyph *glyph;
glyph = gregorio_first_glyph(syllable);
if (glyph == NULL) {
return 0;
}
if (glyph->type == GRE_MANUAL_CUSTOS) {
return glyph->u.misc.pitched.pitch;
}
assert(glyph->type == GRE_GLYPH);
assert(glyph->u.notes.first_note->type == GRE_NOTE);
return glyph->u.notes.first_note->u.note.pitch;
return 0;
}

signed char gregorio_determine_next_pitch(gregorio_syllable *syllable,
gregorio_element *element, gregorio_glyph *glyph)
{
char temp;
signed char temp;
if (!element || !syllable) {
gregorio_message(_("called with a NULL argument"),
"gregorio_determine_next_pitch", VERBOSITY_ERROR, 0);
Expand All @@ -1546,6 +1536,9 @@ signed char gregorio_determine_next_pitch(gregorio_syllable *syllable,
/* then we do the same with the elements */
element = element->next;
while (element) {
if (element->type == GRE_CUSTO) {
return element->u.misc.pitched.pitch;
}
if (element->type == GRE_ELEMENT && element->u.first_glyph) {
glyph = element->u.first_glyph;
while (glyph) {
Expand Down
6 changes: 3 additions & 3 deletions tex/gregoriotex-signs.tex
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
}%

% custo just typesets a custo, useful for before the key changes for example
\def\GreCusto#1{%
\def\GreCustos#1{%
\gre@calculate@glyphraisevalue{#1}{0}%
%here we need some tricks to draw the line before the custo (for the color)
\setbox\gre@box@temp@width=\hbox{\grecustochar{#1}}%
Expand Down Expand Up @@ -291,7 +291,7 @@
}%

% the argument is the height
\def\gresetcusto#1{%
\def\GreNextCustos#1{%
\ifnum\greinsidediscretionary=0\relax %
\ifgre@blockeolcustos\else%
\gre@calculate@glyphraisevalue{#1}{0}%
Expand Down Expand Up @@ -329,7 +329,7 @@

\def\GreManualCusto#1{%
\gre@skip@temp@four = \gre@skip@spacebeforecusto%
\kern\gre@skip@temp@four\GreCusto{#1}%
\kern\gre@skip@temp@four\GreCustos{#1}%
}%

% macro that typesets an additional line at the top for custos at end of line
Expand Down
2 changes: 1 addition & 1 deletion tex/gregoriotex-syllable.tex
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
\raise\gre@dimen@glyphraisevalue %
\copy\gre@box@temp@width%
\ifnum\the\greendofscore=0 %
\gresetcusto{#3}%
\GreNextCustos{#3}%
\fi %
\ifnum\the\grefirstglyph=1% we check if it is the first glyph
\grefindnotesaligncenter{#4}%
Expand Down

0 comments on commit 88649c6

Please sign in to comment.