lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Chromatic staff


From: Kevin Dalley
Subject: Re: [PATCH] Chromatic staff
Date: Sat, 14 Apr 2007 16:51:07 -0700
User-agent: Gnus/5.110006 (No Gnus v0.6) XEmacs/21.4.19 (linux)

Sorry, I didn't realize that braces are prohibited when there is only
one line.  You might want to mention that on the coding standards
page. 

I included a new improved patch below.  I hope that it follows your
suggestions. 

I believe that I am using the gnu style, which is your
recommended style.  If I'm missing anything else, please note it.

I'm not sure that I understand the use of a space before a closing "
in the '/* read */' section.  The use in the code does not seem
consistent, but that may be part of your point.

>From 9346e6f6a84b6d943358e452a8c6bcffa458287f Mon Sep 17 00:00:00 2001
From: Kevin Dalley <address@hidden>
Date: Sat, 14 Apr 2007 16:29:55 -0700
Subject: [PATCH] Chromatic staff
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 |   33 +++++++++++++++++++++++++++++++++
 lily/note-heads-engraver.cc          |   26 ++++++++++++++++++--------
 scm/define-context-properties.scm    |    1 +
 3 files changed, 52 insertions(+), 8 deletions(-)
 create mode 100644 input/regression/chromatic-scales.ly

diff --git a/input/regression/chromatic-scales.ly 
b/input/regression/chromatic-scales.ly
new file mode 100644
index 0000000..c16f238
--- /dev/null
+++ b/input/regression/chromatic-scales.ly
@@ -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
+    }
+  >>
+}
diff --git a/lily/note-heads-engraver.cc b/lily/note-heads-engraver.cc
index a49bbbe..7240d61 100644
--- a/lily/note-heads-engraver.cc
+++ b/lily/note-heads-engraver.cc
@@ -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 */ "");
diff --git a/scm/define-context-properties.scm 
b/scm/define-context-properties.scm
index 0197dfe..1d0b28c 100644
--- a/scm/define-context-properties.scm
+++ b/scm/define-context-properties.scm
@@ -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
-- 
1.5.0.3





reply via email to

[Prev in Thread] Current Thread [Next in Thread]