[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Question about custom articulation
From: |
Jean Abou Samra |
Subject: |
Re: Question about custom articulation |
Date: |
Tue, 10 Jan 2023 12:28:18 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 |
Le 10/01/2023 à 08:12, Rip _Mus a écrit :
Hello,
I'm trying to define a new articulation, based on two stencils (above
and below the staff), that I wrote.
I succeeded in making two distinct articulations. However, the attempt
to create a single articulation, which chooses the stencil based on
the direction specified in the post-event, failed.
Does anyone have any advice for me?
In the script definition, you put
(stencil . (lAccUpStencil . lAccDownStencil))
which is ignored because a pair is not a valid stencil value.
(Also, you forgot unquotes, so it's a pair of symbols, not
a pair of stencils.)
Instead, try using a callback:
(stencil . ,lAccStencil)
after having defined
#(define (lAccStencil grob)
(if (eqv? UP (ly:grob-property grob 'direction))
lAccUpStencil
lAccDownStencil))
Another comment: do not do this
#(append! default-script-alist (list ...))
because
- it mutates the built-in default, so even if you put the scriptDefinitions
change in a \layout local to a \score, it will affect all scores.
- whether append! actually modifies the original list is not specified.
Example:
$ ~/lilies/2.24.0/bin/lilypond scheme-sandbox
GNU LilyPond 2.24.0 (running Guile 2.2)
Traitement de
« /home/jean/lilies/2.24.0/share/lilypond/2.24.0/ly/scheme-sandbox.ly »
Analyse...
GNU Guile 2.2.7
Copyright (C) 1995-2019 Free Software Foundation, Inc.
Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.
Enter `,help' for help.
scheme@(#{ g100}#)> (define lst (list 'a 'b 'c))
scheme@(#{ g100}#)> (append! lst '(d e f))
$1 = (a b c d e f)
scheme@(#{ g100}#)> lst
$2 = (a b c d e f)
scheme@(#{ g100}#)> (define lst2 (list))
scheme@(#{ g100}#)> (append! lst2 '(d e f))
$3 = (d e f)
scheme@(#{ g100}#)> lst2 ;; still empty
$4 = ()
Instead, you should save the result in a variable. Also, do not
use the mutating append! but the non-mutating append. Even better,
it's more efficient in Scheme to add things at the beginning
of a list rather than at the end [1], so make that
#(define my-script-alist
(cons*
`(little-accent-up
. (
(stencil . ,lAccUpStencil)
(toward-stem-shift-in-column . 0.0)
(padding . 0.20)
(avoid-slur . around)
(direction . ,UP)))
`(little-accent-down
. (
(stencil . ,lAccDownStencil)
(toward-stem-shift-in-column . 0.0)
(padding . 0.20)
(avoid-slur . around)
(direction . ,DOWN)))
`(little-accent
. (
(stencil . ,lAccStencil)
(toward-stem-shift-in-column . 0.0)
(padding . 0.20)
(avoid-slur . around)
(direction . ,UP)))
default-script-alist))
\layout {
\context {
\Score
scriptDefinitions = #my-script-alist
}
}
[1]
https://tutoriel-scheme.readthedocs.io/en/latest/listes.html#operations-de-base
and
https://tutoriel-scheme.readthedocs.io/en/latest/recursivite.html#retour-sur-les-listes
might help you understand why.
Best,
Jean
OpenPGP_signature
Description: OpenPGP digital signature