]> git.donarmstrong.com Git - lilypond.git/commitdiff
LSR: Update.
authorNeil Puttock <n.puttock@gmail.com>
Wed, 7 Jul 2010 00:02:34 +0000 (01:02 +0100)
committerNeil Puttock <n.puttock@gmail.com>
Wed, 7 Jul 2010 00:02:34 +0000 (01:02 +0100)
Documentation/snippets/centering-markup-on-note-heads-automatically.ly
Documentation/snippets/changing-the-interval-of-lines-on-the-stave.ly [new file with mode: 0644]
Documentation/snippets/clefs-can-be-transposed-by-arbitrary-amounts.ly [new file with mode: 0644]
Documentation/snippets/contexts-and-engravers.snippet-list
Documentation/snippets/expressive-marks.snippet-list
Documentation/snippets/marking-notes-of-spoken-parts-with-a-cross-on-the-stem.ly
Documentation/snippets/new/centering-markup-on-note-heads-automatically.ly [new file with mode: 0644]
Documentation/snippets/new/showing-the-same-articulation-above-and-below-a-note-or-chord.ly [new file with mode: 0644]
Documentation/snippets/pitches.snippet-list
Documentation/snippets/showing-the-same-articulation-above-and-below-a-note-or-chord.ly

index f970c255f26dcd16ec647ca1040f6e837a7e7d0b..75ba91aeac9dbe4b2412338325ed72be6e83a147 100644 (file)
@@ -1,48 +1,68 @@
-%% Do not edit this file; it is automatically
-%% generated from LSR http://lsr.dsi.unimi.it
-%% This file is in the public domain.
+% Do not edit this file; it is automatically
+% generated from Documentation/snippets/new
+% This file is in the public domain.
+%% Note: this file works from version 2.13.15
 \version "2.13.20"
 
 \header {
-  lsrtags = "text, tweaks-and-overrides"
-
+  lsrtags = "text, tweaks-and-overrides, contexts-and-engravers"
   texidoc = "
 For technical reasons, text scripts attached to note heads cannot
 easily be centered on a note head's width, unlike articulations.
 
-Instead of using trial-and-error offset tweaks, this snippet accesses a
-note head (or rest) from the @code{TextScript} object's horizontal
-parent (a paper column), using its extent to correct the positioning.
-
-
-
+Instead of using trial-and-error offset tweaks, this snippet uses a
+Scheme engraver to reset the horizontal parent of each markup to a
+@code{NoteColumn}.  This also allows text to follow note heads which have
+been shifted via @code{force-hshift}.
 "
   doctitle = "Centering markup on note heads automatically"
 } % begin verbatim
 
-textScriptCenterOnNote = \override TextScript #'X-offset =
-#(lambda (grob)
-   (let* ((paper-col (ly:grob-parent grob X))
-          (elts (ly:grob-object paper-col 'elements))
-          (rhythmic-head grob))
-
-     (for-each
-      (lambda (idx)
-        (let ((elt (ly:grob-array-ref elts idx)))
-          (if (grob::has-interface elt
-                                   'rhythmic-grob-interface)
-              (set! rhythmic-head elt))))
-      (reverse (iota (ly:grob-array-length elts))))
-
-     (+
-      (ly:self-alignment-interface::x-aligned-on-self grob)
-      (interval-center
-       (ly:grob-robust-relative-extent rhythmic-head rhythmic-head X)))))
-
-\relative c' {
-  \override TextScript #'self-alignment-X = #CENTER
-  \textScriptCenterOnNote
-  <c e g c>1-\markup \arrow-head #Y #UP ##t
-  <c e g c>1-\markup \huge "^"
+
+#(define (Text_align_engraver ctx)
+  (let ((scripts '())
+        (note-column #f))
+
+    `((acknowledgers
+       (note-column-interface
+        . ,(lambda (trans grob source)
+             ;; cache NoteColumn in this Voice context
+             (set! note-column grob)))
+
+       (text-script-interface
+        . ,(lambda (trans grob source)
+             ;; whenever a TextScript is acknowledged,
+             ;; add it to `scripts' list
+             (set! scripts (cons grob scripts)))))
+
+      (stop-translation-timestep
+       . ,(lambda (trans)
+            ;; if any TextScript grobs exist,
+            ;; set NoteColumn as X-parent
+            (and (pair? scripts)
+                 (for-each (lambda (script)
+                             (set! (ly:grob-parent script X) note-column))
+                           scripts))
+            ;; clear scripts ready for next timestep
+            (set! scripts '()))))))
+
+\layout {
+  \context {
+    \Voice
+    \consists #Text_align_engraver
+    \override TextScript #'X-offset =
+      #ly:self-alignment-interface::aligned-on-x-parent
+    \override TextScript #'self-alignment-X = #CENTER
+  }
 }
 
+\new Staff <<
+  \relative c'' {
+    \override NoteColumn #'force-hshift = #3
+    c1-\markup { \arrow-head #Y #DOWN ##t }
+  }
+  \\
+  \relative c' {
+    a4 a-\markup { \huge ^ } a a
+  }
+>>
diff --git a/Documentation/snippets/changing-the-interval-of-lines-on-the-stave.ly b/Documentation/snippets/changing-the-interval-of-lines-on-the-stave.ly
new file mode 100644 (file)
index 0000000..b11d748
--- /dev/null
@@ -0,0 +1,38 @@
+%% Do not edit this file; it is automatically
+%% generated from LSR http://lsr.dsi.unimi.it
+%% This file is in the public domain.
+\version "2.13.20"
+
+\header {
+  lsrtags = "pitches"
+
+  texidoc = "
+@code{staffLineLayoutFunction} is used to change the position of notes.
+This snippet shows setting its value to @code{ly:pitch-semitones} in
+order to produce a chromatic scale with the distance between each space
+and line of the stave equal to one semitone.
+
+"
+  doctitle = "Changing the interval of lines on the stave"
+} % begin verbatim
+
+scale = \relative c' {
+  a4 ais b c
+  cis4 d dis e
+  f4 fis g gis
+  a1
+}
+
+\new Staff \with {
+  \remove "Accidental_engraver"
+  staffLineLayoutFunction = #ly:pitch-semitones
+}
+{
+  <<
+    \scale
+    \context NoteNames {
+      \set printOctaveNames = ##f
+      \scale
+    }
+  >>
+}
diff --git a/Documentation/snippets/clefs-can-be-transposed-by-arbitrary-amounts.ly b/Documentation/snippets/clefs-can-be-transposed-by-arbitrary-amounts.ly
new file mode 100644 (file)
index 0000000..2033c42
--- /dev/null
@@ -0,0 +1,25 @@
+%% Do not edit this file; it is automatically
+%% generated from LSR http://lsr.dsi.unimi.it
+%% This file is in the public domain.
+\version "2.13.20"
+
+\header {
+  lsrtags = "pitches"
+
+  texidoc = "
+Clefs can be transposed by arbitrary amounts, not just by octaves.
+
+"
+  doctitle = "Clefs can be transposed by arbitrary amounts"
+} % begin verbatim
+
+\relative c' {
+  \clef treble
+  c4 c c c
+  \clef "treble_8"
+  c4 c c c
+  \clef "treble_5"
+  c4 c c c
+  \clef "treble^3"
+  c4 c c c
+}
index 4d435cd5028b1453d0d81636899a4f3026bd41b7..2b4356606f1acf0e45cc4c595369dfdf5671f9bf 100644 (file)
@@ -1,6 +1,7 @@
 adding-a-figured-bass-above-or-below-the-notes.ly
 adding-an-extra-staff-at-a-line-break.ly
 adding-an-extra-staff.ly
+centering-markup-on-note-heads-automatically.ly
 changing-midi-output-to-one-channel-per-voice.ly
 changing-time-signatures-inside-a-polymetric-section-using--scaledurations.ly
 chant-or-psalms-notation.ly
index cebfd7777b47d8f9634f4d03e065b0073e33da67..d8d9ba3be6cb1840622c576f6bad68d7f20e00bc 100644 (file)
@@ -1,4 +1,3 @@
-accidental-tie-overridden.ly
 adding-beams,-slurs,-ties-etc.-when-using-tuplet-and-non-tuplet-rhythms.ly
 adding-parentheses-around-an-expressive-mark-or-chordal-note.ly
 adjusting-the-shape-of-falls-and-doits.ly
index cae626b4af6c3bb0ca4d0a64caa404426f22121c..d8c04a8d4cf5f07066fadfd9cdc7c968f0489e8b 100644 (file)
@@ -16,19 +16,20 @@ a spoken section with the @code{\\speakOn} keyword, and end it with the
 } % begin verbatim
 
 speakOn = {
-  \override Stem #'stencil = #(lambda (grob)
-    (let* ((x-parent (ly:grob-parent grob X))
-           (is-rest? (ly:grob? (ly:grob-object x-parent 'rest))))
-      (if is-rest?
-        empty-stencil
-        (ly:stencil-combine-at-edge
-          (ly:stem::print grob)
-          Y
-          (- (ly:grob-property grob 'direction))
-          (grob-interpret-markup grob
-            (markup #:hspace -1.025 #:fontsize -4
-              #:musicglyph "noteheads.s2cross"))
-          -2.3 0))))
+  \override Stem #'stencil =
+    #(lambda (grob)
+       (let* ((x-parent (ly:grob-parent grob X))
+              (is-rest? (ly:grob? (ly:grob-object x-parent 'rest))))
+         (if is-rest?
+             empty-stencil
+             (ly:stencil-combine-at-edge
+              (ly:stem::print grob)
+              Y
+              (- (ly:grob-property grob 'direction))
+              (grob-interpret-markup grob
+                                    (markup #:center-align #:fontsize -4
+                                            #:musicglyph "noteheads.s2cross"))
+              -2.3 0))))
 }
 
 speakOff = {
diff --git a/Documentation/snippets/new/centering-markup-on-note-heads-automatically.ly b/Documentation/snippets/new/centering-markup-on-note-heads-automatically.ly
new file mode 100644 (file)
index 0000000..1a0c928
--- /dev/null
@@ -0,0 +1,63 @@
+\version "2.13.15"
+
+\header {
+  lsrtags = "text, tweaks-and-overrides, contexts-and-engravers"
+  texidoc = "
+For technical reasons, text scripts attached to note heads cannot
+easily be centered on a note head's width, unlike articulations.
+
+Instead of using trial-and-error offset tweaks, this snippet uses a
+Scheme engraver to reset the horizontal parent of each markup to a
+@code{NoteColumn}.  This also allows text to follow note heads which have
+been shifted via @code{force-hshift}.
+"
+  doctitle = "Centering markup on note heads automatically"
+}
+
+#(define (Text_align_engraver ctx)
+  (let ((scripts '())
+        (note-column #f))
+
+    `((acknowledgers
+       (note-column-interface
+        . ,(lambda (trans grob source)
+             ;; cache NoteColumn in this Voice context
+             (set! note-column grob)))
+
+       (text-script-interface
+        . ,(lambda (trans grob source)
+             ;; whenever a TextScript is acknowledged,
+             ;; add it to `scripts' list
+             (set! scripts (cons grob scripts)))))
+
+      (stop-translation-timestep
+       . ,(lambda (trans)
+            ;; if any TextScript grobs exist,
+            ;; set NoteColumn as X-parent
+            (and (pair? scripts)
+                 (for-each (lambda (script)
+                             (set! (ly:grob-parent script X) note-column))
+                           scripts))
+            ;; clear scripts ready for next timestep
+            (set! scripts '()))))))
+
+\layout {
+  \context {
+    \Voice
+    \consists #Text_align_engraver
+    \override TextScript #'X-offset =
+      #ly:self-alignment-interface::aligned-on-x-parent
+    \override TextScript #'self-alignment-X = #CENTER
+  }
+}
+
+\new Staff <<
+  \relative c'' {
+    \override NoteColumn #'force-hshift = #3
+    c1-\markup { \arrow-head #Y #DOWN ##t }
+  }
+  \\
+  \relative c' {
+    a4 a-\markup { \huge ^ } a a
+  }
+>>
diff --git a/Documentation/snippets/new/showing-the-same-articulation-above-and-below-a-note-or-chord.ly b/Documentation/snippets/new/showing-the-same-articulation-above-and-below-a-note-or-chord.ly
new file mode 100644 (file)
index 0000000..6a1a663
--- /dev/null
@@ -0,0 +1,36 @@
+\version "2.13.27"
+
+\header {
+  lsrtags = "expressive-marks, tweaks-and-overrides"
+
+  texidoc = "
+By default, LilyPond does not allow the same articulation (e.g., an
+accent, a fermata, a flageolet, etc.) to be displayed above and below a
+note.  For example, @code{c4_\\fermata^\\fermata} will only show a fermata
+below, ignoring the fermata above.  However, one can stick
+scripts (just like fingerings) inside a chord, which means it is
+possible to have as many articulations as desired.  So, the solution is to
+write the note as a chord and add the articulations inside the @code{<@dots{}>}.
+"
+  doctitle = "Showing the same articulation above and below a note or chord"
+}
+
+% The same as \flageolet, just a little smaller
+smallFlageolet =
+#(let ((m (make-articulation "flageolet")))
+   (set! (ly:music-property m 'tweaks)
+         (acons 'font-size -2
+                (ly:music-property m 'tweaks)))
+   m)
+
+\relative c' {
+  s4^"Wrong:"
+  c4_\fermata^\fermata % The second fermata is ignored!
+  <e d'>4^\smallFlageolet_\smallFlageolet
+
+  s4^"Works if written inside a chord:"
+  <e_\smallFlageolet d'^\smallFlageolet>4
+  <e_\flageolet d'^\flageolet>4
+  <e_\smallFlageolet^\smallFlageolet>4
+  <e_\fermata^\fermata>4
+}
index 9e0bb550258223434d3874f055a810ebdf753893..101d0dc519599e326aabf83ee968175986980a79 100644 (file)
@@ -3,6 +3,8 @@ altering-the-length-of-beamed-stems.ly
 ambitus-with-multiple-voices.ly
 ambitus.ly
 applying-note-head-styles-depending-on-the-step-of-the-scale.ly
+changing-the-interval-of-lines-on-the-stave.ly
+clefs-can-be-transposed-by-arbitrary-amounts.ly
 coloring-notes-depending-on-their-pitch.ly
 creating-a-sequence-of-notes-on-various-pitches.ly
 dodecaphonic-style-accidentals-for-each-note-including-naturals.ly
index 92968bb9d6f257c9f97762933a1845272f324b96..96feaa19b60b80767b01b9c08bc2a25d79acbe5e 100644 (file)
@@ -1,30 +1,25 @@
-%% Do not edit this file; it is automatically
-%% generated from LSR http://lsr.dsi.unimi.it
-%% This file is in the public domain.
-\version "2.13.20"
+% Do not edit this file; it is automatically
+% generated from Documentation/snippets/new
+% This file is in the public domain.
+%% Note: this file works from version 2.13.27
+\version "2.13.27"
 
 \header {
   lsrtags = "expressive-marks, tweaks-and-overrides"
 
   texidoc = "
-By default, LilyPond does not allow the same articulation (e.g. an
+By default, LilyPond does not allow the same articulation (e.g., an
 accent, a fermata, a flageolet, etc.) to be displayed above and below a
-note. For example, c4_\\fermata^\\fermata will only show a fermata
-below. The fermata above will simply be ignored. However, one can stick
+note.  For example, @code{c4_\\fermata^\\fermata} will only show a fermata
+below, ignoring the fermata above.  However, one can stick
 scripts (just like fingerings) inside a chord, which means it is
-possible to have as many articulations as desired. This approach has
-the advantage that it ignores the stem and positions the articulation
-relative to the note head. This can be seen in the case of the
-flageolets in the snippet. To mimic the behaviour of scripts outside a
-chord, 'add-stem-support would be required. So, the solution is to
-write the note as a chord and add the articulations inside the <...>.
-The direction will always be above, but one can tweak this via a
-\\tweak: @code{<c-\\tweak #'direction #DOWN-\\fermata^\\fermata>}
-
+possible to have as many articulations as desired.  So, the solution is to
+write the note as a chord and add the articulations inside the @code{<@dots{}>}.
 "
   doctitle = "Showing the same articulation above and below a note or chord"
 } % begin verbatim
 
+
 % The same as \flageolet, just a little smaller
 smallFlageolet =
 #(let ((m (make-articulation "flageolet")))
@@ -34,17 +29,13 @@ smallFlageolet =
    m)
 
 \relative c' {
-  s4^"wrong:"
-  c_\fermata^\fermata % The second fermata is ignored!
-  <e d'>^\smallFlageolet_\smallFlageolet
+  s4^"Wrong:"
+  c4_\fermata^\fermata % The second fermata is ignored!
+  <e d'>4^\smallFlageolet_\smallFlageolet
 
-  % it works only if you wrap the note inside a chord. By default,
-  % all articulations will be printed above, so you have to tweak
-  % the direction.
   s4^"Works if written inside a chord:"
-  <e-\tweak #'direction #DOWN -\smallFlageolet d'^\smallFlageolet>
-  <e-\tweak #'direction #DOWN -\flageolet d'^\flageolet>
-  <e-\tweak #'direction #DOWN -\smallFlageolet^\smallFlageolet>
-  <e-\tweak #'direction #DOWN -\fermata^\fermata>
+  <e_\smallFlageolet d'^\smallFlageolet>4
+  <e_\flageolet d'^\flageolet>4
+  <e_\smallFlageolet^\smallFlageolet>4
+  <e_\fermata^\fermata>4
 }
-