lilypond-user
[Top][All Lists]
Advanced

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

Re: Notehead position


From: Thomas Morley
Subject: Re: Notehead position
Date: Fri, 19 Jul 2013 15:52:22 +0200

2013/7/19 Thomas Morley <address@hidden>:

>> 2013/7/19 Andrew Bernard <address@hidden>
>>> How would one get lilypond to place all noteheads on the right of their
>>> stems regardless of whether they are up or down?
[...]

Ah, sorry.
You wanted them right, not left:

\version "2.16.2"

%% A new NoteHead 'stencil
%% For testing only.
% #(define rhomb-note
%   (lambda (grob)
%     (let* ((stencil (ly:note-head::print grob))
%            (new-stil
%              (grob-interpret-markup grob
%                (markup #:rotate -45
%                        #:override '(box-padding . 0.3)
%                        #:box #:rotate 45
%                        #:stencil
%                        stencil))))
%     new-stil)))

stemRight =
\override NoteColumn #'before-line-breaking =
  #(lambda (grob)
    (if (not (null? (ly:grob-object grob 'note-heads)))
        (let* ((stem (ly:grob-object grob 'stem))
               (stem-dir (ly:grob-property stem 'direction))
               (layout (ly:grob-layout grob))
               (line-thickness (ly:output-def-lookup layout 'line-thickness))
               (n-h (ly:grob-array->list (ly:grob-object grob 'note-heads)))
               (stem-at
                 (map
                   (lambda (nh)
                     (ly:grob-property nh 'stem-attachment))
                   n-h)))
        ;(display "\n\tstem-at-old \t")(write stem-at)
        (for-each
          (lambda (x y)
            (ly:grob-set-property! x 'stem-attachment
              (if (= 1 stem-dir)
                  (cons (- (* 2 line-thickness) (car y)) (* -1 (cdr y)))
                  y)))
            n-h
            stem-at)
        ;; Perhaps of interest:
        ; (display "\n\tstem \t")
        ;   (write (ly:grob? stem))
        ; (display "\n\tn-h \t")
        ;   (write n-h)
        ; (display "\n\tstem-at-new \t")
        ;   (write (map
        ;            (lambda (nh)
        ;              (ly:grob-property nh 'stem-attachment))
        ;            n-h))
        ; (display "\n\tstem-dir \t")
        ;   (write stem-dir)
        ; (newline)
        )))

revertStemRight = \revert NoteColumn #'before-line-breaking

centerStem = \override NoteHead #'stem-attachment = #'(0 . 0)

%% Debugging helper
debuggingHelper = {
  \override Stem #'color = #red
  \override Stem #'layer = #10
}

\layout {
  \context {
    \Voice
    \stemRight
    % Doesn't work here with 2.16.2, needs to be put in \mus
    % Works with 2.17.22
    % \xNotesOn
    %\centerStem
    %\debuggingHelper
    %% Other NoteHead 'stencil
    %\override NoteHead #'stencil = #rhomb-note
  }
}

mus =
\relative c' {
    %% Other NoteHead 'style
    % \xNotesOn
    c d e f r s g a b c d
    \revertStemRight
    <e g f>-"What here?"
}

\new Staff \mus

\new Staff <<
\new Voice { \voiceOne \transpose c c' \mus }
\new Voice { \voiceTwo \mus }
>>

-Harm



reply via email to

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