lilypond-user
[Top][All Lists]
Advanced

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

Re: music function playing well with context


From: Jean Abou Samra
Subject: Re: music function playing well with context
Date: Tue, 7 Feb 2023 22:07:05 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0

On 07/02/2023 21:57, Alberto Simões wrote:
> Hello
> 
> I am transcribing a piece that has a lot of tuplets:
>  
>    \tuplet 3/2 { a4 b8 }
> 
> The duration of the notes is always this, just the pitch changes.
> I tried to create a music function with this code
> 
> myT = #(define-music-function (pa pb) (ly:pitch? ly:pitch?)
>         #{
>             \tuplet 3/2 { $pa 4 $pb 8 }
>         #})
> 
> it works well, but I can't combine it with the context, for instance, adding 
> slurs:
> 
>   \myT c( gis  a4_.)
> 
> also, I will need to attach other stuff to the notes:
> 
>   \myT c_. d^^ e4
> 
> I understand that having a ly:pitch argument, I can only use... pitch
> But changing it to ly:music?, I am not being able to control the notes 
> duration.
> 
> This is my first function, so sorry if this is too basic :-)



This is not a dumb question. Try this:

\version "2.24.0"

myT =
#(define-music-function (pa pb) (ly:music? ly:music?)
   (ly:music-set-property! pa 'duration #{ 4 #})
   (ly:music-set-property! pb 'duration #{ 8 #})
    #{ \tuplet 3/2 { #pa #pb } #})

{
  \myT c( gis a4_.)
  \myT c_. d^^ e4
}


You need to receive the argument as ly:music? so as to allow
articulations on the note. Then, you can override the duration,
with ly:music-set-property! .

Also, you may already know this, but I want to make sure:
\tuplet supports a form that allows writing consecutive
tuplets with a single \tuplet command, like this:

\version "2.24.0"

{
  \tuplet 3/2 4. { c4( gis8 c4_. d8^^) }
}


Best,
Jean


Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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