-%% 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
+ }
+>>
--- /dev/null
+%% 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
+ }
+ >>
+}
--- /dev/null
+%% 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
+}
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
-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
} % 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 = {
--- /dev/null
+\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
+ }
+>>
--- /dev/null
+\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
+}
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
-%% 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")))
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
}
-