lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scheme question


From: Thomas Morley
Subject: Re: Scheme question
Date: Wed, 26 Dec 2018 00:13:18 +0100

Am Di., 25. Dez. 2018 um 21:19 Uhr schrieb Jacques Menu <address@hidden>:
>
> Hello folks,
>
> I don’t succeed in using ‘#:concat’ to compute the second argument to 
> ‘#(:note’ in the following Scheme code, where HERE occurs.
>
> What should I use instead? The aim is to use half the value of ‘den’ instead 
> of 4 in the previous line.
>
> Thanks for your help!
>
> JM
>
> --
>
>
> #(define-public (format-time-sig-dotted-note-horizontally grob)
>    (let* ((frac (ly:grob-property grob 'fraction))
>           (num (if (pair? frac) (car frac) 4))
>           (den (if (pair? frac) (cdr frac) 4))
>           (m (markup #:override '(baseline-skip . 0.5)
>                #:line (#:number (number->string (/ num 3))
>                                  #'"/"
>                                  #:override '(style . default)
>                                  #:raise 0.6 (#:note (number->string den) UP)
>
>                                  #:raise 0.6 (#:note #'"4." UP)
>                                  #:raise 0.6 (#:note (#:concat #'"4" #'".") 
> UP) ;; HERE
>                                  )
>             )
>           )
>           )
>      (grob-interpret-markup grob m)))
>
>  Starting lilypond 2.19.82 [NotesInTimeSignatureExample.ly]...
> Processing 
> `/Users/menu/Documents/LaTeX/PartitionsLilypond/NotesInTimeSignatureExample.ly'
> Parsing...
> Interpreting music...[8]
> Preprocessing graphical 
> objects.../Applications/LilyPond.app/Contents/Resources/share/lilypond/current/scm/markup-macros.scm:368:18:
>  In procedure car in expression (car expr):
> /Applications/LilyPond.app/Contents/Resources/share/lilypond/current/scm/markup-macros.scm:368:18:
>  Wrong type (expecting pair): "4"
> Exited with return code 1.

Hi,

in scheme-syntax don't prepend strings with a #-sign:
$(markup (#:note "4." UP))

concat-markup expects a markup-list, thus place parens correctly:
$(markup (#:concat ("4" ".")))

Though, note-markup expects a string (in 2.19.82), thus below does not
work, but the error-message is helpful:
$(markup (#:note (#:concat ("4" ".")) UP))
->
fatal error: make-note-markup: Invalid argument in position 1.
Expect: string, found: (#<procedure concat-markup (layout props args)>
((#<procedure simple-markup (layout props str)> "4") (#<procedure
simple-markup (layout props str)> "."))).

You need to create a simple string, here some methods:
$(markup (#:note (string-concatenate '("4" ".")) UP))
$(markup (#:note (string-append "4" ".") UP))
$(markup (#:note (format #f "~a~a" "4" ".") UP))
$(markup (#:note (format #f "~a." "4") UP))
$(markup (#:note (format #f "~a." 4) UP))


HTH,
  Harm



reply via email to

[Prev in Thread] Current Thread [Next in Thread]