lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Merge upStem quarter with downStem 16th


From: Thomas Morley
Subject: Re: Merge upStem quarter with downStem 16th
Date: Tue, 3 Feb 2015 23:27:40 +0100

2015-02-03 22:07 GMT+01:00 Kevin Barry <address@hidden>:
> OK I found a much simpler and slightly less hackish way to do it: just add
> \once \override Stem.X-offset = #1.25

\once \override Stem.X-offset = #1.251
is better. ;)
look at very high zoom maybe adding colors and layers for Stem and NoteHead.
The offset in Y-direction remains untouched, though...

> before the C sharp and that should keep the stem correctly positioned even
> if other things change.
>

I was looking for an automagic method to do so using 'stem-attachment,
though there is still one value which needed to be found by try and
error and I've no clue why ...

Anyway, here the code:

\version "2.19.15"
\language "english"

upperStaffTop = \relative c' {
  cs4 <cs' cs'> <cs' cs'> |
}

upperStaffBottom = \relative c' {

%% Some overrides for debugging, delete them
%  \once \override Stem.color = #red
%  \once \override Stem.layer = #-100
%  \once \override NoteHead.color = #green
  \once \override NoteHead.stem-attachment =
  #(lambda (grob)
    (let* ((stem (ly:grob-object grob 'stem))
           (stem-thick (ly:grob-property stem 'thickness))
           (layout (ly:grob-layout grob))
           (blot-diameter (ly:output-def-lookup layout 'blot-diameter))
           (default-stem-attach (ly:note-head::calc-stem-attachment grob)))

    ;(display default-stem-attach)
    ;; returns: (1.0 . 0.341476274804275)

    ;; use the reciprocal values for x/y offset
      (cons
        (+ (- (car default-stem-attach))
           ;; move the stem back using his own thickness
           ;; and blot-diameter
           (/ stem-thick 10)
           blot-diameter
           ;; n.b.
           ;; no clue where this value comes from
           ;; found it by try and error!!
           -0.012)
        (- (cdr default-stem-attach)))))

  cs16
  %% maybe add the following override
  \once \override Score.NoteColumn.X-offset = 0.9
  d fs gs cs d fs gs cs gs fs d |
}

lowerStaffTop = \relative c {
  <<
    \new Voice {
      \voiceThree \crossStaff { cs4 } s2 |
    }
    \new Voice {
      \voiceFour cs16 d fs gs \stemUp cs \clef treble d fs gs cs gs fs d |
    }
  >>
}

lowerStaffBottom = \relative c,, {
  <cs cs'>4 <cs'' cs'> \clef treble <cs' cs'> |
}

% --- Biolerplate

global = {
  \key a \major
  \time 3/4
}

upperStaff = {
  \clef treble
  \global
  <<
    \new Voice { \voiceOne \upperStaffTop }
    \new Voice { \voiceTwo \upperStaffBottom }
  >>
}

lowerStaff = {
  \clef bass
  \global
  <<
    \new Voice { \voiceThree \lowerStaffTop }
    \new Voice { \voiceFour \lowerStaffBottom }
  >>
}

\score {
  \new PianoStaff {
    <<
      \new Staff \upperStaff
      \new Staff \lowerStaff
    >>
  }
  \layout {
    \context {
      \PianoStaff
      \consists #Span_stem_engraver
    }
  }
}


Cheers,
  Harm



reply via email to

[Prev in Thread] Current Thread [Next in Thread]