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:14:44 +0200

Hi,

2013/7/19 Pierre Perol-Schneider <address@hidden>:
> 2013/7/19 Andrew Bernard <address@hidden>
>>
>> Greetings List,
>
>
> Hi Andrew,
>
>>
>> How would one get lilypond to place all noteheads on the right of their
>> stems regardless of whether they are up or down?
>
>
> See :  http://lsr.dsi.unimi.it/LSR/Item?id=861

This snippet moves noteheads.
For the current purpose I'd prefer to change 'stem-attachment only.
See code below.

Btw, I didn't delete my tools for testing or the lines which display
several values, maybe of interest for someone.

>
>> Or indeed, for the contemporary score I am doing, centred on the stem?
>>
> See :  http://lsr.dsi.unimi.it/LSR/Item?id=847
>
> Cheers,
> Pierre
>
>
> _______________________________________________
> lilypond-user mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/lilypond-user
>


\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))
               (line-thickness (ly:output-def-lookup (ly:grob-layout
grob) '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
    %\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 }
>>

One problem persists: what to do with the last chord?
For now I reverted 'stem-attachment there.


HTH,
  Harm



reply via email to

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