\version "2.18" %\version "2.19" %%http://lsr.di.unimi.it/LSR/Item?id=890 % Two lines commented out below to allow submission to LSR % Credits: code by Pierre Perol-Schneider and Paul Morris %% http://lsr.di.unimi.it/LSR/Item?id=890 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % LSR workaround: #(set! paper-alist (cons '("snippet" . (cons (* 210 mm) (* 180 mm))) paper-alist)) \paper { #(set-paper-size "snippet") tagline = ##f } \markup\vspace #.5 #(set-global-staff-size 30) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% coloredNoteHeads = #(lambda (color-outline line-width) ;; @var{color-outline} is a boolean for whether ;; the outline is colored (#t) or the note head (#f). ;; @var{line-width} is a number, the width of ;; the outline, 7 is a good default. (lambda (grob) (let* ((fsz (ly:grob-property grob 'font-size 0.0)) (mult (magstep fsz)) (stl empty-stencil) (dur-log (ly:grob-property grob 'duration-log)) (pch (ly:event-property (event-cause grob) 'pitch)) (nnm (ly:pitch-notename pch)) (alt (ly:pitch-alteration pch)) (clr (case nnm ((0) (case alt ((-1) red) ;; Cbb ((-1/2) red) ;; Cb ((0) red) ;; C ((1/2) red) ;; C# ((1) red) ;; C## (else black))) ((1) (case alt ((-1) (x11-color 'orange)) ;; Dbb ((-1/2) (x11-color 'orange)) ;; Db ((0) (x11-color 'orange)) ;; D ((1/2) (x11-color 'orange)) ;; D# ((1) (x11-color 'orange)) ;; D## (else black))) ((2) (case alt ((-1) yellow) ;; Ebb ((-1/2) yellow) ;; Eb ((0) yellow) ;; E ((1/2) yellow) ;; E# ((1) yellow) ;; E## (else black))) ((3) (case alt ((-1) green) ;; Fbb ((-1/2) green) ;; Fb ((0) green) ;; F ((1/2) green) ;; F# ((1) green) ;; F## (else black))) ((4) (case alt ((-1) blue) ;; Gbb ((-1/2) blue) ;; Gb ((0) blue) ;; G ((1/2) blue) ;; G# ((1) blue) ;; G## (else blue))) ((5) (case alt ((-1) (x11-color 'purple)) ;; Abb ((-1/2) (x11-color 'purple)) ;; Ab ((0) (x11-color 'purple)) ;; A ((1/2) (x11-color 'purple)) ;; A# ((1) (x11-color 'purple)) ;; A## (else black))) ((6) (case alt ((-1) (x11-color 'brown)) ;; Bbb ((-1/2) (x11-color 'brown)) ;; Bb ((0) (x11-color 'brown)) ;; B ((1/2) (x11-color 'brown)) ;; B# ((1) (x11-color 'brown)) ;; B## (else black))) (else black))) (outline-clr (if color-outline clr black)) (note-clr (if color-outline black clr))) (set! stl (cond ;; quarter notes and smaller ((> dur-log 1) (grob-interpret-markup grob #{ \markup { \combine \with-color #outline-clr \path #(/ line-width 10) #'((moveto 0.07 -0.40) (curveto -0.31 0.16 0.90 0.86 1.25 0.40) (curveto 1.60 -0.12 0.46 -0.87 0.07 -0.40)) \translate #(cons (* 0.0002 line-width) 0) \with-color #note-clr \musicglyph #"noteheads.s2" } #} )) ;; half notes ((= dur-log 1) (grob-interpret-markup grob #{ \markup { \combine \with-color #outline-clr \path #(/ line-width 10) #'((moveto 0.14 -0.37) (curveto 0.26 -0.55 0.62 -0.28 0.80 -0.17) (curveto 1.05 0.00 1.36 0.16 1.24 0.37) (curveto 1.12 0.56 0.79 0.30 0.55 0.15) (curveto 0.40 0.05 0.00 -0.15 0.14 -0.37) (moveto 0.05 -0.43) (curveto -0.09 -0.23 0.11 0.17 0.25 0.29) (curveto 0.50 0.52 1.18 0.67 1.34 0.42) (curveto 1.45 0.26 1.29 -0.13 1.14 -0.28) (curveto 0.85 -0.55 0.18 -0.63 0.05 -0.43)) \translate #(cons (* 0.0002 line-width) 0) \with-color #note-clr \musicglyph #"noteheads.s1" } #} )) ;; whole notes ((= dur-log 0) (grob-interpret-markup grob #{ \markup { \combine \with-color #outline-clr \path #(/ line-width 10) #'((moveto 0.66 -0.19) (curveto 0.54 0.00 0.55 0.31 0.71 0.41) (curveto 0.90 0.54 1.21 0.40 1.34 0.20) (curveto 1.45 0.03 1.46 -0.30 1.29 -0.41) (curveto 1.11 -0.53 0.80 -0.41 0.66 -0.19) (moveto 0.00 0.00) (curveto 0.00 -0.34 0.55 -0.54 1.00 -0.54) (curveto 1.45 -0.54 2.00 -0.34 2.00 0.00) (curveto 2.00 0.35 1.46 0.54 1.00 0.545) (curveto 0.56 0.545 0.00 0.35 0.00 0.00)) \translate #(cons (* 0.0002 line-width) 0) \with-color #note-clr \musicglyph #"noteheads.s0" } #} )) ;; breve notes ((< dur-log 0) (grob-interpret-markup grob #{ \markup { \combine \with-color #outline-clr \path #(/ line-width 10) #'((moveto 0.65 -0.20) (curveto 0.51 0.02 0.53 0.32 0.69 0.42) (curveto 0.84 0.53 1.17 0.42 1.30 0.22) (curveto 1.41 0.06 1.43 -0.31 1.25 -0.42) (curveto 1.10 -0.51 0.80 -0.43 0.65 -0.20) (moveto -0.16 0.10) (lineto -0.16 -0.61) (curveto -0.16 -0.657 -0.122 -0.70 -0.075 -0.70) (curveto -0.028 -0.70 0.01 -0.657 0.01 -0.61) (lineto 0.01 -0.09) (curveto 0.05 -0.33 0.51 -0.54 0.975 -0.54) (curveto 1.51 -0.54 1.91 -0.28 1.94 -0.09) (lineto 1.94 -0.61) (curveto 1.94 -0.657 1.98 -0.70 2.025 -0.70) (curveto 2.07 -0.70 2.11 -0.657 2.11 -0.61) (lineto 2.11 0.61) (curveto 2.11 0.657 2.07 0.70 2.025 0.70) (curveto 1.98 0.70 1.94 0.657 1.94 0.61) (lineto 1.94 0.09) (curveto 1.90 0.30 1.51 0.55 0.975 0.55) (curveto 0.51 0.55 0.05 0.34 0.01 0.09) (lineto 0.01 0.61) (curveto 0.01 0.657 -0.028 0.70 -0.075 0.70) (curveto -0.122 0.70 -0.16 0.657 -0.16 0.61) (lineto -0.16 0.10)) \translate #(cons (* 0.0002 line-width) 0) \with-color #note-clr \musicglyph #"noteheads.sM1" } #} )) )) (set! (ly:grob-property grob 'stencil) (ly:stencil-scale stl mult mult))))) %%%% USAGE EXAMPLE %%%% music = \relative f' { c4 d e f g4 a b c d2 e f2 g a1 b \set Timing.measureLength = #(ly:make-moment 2/1) c\breve } \markup\italic "Thin (#1) outlines:" \new Staff \with { \override NoteHead.layer = #2 \override NoteHead.before-line-breaking = #(coloredNoteHeads #f 1) } { \music } \markup\column { \vspace #.5 \italic "Heavy (#4) outlines:" } \new Staff \with { \override NoteHead.layer = #2 \override NoteHead.before-line-breaking = #(coloredNoteHeads #f 4) } { \music } \markup\column { \vspace #.5 \italic "Mid (#2) colored outlines:" } \new Staff \with { \override NoteHead.layer = #2 \override NoteHead.before-line-breaking = #(coloredNoteHeads #t 2) } { \music } %%% LSR workaround \markup\vspace #.5