]> git.donarmstrong.com Git - lilypond.git/commitdiff
''
authorhanwen <hanwen>
Sun, 19 May 2002 00:14:07 +0000 (00:14 +0000)
committerhanwen <hanwen>
Sun, 19 May 2002 00:14:07 +0000 (00:14 +0000)
14 files changed:
ChangeLog
lily/include/ligature-bracket.hh
lily/include/ligature-engraver.hh [new file with mode: 0644]
lily/include/lily-proto.hh
lily/include/my-lily-parser.hh
lily/ligature-bracket-engraver.cc
lily/ligature-bracket.cc
lily/note-heads-engraver.cc
lily/parser.yy
mf/parmesan-heads.mf
scm/function-documentation.scm [new file with mode: 0644]
scm/grob-description.scm
scm/grob-property-description.scm
scm/interface-description.scm

index 34f3a76a4af716f53621b3c11d9898d9c7dd5897..4c62d7d994980974446d760d8b478a88446ae243 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2002-05-18  Juergen Reuter  <reuter@ipd.uka.de>
+
+       * 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  <hanwen@cs.uu.nl>
 
        * lily/*.cc: use LY_DEFINE everywhere. Move doc strings from
index 74c6ca95a29b888bf84053e429075a2ff71abe90..696e9fbe49efd18be8ae7d5fdc1c8c9dc7408ba2 100644 (file)
 #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 (file)
index 0000000..975d0d2
--- /dev/null
@@ -0,0 +1,46 @@
+/*   
+  ligature-engraver.hh -- declare Ligature_engraver
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 2002 Juergen Reuter <reuter@ipd.uka.de>
+  
+ */
+#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<Span_req*> reqs_drul_;
+  
+  Span_req *prev_start_req_;
+
+  // moment where ligature started.
+  Moment ligature_start_mom_;
+
+  Grob *last_bound;
+
+};
+
+#endif // ENGRAVERGROUP_HH
index 329d08cefa4c5a0e80b4be7952bfe88804c8ef64..a73992fe2b8fff877a6b9e013fe19b2a960b7402 100644 (file)
@@ -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;
index 979fd0bfe1b24a3ed4b58c2abf354667666a4471..b0482d7458a45adce9ba35191c641a3bfb7f8e11 100644 (file)
@@ -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 ();
index d933448862f12c7357225e3a12e712133bbddb6f..3230988cc57b9f0f99ee665a31b976481986853b 100644 (file)
@@ -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 <reuter@ipd.uka.de>
   
  */
-#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<Span_req*> 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<Span_req*> (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 */       "");
index 03138e7538a702717c378cb7d7ca0f828f442f68..eb190aca44944725d6412d419192165628c84381 100644 (file)
@@ -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");
index 23ded7abd544d84c12bd61842b2bef96ff9270ef..c6ae621e9b4889ed8445c7d9c0b55564fc192762 100644 (file)
@@ -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<Span_req*> (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"));
index c1a0b28271f7eaa856f5121affd26c81e9d0be97..13ec353baab3d76ae8f2f1c29ea2732fd39acb70 100644 (file)
@@ -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;
        }
index ef9a78dcaf9309937630e37e3b1e199b407ac79e..2b35a7eb62997c1336b2e90f05ec90e6fa8820d0 100644 (file)
@@ -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 (file)
index 0000000..e2d8c9d
--- /dev/null
@@ -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 string<?))
+       )
+
+    (apply string-append sfdocs)
+        
+  ))
+
+
index 474db70d679afc710e14d858d647a6d1c5e42664..e1cc5ba6cbd29850cf3766b4cac29e8394372476 100644 (file)
        (meta . ((interfaces . (key-signature-interface  font-interface  break-aligned-interface))))
        ))
 
+    (Ligature
+     . (
+       (molecule-callback . ,Ligature_bracket::brew_molecule)
+       (meta . ((interfaces . (ligature-interface))))
+       ))
+
     (LigatureBracket
      . (
        (width . 0.75)
        (height . 0.5)
+       (ligature-primitive-callback . ,Note_head::brew_molecule)
        (molecule-callback . ,Ligature_bracket::brew_molecule)
        (meta . ((interfaces . (ligature-bracket-interface))))
        ))
 
+    (LigatureHead
+     . (
+       (ligature-primitive-callback . ,Note_head::brew_molecule)
+       (molecule-callback . ,Ligature_head::brew_molecule)
+       (Y-offset-callbacks  . (,Staff_symbol_referencer::callback))
+       (stem-attachment-function . ,note-head-style->attachment-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)
        (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)
index f9031e12a767d98ba4ea59132321e1f8a628bd25..22fc2fc0d2e9175b63b863e756d38c83d473184c 100644 (file)
@@ -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.
index 9af686f69f6d9192fc03f56f738492e6b13d55b3..258d15273d776a8d05fa74825aadbe7163d0707f 100644 (file)
  '()
  )
 
+(ly-add-interface
+ 'ligature-interface
+ "A ligature"
+ '()
+ )
+
 (ly-add-interface
  'mark-interface
  "a rehearsal mark"