Le 22/01/2023 à 17:33, Jean Abou Samra a écrit :
Le 22/01/2023 à 17:20, Darren Ng a écrit :Define substitution function accOne() as: accOne = #(define-music-function (x ) (ly:music?) #{ $x8 $x8 $x8 $x8 $x8 #}) Call accOne() with: \accOne f Expected output is: f8 f8 f8 f8 f8 However, lilypond reports error as follows: GNU LilyPond 2.24.0 (running Guile 2.2) Processing `main.ly' Parsing... accompanimentfunc.ly:19:6: error: Guile signaled an error for the expression beginning here $ x8 $x8 $x8 $x8 $x8 Unbound variable: x8 accompanimentfunc.ly:19:10: error: Guile signaled an error for the expression beginning here $x8 $ x8 $x8 $x8 $x8 Unbound variable: x8 accompanimentfunc.ly:19:14: error: Guile signaled an error for the expression beginning here $x8 $x8 $ x8 $x8 $x8 Unbound variable: x8 accompanimentfunc.ly:19:18: error: Guile signaled an error for the expression beginning here $x8 $x8 $x8 $ x8 $x8 Unbound variable: x8 accompanimentfunc.ly:19:22: error: Guile signaled an error for the expression beginning here $x8 $x8 $x8 $x8 $ x8 Unbound variable: x8 Interpreting music...How to tell lilypond to look for variable "x" and make a 1/8 note out of it,instead of looking for variable "x8"?Simply insert a space between "x" and "8".
Also, the result will likely still surprise you because you are receiving the argument "x" as ly:music?, which means a full note, with its duration (implicitly taken from the previous duration if you call it as \accNote f rather than \accNote f16 for example), so the "8" parts in the function are standalone durations, which inherit the pitch from the previous note, and you get something equivalent to f4 f8 f4 f8 f4 f8 f4 f8 f4 f8 So better replace ly:music? with ly:pitch?. See also https://extending-lilypond.readthedocs.io/en/latest/music.html#argument-type-checking Best, Jean
OpenPGP_signature
Description: OpenPGP digital signature