From adda7fc183073d08e364550ce4155ba159fe982c Mon Sep 17 00:00:00 2001 From: Neil Puttock Date: Wed, 7 Jul 2010 01:02:34 +0100 Subject: [PATCH] LSR: Update. --- ...ring-markup-on-note-heads-automatically.ly | 90 +++++++++++-------- ...ging-the-interval-of-lines-on-the-stave.ly | 38 ++++++++ ...-can-be-transposed-by-arbitrary-amounts.ly | 25 ++++++ .../contexts-and-engravers.snippet-list | 1 + .../snippets/expressive-marks.snippet-list | 1 - ...f-spoken-parts-with-a-cross-on-the-stem.ly | 27 +++--- ...ring-markup-on-note-heads-automatically.ly | 63 +++++++++++++ ...ulation-above-and-below-a-note-or-chord.ly | 36 ++++++++ Documentation/snippets/pitches.snippet-list | 2 + ...ulation-above-and-below-a-note-or-chord.ly | 45 ++++------ 10 files changed, 252 insertions(+), 76 deletions(-) create mode 100644 Documentation/snippets/changing-the-interval-of-lines-on-the-stave.ly create mode 100644 Documentation/snippets/clefs-can-be-transposed-by-arbitrary-amounts.ly create mode 100644 Documentation/snippets/new/centering-markup-on-note-heads-automatically.ly create mode 100644 Documentation/snippets/new/showing-the-same-articulation-above-and-below-a-note-or-chord.ly diff --git a/Documentation/snippets/centering-markup-on-note-heads-automatically.ly b/Documentation/snippets/centering-markup-on-note-heads-automatically.ly index f970c255f2..75ba91aeac 100644 --- a/Documentation/snippets/centering-markup-on-note-heads-automatically.ly +++ b/Documentation/snippets/centering-markup-on-note-heads-automatically.ly @@ -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 - 1-\markup \arrow-head #Y #UP ##t - 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 index 0000000000..b11d748655 --- /dev/null +++ b/Documentation/snippets/changing-the-interval-of-lines-on-the-stave.ly @@ -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 index 0000000000..2033c42fd3 --- /dev/null +++ b/Documentation/snippets/clefs-can-be-transposed-by-arbitrary-amounts.ly @@ -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 +} diff --git a/Documentation/snippets/contexts-and-engravers.snippet-list b/Documentation/snippets/contexts-and-engravers.snippet-list index 4d435cd502..2b4356606f 100644 --- a/Documentation/snippets/contexts-and-engravers.snippet-list +++ b/Documentation/snippets/contexts-and-engravers.snippet-list @@ -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 diff --git a/Documentation/snippets/expressive-marks.snippet-list b/Documentation/snippets/expressive-marks.snippet-list index cebfd7777b..d8d9ba3be6 100644 --- a/Documentation/snippets/expressive-marks.snippet-list +++ b/Documentation/snippets/expressive-marks.snippet-list @@ -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 diff --git a/Documentation/snippets/marking-notes-of-spoken-parts-with-a-cross-on-the-stem.ly b/Documentation/snippets/marking-notes-of-spoken-parts-with-a-cross-on-the-stem.ly index cae626b4af..d8c04a8d4c 100644 --- a/Documentation/snippets/marking-notes-of-spoken-parts-with-a-cross-on-the-stem.ly +++ b/Documentation/snippets/marking-notes-of-spoken-parts-with-a-cross-on-the-stem.ly @@ -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 index 0000000000..1a0c928a0c --- /dev/null +++ b/Documentation/snippets/new/centering-markup-on-note-heads-automatically.ly @@ -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 index 0000000000..6a1a663820 --- /dev/null +++ b/Documentation/snippets/new/showing-the-same-articulation-above-and-below-a-note-or-chord.ly @@ -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! + 4^\smallFlageolet_\smallFlageolet + + s4^"Works if written inside a chord:" + 4 + 4 + 4 + 4 +} diff --git a/Documentation/snippets/pitches.snippet-list b/Documentation/snippets/pitches.snippet-list index 9e0bb55025..101d0dc519 100644 --- a/Documentation/snippets/pitches.snippet-list +++ b/Documentation/snippets/pitches.snippet-list @@ -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 diff --git a/Documentation/snippets/showing-the-same-articulation-above-and-below-a-note-or-chord.ly b/Documentation/snippets/showing-the-same-articulation-above-and-below-a-note-or-chord.ly index 92968bb9d6..96feaa19b6 100644 --- a/Documentation/snippets/showing-the-same-articulation-above-and-below-a-note-or-chord.ly +++ b/Documentation/snippets/showing-the-same-articulation-above-and-below-a-note-or-chord.ly @@ -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{} - +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! - ^\smallFlageolet_\smallFlageolet + s4^"Wrong:" + c4_\fermata^\fermata % The second fermata is ignored! + 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:" - - - - + 4 + 4 + 4 + 4 } - -- 2.39.5