From: Han-Wen Nienhuys Date: Sun, 19 May 2002 00:14:07 +0000 (+0000) Subject: '' X-Git-Tag: release/1.5.57 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=21d5a9c520f4bfcd19ab99243706f006f96aabef;p=lilypond.git '' --- diff --git a/ChangeLog b/ChangeLog index 34f3a76a4a..4c62d7d994 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2002-05-18 Juergen Reuter + + * mf/parmesan-heads.mf, scm/grob-description.scm, + scm/grob-property-description.scm, scm/interface-description, + lily/include/my-lily-parser.hh, lily/include/ligature-head.hh, + lily/include/mensural-ligature.hh, lily/include/lily-proto.hh, + lily/include/ligature-engraver.hh, + lily/include/ligature-bracket.hh, lily/parser.yy, + lily/ligature-bracket-engraver.cc, lily/mensural-ligature.cc, + lily/mensural-ligature-engraver.cc, lily/note-heads-engraver.cc, + lily/ligature-head.cc, lily/ligature-engraver.cc, + lily/ligature-bracket.cc, input/test/mensural-ligatures.ly: + implemented white mensural ligatures (still with a big list of + TODOs) + + 2002-05-19 Han-Wen * lily/*.cc: use LY_DEFINE everywhere. Move doc strings from diff --git a/lily/include/ligature-bracket.hh b/lily/include/ligature-bracket.hh index 74c6ca95a2..696e9fbe49 100644 --- a/lily/include/ligature-bracket.hh +++ b/lily/include/ligature-bracket.hh @@ -12,14 +12,10 @@ #include "lily-proto.hh" #include "lily-guile.hh" -class Ligature_bracket +struct Ligature_bracket { -public: - Ligature_bracket (SCM); DECLARE_SCHEME_CALLBACK (brew_molecule, (SCM )); static bool has_interface (Grob*); - -private: }; #endif /* LIGATURE_BRACKET_HH */ diff --git a/lily/include/ligature-engraver.hh b/lily/include/ligature-engraver.hh new file mode 100644 index 0000000000..975d0d2f9b --- /dev/null +++ b/lily/include/ligature-engraver.hh @@ -0,0 +1,46 @@ +/* + ligature-engraver.hh -- declare Ligature_engraver + + source file of the GNU LilyPond music typesetter + + (c) 2002 Juergen Reuter + + */ +#ifndef LIGATUREENGRAVER_HH +#define LIGATUREEENGRAVER_HH + +#include "engraver.hh" + +class Ligature_engraver : public Engraver +{ +protected: + virtual void stop_translation_timestep (); + virtual void start_translation_timestep (); + virtual void finalize (); + + virtual void acknowledge_grob (Grob_info); + virtual bool try_music (Music*); + virtual void process_music (); + virtual void try_stop_ligature (); + virtual Spanner *create_ligature_spanner (); + + Spanner *finished_ligature_p_; + Spanner *ligature_p_; + SCM brew_ligature_primitive_proc; + +public: + TRANSLATOR_DECLARATIONS(Ligature_engraver); + +private: + Drul_array reqs_drul_; + + Span_req *prev_start_req_; + + // moment where ligature started. + Moment ligature_start_mom_; + + Grob *last_bound; + +}; + +#endif // ENGRAVERGROUP_HH diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index 329d08cefa..a73992fe2b 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -74,6 +74,8 @@ class Key_change_req; class Key_performer; class Keyword_ent; class Keyword_table; +class Ligature_engraver; +class Ligature_bracket_engraver; class Line_group_engraver_group; class System; class Local_key_item; @@ -88,6 +90,7 @@ class Mark_req; class Melisma_playing_req; class Melisma_req; class Melodic_req; +class Mensural_ligature_engraver; class Midi_chunk; class Midi_def; class Midi_duration; diff --git a/lily/include/my-lily-parser.hh b/lily/include/my-lily-parser.hh index 979fd0bfe1..b0482d7458 100644 --- a/lily/include/my-lily-parser.hh +++ b/lily/include/my-lily-parser.hh @@ -52,8 +52,6 @@ public: SCM last_beam_start_; void beam_check (SCM); - SCM last_ligature_start_; - Input here_input () const; void push_spot (); Input pop_spot (); diff --git a/lily/ligature-bracket-engraver.cc b/lily/ligature-bracket-engraver.cc index d933448862..3230988cc5 100644 --- a/lily/ligature-bracket-engraver.cc +++ b/lily/ligature-bracket-engraver.cc @@ -1,42 +1,18 @@ /* - ligature-bracket-engraver.cc -- implement Ligature__bracket_engraver + ligature-bracket-engraver.cc -- implement Ligature_bracket_engraver source file of the GNU LilyPond music typesetter (c) 2002 Juergen Reuter */ -#include "engraver.hh" -#include "musical-request.hh" -#include "warn.hh" -#include "drul-array.hh" -#include "item.hh" +#include "ligature-engraver.hh" #include "spanner.hh" -#include "score-engraver.hh" -#include "note-head.hh" -#include "stem.hh" -#include "rest.hh" -class Ligature_bracket_engraver : public Engraver +class Ligature_bracket_engraver : public Ligature_engraver { - Drul_array reqs_drul_; - - Spanner *finished_ligature_bracket_p_; - Spanner *ligature_bracket_p_; - Span_req *prev_start_req_; - - // moment where ligature started. - Moment ligature_start_mom_; - Grob *last_bound; - protected: - virtual void stop_translation_timestep (); - virtual void start_translation_timestep (); - virtual void finalize (); - - virtual void acknowledge_grob (Grob_info); - virtual bool try_music (Music*); - virtual void process_music (); + virtual Spanner *create_ligature_spanner (); public: TRANSLATOR_DECLARATIONS(Ligature_bracket_engraver); @@ -48,146 +24,17 @@ private: Ligature_bracket_engraver::Ligature_bracket_engraver () { - ligature_bracket_p_ = 0; - finished_ligature_bracket_p_ = 0; - reqs_drul_[LEFT] = reqs_drul_[RIGHT] = 0; - prev_start_req_ = 0; - last_bound = 0; -} - -bool -Ligature_bracket_engraver::try_music (Music *m) -{ - if (Span_req *req_ = dynamic_cast (m)) - { - if (scm_equal_p (req_->get_mus_property ("span-type"), - ly_str02scm ("abort")) == SCM_BOOL_T) - { - reqs_drul_[START] = 0; - reqs_drul_[STOP] = 0; - if (ligature_bracket_p_) - ligature_bracket_p_->suicide (); - ligature_bracket_p_ = 0; - } - else if (scm_equal_p (req_->get_mus_property ("span-type"), - ly_str02scm ("ligature-bracket")) == SCM_BOOL_T) - { - Direction d = req_->get_span_dir (); - reqs_drul_[d] = req_; - return true; - } - } - return false; -} - -void -Ligature_bracket_engraver::process_music () -{ - if (reqs_drul_[STOP]) - { - if (!ligature_bracket_p_) - reqs_drul_[STOP]->origin ()->warning (_ ("can't find start of ligature")); - else - { - if (!last_bound) - { - reqs_drul_[STOP]->origin ()->warning (_ ("no right bound")); - } - else - { - ligature_bracket_p_->set_bound (RIGHT, last_bound); - } - } - prev_start_req_ = 0; - finished_ligature_bracket_p_ = ligature_bracket_p_; - ligature_bracket_p_ = 0; - } - last_bound = unsmob_grob (get_property ("currentMusicalColumn")); - - if (ligature_bracket_p_) - { - // TODO: maybe forbid breaks only if not transcribing - top_engraver ()->forbid_breaks (); - } - if (reqs_drul_[START]) - { - if (ligature_bracket_p_) - { - reqs_drul_[START]->origin ()->warning (_ ("already have a ligature")); - return; - } - - prev_start_req_ = reqs_drul_[START]; - ligature_bracket_p_ = new Spanner (get_property ("LigatureBracket")); - - Grob *bound = unsmob_grob (get_property ("currentMusicalColumn")); - if (!bound) - { - reqs_drul_[START]->origin ()->warning (_ ("no left bound")); - } - else - { - ligature_bracket_p_->set_bound (LEFT, bound); - } - - ligature_start_mom_ = now_mom (); - - announce_grob(ligature_bracket_p_, reqs_drul_[START]->self_scm()); - } -} - -void -Ligature_bracket_engraver::start_translation_timestep () -{ - reqs_drul_[START] = 0; - reqs_drul_[STOP] = 0; -} - -void -Ligature_bracket_engraver::typeset_ligature_bracket () -{ - if (finished_ligature_bracket_p_) - { - typeset_grob (finished_ligature_bracket_p_); - finished_ligature_bracket_p_ = 0; - } -} - -void -Ligature_bracket_engraver::stop_translation_timestep () -{ - typeset_ligature_bracket (); -} - -void -Ligature_bracket_engraver::finalize () -{ - typeset_ligature_bracket (); - if (ligature_bracket_p_) - { - prev_start_req_->origin ()->warning (_ ("unterminated ligature")); - ligature_bracket_p_->suicide (); - } } -void -Ligature_bracket_engraver::acknowledge_grob (Grob_info info) +Spanner * +Ligature_bracket_engraver::create_ligature_spanner () { - if (ligature_bracket_p_) - { - if (Rest::has_interface (info.grob_l_)) - { - reqs_drul_[START]->origin ()->warning (_ ("ligature may not contain rest; ignoring rest")); - prev_start_req_->origin ()->warning (_ ("ligature was started here")); - // TODO: maybe better should stop ligature here rather than - // ignoring the rest? - } - } + return new Spanner (get_property ("LigatureBracket")); } ENTER_DESCRIPTION(Ligature_bracket_engraver, /* descr */ "Handles Ligature_requests by engraving Ligature brackets.", /* creats*/ "LigatureBracket", -/* acks */ "rest-interface", +/* acks */ "ligature-head-interface rest-interface", /* reads */ "", /* write */ ""); diff --git a/lily/ligature-bracket.cc b/lily/ligature-bracket.cc index 03138e7538..eb190aca44 100644 --- a/lily/ligature-bracket.cc +++ b/lily/ligature-bracket.cc @@ -145,5 +145,5 @@ Ligature_bracket::brew_molecule (SCM smob) } ADD_INTERFACE(Ligature_bracket, "ligature-bracket-interface", - "", + "A bracket indicating a ligature in the original edition", "width thickness height"); diff --git a/lily/note-heads-engraver.cc b/lily/note-heads-engraver.cc index 23ded7abd5..c6ae621e9b 100644 --- a/lily/note-heads-engraver.cc +++ b/lily/note-heads-engraver.cc @@ -34,11 +34,14 @@ protected: virtual void process_music (); virtual void stop_translation_timestep (); -}; +private: + bool in_ligature; +}; Note_heads_engraver::Note_heads_engraver() { + in_ligature = 0; } bool @@ -53,6 +56,19 @@ Note_heads_engraver::try_music (Music *m) { return note_req_l_arr_.size (); } + else if (Span_req *req_ = dynamic_cast (m)) + { + if (scm_equal_p (req_->get_mus_property ("span-type"), + ly_str02scm ("abort")) == SCM_BOOL_T) + { + in_ligature = 0; + } + else if (scm_equal_p (req_->get_mus_property ("span-type"), + ly_str02scm ("ligature")) == SCM_BOOL_T) + { + in_ligature = (req_->get_span_dir () == START); + } + } return false; } @@ -63,8 +79,9 @@ Note_heads_engraver::process_music () { for (int i=0; i < note_req_l_arr_.size (); i++) { - Item *note_p = new Item (get_property ("NoteHead")); - + Item *note_p = + new Item (get_property ((in_ligature) ? "LigatureHead" : "NoteHead")); + Music * req = note_req_l_arr_[i]; Duration dur = *unsmob_duration (req->get_mus_property ("duration")); diff --git a/lily/parser.yy b/lily/parser.yy index c1a0b28271..13ec353baa 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -1127,6 +1127,26 @@ command_element: $$-> set_spot (THIS->here_input ()); $1-> set_spot (THIS->here_input ()); } + | E_LEFTSQUARE { + Span_req *l = new Span_req; + l->set_span_dir (START); + l->set_mus_property ("span-type", ly_str02scm ("ligature")); + l->set_spot (THIS->here_input ()); + + $$ = new Request_chord (SCM_EOL); + $$->set_mus_property ("elements", gh_cons (l->self_scm (), SCM_EOL)); + $$->set_spot (THIS->here_input ()); + } + | E_RIGHTSQUARE { + Span_req *l = new Span_req; + l->set_span_dir (STOP); + l->set_mus_property ("span-type", ly_str02scm ("ligature")); + l->set_spot (THIS->here_input ()); + + $$ = new Request_chord (SCM_EOL); + $$->set_mus_property ("elements", gh_cons (l->self_scm (), SCM_EOL)); + $$->set_spot (THIS->here_input ()); + } | E_BACKSLASH { $$ = new Music (gh_list (gh_cons (ly_symbol2scm ("name"), ly_symbol2scm ("separator")), SCM_UNDEFINED)); $$->set_spot (THIS->here_input ()); @@ -1249,19 +1269,6 @@ shorthand_command_req: b->set_mus_property ("span-type", ly_str02scm ("beam")); $$ = b; } - | E_LEFTSQUARE { - Span_req *b = new Span_req; - b->set_span_dir (START); - b->set_mus_property ("span-type", ly_str02scm ("ligature-bracket")); - $$ = b; - THIS->last_ligature_start_ = b->self_scm (); - } - | E_RIGHTSQUARE { - Span_req *b = new Span_req; - b->set_span_dir (STOP); - b->set_mus_property ("span-type", ly_str02scm ("ligature-bracket")); - $$ = b; - } | BREATHE { $$ = new Breathing_sign_req; } diff --git a/mf/parmesan-heads.mf b/mf/parmesan-heads.mf index ef9a78dcaf..2b35a7eb62 100644 --- a/mf/parmesan-heads.mf +++ b/mf/parmesan-heads.mf @@ -25,7 +25,7 @@ define_pixels(noteheight); % brevis_wid# := 2 staff_space#; -def draw_brevis(expr brevwid) = +def draw_neo_brevis(expr brevwid) = save beamheight, head_width; save holeheight, stem_width; save serif_size, serif_protrude; @@ -66,12 +66,26 @@ def draw_brevis(expr brevwid) = enddef; +def draw_neo_left_stemmed_head (expr wid) = + draw_neo_brevis(wid); + + x6 = x7 = head_width - stem_width/2; + y6 = y5; + y7 = y5 - 2.25staff_space; + pickup pencircle scaled stem_width; + draw z6 .. z7; +enddef; + +fet_beginchar("Left stemmed notehead", "lneo_mensural", "mensuralleftstemmedhead"); + draw_neo_left_stemmed_head (brevis_wid#) +fet_endchar; + % % Some sources (eg Musix/OpusTeX think that the appendage should be on % the left, some say right. Right wins democratically. % def draw_neo_longa (expr wid) = - draw_brevis(wid); + draw_neo_brevis(wid); save theta; x7r = head_width; @@ -100,7 +114,7 @@ fet_beginchar("Longa notehead", "-2neo_mensural", "mensurallongahead"); fet_endchar; fet_beginchar("Brevis notehead", "-1neo_mensural", "mensuralbrevishead") - draw_brevis(brevis_wid#); + draw_neo_brevis(brevis_wid#); fet_endchar; def draw_neo_mensural_black_head (expr wid) = @@ -156,10 +170,29 @@ fet_endchar; brevis_wid# := 1 staff_space#; -def draw_longa (expr wid) = +def draw_brevis (expr wid) = + % TODO. For the moment, fall back to draw_neo_brevis. + draw_neo_brevis(wid); +enddef; + +def draw_left_stemmed_head (expr wid) = draw_brevis(wid); save theta; + x6 = x7 = stem_width/2; + y6 = y5; + y7 = y5 - 2.25staff_space; + pickup pencircle scaled stem_width; + draw z6 .. z7; +enddef; + +fet_beginchar("Left stemmed notehead", "lmensural", "mensuralleftstemmedhead"); + draw_left_stemmed_head (brevis_wid#) +fet_endchar; + +def draw_longa (expr wid) = + draw_brevis(wid); + x6 = x7 = head_width - stem_width/2; y6 = y5; y7 = y5 - 2.25staff_space; diff --git a/scm/function-documentation.scm b/scm/function-documentation.scm new file mode 100644 index 0000000000..e2d8c9df9e --- /dev/null +++ b/scm/function-documentation.scm @@ -0,0 +1,42 @@ +(use-modules + (ice-9 regex)) + +(define (format-c-header c-h) + (regexp-substitute/global + #f "," + (regexp-substitute/global #f "(SCM|\\)|\\() *" c-h 'pre "" 'post) + 'pre " " 'post) + ) + +(define (document-scheme-function name c-header doc-string) + (string-append + "@defun " (symbol->string name) " " (format-c-header c-header) "\n" + doc-string + "\n@end defun\n\n") + ) + +(define all-scheme-functions + (hash-fold + (lambda (key val prior) + (cons (cons key val) prior) + ) + '() (ly-get-all-function-documentation)) + ) + +(define (document-all-scheme-functions) + (let* + ( + + (fdocs (map (lambda (x) + (document-scheme-function (car x) (cadr x) (cddr x)) + ) + all-scheme-functions) + ) + (sfdocs (sort fdocs stringattachment-coordinates) + (font-family . ancient) + (style . mensural) + (meta . ((interfaces . (ligature-head-interface rhythmic-head-interface note-head-interface staff-symbol-referencer-interface)))) + )) + (LyricHyphen . ( (thickness . 1.0) @@ -416,6 +434,16 @@ (meta . ((interfaces . (lyric-syllable-interface self-alignment-interface text-interface font-interface)))) )) + (MensuralLigature + . ( + (thickness . 1.4) + (flexa-width . 2.0) + (ligature-primitive-callback . ,Mensural_ligature::brew_ligature_primitive) + (molecule-callback . ,Mensural_ligature::brew_molecule) + (font-family . ancient) + (meta . ((interfaces . (mensural-ligature-interface)))) + )) + (Porrectus . ( (style . mensural) diff --git a/scm/grob-property-description.scm b/scm/grob-property-description.scm index f9031e12a7..22fc2fc0d2 100644 --- a/scm/grob-property-description.scm +++ b/scm/grob-property-description.scm @@ -155,6 +155,7 @@ procedure returns #t, attachment is used. Otherwise, the next procedure is tried.") (grob-property-description 'flag-style string? "turn stroke through stem on/off.") (grob-property-description 'flag-width-function procedure? "Procedure that computes the width of a half-beam (a non-connecting beam.).") +(grob-property-description 'flexa-width number? "width of a flexa shape in a ligature grob.") (grob-property-description 'font-family symbol? "partial font definition: music roman braces dynamic math ...") (grob-property-description 'font-name string? "file name for the font to load. diff --git a/scm/interface-description.scm b/scm/interface-description.scm index 9af686f69f..258d15273d 100644 --- a/scm/interface-description.scm +++ b/scm/interface-description.scm @@ -25,6 +25,12 @@ '() ) +(ly-add-interface + 'ligature-interface + "A ligature" + '() + ) + (ly-add-interface 'mark-interface "a rehearsal mark"