lilypond-devel
[Top][All Lists]
Advanced

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

[GLISS] facilitate changes of the (default-) drumStyleTable


From: Thomas Morley
Subject: [GLISS] facilitate changes of the (default-) drumStyleTable
Date: Wed, 26 Sep 2012 02:25:34 +0200

Hi,

sometimes I heard users complaining about the difficulty of changing
the appearance of customized percussion staves,

The NR "Custom percussion staves"
states: "If you do not like any of the predefined lists you can define
your own list at the top of your file." and demonstrates the use of
\set DrumStaff.drumStyleTable = #(alist->hash-table <mydrums>)
http://lilypond.org/doc/v2.17/Documentation/notation-big-page#custom-percussion-staves

But if you only want to change _one_ value in the predefined lists you
have no other chance than to follow the method mentioned above, i.e.
_completely_ redefine the whole list.

What do you think about providing a music-function, faciltating this, perhaps:

%%%%%%%%%%%%%%%%%%%%%%

\version "2.17.0"

changeDrumStyleTable =
#(define-music-function (parser location custom-style)(list?)
  (make-music
    'ApplyContext
    'procedure
    (lambda (x)
     (let* ((ctx (ly:context-property-where-defined x 'drumStyleTable))
            (dr-st-tab (ly:context-property ctx 'drumStyleTable)))
     (if (list? (car custom-style))
       (for-each (lambda (x) (hashq-set! dr-st-tab (car x) (cdr x)))
custom-style)
       (hashq-set! dr-st-tab (car custom-style) (cdr custom-style)))))))

%--- Test

customChanges =
\with {
        % changing single value:
        \changeDrumStyleTable #'(lowtom () #t 30)
        % changing a list of values:
        \changeDrumStyleTable
        #'(
           (triangle doThin #f 16)
           (bassdrum faThin #f -15)
           (snare () #f 0)
           )
}

\layout {
        \context {
                \DrumStaff
                \customChanges
        }
}
                

mus = \drummode {
        bd4  sn  bd toml8 tri
        bd ssh ss ssl  sna sn hh hh
        hhc4 r sn tri
}

\new DrumStaff {
        \mus
        <<
        \new DrumVoice { \voiceOne \mus }
        \new DrumVoice { \voiceTwo \mus }
        >>
}

%%%%%%%%%%%%%%%%%%%%%%

-Harm



reply via email to

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