From: Kevin Dalley Date: Sat, 14 Apr 2007 23:29:55 +0000 (-0700) Subject: Chromatic staff X-Git-Tag: release/2.11.23-1~22^2~18 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=9103f41195641e9286cfa1fb06874ad4a9daa060;p=lilypond.git 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. --- diff --git a/input/regression/chromatic-scales.ly b/input/regression/chromatic-scales.ly new file mode 100644 index 0000000000..c16f238011 --- /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 a49bbbe81f..7240d61d51 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 0197dfea47..1d0b28cf6c 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