Hi all,

I wrote a small function which makes it possible to use custom stencils for 
NoteHeads in a costum drumstyle-table.
This issue has come up a few times in the past:
http://www.mail-archive.com/lilypond-user@gnu.org/msg44108.html
http://www.mail-archive.com/lilypond-user@gnu.org/msg45133.html

Actually my function is more of a dirty workaround than actually creating new 
notehead styles such as 'cross or 'xcircle because to achieve that it would be 
necessary to change the LP source (at least that's what I think, maybe one of 
the more skilled Scheme gurus out there can prove me wrong).

Well, since this function is intended to be used for custom content I'll need 
to explain a few things how to customise the function for usage.

The first step is to create a custom drum-table.
Actually this is not really necessary but I suppose that custom stencils 
usually go hand in hand with custom drum-tables.
So, when you define your custom table the 'style field of the notes you want to 
be displayed with your custom stencil can be set to () which is just an 'empty' 
style. Something like this:
(bassdrum () #f 3)

The second step is to actually make a stencil.
I'm not gonna explain how to do that here since this topic has been covered 
quite often already.

The third step is to customise the custom-notehead function from my sample.ly 
file.
Inside the function there is a part which looks like this:

(case dt
  ((bassdrum) (set! mus (make-drum-note dt dur parallelogram)))
  ((hihat) (set! mus (make-drum-note dt dur parallelogram))))

This part has to be tweaked for custom usage.
Below is like a general instruction:

(case dt
  (([drumnote name]) (set! mus (make-drum-note dt dur [your stencil])))
  (...))

So, this is like telling those lines from your custom drum-table to be used 
with your stencil(s).
The parts with the brackets are the ones that have to be replaced by your own 
to work as you want them to.

Well, I hope this was more or less clear and that this function might be to 
some use for someone.
If there's more questions just ask.

Regards,

Tao
-- 
Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: 
http://www.gmx.net/de/go/multimessenger01
#(define mydrums
   '((bassdrum () #f -5)
     (snare () #f 0)
     (lowtom cross #f -2)
     (hihat () #f 3)))
	    
#(define parallelogram
   (ly:make-stencil (list 'embedded-ps
      "gsave
       currentpoint translate
       newpath
       0 0.25 moveto
       1.3125 0.75 lineto
       1.3125 -0.25 lineto
       0 -0.75 lineto
       closepath
       fill
       grestore" )
      (cons 0 1.3125)
      (cons 0 0)))

#(define (make-drum-note dt dur st)
   (make-music
     'SequentialMusic
     'elements
       (list
	 (make-music
	   'ContextSpeccedMusic
	   'context-type 'Bottom
	   'element
             (make-music
               'OverrideProperty
               'pop-first #t
               'grob-property-path (list (quote stencil))
               'grob-value st
               'once #t
               'symbol 'NoteHead))
	 (make-music
	   'EventChord
	   'elements
	     (list
	       (make-music
	         'NoteEvent
	         'drum-type dt
		 'duration dur))))))
		       
#(define (custom-notehead mus)
   (if (eq? (ly:music-property mus 'name) 'EventChord)
   (let* ((e (car (ly:music-property mus 'elements)))
	  (dur (ly:music-property e 'duration))
	  (dt (ly:music-property e 'drum-type)))
	 (case dt
	   ((bassdrum) (set! mus (make-drum-note dt dur parallelogram)))
	   ((hihat) (set! mus (make-drum-note dt dur parallelogram))))))
   mus)
	 
customHeads =
#(define-music-function (parser location music) (ly:music?)
   (music-map (lambda (x) (custom-notehead x)) music))

<<
\new DrumStaff \with { drumStyleTable = #(alist->hash-table mydrums) }
\new DrumVoice \drummode
{
	\customHeads { bd8 sn toml hh }
}
>>

<<attachment: sample.png>>

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to