Am 26.09.2012 02:25, schrieb Thomas Morley:
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:
I like the idea of giving the user the ability to change only parts of the list without having to rewrite the full list; I think that this concept could be of use in other parts of lilypond as well, so perhaps it would be more general to
have something like

\changeTable 'drumStyleTable (...)

I'd like to avoid to have different commands with a different syntax; it makes
it harder for the user to remember ...

Oh, but a git grep "aslist->hash-table" shows that only 'drumStyleTable
seems to have a hash-table structure, so my proposal is probably useless.

+1

Marc

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

\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

_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel



_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to