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! .
Understood. Thank you .
After looking to the example, it makes sense, but it wasn't easy to get there :-)
Always great to learn!
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:
{
\tuplet 3/2 4. { c4( gis8 c4_. d8^^) }
}
Didn't knew, but in my case it doesn't help much :-)
Thank you,
Alberto