Carl D. Sorensen wrote:

> I'm currently working on a music function which could do all of the tweaking
> internally.

Me too!
I'm close, but I got stuck on notehead X-extents...

- Mark



      

<<attachment: breath-tones_1.png>>

\version "2.12.1"
\include "english.ly"

#(define (stencil-width stil)
  (let ((X-ext (ly:stencil-extent stil 0)))
    (- (cdr X-ext) (car X-ext))))

#(define (center-notehead grob)
  (let* ((stil    (ly:note-head::print grob))
         (width   (stencil-width stil)))
    (/ (- width) 2)))

#(define (circStil grob)
  (let* ((line-thickness (ly:staff-symbol-line-thickness grob))
         (width (+ line-thickness 1))
         (stem-thickness (* line-thickness 1.3))
         (radius (/ (- width stem-thickness) 2))
         (duration-log (note-head::calc-duration-log grob))
         (fill-or-stroke (if (< duration-log 2) "stroke" "fill")))
    (ly:grob-set-property! grob 'stencil
      (ly:make-stencil (list 'embedded-ps
        (ly:format "
          /line-thickness ~a def
          /stem-thickness ~a def
          /radius ~a def
          /width ~a def
          /half-width width 2 div def
          /x0 half-width def
          /y0 0 def
          /x1 width stem-thickness 2 div sub def
          /y1 half-width stem-thickness 2 div sub def
          /x2 stem-thickness 2 div def
          /y2 half-width neg stem-thickness 2 div add def

          gsave
          currentpoint translate
          stem-thickness setlinewidth
          newpath
          x0 y0 radius 0 360 arc
          ~a
          grestore"
          line-thickness stem-thickness radius width fill-or-stroke))
    (cons 0 width)
    (cons 0 0)))))

#(define (circStil grob)
  (let* ((line-thickness (ly:staff-symbol-line-thickness grob))
         (stil (ly:note-head::print grob))
         (width (+ line-thickness 1))
         (stem-thickness (* line-thickness 1.3))
         (radius (/ (- width stem-thickness) 2))
         (duration-log (note-head::calc-duration-log grob))
         (fill-or-stroke (if (< duration-log 2) "stroke" "fill"))
         (offset (/ (- stem-thickness width) 2)))
    (begin (ly:grob-set-property! grob 'stencil
      (ly:make-stencil (list 'embedded-ps
        (ly:format "
          /line-thickness ~a def
          /stem-thickness ~a def
          /radius ~a def
          /width ~a def
          /half-width width 2 div def
          /x0 half-width def
          /y0 0 def
          /x1 width stem-thickness 2 div sub def
          /y1 half-width stem-thickness 2 div sub def
          /x2 stem-thickness 2 div def
          /y2 half-width neg stem-thickness 2 div add def

          gsave
          currentpoint translate
          stem-thickness setlinewidth
          newpath
          x0 y0 radius 0 360 arc
          ~a
          grestore"
          line-thickness stem-thickness radius width fill-or-stroke))
    (cons 0 width)
    (cons 0 0))))
   (ly:grob-set-property! grob 'X-offset offset)))

\score {
  \new StaffGroup 
  <<
  \new RhythmicStaff = "breath" \with {
    \remove "Time_signature_engraver"
    \override StaffSymbol #'line-count = #1
    \override Stem #'direction = #DOWN
    %\override NoteHead #'X-extent = #'(2 . 3)
    %\override NoteHead #'X-offset = #-2
    \override NoteHead #'X-offset = #circStil
  } 
  \relative gf'' {
    \time 3/8 \stopStaff s4 s16 \startStaff s
    \time 4/8 s2
    \time 2/8 s16 \stopStaff s
  }
  \new Staff = "pitch" \relative gf'' {
    \stemDown %% use \stemDown \stemNeutral with breath notes
    \time 3/8 gf4(~ gf16 \change Staff = "breath" b,~ 
    \time 4/8 b2~
    \time 2/8 b16)[ \change Staff = "pitch" r c8]
    \stemNeutral
  }
  >>
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to