|
From: | Mats Bengtsson |
Subject: | Re: music function playing well with context |
Date: | Wed, 8 Feb 2023 14:46:46 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 |
On 2023-02-07 22:07, Jean Abou Samra wrote:
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! .
Out of curiosity, let's say that I have a music pattern where one of the "notes" (pitch+possible articulations/whatever) appears several times with different durations. Is there any simpler solution than
\version "2.24.0" myT = #(define-music-function (pa pb) (ly:music? ly:music?) Â (let ((pa8 (music-clone pa 'duration #{ 8 #})) Â Â Â (pa16 (music-clone pa 'duration #{ 16 #})) Â Â Â (pb8 (music-clone pb 'duration #{ 8 #})) Â Â Â (pb16 (music-clone pb 'duration #{ 16 #}))) Â Â Â #{ \tuplet 3/2 { #pa8 #pb16 #pa16 #pb8 } #})) \absolute c' { Â \myT c \f gis \p a4_. Â \myT c_. d'^^ e4 }I know that there are solutions such as http://gillesth.free.fr/Lilypond/changePitch/ available, that at least partly handles the same problem in a convenient way.
  /Mats
[Prev in Thread] | Current Thread | [Next in Thread] |