Lukas-Fabian Moser <l...@gmx.de> writes: > Hi Aaron, > >> \tweak form is a little shorter, although you could bake this into a >> function if you needed to use this a lot: >> >> %%%% >> \version "2.22.0" >> >> "\\@" = >> #(define-music-function >> (staff-position music) >> (integer? ly:music?) >> #{ \tweak staff-position #staff-position #music #}) >> >> \new DrumStaff \drummode { bd4 sn \@4 r4 r8 \@-4 r } >> %%%% >> >> Not sure if \@ is a good name for this, but it is conveniently short >> like \=. > > I think the naming is a stroke of genius :-). But perhaps > surprisingly, David Kastrup's \etc shorthand is even robust enough to > allow for: > > \version "2.22.0" > > "\\@" = \tweak staff-position \etc > > \new DrumStaff \drummode { bd4 sn \@2 r4 r8 \@-4 r }
Well, I am not sure whether the drum type is not typically a more appropriate instruction than the numeric height: I should think that if you, say, change the notation convention to one using different staff positions, you'd want the rests to move along. Now void Drum_notes_engraver::process_music () { if (events_.empty ()) return; SCM tab = get_property (this, "drumStyleTable"); for (vsize i = 0; i < events_.size (); i++) { Stream_event *ev = events_[i]; Item *note = make_item ("NoteHead", ev->self_scm ()); SCM drum_type = get_property (ev, "drum-type"); SCM defn = SCM_EOL; if (from_scm<bool> (scm_hash_table_p (tab))) defn = scm_hashq_ref (tab, drum_type, SCM_EOL); if (scm_is_pair (defn)) { SCM pos = scm_caddr (defn); SCM style = scm_car (defn); SCM script = scm_cadr (defn); if (scm_is_integer (pos)) set_property (note, "staff-position", pos); if (scm_is_symbol (style)) set_property (note, "style", style); if (scm_is_string (script)) { Item *p = make_item ("Script", ev->self_scm ()); make_script_from_event (p, context (), script, 0); p->set_y_parent (note); Side_position_interface::add_support (p, note); scripts_.push_back (p); } } } } looks like the logic could easily be put in Scheme, but the lookup of drumStyleTable would have to happen at engraving time. Which begs the question whether it would not make sense to let Rest_engraver look at drum-type in the same manner it looks at pitch for the sake of potentially resolving the drum-type to staff-position mapping. Thoughts? -- David Kastrup