Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to print only the first flat on each line #1607

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
3ae07bb
Adds a new option (alteration-scope: line in header, \setalterationsc…
davidweichiang Jan 22, 2025
f16aa96
Adds a new option (alteration-scope: line in header, \setalterationsc…
davidweichiang Jan 22, 2025
a2a2e0c
correctly compute space before suppressed flats
davidweichiang Jan 24, 2025
5ab1c49
resolve conflicts
davidweichiang Jan 24, 2025
7043fdb
fix bug in previous commit
davidweichiang Jan 24, 2025
949b794
with alteration-scope:line, if a natural follows a flat on the same l…
davidweichiang Jan 24, 2025
3eac5d4
fix bug in last commit and clean up
davidweichiang Jan 25, 2025
e2f293b
suppressed flats shouldn't have ledger lines
davidweichiang Jan 25, 2025
1a0b474
rename some local macros with \gre@ prefix
davidweichiang Jan 25, 2025
a0054fd
Add "soft" flat (X), sharp (#*), and natural (Y), which appear only i…
davidweichiang Jan 26, 2025
d28a7e6
a soft natural shouldn't be printed if it's the first on the line
davidweichiang Jan 26, 2025
348de3c
new cases needed for soft flats with ledger lines
davidweichiang Jan 27, 2025
24b60df
Add \gresetalterationeffect option and some documentation
davidweichiang Jan 27, 2025
a35eb55
fix spacing between bar and suppressed flat
davidweichiang Jan 28, 2025
fc38e7a
change soft sharp to ##
davidweichiang Jan 28, 2025
4005bb8
update docs for soft alterations
davidweichiang Jan 29, 2025
88c8928
change many double quotes
davidweichiang Jan 29, 2025
48dce0b
improve "rerun to fix" warning and some comments
davidweichiang Jan 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/gabc/gabc-glyphs-determination.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,13 @@ static char add_note_to_a_glyph(gregorio_glyph_type current_glyph_type,
break;
case S_FLAT:
case S_FLAT_PAREN:
case S_FLAT_SOFT:
case S_SHARP:
case S_SHARP_PAREN:
case S_SHARP_SOFT:
case S_NATURAL:
case S_NATURAL_PAREN:
case S_NATURAL_SOFT:
next_glyph_type = G_ALTERATION;
*end_of_glyph = DET_END_OF_BOTH;
break;
Expand Down
12 changes: 12 additions & 0 deletions src/gabc/gabc-notes-determination.l
Original file line number Diff line number Diff line change
Expand Up @@ -1302,6 +1302,10 @@ x\? {
gregorio_change_shape(current_note, S_FLAT_PAREN,
legacy_oriscus_orientation);
}
X {
gregorio_change_shape(current_note, S_FLAT_SOFT,
legacy_oriscus_orientation);
}
# {
gregorio_change_shape(current_note, S_SHARP,
legacy_oriscus_orientation);
Expand All @@ -1310,6 +1314,10 @@ x\? {
gregorio_change_shape(current_note, S_SHARP_PAREN,
legacy_oriscus_orientation);
}
#\* {
gregorio_change_shape(current_note, S_SHARP_SOFT,
legacy_oriscus_orientation);
}
y {
gregorio_change_shape(current_note, S_NATURAL,
legacy_oriscus_orientation);
Expand All @@ -1318,6 +1326,10 @@ y\? {
gregorio_change_shape(current_note, S_NATURAL_PAREN,
legacy_oriscus_orientation);
}
Y {
gregorio_change_shape(current_note, S_NATURAL_SOFT,
legacy_oriscus_orientation);
}
!?\/0 {
gregorio_add_space_as_note(&current_note, SP_HALF_SPACE, NULL,
&notes_lloc);
Expand Down
9 changes: 9 additions & 0 deletions src/gabc/gabc-write.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,18 +631,27 @@ static void gabc_write_gregorio_note(FILE *f, gregorio_note *note,
case S_FLAT_PAREN:
fprintf(f, "%cx?", pitch_letter(note->u.note.pitch));
break;
case S_FLAT_SOFT:
fprintf(f, "%cX", pitch_letter(note->u.note.pitch));
break;
case S_NATURAL:
fprintf(f, "%cy", pitch_letter(note->u.note.pitch));
break;
case S_NATURAL_PAREN:
fprintf(f, "%cy?", pitch_letter(note->u.note.pitch));
break;
case S_NATURAL_SOFT:
fprintf(f, "%cY", pitch_letter(note->u.note.pitch));
break;
case S_SHARP:
fprintf(f, "%c#", pitch_letter(note->u.note.pitch));
break;
case S_SHARP_PAREN:
fprintf(f, "%c#?", pitch_letter(note->u.note.pitch));
break;
case S_SHARP_SOFT:
fprintf(f, "%c#*", pitch_letter(note->u.note.pitch));
break;
case S_VIRGA:
fprintf(f, "%cv", pitch_letter(note->u.note.pitch));
break;
Expand Down
12 changes: 12 additions & 0 deletions src/gregoriotex/gregoriotex-position.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,13 @@ OFFSET_CASE(LeadingQuilisma);
OFFSET_CASE(LeadingOriscus);
OFFSET_CASE(Flat);
OFFSET_CASE(FlatParen);
OFFSET_CASE(FlatSoft);
OFFSET_CASE(Sharp);
OFFSET_CASE(SharpParen);
OFFSET_CASE(SharpSoft);
OFFSET_CASE(Natural);
OFFSET_CASE(NaturalParen);
OFFSET_CASE(NaturalSoft);

static __inline const char *note_before_last_note_case_ignoring_deminutus(
const gregorio_note *const current_note)
Expand Down Expand Up @@ -951,18 +954,27 @@ static gregorio_vposition advise_positioning(const gregorio_glyph *const glyph,
case S_FLAT_PAREN:
note->gtex_offset_case = FlatParen;
break;
case S_FLAT_SOFT:
note->gtex_offset_case = FlatSoft;
break;
case S_SHARP:
note->gtex_offset_case = Sharp;
break;
case S_SHARP_PAREN:
note->gtex_offset_case = SharpParen;
break;
case S_SHARP_SOFT:
note->gtex_offset_case = SharpSoft;
break;
case S_NATURAL:
note->gtex_offset_case = Natural;
break;
case S_NATURAL_PAREN:
note->gtex_offset_case = NaturalParen;
break;
case S_NATURAL_SOFT:
note->gtex_offset_case = NaturalSoft;
break;
default:
note->gtex_offset_case = last_note_case(glyph,
fused_single_note_case(glyph, FinalPunctum, LeadingPunctum),
Expand Down
33 changes: 33 additions & 0 deletions src/gregoriotex/gregoriotex-write.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ SHAPE(DescendensOriscusScapusOpenqueue);
SHAPE(DescendensPunctumInclinatum);
SHAPE(Flat);
SHAPE(FlatParen);
SHAPE(FlatSoft);
SHAPE(Flexus);
SHAPE(FlexusLongqueue);
SHAPE(FlexusNobar);
Expand All @@ -106,6 +107,7 @@ SHAPE(Linea);
SHAPE(LineaPunctum);
SHAPE(Natural);
SHAPE(NaturalParen);
SHAPE(NaturalSoft);
SHAPE(OriscusDeminutus);
SHAPE(Pes);
SHAPE(PesAscendensOriscus);
Expand Down Expand Up @@ -145,6 +147,7 @@ SHAPE(SalicusLongqueue);
SHAPE(Scandicus);
SHAPE(Sharp);
SHAPE(SharpParen);
SHAPE(SharpSoft);
SHAPE(Stropha);
SHAPE(StrophaAucta);
SHAPE(StrophaAuctaLongtail);
Expand Down Expand Up @@ -789,14 +792,20 @@ static const char *determine_note_glyph_name(const gregorio_note *const note,
return SHAPE_Flat;
case S_FLAT_PAREN:
return SHAPE_FlatParen;
case S_FLAT_SOFT:
return SHAPE_FlatSoft;
case S_SHARP:
return SHAPE_Sharp;
case S_SHARP_PAREN:
return SHAPE_SharpParen;
case S_SHARP_SOFT:
return SHAPE_SharpSoft;
case S_NATURAL:
return SHAPE_Natural;
case S_NATURAL_PAREN:
return SHAPE_NaturalParen;
case S_NATURAL_SOFT:
return SHAPE_NaturalSoft;
default:
/* not reachable unless there's a programming error */
/* LCOV_EXCL_START */
Expand Down Expand Up @@ -2609,14 +2618,20 @@ static __inline const char *alteration_name(
return "Flat";
case S_FLAT_PAREN:
return "FlatParen";
case S_FLAT_SOFT:
return "FlatSoft";
case S_SHARP:
return "Sharp";
case S_SHARP_PAREN:
return "SharpParen";
case S_SHARP_SOFT:
return "SharpSoft";
case S_NATURAL:
return "Natural";
case S_NATURAL_PAREN:
return "NaturalParen";
case S_NATURAL_SOFT:
return "NaturalSoft";
default:
return "";
}
Expand Down Expand Up @@ -2689,10 +2704,13 @@ static void write_note(FILE *f, gregorio_note *note,
switch (note->u.note.shape) {
case S_FLAT:
case S_FLAT_PAREN:
case S_FLAT_SOFT:
case S_NATURAL:
case S_NATURAL_PAREN:
case S_NATURAL_SOFT:
case S_SHARP:
case S_SHARP_PAREN:
case S_SHARP_SOFT:
fprintf(f, "\\Gre%s{%d}{0}", alteration_name(note->u.note.shape),
pitch_value(note->u.note.pitch));
break;
Expand Down Expand Up @@ -2783,18 +2801,27 @@ static void syllable_first_type(gregorio_syllable *syllable,
case S_FLAT_PAREN:
*alteration = ALT_FLAT_PAREN;
break;
case S_FLAT_SOFT:
*alteration = ALT_FLAT_SOFT;
break;
case S_NATURAL:
*alteration = ALT_NATURAL;
break;
case S_NATURAL_PAREN:
*alteration = ALT_NATURAL_PAREN;
break;
case S_NATURAL_SOFT:
*alteration = ALT_NATURAL_SOFT;
break;
case S_SHARP:
*alteration = ALT_SHARP;
break;
case S_SHARP_PAREN:
*alteration = ALT_SHARP_PAREN;
break;
case S_SHARP_SOFT:
*alteration = ALT_SHARP_SOFT;
break;
default:
/* not reachable unless there's a programming error */
/* LCOV_EXCL_START */
Expand Down Expand Up @@ -3938,10 +3965,13 @@ static void write_default_end_of_element(FILE *f,
switch(last_note->u.note.shape) {
case S_FLAT:
case S_FLAT_PAREN:
case S_FLAT_SOFT:
case S_SHARP:
case S_SHARP_PAREN:
case S_SHARP_SOFT:
case S_NATURAL:
case S_NATURAL_PAREN:
case S_NATURAL_SOFT:
break;
default:
last_pitch = last_note->u.note.pitch;
Expand All @@ -3955,10 +3985,13 @@ static void write_default_end_of_element(FILE *f,
switch(next_note->u.note.shape) {
case S_FLAT:
case S_FLAT_PAREN:
case S_FLAT_SOFT:
case S_SHARP:
case S_SHARP_PAREN:
case S_SHARP_SOFT:
case S_NATURAL:
case S_NATURAL_PAREN:
case S_NATURAL_SOFT:
break;
default:
if (next_note->u.note.pitch != NO_PITCH &&
Expand Down
5 changes: 4 additions & 1 deletion src/gregoriotex/gregoriotex.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ typedef enum gtex_alteration {
ALT_SHARP = 3,
ALT_FLAT_PAREN = 4,
ALT_NATURAL_PAREN = 5,
ALT_SHARP_PAREN = 6
ALT_SHARP_PAREN = 6,
ALT_FLAT_SOFT = 7,
ALT_NATURAL_SOFT = 8,
ALT_SHARP_SOFT = 9
} gtex_alteration;

/* Here we define a function that will determine the number of the
Expand Down
3 changes: 3 additions & 0 deletions src/struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -1301,10 +1301,13 @@ static __inline signed char next_pitch_from_glyph(const gregorio_glyph *glyph,
switch (note->u.note.shape) {
case S_FLAT:
case S_FLAT_PAREN:
case S_FLAT_SOFT:
case S_SHARP:
case S_SHARP_PAREN:
case S_SHARP_SOFT:
case S_NATURAL:
case S_NATURAL_PAREN:
case S_NATURAL_SOFT:
if (note->u.note.pitch >= LOWEST_PITCH &&
note->u.note.pitch <= MAX_PITCH) {
alterations[note->u.note.pitch] =
Expand Down
3 changes: 3 additions & 0 deletions src/struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,13 @@ ENUM(gregorio_clef, GREGORIO_CLEF);
E(S_LINEA_PUNCTUM) \
E(S_FLAT) \
E(S_FLAT_PAREN) \
E(S_FLAT_SOFT) \
E(S_SHARP) \
E(S_SHARP_PAREN) \
E(S_SHARP_SOFT) \
E(S_NATURAL) \
E(S_NATURAL_PAREN) \
E(S_NATURAL_SOFT) \
/* special shapes that must not appear in the final form of the score :
* quadratum is the shape of the first note of a punctum quadratum
* and quilisma quadratum is the shape of the first note of a pes
Expand Down
8 changes: 8 additions & 0 deletions tex/gregoriotex-main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@
% attribute for syllable tracking
\newluatexattribute\gre@attr@syllable@id %

% attributes for soft alterations
\newluatexattribute\gre@attr@alteration@height %
\edef\gre@attrid@alteration@height{\the\allocationnumber}%
\newluatexattribute\gre@attr@alteration@type % see \gre@alteration for codes
\edef\gre@attrid@alteration@type{\the\allocationnumber}%
\newluatexattribute\gre@attr@alteration@id %

\newluatexcatcodetable\gre@atletter %
\setluatexcatcodetable\gre@atletter{%
\catcode`\@=11 %
Expand Down Expand Up @@ -1276,6 +1283,7 @@
\gre@resetledgerlineheuristics%
\global\setluatexattribute\gre@attr@glyph@id{0}%
\global\setluatexattribute\gre@attr@syllable@id{0}%
\global\setluatexattribute\gre@attr@alteration@id{0}%
\let\gre@pitch@cleftop\gre@pitch@dummy %
\let\gre@pitch@clefbottom\gre@pitch@dummy %
\xdef\gre@gabcname{#6}%
Expand Down
Loading