]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.1.7
authorfred <fred>
Tue, 26 Mar 2002 21:44:34 +0000 (21:44 +0000)
committerfred <fred>
Tue, 26 Mar 2002 21:44:34 +0000 (21:44 +0000)
15 files changed:
NEWS
VERSION
init/engraver.ly
init/lily.scm
input/test/repeat.fly [new file with mode: 0644]
lily/include/lookup.hh
lily/include/repeat-engraver.hh [new file with mode: 0644]
lily/include/volta-spanner.hh [new file with mode: 0644]
lily/lookup.cc
lily/repeat-engraver.cc [new file with mode: 0644]
lily/repeated-music-iterator.cc [new file with mode: 0644]
lily/volta-spanner.cc [new file with mode: 0644]
mf/cmr10.afm.in
ps/lily.ps
tex/lily-ps-defs.tex

diff --git a/NEWS b/NEWS
index b340ce878b4513f7f783a76301ee2843973eb2ef..129bd32d4fa70ef4b48b30f4adf47d78ca819426 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,21 @@
+pl6.jcn5
+       - repeatbars, volta-spanner work, alternative iteration still broken
+       - volta symbol
+
+pl5.szmulewicz2
+       - more GUILE stuff.
+       - tutorial doco updates
+
+pl6.jcn4
+       - volta-spanner
+       - repeat-engraver
+       - repeat/alternative music layout (hehe)
+  
+pl6.uu1
+       - Doco of music iterators.
 
+********
+pl 6
 
 pl5.szmulewicz1
        - rtti stuff
diff --git a/VERSION b/VERSION
index 9fa405bb94a8e0dcb234c7b1b16d94a8e894ca60..af5d5f04490dc312df74683828b667b51d7e5fd6 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1,7 +1,7 @@
 PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=1
-PATCH_LEVEL=6
+PATCH_LEVEL=7
 MY_PATCH_LEVEL=
 
 # use the above to send patches: MY_PATCH_LEVEL is always empty for a
index 48c0145b5bb03fbd997972d06735cf91d3d73413..c34f9df8f36a14519ce6c453a387474519edd6f9 100644 (file)
@@ -20,6 +20,7 @@ StaffContext=\translator {
        \consists "Key_engraver";
        \consists "Local_key_engraver";
        \consists "Time_signature_engraver";
+       \consists "Repeat_engraver";
        \consists "Staff_symbol_engraver";
        \consists "Collision_engraver";
        \consists "Rest_collision_engraver";
@@ -76,6 +77,7 @@ RhythmicStaffContext=\translator{
        \consists "Separating_line_group_engraver";     
        \name RhythmicStaff;
        \consists "Bar_engraver";
+       \consists "Repeat_engraver";
        \consists "Time_signature_engraver";
        \consists "Staff_symbol_engraver";
        \accepts "Voice";
@@ -206,6 +208,7 @@ HaraKiriStaffContext = \translator {
 
        \consists "Bar_engraver";
        \consists "Clef_engraver";
+       \consists "Repeat_engraver";
        \consists "Key_engraver";
        \consists "Time_signature_engraver";
        \consists "Local_key_engraver";
index e045426a26641b52d6c02ca385740e0ae3a04cc3..f813358ede8276510f9d8b7c48146b13e894decc 100644 (file)
@@ -43,9 +43,9 @@
     (string-append (number->string (cadr c)) " ")))
 
 ;;;;;;;; TeX
-; (define (tex action)
+;(define (tex action)
 
-(define 
+(define  
   (beam-tex width slope thick)
   (embedded-ps-tex (beam-ps width slope thick)))
 
   (text-tex f s)
   (string-append "\\set" f "{" s "}"))
 
+(define 
+  (tuplet-tex dx dy dir)
+  (embedded-ps-tex (tuplet-ps dx dy dir)))
+
 
+(define 
+  (volta-tex w last)
+  (embedded-ps-tex (volta-ps w last)))
 
 ;;;;;;;;;;;; PS
 
   (string-append "(" s ") set" f " "))
 
 
+(define 
+  (volta-ps w last)
+  (string-append 
+   (numbers->string (list w (inexact->exact last)))
+   "draw_volta"))
+
 ;;; output definitions
 
 (define 
    (numbers->string (list dx dy (inexact->exact dir)))
    "draw_tuplet"))
 
-(define 
-  (tuplet-tex dx dy dir)
-  (embedded-ps-tex (tuplet-ps dx dy dir)))
-
 (define 
   (stem o kern width height depth) 
   ((invoke-output o "stem") kern width height depth))
   (startrepeat o h)
   ((invoke-output o "invoke-dim1") "startrepeat" h))
 
-
 (define 
   (stop-line o) 
   ((invoke-output o "stop-line")))
 
-
 (define
   (stoprepeat o h)
   ((invoke-output o "invoke-dim1") "stoprepeat" h))
 
+(define 
+  (volta o w last)
+  ((invoke-output o "volta") w last))
 
diff --git a/input/test/repeat.fly b/input/test/repeat.fly
new file mode 100644 (file)
index 0000000..d967920
--- /dev/null
@@ -0,0 +1 @@
+a b c d \repeat 2 { { c c c c d d d d } } \alternative { { e e e e } { e e e g } } c c c c  c c c c
index 5b5685a40c6c95ee40b3667d32e5278c0c65bdc7..e236e56f66802fb859cd375849acffe3ccaf7a27 100644 (file)
@@ -55,6 +55,7 @@ public:
   Atom text (String style, String text) const;
   Atom vbrace (Real &dy) const;
   Atom vbracket (Real &dy) const;
+  Atom volta (Real w, bool last_b) const;
   Atom special_time_signature (String, Array<int>) const;
   Atom time_signature (Array<int>) const;
 
diff --git a/lily/include/repeat-engraver.hh b/lily/include/repeat-engraver.hh
new file mode 100644 (file)
index 0000000..e3d6f9e
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+  repeat-engraver.hh -- declare Repeat_engraver
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#ifndef REPEAT_ENGRAVER_HH
+#define REPEAT_ENGRAVER_HH
+
+#include "engraver.hh"
+
+/**
+  Generate repeat-bars |: :| for repeated-music
+  */
+class Repeat_engraver : public Engraver 
+{
+public:
+  Repeat_engraver ();
+  VIRTUAL_COPY_CONS(Translator);
+  
+protected:
+  virtual void acknowledge_element (Score_element_info i);
+  virtual void do_removal_processing ();
+  virtual bool do_try_music (Music *req_l);
+  virtual void do_process_requests();
+  virtual void do_pre_move_processing();
+  virtual void do_post_move_processing();
+
+private:
+  Link_array<Repeated_music> repeated_music_arr_;
+  Link_array<Music> alternative_music_arr_;
+  Link_array<Bar> bar_p_arr_;
+  Link_array<Volta_spanner> volta_p_arr_;
+  Array<Moment> stop_mom_arr_;
+  Array<Moment> alternative_start_mom_arr_;
+  Array<Moment> alternative_stop_mom_arr_;
+};
+
+#endif // REPEAT_ENGRAVER_HH
+
diff --git a/lily/include/volta-spanner.hh b/lily/include/volta-spanner.hh
new file mode 100644 (file)
index 0000000..18fd91a
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+  volta-spanner.hh -- part of GNU LilyPond
+
+  (c) 1997--1998 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#ifndef VOLTA_SPANNER_HH
+#define VOLTA_SPANNER_HH
+
+#include "text-def.hh"
+#include "pointer.hh"
+#include "directional-spanner.hh"
+
+/** Volta bracket with number */
+
+class Volta_spanner : public Directional_spanner
+{
+public:
+  Volta_spanner ();
+  void add_column (Note_column*);
+  P<Text_def>  tdef_p_;
+  Link_array<Note_column> column_arr_;
+  bool last_b_;
+protected:
+  virtual Molecule* brew_molecule_p () const;
+  VIRTUAL_COPY_CONS(Score_element);
+
+  virtual void do_add_processing ();
+  virtual void do_post_processing ();
+  virtual void do_substitute_dependency (Score_element*,Score_element*);
+};
+
+#endif // VOLTA_SPANNER_HH
+
index e579ca8231ea38be88313c4a66b63c945f68f394..1c3d1c71456b90b44868e28ac9c54891419f4e2e 100644 (file)
@@ -181,8 +181,8 @@ Lookup::dashed_slur (Array<Offset> controls, Real thick, Real dash) const
 
   // (lambda (o) (dashed-slur o thick dash '(stuff))
   a.lambda_ = 
-    ly_append (ly_lambda_o (),
-    gh_list (ly_append (ly_func_o ("dashed-slur"),
+    gh_append2 (ly_lambda_o (),
+    gh_list (gh_append2 (ly_func_o ("dashed-slur"),
     gh_cons (gh_double2scm (thick), 
     gh_cons (gh_double2scm (dash),
     gh_list (ly_quote_scm (gh_list (sc[1], sc[2], sc[3], sc[0], SCM_UNDEFINED)), SCM_UNDEFINED)))), SCM_UNDEFINED));
@@ -380,9 +380,10 @@ Lookup::text (String style, String text) const
          ;
       else
        {
-         if (afm_p)
+         int c = text[i];
+         if (afm_p && ((c >= 0) && (c < afm_p->char_metrics_.size ())))
            {
-             Adobe_font_char_metric m = afm_p->char_metrics_[(int)text[i]];
+             Adobe_font_char_metric m = afm_p->char_metrics_[c];
              w += m.B_.x ().length ();
              DOUT << to_str (m.B_.x ().length ()) << " ";
            }
@@ -537,4 +538,15 @@ Lookup::vbracket (Real &y) const
   return a;
 }
 
+Atom
+Lookup::volta (Real w, bool last_b) const
+{
+  Array<Real> arr;
+  arr.push (w);
+  arr.push (last_b);
+  Atom a;
+  a.lambda_ = (lambda_scm ("volta", arr));
+  a.str_ = "volta";
+  return a;
+}
 
diff --git a/lily/repeat-engraver.cc b/lily/repeat-engraver.cc
new file mode 100644 (file)
index 0000000..110169f
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+  repeat-engraver.cc -- implement Repeat_engraver
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#include "repeat-engraver.hh"
+#include "bar.hh"
+#include "musical-request.hh"
+#include "multi-measure-rest.hh"
+#include "command-request.hh"
+#include "time-description.hh"
+#include "engraver-group.hh"
+#include "repeated-music.hh"
+#include "time-description.hh"
+#include "volta-spanner.hh"
+#include "note-column.hh"
+
+ADD_THIS_TRANSLATOR (Repeat_engraver);
+
+Repeat_engraver::Repeat_engraver ()
+{
+}
+
+bool
+Repeat_engraver::do_try_music (Music* m)
+{
+  if (Repeated_music* r = dynamic_cast<Repeated_music *> (m))
+    {
+      repeated_music_arr_.push (r);
+      stop_mom_arr_.push (now_moment () + r->duration ());
+      // urg, something broken with alternative time...
+      //Moment alt_mom = now_moment () + r->repeat_p_->duration ();
+      Moment alt_mom = now_moment ();
+      for (PCursor<Music*> i (r->alternative_p_->music_p_list_p_->top ()); i.ok (); i++)
+        {
+         alternative_music_arr_.push (i.ptr ());
+         alternative_start_mom_arr_.push (alt_mom);
+         // urg, something broken with alternative time...
+         // alt_mom += i->duration ();
+         alt_mom += Moment (1);
+         alternative_stop_mom_arr_.push (alt_mom);
+       }
+      return true;
+    }
+  return false;
+}
+
+void
+Repeat_engraver::acknowledge_element (Score_element_info i)
+{
+  Moment now = now_moment ();
+  if (Note_column *nc = dynamic_cast<Note_column *> (i.elem_l_))
+    {
+      for (int i = 0; i < volta_p_arr_.size (); i++)
+        if ((now >= alternative_start_mom_arr_[i]) && volta_p_arr_[i])
+         volta_p_arr_[i]->add_column (nc);
+    }
+}
+
+void
+Repeat_engraver::do_removal_processing ()
+{
+  for (int i = 0; i < bar_p_arr_.size (); i++)
+    if (bar_p_arr_[i])
+      typeset_element (bar_p_arr_[i]);
+  for (int i = 0; i < volta_p_arr_.size (); i++)
+    if (volta_p_arr_[i])
+      typeset_element (volta_p_arr_[i]);
+}
+
+void
+Repeat_engraver::do_process_requests ()
+{  
+  for (int i = bar_p_arr_.size (); i < repeated_music_arr_.size (); i++)
+    {
+      Bar* bar_p = new Bar;
+      bar_p-> type_str_ = "|:";
+      bar_p_arr_.push (bar_p);
+      announce_element (Score_element_info (bar_p, repeated_music_arr_[i])); 
+    }
+  int bees = volta_p_arr_.size ();
+  for (int i = volta_p_arr_.size (); i < alternative_music_arr_.size (); i++)
+    {
+      Volta_spanner* v = new Volta_spanner;
+      if (i == alternative_music_arr_.size () - 1)
+        v->last_b_ = true;
+      Text_def* t = new Text_def;
+      t->text_str_ = to_str (i - bees + 1);
+      v->tdef_p_.set_p (t);
+      volta_p_arr_.push (v);
+      announce_element (Score_element_info (v, alternative_music_arr_[i]));
+    }
+}
+
+void 
+Repeat_engraver::do_pre_move_processing ()
+{
+  for (int i = bar_p_arr_.size (); i--; )
+    {
+      if (bar_p_arr_[i])
+        {
+         typeset_element (bar_p_arr_[i]);
+         bar_p_arr_[i] = 0;
+       }
+    }
+}
+
+void 
+Repeat_engraver::do_post_move_processing ()
+{
+  Moment now = now_moment ();
+  for (int i = bar_p_arr_.size (); i--; )
+    {
+      if (now >= stop_mom_arr_[i])
+       {
+         Bar* bar_p = new Bar;
+         bar_p-> type_str_ = ":|";
+         typeset_element (bar_p);
+         bar_p_arr_.del (i);
+         stop_mom_arr_.del (i);
+         repeated_music_arr_.del (i);
+       }
+    }
+  for (int i = volta_p_arr_.size (); i--; )
+    {
+      //if (now >= alternative_start_mom_arr_[i])
+      if (now >= alternative_stop_mom_arr_[i])
+        {
+         if (volta_p_arr_[i])
+           {
+             typeset_element (volta_p_arr_[i]);
+             volta_p_arr_[i] = 0;
+           }
+        }
+    }
+}
+
diff --git a/lily/repeated-music-iterator.cc b/lily/repeated-music-iterator.cc
new file mode 100644 (file)
index 0000000..66180fd
--- /dev/null
@@ -0,0 +1,91 @@
+/*   
+  repeated-music-iterator.cc --  implement Repeated_music_iterator
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
+  
+ */
+
+#include "repeated-music-iterator.hh"
+#include "repeated-music.hh"
+#include "musical-request.hh"
+#include "translator-group.hh"
+#include "command-request.hh"
+
+Repeated_music_iterator::Repeated_music_iterator ()
+{
+  repeat_iter_p_ = 0;
+  alternative_iter_p_ = 0;
+}
+
+Repeated_music_iterator::~Repeated_music_iterator ()
+{
+  delete repeat_iter_p_;
+  delete alternative_iter_p_;
+}
+
+void
+Repeated_music_iterator::do_print () const
+{
+  if (repeat_iter_p_) repeat_iter_p_->print ();
+  if (alternative_iter_p_) alternative_iter_p_->print ();
+}
+
+void
+Repeated_music_iterator::construct_children ()
+{
+  repeat_iter_p_ = get_iterator_p (repeated_music_l ()->repeat_p_);  
+}
+
+void
+Repeated_music_iterator::do_process_and_next (Moment m)
+{
+  if (first_b_)
+    {
+      bool success = report_to_l ()->try_music (repeated_music_l ());
+      if (!success)
+       music_l_->warning ( _("No one to print a volta bracket"));
+    }
+  if (repeat_iter_p_->ok ())
+    repeat_iter_p_->process_and_next (m);
+  else
+    {
+      if (!alternative_iter_p_)
+        {
+         delete repeat_iter_p_;
+         repeat_iter_p_ = 0;
+         alternative_iter_p_ = dynamic_cast<Sequential_music_iterator*>
+           (get_iterator_p (repeated_music_l ()->alternative_p_));  
+       }
+      alternative_iter_p_->process_and_next (m);
+    }
+  Music_iterator::do_process_and_next (m);
+}
+
+Moment
+Repeated_music_iterator::next_moment () const
+{
+  if (repeat_iter_p_)
+    return repeat_iter_p_->next_moment ();
+  else if (alternative_iter_p_)
+    return alternative_iter_p_->next_moment ();
+  return 0;
+}
+
+bool
+Repeated_music_iterator::ok () const
+{
+  if (repeat_iter_p_)
+    return repeat_iter_p_->ok ();
+  else if (alternative_iter_p_)
+    return alternative_iter_p_->ok ();
+  return false;
+}
+
+Repeated_music*
+Repeated_music_iterator::repeated_music_l () const
+{
+  return (Repeated_music*)Music_iterator::music_l_;
+}
+
diff --git a/lily/volta-spanner.cc b/lily/volta-spanner.cc
new file mode 100644 (file)
index 0000000..884f8c9
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+  volta-spanner.cc -- implement Volta_spanner
+
+  source file of the GNU LilyPond music typesetter
+
+  (c)  1997--1998 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#include "atom.hh"
+#include "box.hh"
+#include "debug.hh"
+#include "lookup.hh"
+#include "molecule.hh"
+#include "note-column.hh"
+#include "p-col.hh"
+#include "paper-def.hh"
+#include "volta-spanner.hh"
+#include "stem.hh"
+#include "text-def.hh"
+
+/*
+   Hmm, should probably make generic Bracket_spanner,
+   or and derive Plet and volta spanner from that.
+ */
+
+Volta_spanner::Volta_spanner ()
+{
+  dir_ = UP;
+  last_b_ = false;
+  tdef_p_.set_p (new Text_def);
+  tdef_p_->align_dir_ = CENTER;
+  tdef_p_->style_str_ = "nummer";
+}
+
+Molecule*
+Volta_spanner::brew_molecule_p () const
+{
+  Molecule* mol_p = new Molecule;
+
+  if (column_arr_.size ()){
+    Real w = width ().length ();
+    Real dy = column_arr_.top ()->extent (Y_AXIS) [dir_]
+      - column_arr_[0]->extent (Y_AXIS) [dir_];
+
+    Atom num (tdef_p_->get_atom (paper (), CENTER));
+    mol_p->add_atom (num);
+    mol_p->add_atom (lookup_l ()->volta (w, last_b_));
+  }
+  return mol_p;
+}
+  
+void
+Volta_spanner::do_add_processing ()
+{
+  if (column_arr_.size ())
+    {
+      set_bounds (LEFT, column_arr_[0]);
+      set_bounds (RIGHT, column_arr_.top ());  
+    }
+}
+  
+void
+Volta_spanner::do_post_processing ()
+{
+    if (column_arr_.size())
+       translate_axis (column_arr_[0]->extent (Y_AXIS)[dir_], Y_AXIS);
+}
+
+void
+Volta_spanner::do_substitute_dependency (Score_element* o, Score_element* n)
+{
+  if (Note_column *onc = dynamic_cast <Note_column *> (o))
+    column_arr_.substitute (onc, dynamic_cast<Note_column*> (n));
+}
+  
+void
+Volta_spanner::add_column (Note_column*n)
+{
+  column_arr_.push (n);
+  add_dependency (n);
+}
+
index df080fdfd30488a8fb536bf600a93ef94b8d7065..78a59e7e2ba0925203124ede64dc210451eae5a1 100644 (file)
@@ -25,7 +25,7 @@ C 20; Character-20; B 0.00 0.00       5.24290 6.59002
 C 21;  Character-21; B 0.00 0.00       5.24290 7.28178 
 C 22;  Character-22; B 0.00 0.00       5.24290 5.95357 
 C 23;  Character-23; B 0.00 0.00       7.86434 7.28178 
-C 24;  Character-24; B 0.00 0.00       4.66035 0 
+C 24;  Character-24; B 0.00 0.00       4.66035 0.0
 C 25;  Character-25; B 0.00 0.00       5.24291 7.28178 
 C 26;  Character-26; B 0.00 0.00       7.57307 4.51470 
 C 27;  Character-27; B 0.00 0.00       8.15562 4.51470 
index 32c75a0f2564748ba541a681bc393e50ef5684d0..6ea6920d23c9d4b469145cac2b4e3e704401f4cf 100644 (file)
@@ -16,7 +16,7 @@
         closepath fill
 } bind def
 
-/draw_decrescendo % cont height width
+/draw_decrescendo % width height cons
 {
        stafflinethickness setlinewidth
        /cresc_cont exch def
@@ -31,7 +31,7 @@
        stroke
 } bind def
 
-/draw_crescendo % cont height width
+/draw_crescendo % width height cons
 {
        stafflinethickness setlinewidth
        /cresc_cont exch def
        stroke
 } bind def
 
+/draw_volta % w last
+{
+       /last exch def
+       /volta_w exch def
+       staffheight 2 div /volta_h exch def
+       volta_t setlinewidth
+       0 0 moveto
+       0 volta_h lineto
+       volta_w volta_h lineto
+       last 0 eq {
+               volta_w 0 lineto
+       } if
+       stroke
+} bind def
+
 /draw_slur
 {
        stafflinethickness setlinewidth
index 93bf012315193ee3f29a11aac74d930c979dbdf9..7fb1fcfec790dd66a43a176a7d1dc06aa10d9d48 100644 (file)
@@ -82,6 +82,7 @@ bracket_v /bracket_u exch def
 50 /bracket_alpha exch def
 staffheight 4 div /interline exch def
 stafflinethickness 1.2 mul /tuplet_t exch def
+stafflinethickness 1.2 mul /volta_t exch def
 1 setlinecap}
 }