lilypond-user
[Top][All Lists]
Advanced

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

Re: Scheme function to return pitchnames as markup/text


From: Stephen Cummings
Subject: Re: Scheme function to return pitchnames as markup/text
Date: Wed, 27 Nov 2019 07:39:42 -0800
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1

David, a follow-up--

I came across a post of yours from some years back in response to a sort-of-similar question,
in which you suggested a more direct/more succinct way to access LilyPond's music-to-string functionality,
via "value->lilystring." (More succinct, that is, if don't count the necessary "use-modules" line).

So this:

#(use-modules (scm display-lily))

musmarkA = ^\tweak self-alignment-X #CENTER
    -$(define-scheme-function (music) (ly:music?)
       (value->lily-string music)) \etc
 {
    c'\musmarkA { c' }
 }

...is equivalent, I think, to this:

musmarkA = ^\tweak self-alignment-X #CENTER
    -$(define-scheme-function (music) (ly:music?)
       (with-output-to-string (lambda () (displayLilyMusic music)))) \etc
 {
    c'\musmarkA { c' }
 }

...the suggestion you made to me.

David Kastrup wrote on 11/20/2019 3:40 AM:
Stephen Cummings <address@hidden> writes:
.....
I would be skeptical anyway that \displayLilyMusic would be the best
approach for your purpose but I did want to point out that catching
output in a string is always an option in Scheme's port model.

David Kastrup wrote on 11/19/2019 3:43 PM:
Stephen Cummings <address@hidden> writes:

Am I missing a basic LilyPond command/directive--something built-in
that takes music as input and returns note names as text? Such a
functionality would seem to be useful in all kinds of
annotations/quotations. I know about \displayMusic but its output only
goes to the console/output stream and can't be routed to markup, correct?
Hm?

musmark
= ^\tweak self-alignment-X #CENTER
   -$(define-scheme-function (music) (ly:music?)
      (with-output-to-string (lambda () (displayLilyMusic music)))) \etc

{
   c'\musmark { c' }
}

Though it's probably a bit cheeky to $\etc the scheme function
in anonymously.  But you could give a name to the define-scheme-function
call as usual.




reply via email to

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