[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: |
Wed, 8 Feb 2023 19:50:38 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 |
On 08/02/2023 19:45, Alberto Simões wrote:
> I just noticed this does not support chords: \myT <c e> f
> While I can do that manually (just a couple of cases) it would be nice to
> learn how to handle these cases.
> Would it be possible?
Chords are distinguished by having the music class 'event-chord,
and the duration is on the contained notes rather than the
chord itself.
\version "2.24.0"
#(define (set-note-or-chord-duration! note-or-chord duration)
(if (music-is-of-type? note-or-chord 'event-chord)
(for-each (lambda (ev)
(when (music-is-of-type? ev 'rhythmic-event)
(ly:music-set-property! ev 'duration duration)))
(ly:music-property note-or-chord 'elements))
(ly:music-set-property! note-or-chord 'duration duration)))
myT =
#(define-music-function (pa pb) (ly:music? ly:music?)
(set-note-or-chord-duration! pa #{ 4 #})
(set-note-or-chord-duration! pb #{ 8 #})
#{ \tuplet 3/2 { #pa #pb } #})
{
\myT c( gis a4_.)
\myT c_. d^^ e4
\myT <c e>\p f
}
Best,
Jean
OpenPGP_signature
Description: OpenPGP digital signature