[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Chromatic staff
From: |
Kevin Dalley |
Subject: |
[PATCH] Chromatic staff |
Date: |
Sun, 08 Apr 2007 09:55:47 -0700 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) XEmacs/21.4.19 (linux) |
This patch is to be applied to the head. It's a simple patch than my
previous try. Regression test included.
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 | 34 ++++++++++++++++++++++++++++++++++
lily/note-heads-engraver.cc | 25 ++++++++++++++++++-------
scm/define-context-properties.scm | 1 +
3 files changed, 53 insertions(+), 7 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..d176199
--- /dev/null
+++ b/input/regression/chromatic-scales.ly
@@ -0,0 +1,34 @@
+\version "2.10"
+\include "english.ly"
+\header{
+ texidoc="@code{staffLineLayout} is used to change the position of the notes.
+This sets @code{staffLineLayout} 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 as b c cs d ds e f fs g gs
+ a
+}
+
+\new Staff \with {
+ \remove "Accidental_engraver"
+ \remove "Key_engraver"
+ staffLineLayout = #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..c1a147f 100644
--- a/lily/note-heads-engraver.cc
+++ b/lily/note-heads-engraver.cc
@@ -48,6 +48,7 @@ Note_heads_engraver::listen_note (Stream_event *ev)
void
Note_heads_engraver::process_music ()
{
+ SCM layout_proc = get_property("staffLineLayout");
for (vsize i = 0; i < note_evs_.size (); i++)
{
Stream_event *ev = note_evs_[i];
@@ -61,11 +62,22 @@ 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 +116,6 @@ ADD_TRANSLATOR (Note_heads_engraver,
/* doc */ "Generate noteheads.",
/* create */
"NoteHead ",
- /* read */
- "middleCPosition",
- /* write */
- "");
+ /* read */ "middleCPosition "
+ "staffLineLayout",
+ /* write */ "");
diff --git a/scm/define-context-properties.scm
b/scm/define-context-properties.scm
index 0197dfe..e5de56d 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}.")
+ (staffLineLayout ,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
- [PATCH] Chromatic staff,
Kevin Dalley <=