lilypond-user
[Top][All Lists]
Advanced

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

Re: define-music-function -> unexpected EVENT_FUNCTION


From: Thomas Morley
Subject: Re: define-music-function -> unexpected EVENT_FUNCTION
Date: Tue, 27 Jan 2015 00:56:00 +0100

2015-01-26 23:55 GMT+01:00 address@hidden <address@hidden>:
> Hello Klaus,
>
> On 2015-01-26 22:08, Klaus Blum wrote:
>>
>> Hi Anders,
>>
>> the "\rightHandFinger" command can only be used for a single note, not for
>> a
>> whole "music" expression that could also be a chord or a sequence of notes
>> and rests.
>> Replacing "ly:music?" by "ly:pitch?" should do the trick:
>>
> Aha! I thought about this but I never tried it...
>
> Can you please direct me to where in the documentation this is specified!
>
>> %
>>
>> ---------------------------------------------------------------------------------
>> \version "2.19.15"
>>
>> meTrans =
>> #(define-music-function (parser location mus txt) (ly:pitch? string?)
>>     #{
>>       \transpose c cis $mus \rightHandFinger
>> \markup\normal-text\bold\fontsize #0 $txt
>>     #}
>>     )
>>
>>
>>    {
>>    \transpose c cis c' \rightHandFinger \markup\normal-text\bold\fontsize
>> #0
>> "A"
>>    \meTrans c' "a"
>>    }
>> %
>>
>> ---------------------------------------------------------------------------------
>
> This function is almost what I need. I would need to be able to write
> {
>         < e' \meTrans a'\5 "A" \meTrans cis'\6 "F" >2. e'4
> }
>
> Which doesn't work. Since \5 isn't a pitch it's a string-number (Yes I'm
> doing Tab)
>
> It doesn't seems like a'\5 counts as a ly:music. Just the a' is the music
> and \5 is a string-number.
>
>>
>> If you want to transpose more than just one note, you should split things
>> up:
>> One function to apply the fingering markup on single notes, another
>> function
>> to transpose the whole music expression:
>>
>
> If it's possible I would like to have one function only.
> I have already made some shortcuts that has the txt param as a constant.
> So I can call
> \pedA c'
>
> Where pedA =
> #(define-music-function (parser location mm)(ly:pitch?)
>           #{ \pedalAction "A" $mm #})
>
> In the real code I have switched the params and meTrans is called
> pedalAction
>
> so the music above will be written
> < e' \pedA a'\5  \pedF cis'\6  >2. e'4
>
> (Yes, I'm still fiddling with my Pedal Steel Guitar Tab mode)
>
>

How about:

\version "2.19.15"

meTrans =
#(define-music-function (parser location mus txt) (ly:music? string?)
  (if (music-is-of-type? mus 'note-event)
      (ly:music-set-property! mus 'articulations
        (cons
          #{ \rightHandFinger \markup\normal-text\bold\fontsize #0 $txt #}
          (ly:music-property mus 'articulations)))
      (ly:warning "mus is not a note-event, ignoring"))
  ;(display-scheme-music mus)
   #{
     \transpose c cis $mus
   #})


{
  \transpose c cis
  c'\5 \rightHandFinger \markup\normal-text\bold \fontsize #0 "A"

  \meTrans c'\5 "a"
}

Needs further testing, though.

Cheers,
  Harm



reply via email to

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