]> git.donarmstrong.com Git - lilypond.git/commitdiff
Chromatic staff
authorKevin Dalley <kevin@kelphead.org>
Sat, 14 Apr 2007 23:29:55 +0000 (16:29 -0700)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 16 Apr 2007 04:31:38 +0000 (00:31 -0400)
This version of the patch incorporates Han-Wen's suggestions.
This patch allows the vertical position of each note
to be set with a scheme function.
This feature can be used for creating a chromatic staff, for example.

input/regression/chromatic-scales.ly [new file with mode: 0644]
lily/note-heads-engraver.cc
scm/define-context-properties.scm

diff --git a/input/regression/chromatic-scales.ly b/input/regression/chromatic-scales.ly
new file mode 100644 (file)
index 0000000..c16f238
--- /dev/null
@@ -0,0 +1,33 @@
+\version "2.10"
+\header{
+  texidoc="@code{staffLineLayoutFunction} is used to change the position of the notes.
+This sets @code{staffLineLayoutFunction} to @code{ly:pitch-semitones} to
+produce a chromatic scale with the distance between a consecutive
+space and line equal to one semitone.
+"
+}
+
+scales = \relative {
+  a ais b c cis d dis e f fis g gis
+  a
+}
+
+\new Staff \with {
+  \remove "Accidental_engraver"
+  \remove "Key_engraver" 
+  staffLineLayoutFunction = #ly:pitch-semitones
+  middleCPosition = #-6
+  clefGlyph = #"clefs.G"
+  clefPosition = #(+ -6 7)
+}
+{
+  \override Staff.StaffSymbol #'line-count = #5
+  \time 4/4
+  <<
+    \scales
+    \context NoteNames {
+      \set printOctaveNames= ##f
+      \scales
+    }
+  >>
+}
index a49bbbe81f64bfefb3d4d43ac1d35111a7895c44..7240d61d51e267ca9ad56a2976ba47cfd7e9ec90 100644 (file)
@@ -48,6 +48,9 @@ Note_heads_engraver::listen_note (Stream_event *ev)
 void
 Note_heads_engraver::process_music ()
 {
+  SCM c0 = get_property ("middleCPosition");
+  SCM layout_proc = get_property("staffLineLayoutFunction");
+      
   for (vsize i = 0; i < note_evs_.size (); i++)
     {
       Stream_event *ev = note_evs_[i];
@@ -61,11 +64,19 @@ Note_heads_engraver::process_music ()
        ev->origin ()->warning (_ ("NoteEvent without pitch"));
 #endif
 
-      int pos = pit ? pit->steps () : 0;
-      SCM c0 = get_property ("middleCPosition");
-      if (scm_is_number (c0))
-       pos += scm_to_int (c0);
+      int pos;
+      if (pit == 0)
+       pos = 0;
+      else if (ly_is_procedure (layout_proc)){
+       SCM pitch = ev->get_property("pitch");
+       pos = scm_to_int(scm_call_1 (layout_proc, pitch));
+      }
+      else 
+       pos = pit->steps ();
 
+      if (scm_is_number (c0))
+       pos += scm_to_int(c0);
+      
       note->set_property ("staff-position", scm_from_int (pos));
 
       /*
@@ -104,7 +115,6 @@ ADD_TRANSLATOR (Note_heads_engraver,
                /* doc */ "Generate noteheads.",
                /* create */
                "NoteHead ",
-               /* read */
-               "middleCPosition",
-               /* write */
-               "");
+               /* read */ "middleCPosition "
+               "staffLineLayoutFunction ",
+               /* write */ "");
index 0197dfea479ccadd62a70e88e2600a00e009daac..1d0b28cf6ca3a295de73bbf82b08076e0dfc0d78 100644 (file)
@@ -380,6 +380,7 @@ up the interpretation phase. This speeds up debugging large scores.")
      (squashedPosition ,integer? " Vertical position of
 squashing for @internalsref{Pitch_squash_engraver}.")
 
+     (staffLineLayoutFunction ,procedure? "Layout of staff lines, 'traditional, or 'semitone.")
      (stringNumberOrientations ,list? "See @code{fingeringOrientations}")
      (strokeFingerOrientations ,list? "See @code{fingeringOrientations}")
      (stringOneTopmost ,boolean? "Whether the 1st string is printed on the