Re: Scheme function to return pitchnames as markup/text

2019-11-27 Thread Stephen Cummings

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  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  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.


Re: Scheme function to return pitchnames as markup/text

2019-11-19 Thread Stephen Cummings

Quite comfortable with such cheek. Thank you.

Still, I will try to package up a more formally named version of that 
little function. A translating map or loop will then be needed to 
extract note names and render them in more conventional form, but that 
won't require inscrutable-for-me ly:xxx calls. (Pardon the mistaken 
reference to displayMusic rather than displayLilyMusic.)


I'll pursue getting my original to work for learning purposes, and with 
the thought that discarding non-pitch events early rather than late 
might be better: if pitch -> convert to custom note name -> add to 
output string -> loop; then return the string. Sure helps to know that 
pitch-notename returns a number.


David Kastrup wrote on 11/19/2019 3:43 PM:

Stephen Cummings  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.





Re: Scheme function to return pitchnames as markup/text

2019-11-19 Thread Stephen Cummings
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?


As for my effort to code my own music-to-text/markup function: 
apologies, but I left off the function name when I copied the code over. 
See correction below.


Also, I've since tried closing the " let* ( " block at the very end, 
rather than after the third binding, but that errors out too.


notenamer =
#(define-scheme-function
(pitchin)
(ly:music?)
(let* (
    (note-datum (car (ly:music-property pitchin 'elements)))
    (pitch-datum (ly:music-property note-datum 'pitch))
    (out-notename (ly:pitch-notename pitch-datum)))
#{  \markup
    \bold
    $out-notename
#}
))

Steve Cummings wrote on 11/18/2019 5:23 PM:


Though I remain baffled by Scheme and its use in LilyPond, my hope is 
to build one or more functions/procedures that would transpose input 
music and for each chord display the transposed chord's note names, 
with control over the way the names are represented (as in Cb or F# 
instead of ces and fis).


Here, I'm just asking for help with one part of the function-to-be: 
how to turn notes in LilyPond music into note names as text (schematic 
of the complete imagined function below).


Here's what I've tried so far, in LilyPond 2.19.8x, based closely on 
working procedures found on this list. Once this is running right for 
single notes I'll (hope to) get it to loop through all input music.


#(define-scheme-function
(pitchin)
(ly:music?)
(let* (
    (note-datum (car (ly:music-property pitchin 'elements)))
    (pitch-datum (ly:music-property note-datum 'pitch))
    (out-notename (ly:pitch-notename pitch-datum)))
#{  \markup
    \bold
    $out-notename
#}
))

I get "syntax error, unexpected NUMBER_IDENTIFIER" on the 
$out-notename line when calling notenamer with a note wrapped in 
braces, as in:


\notenamer {a}

Without the braces around the music,  the error is "In procedure car 
in expression (car (ly:music-property pitchin #)):Wrong type 
(expecting pair): ()


Results are the same if I do "define-music-function" instead of 
"define-scheme-function."


Many thanks for your attention and help,
Steve

PS: I have a working NoteNames reformatter but it seems to require 
listing in a substitution table the specific notes of each and every 
chord in each transposition. A custom function would allow display of 
the chord note names in a columnar stack so if these markups were used 
as text scripts they wouldn't either take too much space or collide 
with the names of adjacent notes. Alternatively, chord note names 
could be placed beneath ChordNames.




Re: Bar number position and text (especially for anacruses)

2018-06-26 Thread Stephen Cummings

Thanks so much, Andrew--never would have figured that out.

Have a long way to go before I understand the sort of code you provided 
so I just experimented with various examples I found that contained the 
word "markup" until I got successful compilation. That crude 
trial-and-error gave me a working adaptation that shrinks the text so 
that it more or less fits:


... (markup  #:tiny #:italic"pickup"))

and I now see how markups in lambda functions or whatever they're called 
can be formatted.


Anyone with suggestions for points 1 and 2?



Stephen Cummings wrote on 6/23/2018 8:07 AM:
>
 1. Vertical alignment/positioning of  bar numbers. In the output the 
parenthetical bar number for the anacrusis is higher than the remaining 
bar numbers.


 a. How can I lower it, and how can I raise the others? Are there 
commands that would automatically ensure that all are at the same 
vertical position?


 b. Not as important: is there a way to raise/lower any given bar 
number independently?


  2.  Full control over horizontal alignment of bar numbers. I (think 
I) want the bar number for the anacrusis to appear just right of the 
clef. I found commands that change the object its aligned to, but none 
of those positions were satisfactory. How can move it horizontally 
exactly where I want it? Not as important: Is the procedure different 
for other individual bar numbers?


andrew.bern...@gmail.com wrote on 6/25/2018 4:36 PM:

Hi Steve,


Re point 3:

You can do this:

  \once \set Score.barNumberFormatter =  #(lambda (bar-number 
measure-position alternative-number extra)


(markup "pickup"))

But note that the length of the text in this case is problematic. 
Nevertheless, you may find this formatter very adaptable.


Andrew

*From:*lilypond-user 
 *On Behalf Of 
*Stephen Cummings

*Sent:* Sunday, 24 June 2018 1:08 AM
*To:* lilypond-user@gnu.org
*Subject:* Bar number position and text (especially for anacruses)

3.  Changing bar number text. Can I change the text for the anacrusis 
bar number to something other than "(1)"? Like "0" or "pickup"?





___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Fix or workaround for spacing problems in SVG output?

2018-06-23 Thread Stephen Cummings
My project requires SVG rather than PDF output but LP 2.19 gives 
unexpected, unacceptable results in the spacing of some elements. The 
PDF for the code below looks fine. In the SVG, not only does the tempo 
mark print on top of the first two bar numbers but the spacing of text 
in the tempo mark is goofed up--the metronome quarter note collides with 
the "=" and I think the dash between tempo values is off to one side.


I'm a Lilypond novice. So far I've tried adding markups to the tempo 
command but they haven't worked or they've crashed. I'm quite willing to 
add lengthy hacky spacing commands even if they make the PDF look 
terrible, as long as they give the desired SVG output. So if anyone can 
suggest some specific commands to try, including where to put them, I'm 
content to experiment with nudge values and other options until the SVG 
positioning comes out ok. And if you already know that what I'm trying 
to kludge isn't kludgeable, please let me know.


If it matters, I'm making separate MIDI versions of the scores so the 
tempo mark doesn't have to be a "real" one.


I do see there's a patch addressing SVG spacing issue. Even if that 
patch fixes what I'm complaining about, I don't know from patches and 
fear that learning how to patch and compile Lilypond is beyond what I 
can do for now. If anyone can direct me to or provide me with a Windows 
version of Lilypond 2.19+ compiled with the SVG-fixing patch, well that 
would be marvelous.


Thank you,
Steve Cummings


Code:

%---

\version "2.19.48"

\book {

\paper {
  indent = #0
}

\score {
  \header {
  piece = \markup {
    \override #'(font-name . "Calibri Bold")
    \raise #1 { "Example piece" }
    " "
  }
  title = ##f
  }
  \new StaffGroup
<<
    \new staff {
  \time 2/4
  \tempo 4 = 60-80
  \bar ""
  \partial 8
    r8   |   %  0
    a'8 r8 r4    |   %  1
    b'8 c'8 r4   |   %  2
    }

    \new staff {
  \time 2/4
  \bar ""
  \partial 8
    b'8  |   %  0
    r4 e'8 d'8   |   %  1
    r4 r8 g'8    |   %  2
    }

>>
\layout {
  \context {
    \Score
  \omit SystemStartBar
  \override BarNumber.break-visibility = ##(#f #t #t4f/)
  \override BarNumber.self-alignment-X = #LEFT
  \override BarNumber #'break-align-symbols = #'(staff-bar clef) % 
#'(left-edge)

  \override BarNumber.font-size = #0.35
  barNumberVisibility = #all-bar-numbers-visible
  }
}
}
}
%---

SVG:

PDF:



___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Bar number position and text (especially for anacruses)

2018-06-23 Thread Stephen Cummings

With code below as reference, please help me with:

1. Vertical alignment/positioning of  bar numbers. In the output the 
parenthetical bar number for the anacrusis is higher than the remaining 
bar numbers.


    a. How can I lower it, and how can I raise the others? Are there 
commands that would automatically ensure that all are at the same 
vertical position?


    b. Not as important: is there a way to raise/lower any given bar 
number independently?


2.  Full control over horizontal alignment of bar numbers. I (think I) 
want the bar number for the anacrusis to appear just right of the clef. 
I found commands that change the object its aligned to, but none of 
those positions were satisfactory. How can move it horizontally exactly 
where I want it? Not as important: Is the procedure different for other 
individual bar numbers?


3.  Changing bar number text. Can I change the text for the anacrusis 
bar number to something other than "(1)"? Like "0" or "pickup"? Not as 
important: Is that also possible for any arbitrary bar number?


I can't find instructions on how to include or post example output so 
I've taken a chance and embedded an image of the output below after the 
code.


Thank you,

Steve Cummings


Code:

%---

% please note that this example "omits" the SystemStartBar, in case part 
of the solution to #2 involves choosing an object to which to align the 
bar number to.


\version "2.19.48"

\score {
  \new StaffGroup
<<
    \new staff {
  \time 2/4
  \bar ""
  \partial 8
    r8   |   %  0
    a'8 r8 r4    |   %  1
    b'8 c'8 r4   |   %  2
    }

    \new staff {
  \time 2/4
  \bar ""
  \partial 8
    b'8  |   %  0
    r4 e'8 d'8   |   %  1
    r4 r8 g'8    |   %  2
    }

>>
\layout {
  \context {
    \Score
  \omit SystemStartBar
    \override BarNumber.break-visibility = ##(#f #t #t4f/)
    \override BarNumber.self-alignment-X = #LEFT
    \override BarNumber #'break-align-symbols = #'(staff-bar clef) 
% #'(left-edge)

    \override BarNumber.font-size = #0.35
    barNumberVisibility = #all-bar-numbers-visible
  }
}
}

%---



___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user