lilypond-user
[Top][All Lists]
Advanced

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

Re: Explicit placement of rests in a percussion staff


From: David Kastrup
Subject: Re: Explicit placement of rests in a percussion staff
Date: Sat, 27 Feb 2021 12:10:35 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Lukas-Fabian Moser <lfm@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



reply via email to

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