Re: Scheme: help with "Center text below hairpin dynamics"

2021-01-27 Thread David Stephen Grant
Many thanks for this! For my case the hairpin-attached text will have
a different size to other text anyway, so a slight difference is
perfectly fine.

Best,
David

On Wed, 27 Jan 2021 at 22:59, Thomas Morley  wrote:
>
> Am Mi., 27. Jan. 2021 um 21:32 Uhr schrieb David Stephen Grant
> :
> >
> > Hi all,
> >
> > For "Center text below hairpin dynamics" in the LSR
> > (http://lsr.di.unimi.it/LSR/Snippet?id=233) I'd like the text to scale
> > with the staff size for ossia staves. Does anyone have any pointers?
> >
> > hairpinWithCenteredText =
> > #(define-music-function (parser location text) (markup?)
> >   #{
> > \once \override Voice.Hairpin.after-line-breaking =
> >   #(lambda (grob)
> > (let* ((stencil (ly:hairpin::print grob))
> >(par-y (ly:grob-parent grob Y))
> >(dir (ly:grob-property par-y 'direction))
> >(staff-space (ly:output-def-lookup
> >  (ly:grob-layout grob) 'staff-space))
> >(staff-line-thickness
> >  (ly:output-def-lookup (ly:grob-layout grob) 
> > 'line-thickness))
> >(new-stencil (ly:stencil-aligned-to
> >  (ly:stencil-combine-at-edge
> >(ly:stencil-aligned-to stencil X CENTER)
> >Y dir
> >(ly:stencil-aligned-to
> >  (grob-interpret-markup grob text) X CENTER))
> >  X LEFT))
> >(par-x (ly:grob-parent grob X))
> >(dyn-text (grob::has-interface par-x 
> > 'dynamic-text-interface))
> >(dyn-text-stencil-x-length
> >  (if dyn-text
> >(interval-length
> >  (ly:stencil-extent (ly:grob-property par-x 'stencil) 
> > X))
> >0))
> >(x-shift
> >  (if dyn-text
> >(-
> >  (+ staff-space dyn-text-stencil-x-length)
> >  (* 0.5 staff-line-thickness)) 0)))
> >
> > (ly:grob-set-property! grob 'Y-offset 0)
> > (ly:grob-set-property! grob 'stencil
> >(ly:stencil-translate-axis
> > new-stencil
> > x-shift X
> >   #})
> >
> > hairpinPoco =
> > \hairpinWithCenteredText \markup { \fontsize #-1 "poco" }
> >
> > music = {
> >   \hairpinPoco
> >   c'4 \< e' f' g' \!
> > }
> >
> > \score {
> >   <<
> > \new Staff \with {
> >   fontSize = #-5
> >   \override StaffSymbol.staff-space = #(magstep -5)
> > } \music
> > \new Staff \music
> >   >>
> > }
> >
>
> Hi David,
>
> below does a fairly good job.
> Alas, it's not perfect: The added TextScript does not have exactly the
> same size as the text added text to the hairpin and I have no clue why
> not ...
>
> hairpinWithCenteredText =
> #(define-music-function (parser location text) (markup?)
>   #{
> \once \override Voice.Hairpin.after-line-breaking =
>   #(lambda (grob)
> (let* ((stencil (ly:hairpin::print grob))
>(par-y (ly:grob-parent grob Y))
>(dir (ly:grob-property par-y 'direction))
>(staff-space (ly:output-def-lookup
>  (ly:grob-layout grob) 'staff-space))
>(staff-line-thickness
>  (ly:output-def-lookup (ly:grob-layout grob) 'line-thickness))
>(new-stencil (ly:stencil-aligned-to
>  (ly:stencil-combine-at-edge
>(ly:stencil-aligned-to stencil X CENTER)
>Y dir
>(ly:stencil-aligned-to
>  (grob-interpret-markup
>grob
>(make-fontsize-markup
>  (magnification->font-size
>(+ (ly:staff-symbol-staff-space grob)
>   (/ staff-line-thickness 2)))
>text)) X CENTER))
>  X LEFT))
>(par-x (ly:grob-parent grob X))
>(dyn-text (grob::has-interface par-x 'dynamic-text-interface))
>(dyn-text-stencil-x-length
>  (if dyn-text
>(interval-length
>  (ly:stencil-extent (ly:grob-property par-x 'stencil) X))
>0))
>(x-shift
>  (if dyn-text
>(-
>  (+ staff-space dyn-text-stencil-x-length)
>  (* 0.5 staff-line-thickness)) 0)))
>
> (ly:grob-set-property! grob 'Y-offset 0)
> (ly:grob-set-property! grob 'stencil
>(ly:stencil-translate-axis
> new-stencil
> x-shift X
>   #})
>
> hairpinPoco =
> \hairpinWithCenteredText \markup { \fontsize #-1 "poco" }
>
> music = {
>   \hairpinPoco
>   c'4 \<_"poco" e' f' g' \!
> }
>
> val = #-5
>
> \score {
>   <<
> \new Staff \with {
>   fontSize = \val
>   \override 

Re: Scheme: help with "Center text below hairpin dynamics"

2021-01-27 Thread Thomas Morley
Am Mi., 27. Jan. 2021 um 21:32 Uhr schrieb David Stephen Grant
:
>
> Hi all,
>
> For "Center text below hairpin dynamics" in the LSR
> (http://lsr.di.unimi.it/LSR/Snippet?id=233) I'd like the text to scale
> with the staff size for ossia staves. Does anyone have any pointers?
>
> hairpinWithCenteredText =
> #(define-music-function (parser location text) (markup?)
>   #{
> \once \override Voice.Hairpin.after-line-breaking =
>   #(lambda (grob)
> (let* ((stencil (ly:hairpin::print grob))
>(par-y (ly:grob-parent grob Y))
>(dir (ly:grob-property par-y 'direction))
>(staff-space (ly:output-def-lookup
>  (ly:grob-layout grob) 'staff-space))
>(staff-line-thickness
>  (ly:output-def-lookup (ly:grob-layout grob) 'line-thickness))
>(new-stencil (ly:stencil-aligned-to
>  (ly:stencil-combine-at-edge
>(ly:stencil-aligned-to stencil X CENTER)
>Y dir
>(ly:stencil-aligned-to
>  (grob-interpret-markup grob text) X CENTER))
>  X LEFT))
>(par-x (ly:grob-parent grob X))
>(dyn-text (grob::has-interface par-x 'dynamic-text-interface))
>(dyn-text-stencil-x-length
>  (if dyn-text
>(interval-length
>  (ly:stencil-extent (ly:grob-property par-x 'stencil) X))
>0))
>(x-shift
>  (if dyn-text
>(-
>  (+ staff-space dyn-text-stencil-x-length)
>  (* 0.5 staff-line-thickness)) 0)))
>
> (ly:grob-set-property! grob 'Y-offset 0)
> (ly:grob-set-property! grob 'stencil
>(ly:stencil-translate-axis
> new-stencil
> x-shift X
>   #})
>
> hairpinPoco =
> \hairpinWithCenteredText \markup { \fontsize #-1 "poco" }
>
> music = {
>   \hairpinPoco
>   c'4 \< e' f' g' \!
> }
>
> \score {
>   <<
> \new Staff \with {
>   fontSize = #-5
>   \override StaffSymbol.staff-space = #(magstep -5)
> } \music
> \new Staff \music
>   >>
> }
>

Hi David,

below does a fairly good job.
Alas, it's not perfect: The added TextScript does not have exactly the
same size as the text added text to the hairpin and I have no clue why
not ...

hairpinWithCenteredText =
#(define-music-function (parser location text) (markup?)
  #{
\once \override Voice.Hairpin.after-line-breaking =
  #(lambda (grob)
(let* ((stencil (ly:hairpin::print grob))
   (par-y (ly:grob-parent grob Y))
   (dir (ly:grob-property par-y 'direction))
   (staff-space (ly:output-def-lookup
 (ly:grob-layout grob) 'staff-space))
   (staff-line-thickness
 (ly:output-def-lookup (ly:grob-layout grob) 'line-thickness))
   (new-stencil (ly:stencil-aligned-to
 (ly:stencil-combine-at-edge
   (ly:stencil-aligned-to stencil X CENTER)
   Y dir
   (ly:stencil-aligned-to
 (grob-interpret-markup
   grob
   (make-fontsize-markup
 (magnification->font-size
   (+ (ly:staff-symbol-staff-space grob)
  (/ staff-line-thickness 2)))
   text)) X CENTER))
 X LEFT))
   (par-x (ly:grob-parent grob X))
   (dyn-text (grob::has-interface par-x 'dynamic-text-interface))
   (dyn-text-stencil-x-length
 (if dyn-text
   (interval-length
 (ly:stencil-extent (ly:grob-property par-x 'stencil) X))
   0))
   (x-shift
 (if dyn-text
   (-
 (+ staff-space dyn-text-stencil-x-length)
 (* 0.5 staff-line-thickness)) 0)))

(ly:grob-set-property! grob 'Y-offset 0)
(ly:grob-set-property! grob 'stencil
   (ly:stencil-translate-axis
new-stencil
x-shift X
  #})

hairpinPoco =
\hairpinWithCenteredText \markup { \fontsize #-1 "poco" }

music = {
  \hairpinPoco
  c'4 \<_"poco" e' f' g' \!
}

val = #-5

\score {
  <<
\new Staff \with {
  fontSize = \val
  \override StaffSymbol.staff-space = #(magstep val)
} \music
\new Staff \music
  >>
}

Cheers,
  Harm



Scheme: help with "Center text below hairpin dynamics"

2021-01-27 Thread David Stephen Grant
Hi all,

For "Center text below hairpin dynamics" in the LSR
(http://lsr.di.unimi.it/LSR/Snippet?id=233) I'd like the text to scale
with the staff size for ossia staves. Does anyone have any pointers?

hairpinWithCenteredText =
#(define-music-function (parser location text) (markup?)
  #{
\once \override Voice.Hairpin.after-line-breaking =
  #(lambda (grob)
(let* ((stencil (ly:hairpin::print grob))
   (par-y (ly:grob-parent grob Y))
   (dir (ly:grob-property par-y 'direction))
   (staff-space (ly:output-def-lookup
 (ly:grob-layout grob) 'staff-space))
   (staff-line-thickness
 (ly:output-def-lookup (ly:grob-layout grob) 'line-thickness))
   (new-stencil (ly:stencil-aligned-to
 (ly:stencil-combine-at-edge
   (ly:stencil-aligned-to stencil X CENTER)
   Y dir
   (ly:stencil-aligned-to
 (grob-interpret-markup grob text) X CENTER))
 X LEFT))
   (par-x (ly:grob-parent grob X))
   (dyn-text (grob::has-interface par-x 'dynamic-text-interface))
   (dyn-text-stencil-x-length
 (if dyn-text
   (interval-length
 (ly:stencil-extent (ly:grob-property par-x 'stencil) X))
   0))
   (x-shift
 (if dyn-text
   (-
 (+ staff-space dyn-text-stencil-x-length)
 (* 0.5 staff-line-thickness)) 0)))

(ly:grob-set-property! grob 'Y-offset 0)
(ly:grob-set-property! grob 'stencil
   (ly:stencil-translate-axis
new-stencil
x-shift X
  #})

hairpinPoco =
\hairpinWithCenteredText \markup { \fontsize #-1 "poco" }

music = {
  \hairpinPoco
  c'4 \< e' f' g' \!
}

\score {
  <<
\new Staff \with {
  fontSize = #-5
  \override StaffSymbol.staff-space = #(magstep -5)
} \music
\new Staff \music
  >>
}



Re: Scheme help request: How can else of an if-statement be made to do nothing?

2020-12-11 Thread Matthew Fong
Hello Aaron,

This makes sense, and the let statement is something I was missing (!)


mattfong

On Fri, Dec 11, 2020 at 12:54 PM Aaron Hill 
wrote:

> On 2020-12-11 12:30 pm, Matthew Fong wrote:
> > Hello Aaron,
> >
> >> .< Oh boy, that is *simple*. I went off the deep end on this, trying
> >> to
> > make another variable that would get assigned the color. That clearly
> > is
> > not the way Scheme works. The inline conditional is a thing of beauty.
> >
> > Looks like I need to spend more time studying Scheme syntax.
>
> Defining a variable would make sense if you needed the value in a few
> places, since that would cut down on redundant expressions.  But even if
> you only needed the value once, it sometimes makes sense to use
> variables to help keep other expressions simpler.  The \markup below is
> arguably easier to follow without the embedded Scheme expression:
>
> 
> print-if-defined =
> #(define-void-function
>(foo sym text)
>((boolean? #f) symbol? markup?)
>(let ((color (if foo '(0.8 0.2 0.2) '(0.2 0.8 0.2
> (if (defined? sym)
> (add-text #{ \markup \with-color #color #text #}
>
> symA = "Something"
>
> \print-if-defined symB "Text" % hidden
> \print-if-defined symA "Text" % shown, green
> \print-if-defined ##t symA "Text" % shown, red
> 
>
> NOTE: LilyPond's parser is able to interpret "symA" as a symbol on its
> own without needing to escape to Scheme syntax by writing #'symA.  Just
> something to keep in mind as I think it results in cleaner usage.
>
>
> -- Aaron Hill
>


Re: Scheme help request: How can else of an if-statement be made to do nothing?

2020-12-11 Thread Aaron Hill

On 2020-12-11 12:30 pm, Matthew Fong wrote:

Hello Aaron,

.< Oh boy, that is *simple*. I went off the deep end on this, trying 
to
make another variable that would get assigned the color. That clearly 
is

not the way Scheme works. The inline conditional is a thing of beauty.

Looks like I need to spend more time studying Scheme syntax.


Defining a variable would make sense if you needed the value in a few 
places, since that would cut down on redundant expressions.  But even if 
you only needed the value once, it sometimes makes sense to use 
variables to help keep other expressions simpler.  The \markup below is 
arguably easier to follow without the embedded Scheme expression:



print-if-defined =
#(define-void-function
  (foo sym text)
  ((boolean? #f) symbol? markup?)
  (let ((color (if foo '(0.8 0.2 0.2) '(0.2 0.8 0.2
   (if (defined? sym)
   (add-text #{ \markup \with-color #color #text #}

symA = "Something"

\print-if-defined symB "Text" % hidden
\print-if-defined symA "Text" % shown, green
\print-if-defined ##t symA "Text" % shown, red


NOTE: LilyPond's parser is able to interpret "symA" as a symbol on its 
own without needing to escape to Scheme syntax by writing #'symA.  Just 
something to keep in mind as I think it results in cleaner usage.



-- Aaron Hill



Re: Scheme help request: How can else of an if-statement be made to do nothing?

2020-12-11 Thread Matthew Fong
Hello Aaron,

>.< Oh boy, that is *simple*. I went off the deep end on this, trying to
make another variable that would get assigned the color. That clearly is
not the way Scheme works. The inline conditional is a thing of beauty.

Looks like I need to spend more time studying Scheme syntax.


Many thanks,
mattfong

On Fri, Dec 11, 2020 at 12:07 PM Aaron Hill 
wrote:

> On 2020-12-11 10:43 am, Matthew Fong wrote:
> > Hello everyone,
> >
> > Resurrecting an old thread. I've been trying my hand in Scheme
> > programming,
> > via small examples on the project I'm working on.
> >
> > I wanted to extend the variable list to this function Harm wrote, to
> > take
> > an extra boolean variable, which is pretty trivial. The boolean is
> > meant to
> > change the color of the text depending if it's true or false. But I am
> > not
> > clear on how to define the color using the boolean. The trivial way to
> > do
> > it is adding a conditional under the first if, and duplicate all the
> > code
> > except the color. Is there a proper Scheme-ish way to do this?
> > (Admittingly, I have not caught on to Scheme just yet -- my brain tends
> > to
> > work with Python)
> >
> > print-if-defined =
> > #(define-void-function (sym text) (symbol? markup?)
> >   (if (defined? sym)
> >   (add-text #{ \markup \with-color #'(0.8 0.2 0.2) #text #})))
> >
> > symA = "Something"
> >
> > \print-if-defined #'symB "Text"
> > \print-if-defined #'symA "Text"
>
> Unless I am missing something from your specific use case, you should
> only need to nest another (if ...) expression in place of the actual
> color:
>
> 
> print-if-defined =
> #(define-void-function (foo sym text) ((boolean? #f) symbol? markup?)
>(if (defined? sym)
>(add-text #{ \markup \with-color
>  #(if foo '(0.8 0.2 0.2) '(0.2 0.8 0.2))
>  #text #})))
>
> symA = "Something"
>
> \print-if-defined #'symB "Text" % hidden
> \print-if-defined #'symA "Text" % shown, green
> \print-if-defined ##t #'symA "Text" % shown, red
> 
>
>
> -- Aaron Hill
>
>


Re: Scheme help request: How can else of an if-statement be made to do nothing?

2020-12-11 Thread Aaron Hill

On 2020-12-11 10:43 am, Matthew Fong wrote:

Hello everyone,

Resurrecting an old thread. I've been trying my hand in Scheme 
programming,

via small examples on the project I'm working on.

I wanted to extend the variable list to this function Harm wrote, to 
take
an extra boolean variable, which is pretty trivial. The boolean is 
meant to
change the color of the text depending if it's true or false. But I am 
not
clear on how to define the color using the boolean. The trivial way to 
do
it is adding a conditional under the first if, and duplicate all the 
code

except the color. Is there a proper Scheme-ish way to do this?
(Admittingly, I have not caught on to Scheme just yet -- my brain tends 
to

work with Python)

print-if-defined =
#(define-void-function (sym text) (symbol? markup?)
  (if (defined? sym)
  (add-text #{ \markup \with-color #'(0.8 0.2 0.2) #text #})))

symA = "Something"

\print-if-defined #'symB "Text"
\print-if-defined #'symA "Text"


Unless I am missing something from your specific use case, you should 
only need to nest another (if ...) expression in place of the actual 
color:



print-if-defined =
#(define-void-function (foo sym text) ((boolean? #f) symbol? markup?)
  (if (defined? sym)
  (add-text #{ \markup \with-color
#(if foo '(0.8 0.2 0.2) '(0.2 0.8 0.2))
#text #})))

symA = "Something"

\print-if-defined #'symB "Text" % hidden
\print-if-defined #'symA "Text" % shown, green
\print-if-defined ##t #'symA "Text" % shown, red



-- Aaron Hill



Re: Scheme help request: How can else of an if-statement be made to do nothing?

2020-12-11 Thread Matthew Fong
Hello everyone,

Resurrecting an old thread. I've been trying my hand in Scheme programming,
via small examples on the project I'm working on.

I wanted to extend the variable list to this function Harm wrote, to take
an extra boolean variable, which is pretty trivial. The boolean is meant to
change the color of the text depending if it's true or false. But I am not
clear on how to define the color using the boolean. The trivial way to do
it is adding a conditional under the first if, and duplicate all the code
except the color. Is there a proper Scheme-ish way to do this?
(Admittingly, I have not caught on to Scheme just yet -- my brain tends to
work with Python)

print-if-defined =
#(define-void-function (sym text) (symbol? markup?)
  (if (defined? sym)
  (add-text #{ \markup \with-color #'(0.8 0.2 0.2) #text #})))

symA = "Something"

\print-if-defined #'symB "Text"
\print-if-defined #'symA "Text"


Many thanks,
mattfong


RE: Scheme help request: How can else of an if-statement be made to do nothing?

2020-10-17 Thread John Schlomann
Ah, thank you much.
John

> -Original Message-
> From: Thomas Morley [mailto:thomasmorle...@gmail.com]
> Sent: Saturday, October 17, 2020 3:14 PM
> To: John Schlomann
> Cc: David Kastrup; Jean Abou Samra; Matthew Fong; lilypond-user
> Subject: Re: Scheme help request: How can else of an if-statement be made
> to do nothing?
> 
> Am Sa., 17. Okt. 2020 um 22:09 Uhr schrieb John Schlomann
> :
> >
> > Harm,
> >
> > You used a function or macro called add-text. I can't seem to find it in any
> LilyPond or Guile manual. What is that?
> >
> > John
> 
> Hi John,
> 
> you'll find it in lily-library.scm
> 
> Cheers,
>   Harm




Re: Scheme help request: How can else of an if-statement be made to do nothing?

2020-10-17 Thread Matthew Fong
Thanks for the pointer, Harm.

Matt

On Sat, Oct 17, 2020 at 13:14 Thomas Morley 
wrote:

> Am Sa., 17. Okt. 2020 um 22:09 Uhr schrieb John Schlomann
> :
> >
> > Harm,
> >
> > You used a function or macro called add-text. I can't seem to find it in
> any LilyPond or Guile manual. What is that?
> >
> > John
>
> Hi John,
>
> you'll find it in lily-library.scm
>
> Cheers,
>   Harm
>


Re: Scheme help request: How can else of an if-statement be made to do nothing?

2020-10-17 Thread Thomas Morley
Am Sa., 17. Okt. 2020 um 22:09 Uhr schrieb John Schlomann
:
>
> Harm,
>
> You used a function or macro called add-text. I can't seem to find it in any 
> LilyPond or Guile manual. What is that?
>
> John

Hi John,

you'll find it in lily-library.scm

Cheers,
  Harm



RE: Scheme help request: How can else of an if-statement be made to do nothing?

2020-10-17 Thread John Schlomann
Harm,

You used a function or macro called add-text. I can't seem to find it in any 
LilyPond or Guile manual. What is that?

John

> -Original Message-
> From: lilypond-user [mailto:lilypond-user-
> bounces+jschlomann=wideopenwest@gnu.org] On Behalf Of Thomas
> Morley
> Sent: Saturday, October 17, 2020 2:24 PM
> To: David Kastrup
> Cc: Jean Abou Samra; Matthew Fong; lilypond-user
> Subject: Re: Scheme help request: How can else of an if-statement be made
> to do nothing?
> 
> Am Sa., 17. Okt. 2020 um 20:33 Uhr schrieb David Kastrup :
> >
> > Thomas Morley  writes:
> >
> > > Am Sa., 17. Okt. 2020 um 19:39 Uhr schrieb Jean Abou Samra
> :
> > >>
> > >> The point of interpret-markup is to turn a markup into a stencil, so I'd
> > >> use empty-stencil:
> > >>
> > >> \version "2.20.0"
> > >>
> > >> #(define-markup-command (print-if-defined layout props sym text)
> > >>  (symbol? markup?)
> > >>(if (defined? sym)
> > >>(interpret-markup layout props
> > >>  #{ \markup \with-color #'(0.8 0.2 0.2) #text #})
> > >>empty-stencil))
> > >>
> > >> symA = "Something"
> > >>
> > >> \markup {
> > >>\print-if-defined #'symA "Text"
> > >>\print-if-defined #'symB "More text"
> > >> }
> > >>
> > >
> > > An empty stencil will still be spaced (unless removed by other
> > > markup-commands).
> >
> > empty-stencil will typically not trigger additional spacing.  That's
> > typically what distinguishes it from point-stencil .
> >
> > --
> > David Kastrup
> 
> Well, I'd say it depends how that empty-stencil is consumed. See:
> 
> \markup
>   \box
>   { \stencil #point-stencil \stencil #empty-stencil \stencil #point-stencil }
> 
> Here I did something silly (of course there are warnings emitted) and
> the output _is_ affected.
> 
> Thus, the detailed use-case is important...
> 
> Cheers,
>   Harm





Re: Scheme help request: How can else of an if-statement be made to do nothing?

2020-10-17 Thread Thomas Morley
Am Sa., 17. Okt. 2020 um 20:33 Uhr schrieb David Kastrup :
>
> Thomas Morley  writes:
>
> > Am Sa., 17. Okt. 2020 um 19:39 Uhr schrieb Jean Abou Samra 
> > :
> >>
> >> The point of interpret-markup is to turn a markup into a stencil, so I'd
> >> use empty-stencil:
> >>
> >> \version "2.20.0"
> >>
> >> #(define-markup-command (print-if-defined layout props sym text)
> >>  (symbol? markup?)
> >>(if (defined? sym)
> >>(interpret-markup layout props
> >>  #{ \markup \with-color #'(0.8 0.2 0.2) #text #})
> >>empty-stencil))
> >>
> >> symA = "Something"
> >>
> >> \markup {
> >>\print-if-defined #'symA "Text"
> >>\print-if-defined #'symB "More text"
> >> }
> >>
> >
> > An empty stencil will still be spaced (unless removed by other
> > markup-commands).
>
> empty-stencil will typically not trigger additional spacing.  That's
> typically what distinguishes it from point-stencil .
>
> --
> David Kastrup

Well, I'd say it depends how that empty-stencil is consumed. See:

\markup
  \box
  { \stencil #point-stencil \stencil #empty-stencil \stencil #point-stencil }

Here I did something silly (of course there are warnings emitted) and
the output _is_ affected.

Thus, the detailed use-case is important...

Cheers,
  Harm



Re: Scheme help request: How can else of an if-statement be made to do nothing?

2020-10-17 Thread David Kastrup
Thomas Morley  writes:

> Am Sa., 17. Okt. 2020 um 19:39 Uhr schrieb Jean Abou Samra 
> :
>>
>> The point of interpret-markup is to turn a markup into a stencil, so I'd
>> use empty-stencil:
>>
>> \version "2.20.0"
>>
>> #(define-markup-command (print-if-defined layout props sym text)
>>  (symbol? markup?)
>>(if (defined? sym)
>>(interpret-markup layout props
>>  #{ \markup \with-color #'(0.8 0.2 0.2) #text #})
>>empty-stencil))
>>
>> symA = "Something"
>>
>> \markup {
>>\print-if-defined #'symA "Text"
>>\print-if-defined #'symB "More text"
>> }
>>
>
> An empty stencil will still be spaced (unless removed by other
> markup-commands).

empty-stencil will typically not trigger additional spacing.  That's
typically what distinguishes it from point-stencil .

-- 
David Kastrup



Re: Scheme help request: How can else of an if-statement be made to do nothing?

2020-10-17 Thread Matthew Fong
Hello Jean and Thomas,

Thank you -- both solutions are insightful and useful in future solutions.

I did not know about empty stencils, and I read about a void-function
earlier, but was not entirely sure how to utilize it.


Many thanks,
mattfong

On Sat, Oct 17, 2020 at 10:49 AM Thomas Morley 
wrote:

> Am Sa., 17. Okt. 2020 um 19:39 Uhr schrieb Jean Abou Samra <
> j...@abou-samra.fr>:
> >
> > Hi,
> >
> > Le 17/10/2020 à 19:27, Matthew Fong a écrit :
> >
> > > Hello Richard,
> > >
> > > I just discovered your explanation is in fact the case, and also
> > > concluded cond wouldn't work either.
> > >
> > > I might have to settle for an empty markup block for now.
> >
> > The point of interpret-markup is to turn a markup into a stencil, so I'd
> > use empty-stencil:
> >
> > \version "2.20.0"
> >
> > #(define-markup-command (print-if-defined layout props sym text)
> >  (symbol? markup?)
> >(if (defined? sym)
> >(interpret-markup layout props
> >  #{ \markup \with-color #'(0.8 0.2 0.2) #text #})
> >empty-stencil))
> >
> > symA = "Something"
> >
> > \markup {
> >\print-if-defined #'symA "Text"
> >\print-if-defined #'symB "More text"
> > }
> >
> > Best,
> > Jean
> >
> >
>
> An empty stencil will still be spaced (unless removed by other
> markup-commands).
> Why not a void-function?
>
> print-if-defined =
> #(define-void-function (sym text) (symbol? markup?)
>   (if (defined? sym)
>   (add-text #{ \markup \with-color #'(0.8 0.2 0.2) #text #})))
>
> symA = "Something"
>
> \print-if-defined #'symB "Text"
> \print-if-defined #'symA "Text"
>
> Cheers,
>   Harm
>


Re: Scheme help request: How can else of an if-statement be made to do nothing?

2020-10-17 Thread Thomas Morley
Am Sa., 17. Okt. 2020 um 19:39 Uhr schrieb Jean Abou Samra :
>
> Hi,
>
> Le 17/10/2020 à 19:27, Matthew Fong a écrit :
>
> > Hello Richard,
> >
> > I just discovered your explanation is in fact the case, and also
> > concluded cond wouldn't work either.
> >
> > I might have to settle for an empty markup block for now.
>
> The point of interpret-markup is to turn a markup into a stencil, so I'd
> use empty-stencil:
>
> \version "2.20.0"
>
> #(define-markup-command (print-if-defined layout props sym text)
>  (symbol? markup?)
>(if (defined? sym)
>(interpret-markup layout props
>  #{ \markup \with-color #'(0.8 0.2 0.2) #text #})
>empty-stencil))
>
> symA = "Something"
>
> \markup {
>\print-if-defined #'symA "Text"
>\print-if-defined #'symB "More text"
> }
>
> Best,
> Jean
>
>

An empty stencil will still be spaced (unless removed by other markup-commands).
Why not a void-function?

print-if-defined =
#(define-void-function (sym text) (symbol? markup?)
  (if (defined? sym)
  (add-text #{ \markup \with-color #'(0.8 0.2 0.2) #text #})))

symA = "Something"

\print-if-defined #'symB "Text"
\print-if-defined #'symA "Text"

Cheers,
  Harm



Re: Scheme help request: How can else of an if-statement be made to do nothing?

2020-10-17 Thread Jean Abou Samra

Hi,

Le 17/10/2020 à 19:27, Matthew Fong a écrit :


Hello Richard,

I just discovered your explanation is in fact the case, and also 
concluded cond wouldn't work either.


I might have to settle for an empty markup block for now.


The point of interpret-markup is to turn a markup into a stencil, so I'd 
use empty-stencil:


\version "2.20.0"

#(define-markup-command (print-if-defined layout props sym text)
    (symbol? markup?)
  (if (defined? sym)
      (interpret-markup layout props
        #{ \markup \with-color #'(0.8 0.2 0.2) #text #})
  empty-stencil))

symA = "Something"

\markup {
  \print-if-defined #'symA "Text"
  \print-if-defined #'symB "More text"
}

Best,
Jean




Re: Scheme help request: How can else of an if-statement be made to do nothing?

2020-10-17 Thread Matthew Fong
Hello Richard,

I just discovered your explanation is in fact the case, and also concluded
cond wouldn't work either.

I might have to settle for an empty markup block for now.


Many thanks,
mattfong

On Sat, Oct 17, 2020 at 9:55 AM Richard Shann 
wrote:

> On Sat, 2020-10-17 at 09:34 -0700, Matthew Fong wrote:
> > Hello everyone,
> >
> > No less than 10 minutes after, I discovered I skipped the section on
> > cond. That solves everything!
>
> I think you are missing something here: the if macro in Scheme does not
> require an else expression
>
> (if a b)
>
> is fine, b will be evaluated if a is not #f
>
> your real problem is that the invocation of the procedure PrintDefined
> will still evaluate to something even when you "do nothing" in the case
> where the else expression would be evaluated. Your \markup will barf if
> the invocation of \PrintDefined evaluates to something that \markup is
> not expecting.
>
> Richard
>
>
> >
> >
> > Many thanks,
> > mattfong
> >
> > On Sat, Oct 17, 2020 at 9:27 AM Matthew Fong 
> > wrote:
> > > Hello everyone,
> > >
> > > I've been digging into guile/scheme and LilyPond, and it doesn't
> > > appear that else-statements can be empty. Any pointers would be
> > > appreciated in advance.
> > >
> > > For the example below, I would prefer the else-statement here to do
> > > nothing, rather than print an empty markup: \markup { "" }, as
> > > doing so creates a small, but observable change in vertical
> > > spacing.
> > >
> > > % Print markup if a symbol is defined
> > > #(define-markup-command (PrintIfDefined layout props sym text)
> > > (symbol? markup?)
> > > (if (defined? sym)
> > > ;; Do this if true
> > > (interpret-markup layout props
> > > #{ \markup \with-color #'(0.8 0.2 0.2) #text #})
> > >
> > > ;; How do I do nothing here? (empty statement preferred)
> > > (interpret-markup layout props
> > > #{ \markup "" #})
> > > )
> > > )
> > >
> > > printInfo = 1
> > > \markup \PrintIfDefined #'printInfo "Print this if symbol printInfo
> > > is defined"
> > >
> > >
> > > Many thanks,
> > > mattfong
> > >
> > >
>


Re: Scheme help request: How can else of an if-statement be made to do nothing?

2020-10-17 Thread Richard Shann
On Sat, 2020-10-17 at 09:34 -0700, Matthew Fong wrote:
> Hello everyone,
> 
> No less than 10 minutes after, I discovered I skipped the section on
> cond. That solves everything!

I think you are missing something here: the if macro in Scheme does not
require an else expression

(if a b)

is fine, b will be evaluated if a is not #f 

your real problem is that the invocation of the procedure PrintDefined
will still evaluate to something even when you "do nothing" in the case
where the else expression would be evaluated. Your \markup will barf if
the invocation of \PrintDefined evaluates to something that \markup is
not expecting.

Richard


> 
> 
> Many thanks,
> mattfong
> 
> On Sat, Oct 17, 2020 at 9:27 AM Matthew Fong 
> wrote:
> > Hello everyone,
> > 
> > I've been digging into guile/scheme and LilyPond, and it doesn't
> > appear that else-statements can be empty. Any pointers would be
> > appreciated in advance.
> > 
> > For the example below, I would prefer the else-statement here to do
> > nothing, rather than print an empty markup: \markup { "" }, as
> > doing so creates a small, but observable change in vertical
> > spacing.
> > 
> > % Print markup if a symbol is defined
> > #(define-markup-command (PrintIfDefined layout props sym text)
> > (symbol? markup?)
> >     (if (defined? sym)
> >         ;; Do this if true
> >         (interpret-markup layout props
> >             #{ \markup \with-color #'(0.8 0.2 0.2) #text #})
> > 
> >     ;; How do I do nothing here? (empty statement preferred)
> >     (interpret-markup layout props
> >         #{ \markup "" #})
> > )
> > )
> > 
> > printInfo = 1
> > \markup \PrintIfDefined #'printInfo "Print this if symbol printInfo
> > is defined"
> > 
> > 
> > Many thanks,
> > mattfong
> > 
> > 



Re: Scheme help request: How can else of an if-statement be made to do nothing?

2020-10-17 Thread Matthew Fong
Hello everyone,

No less than 10 minutes after, I discovered I skipped the section on cond.
That solves everything!


Many thanks,
mattfong

On Sat, Oct 17, 2020 at 9:27 AM Matthew Fong  wrote:

> Hello everyone,
>
> I've been digging into guile/scheme and LilyPond, and it doesn't appear
> that else-statements can be empty. Any pointers would be appreciated in
> advance.
>
> For the example below, I would prefer the else-statement here to do
> nothing, rather than print an empty markup: \markup { "" }, as doing so
> creates a small, but observable change in vertical spacing.
>
> % Print markup if a symbol is defined
> #(define-markup-command (PrintIfDefined layout props sym text) (symbol?
> markup?)
> (if (defined? sym)
> ;; Do this if true
> (interpret-markup layout props
> #{ \markup \with-color #'(0.8 0.2 0.2) #text #})
>;; How do I do nothing here? (empty statement preferred)
>(interpret-markup layout props
>#{ \markup "" #})
> )
> )
>
> printInfo = 1
> \markup \PrintIfDefined #'printInfo "Print this if symbol printInfo is
> defined"
>
>
> Many thanks,
> mattfong
>
>


Scheme help request: How can else of an if-statement be made to do nothing?

2020-10-17 Thread Matthew Fong
Hello everyone,

I've been digging into guile/scheme and LilyPond, and it doesn't appear
that else-statements can be empty. Any pointers would be appreciated in
advance.

For the example below, I would prefer the else-statement here to do
nothing, rather than print an empty markup: \markup { "" }, as doing so
creates a small, but observable change in vertical spacing.

% Print markup if a symbol is defined
#(define-markup-command (PrintIfDefined layout props sym text) (symbol?
markup?)
(if (defined? sym)
;; Do this if true
(interpret-markup layout props
#{ \markup \with-color #'(0.8 0.2 0.2) #text #})
   ;; How do I do nothing here? (empty statement preferred)
   (interpret-markup layout props
   #{ \markup "" #})
)
)

printInfo = 1
\markup \PrintIfDefined #'printInfo "Print this if symbol printInfo is
defined"


Many thanks,
mattfong


Re: Scheme help? snippet for movement page headers

2017-11-21 Thread Timothy Lanfear

On 21/11/17 05:57, Shevek wrote:

Hi Timothy,

Where are you defining #'header:piece, inside or outside a \score block? To
clarify, I'm talking about using \fromproperty with score-level headers.

Saul




I put every \score inside its own \bookpart and define #'header:piece in 
the \bookpart, outside the \score. Although I don't recall the details 
now, I probably adopted this structure to get the page headers working.


--
Timothy Lanfear, Bristol, UK.


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


Re: Scheme help? snippet for movement page headers

2017-11-20 Thread Werner LEMBERG

> Oh ugh, Nabble wrapped my lines and now it's all ugly. :(

One of the reasons to avoid source code lines longer than, say 78
characters...


Werner

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


Re: Scheme help? snippet for movement page headers

2017-11-20 Thread Shevek
Oh ugh, Nabble wrapped my lines and now it's all ugly. :(



--
Sent from: http://lilypond.1069038.n5.nabble.com/User-f3.html

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


Re: Scheme help? snippet for movement page headers

2017-11-20 Thread Shevek
Here is a cleaner, updated version of the snippet. It now gives the stencil
the extent of the longest table of contents entry. Not ideal, but close
enough for practical use. Also added comments and cleaned up variable names.

\version "2.18.2"

#(define-markup-command (current-toc-section layout props)
   ()
   (ly:stencil-add (let* ((titles (map cddr (toc-items)))
  (sorted-titles (stable-sort titles (lambda (item1
item2)
   (<= (length
item1) (length item2)
  (biggest-title (interpret-markup layout props
(caar sorted-titles)))
  (x-extent (ly:stencil-extent biggest-title X))
  (y-extent (ly:stencil-extent biggest-title Y))
  )
 (ly:make-stencil
  `(delay-stencil-evaluation
,(delay (ly:stencil-expr
 (let* ((table (ly:output-def-lookup layout
'label-page-table))
(curr-page (chain-assoc-get
'page:page-number props))
;; TOC entries should be at the
beginning of sections/movements.
;; If a section starts mid-page, the
page header will show the new section.
;; To make it show the title
belonging to the first system of the page,
;; Change >= to <= and put TOC
entries at the END of sections.
;; That breaks the actual TOC,
however.
(labels-up-to-curr (filter (lambda
(item) (>= curr-page (cdr item))) table))
(most-recent-toc-page (apply max
(map cdr labels-up-to-curr)))
;; If there are multiple toc items
on the same page, behavior may be undefined.
(most-recent-label (filter (lambda
(item) (eq? (cdr item) most-recent-toc-page)) labels-up-to-curr))
(title-of-curr-label (cadr
(assoc-get (caar most-recent-label) (toc-items
(curr-markup (interpret-markup
layout props
   title-of-curr-label))
;; How do we get the true extent
outside of the delayed evaluation?
;(x-ext (ly:stencil-extent
curr-markup X))
;(y-ext (ly:stencil-extent
curr-markup Y))
)
   ;(set! x-extent x-ext)
   ;(set! y-extent y-ext)
   curr-markup
   
  ;; Currently, we just use the extent of the longest
toc entry for all of them
  x-extent
  y-extent
  ))
 ))

%% Uncomment below to test
% \paper {
%   evenHeaderMarkup = \markup \current-toc-section
%   oddHeaderMarkup = \markup { "foo" \current-toc-section "bar" }
% }
% 
% \score {
%   \new Staff {
% \tocItem "Title 1"
% s1
% \pageBreak
% s1
% 
%   }
% }
% 
% \score {
%   \new Staff {
% \tocItem "Title 2 is long"
% s1
% \pageBreak
% s1
% 
%   }
% }



--
Sent from: http://lilypond.1069038.n5.nabble.com/User-f3.html

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


Re: Scheme help? snippet for movement page headers

2017-11-20 Thread Shevek
Hi Timothy,

Where are you defining #'header:piece, inside or outside a \score block? To
clarify, I'm talking about using \fromproperty with score-level headers.

Saul



--
Sent from: http://lilypond.1069038.n5.nabble.com/User-f3.html

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


Re: Scheme help? snippet for movement page headers

2017-11-20 Thread Timothy Lanfear

On 20/11/17 08:45, Shevek wrote:

Hi all,

It would be quite nice to be able to use \fromproperty #'header:piece in
oddHeaderMarkup and evenHeaderMarkup, so that the title of the current
movement will display in the page header. Unfortunately, after investigating
the Lilypond source code, I can't see how to make that work, because it
requires the markup command knowing the top system of the current page and
what score it belongs to. That information isn't included in either the
layout or props argument to a markup function.

This works for me. I have a piece with several parts and several pieces 
per part. I print the piece in the odd page header and the part in the 
even page header, except for the first page of the part where I print a 
full title block.


\version "2.19.80"

\paper {
  oddHeaderMarkup = \markup \column {
    \fill-line {
  \null
  \on-the-fly #not-part-first-page \normalsize \fromproperty 
#'header:piece
  \on-the-fly #print-page-number-check-first \number \teeny 
\fromproperty #'page:page-number-string

    }
    \null
  }
  evenHeaderMarkup = \markup \column {
    \fill-line {
  \on-the-fly #print-page-number-check-first \number \teeny 
\fromproperty #'page:page-number-string
  \on-the-fly #print-page-number-check-first \normalsize 
\fromproperty #'header:part

  \null
    }
    \null
  }

}

--
Timothy Lanfear, Bristol, UK.


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


Scheme help? snippet for movement page headers

2017-11-20 Thread Shevek
Hi all,

It would be quite nice to be able to use \fromproperty #'header:piece in
oddHeaderMarkup and evenHeaderMarkup, so that the title of the current
movement will display in the page header. Unfortunately, after investigating
the Lilypond source code, I can't see how to make that work, because it
requires the markup command knowing the top system of the current page and
what score it belongs to. That information isn't included in either the
layout or props argument to a markup function.

But! Lilypond has a table of contents feature that is able to find out what
page a particular musical moment happens on, and to print it in a markup.
I've copied and hacked that code to come up with the following very rough
snippet:

\version "2.18.2"

#(define-markup-command (curent-toc-section layout props)
  ()
  (ly:stencil-add (ly:make-stencil
   `(delay-stencil-evaluation
 ,(delay (ly:stencil-expr
  (let* ((table (ly:output-def-lookup layout 'label-page-table))
  (curr (chain-assoc-get 'page:page-number props))
  (prevs (filter (lambda (item) (<= curr (cdr item)))
table))
  (winpage  (apply min (map cdr prevs)))
  (winner (filter (lambda (item) (eq? (cdr item)
winpage)) prevs))
  (wintext (cdr (assoc-get (caar winner) (toc-items
  (winmarkup (interpret-markup layout props
   (car wintext)))
 )
 (display winner)
 (interpret-markup layout props
   (car wintext))

   )))


\paper {
  evenHeaderMarkup = \markup { \curent-toc-section " " }
  oddHeaderMarkup = \markup { \curent-toc-section " " }
}

\score {
  \new Staff {
s1
\pageBreak
s1
\tocItem "Title 1"
  }
}

\score {
  \new Staff {
s1
\pageBreak
s1
\tocItem "Title 2"
  }
}

The idea here is to put a table of contents entry at the very end of the
music for each movement score, so that the page header reflects the first
system of the page. This behavior can almost certainly be improved, so that
the snippet can coexist with an actual table of context listing movement
beginning pages. Maybe the page header should just reflect if a new movement
starts on that page.

I'd much appreciate feedback on this snippet. In particular, I don't quite
understand how the delayed evaluation part of the code works — I just copied
that from the definition of page-ref in define-markup-commands.scm. It seems
silly to define a whole new stencil when in the end it's just a plain old
markup. For page numbers, it's fine to make the stencil the same size every
time using a template, but since my snippet is for movement titles, and
might be used within text flow, it really ought to have a flexible stencil
extent. Currently, the returned stencil has null extent, since I cut out the
fixed-extent code from page-ref.



--
Sent from: http://lilypond.1069038.n5.nabble.com/User-f3.html

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


Re: Scheme Help

2017-11-13 Thread Benjamin Bloomfield
Thanks, this looks very helpful.  Yes, I want any note at line-begin to be
visible, but if the note is a breve and not at line-begin I want to check
whether there is a breath mark immediately before it, or whether the note
immediately before it is not a breve, in which case the current breve needs
to be visible.

I think this may be enough for me to go on though.

Thanks very much,

*Benjamin Bloomfield*

On Sun, Nov 12, 2017 at 2:37 PM, Thomas Morley 
wrote:

> 2017-11-11 17:11 GMT+01:00 Benjamin Bloomfield :
> > I am trying to write a scheme to achieve the functionality I was asking
> > about in my earlier message.  I think that I could do it with a simple
> > callback function on the NoteHead.transparent property and make the
> notehead
> > transparent if it is a breve that is preceded by another breve and not
> the
> > first note in its system.
> >
> > It's easy enough to determine whether the NoteHead is a breve in scheme,
> but
> > how do I determine whether it's the first of its system, and how do I
> > reference the NoteHead that comes immediately before it (if any) to
> > determine whether that is also a breve?
> >
> > Thanks!
> >
> > Benjamin Bloomfield
>
> Wouldn't you want any note at line-begin to be visible? So why check
> what's the preceding?
>
> For the other stuff you may find some procedures helpful, which David
> Nalesnik had coded:
>
> %% Thanks to David Nalesnik
> #(define (at-line-end? grob)
>(let* ((col (ly:item-get-column grob))
>   (ln (ly:grob-object col 'right-neighbor))
>   (col-to-check (if (ly:grob? ln) ln col)))
>  (and (eq? #t (ly:grob-property col-to-check 'non-musical))
>   (= -1 (ly:item-break-dir col-to-check)
>
> #(define (at-line-beginning? grob)
>(let* ((col (ly:item-get-column grob))
>   (ln (ly:grob-object col 'left-neighbor))
>   (col-to-check (if (ly:grob? ln) ln col)))
>  (and (eq? #t (ly:grob-property col-to-check 'non-musical))
>   (= 1 (ly:item-break-dir col-to-check)
>
>
> {
>   \override NoteHead.after-line-breaking =
> #(lambda (grob)
>   (ly:grob-set-property! grob 'color
> (cond ((at-line-end? grob) cyan)
>   ((at-line-beginning? grob) red)
>   (else '()
>   \repeat unfold 150 c'1
> }
>
> HTH,
>   Harm
>
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Scheme Help

2017-11-12 Thread Thomas Morley
2017-11-11 17:11 GMT+01:00 Benjamin Bloomfield :
> I am trying to write a scheme to achieve the functionality I was asking
> about in my earlier message.  I think that I could do it with a simple
> callback function on the NoteHead.transparent property and make the notehead
> transparent if it is a breve that is preceded by another breve and not the
> first note in its system.
>
> It's easy enough to determine whether the NoteHead is a breve in scheme, but
> how do I determine whether it's the first of its system, and how do I
> reference the NoteHead that comes immediately before it (if any) to
> determine whether that is also a breve?
>
> Thanks!
>
> Benjamin Bloomfield

Wouldn't you want any note at line-begin to be visible? So why check
what's the preceding?

For the other stuff you may find some procedures helpful, which David
Nalesnik had coded:

%% Thanks to David Nalesnik
#(define (at-line-end? grob)
   (let* ((col (ly:item-get-column grob))
  (ln (ly:grob-object col 'right-neighbor))
  (col-to-check (if (ly:grob? ln) ln col)))
 (and (eq? #t (ly:grob-property col-to-check 'non-musical))
  (= -1 (ly:item-break-dir col-to-check)

#(define (at-line-beginning? grob)
   (let* ((col (ly:item-get-column grob))
  (ln (ly:grob-object col 'left-neighbor))
  (col-to-check (if (ly:grob? ln) ln col)))
 (and (eq? #t (ly:grob-property col-to-check 'non-musical))
  (= 1 (ly:item-break-dir col-to-check)


{
  \override NoteHead.after-line-breaking =
#(lambda (grob)
  (ly:grob-set-property! grob 'color
(cond ((at-line-end? grob) cyan)
  ((at-line-beginning? grob) red)
  (else '()
  \repeat unfold 150 c'1
}

HTH,
  Harm

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


Scheme Help

2017-11-11 Thread Benjamin Bloomfield
I am trying to write a scheme to achieve the functionality I was asking
about in my earlier message
.
I think that I could do it with a simple callback function on the
NoteHead.transparent property and make the notehead transparent if it is a
breve that is preceded by another breve and not the first note in its
system.

It's easy enough to determine whether the NoteHead is a breve in scheme,
but how do I determine whether it's the first of its system, and how do I
reference the NoteHead that comes immediately before it (if any) to
determine whether that is also a breve?

Thanks!

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


Re: Further scheme help, please

2016-05-30 Thread Andrew Bernard
Hi Simon,

It’s just the unquote-splicing operator in lilypondish.

https://www.gnu.org/software/guile/docs/docs-1.8/guile-ref/Expression-Syntax.html#index-quasiquote-2199

Andrew


On 31 May 2016 at 2:37:33 AM, Simon Albrecht wrote:


On 30.05.2016 16:18, David Kastrup wrote:
> $@(make-list n #{ \lyricmode { _ } #})

David, could you give a hint as to what the @ does here, or where it’s
documented? Obviously it’s not the use which is documented with Guile
1.8
(<
http://www.gnu.org/software/guile/docs/docs-1.8/guile-ref/Using-Guile-Modules.html#index-g_t_0040_0040-2357>).
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Further scheme help, please

2016-05-30 Thread Simon Albrecht

On 30.05.2016 18:41, David Kastrup wrote:

On 30.05.2016 16:18, David Kastrup wrote:

$@(make-list n #{ \lyricmode { _ } #})


David, could you give a hint as to what the @ does here, or where it’s
documented? Obviously it’s not the use which is documented with Guile
1.8
().

Try LilyPond.




Thanks,
Simon

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


Re: Further scheme help, please

2016-05-30 Thread David Kastrup
Simon Albrecht  writes:

> On 30.05.2016 17:23, Phil Holmes wrote:
>> I obviously need to do more potato peeling.
>
> Words of wisdom :-)
>
>
> On 30.05.2016 16:18, David Kastrup wrote:
>> $@(make-list n #{ \lyricmode { _ } #})
>
> David, could you give a hint as to what the @ does here, or where it’s
> documented? Obviously it’s not the use which is documented with Guile
> 1.8
> ().

Try LilyPond.



   A further convenience can be the ‘list splicing’ operators ‘$@’ and
‘#@’ for inserting the elements of a list in the surrounding context.
Using those, the last part of the example could have been written as

 …
 { #@newLa }

   Here, every element of the list stored in ‘newLa’ is taken in
sequence and inserted into the list, as if we had written

 { #(first newLa) #(second newLa) }


-- 
David Kastrup

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


Re: Further scheme help, please

2016-05-30 Thread Simon Albrecht

On 30.05.2016 17:23, Phil Holmes wrote:

I obviously need to do more potato peeling.


Words of wisdom :-)


On 30.05.2016 16:18, David Kastrup wrote:

$@(make-list n #{ \lyricmode { _ } #})


David, could you give a hint as to what the @ does here, or where it’s 
documented? Obviously it’s not the use which is documented with Guile 
1.8 
().


Best,
Simon

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


Re: Further scheme help, please

2016-05-30 Thread Phil Holmes
- Original Message - 
From: "David Kastrup" <d...@gnu.org>

To: "Phil Holmes" <m...@philholmes.net>
Cc: <lilypond-user@gnu.org>
Sent: Monday, May 30, 2016 4:19 PM
Subject: Re: Further scheme help, please



"Phil Holmes" <m...@philholmes.net> writes:


Thanks David.  This is what I have:

LyRep =
#(define-music-function (n) (number?)
 #{
   \once \override Lyrics.LyricText.Y-extent = #'(-10 . 10) % stops
collisions with stems
   \set Lyrics.lyricMelismaAlignment = #CENTER % keeps the symbol centred
   \markup { \raise #1 % shifts it up
 { \draw-circle #0.1 #0.1 ##t % draw the first circle
 \raise #1 { \draw-line #'( 0 . -2 ) } % draw first line
 \raise #1 { \draw-line #'( 0 . -2 ) } % draw second line
 \draw-circle #0.1 #0.1 ##t } % draw final circle
   }
   $@(make-list n #{ \lyricmode { _ } #})
   \unset lyricMelismaAlignment
 #})

When I run it, I get the output I want, but with the following error
in the log file:

Definitions.ly:111:5: error: markup outside of text script or \lyricmode

   \markup { \raise #1 % shifts it up

LyricTest.ly:27:21: error: error in #{ ... #}

   \LyRep #4

Any idea why?


Oops.  I overlooked the \markup being lyrics already.  So you probably
need to put a \lyricmode { ... } around it as well.

--
David Kastrup



Thanks again.  As it turns out I'd just finished one verse and had gone off 
to cook dinner.  As I started on the spuds I wondered whether putting 
lyricmode around the markup would work (I had tried other things).  Got back 
to the PC and your suggestion was above.  I put that in and the error 
disappears.  I obviously need to do more potato peeling.


--
Phil Holmes 



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


Re: Further scheme help, please

2016-05-30 Thread David Kastrup
"Phil Holmes"  writes:

> Thanks David.  This is what I have:
>
> LyRep =
> #(define-music-function (n) (number?)
>  #{
>\once \override Lyrics.LyricText.Y-extent = #'(-10 . 10) % stops
> collisions with stems
>\set Lyrics.lyricMelismaAlignment = #CENTER % keeps the symbol centred
>\markup { \raise #1 % shifts it up
>  { \draw-circle #0.1 #0.1 ##t % draw the first circle
>  \raise #1 { \draw-line #'( 0 . -2 ) } % draw first line
>  \raise #1 { \draw-line #'( 0 . -2 ) } % draw second line
>  \draw-circle #0.1 #0.1 ##t } % draw final circle
>}
>$@(make-list n #{ \lyricmode { _ } #})
>\unset lyricMelismaAlignment
>  #})
>
> When I run it, I get the output I want, but with the following error
> in the log file:
>
> Definitions.ly:111:5: error: markup outside of text script or \lyricmode
>
>\markup { \raise #1 % shifts it up
>
> LyricTest.ly:27:21: error: error in #{ ... #}
>
>\LyRep #4
>
> Any idea why?

Oops.  I overlooked the \markup being lyrics already.  So you probably
need to put a \lyricmode { ... } around it as well.

-- 
David Kastrup

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


Re: Further scheme help, please

2016-05-30 Thread Phil Holmes
- Original Message - 
From: "David Kastrup" <d...@gnu.org>

To: "Phil Holmes" <m...@philholmes.net>
Cc: <lilypond-user@gnu.org>
Sent: Monday, May 30, 2016 3:18 PM
Subject: Re: Further scheme help, please



Phil Holmes <m...@philholmes.net> writes:

Assuming 2.19.not-too-old:

LyRep =
#(define-music-function (n) (number?)
  #{ all of the above up to the underlines
 $@(make-list n #{ \lyricmode { _ } #})
 \unset lyricMelismaAlignment
  #})

For 2.18, you'll need the typical parser location rap before n.

--
David Kastrup



Thanks David.  This is what I have:

LyRep =
#(define-music-function (n) (number?)
 #{
   \once \override Lyrics.LyricText.Y-extent = #'(-10 . 10) % stops 
collisions with stems

   \set Lyrics.lyricMelismaAlignment = #CENTER % keeps the symbol centred
   \markup { \raise #1 % shifts it up
 { \draw-circle #0.1 #0.1 ##t % draw the first circle
 \raise #1 { \draw-line #'( 0 . -2 ) } % draw first line
 \raise #1 { \draw-line #'( 0 . -2 ) } % draw second line
 \draw-circle #0.1 #0.1 ##t } % draw final circle
   }
   $@(make-list n #{ \lyricmode { _ } #})
   \unset lyricMelismaAlignment
 #})

When I run it, I get the output I want, but with the following error in the 
log file:


Definitions.ly:111:5: error: markup outside of text script or \lyricmode

   \markup { \raise #1 % shifts it up

LyricTest.ly:27:21: error: error in #{ ... #}

   \LyRep #4

Any idea why?

--
Phil Holmes 



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


Re: Further scheme help, please

2016-05-30 Thread David Kastrup
Phil Holmes  writes:

> I have some boiler-plate markup that I use in 16C music to show the lyric 
> repeat sign they use: a small circle, 2 lines and another circle.  This is 
> what I use, split into separate lines and commented:
>
> \once \override Lyrics.LyricText.Y-extent = #'(-10 . 10) % stops 
> collisions with stems
> \set lyricMelismaAlignment = #CENTER % keeps the symbol centred
> \markup { \raise #1 % shifts it up
> { \draw-circle #0.1 #0.1 ##t % draw the first circle
> \raise #1 { \draw-line #'( 0 . -2 ) } % draw first line
> \raise #1 { \draw-line #'( 0 . -2 ) } % draw second line
> \draw-circle #0.1 #0.1 ##t } } % draw final circle
> _ _ _ _ _  % one underscore for each note in the lyric repeat 
> \unset lyricMelismaAlignment % reset alignment
>
> I was hoping to replace this with a function to make the copying and 
> pasting less of a problem.  Ideally, I would have something like:
>
> lyr = \lyricmode { Word \LyRep #5 next word }
>
> And the LyRep command would use the commands above to draw the repeat sign 
> and add 5 skips.  Problem is, I can't currently get close to making this 
> work.  I can draw the symbol with a define-markup-command, but don't know 
> how to deal with the skips.
>
> Help appreciated.

Assuming 2.19.not-too-old:

LyRep =
#(define-music-function (n) (number?)
   #{ all of the above up to the underlines
  $@(make-list n #{ \lyricmode { _ } #})
  \unset lyricMelismaAlignment
   #})

For 2.18, you'll need the typical parser location rap before n.

-- 
David Kastrup

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


Further scheme help, please

2016-05-30 Thread Phil Holmes
I have some boiler-plate markup that I use in 16C music to show the lyric 
repeat sign they use: a small circle, 2 lines and another circle.  This is 
what I use, split into separate lines and commented:

\once \override Lyrics.LyricText.Y-extent = #'(-10 . 10) % stops 
collisions with stems
\set lyricMelismaAlignment = #CENTER % keeps the symbol centred
\markup { \raise #1 % shifts it up
{ \draw-circle #0.1 #0.1 ##t % draw the first circle
\raise #1 { \draw-line #'( 0 . -2 ) } % draw first line
\raise #1 { \draw-line #'( 0 . -2 ) } % draw second line
\draw-circle #0.1 #0.1 ##t } } % draw final circle
_ _ _ _ _  % one underscore for each note in the lyric repeat 
\unset lyricMelismaAlignment % reset alignment

I was hoping to replace this with a function to make the copying and 
pasting less of a problem.  Ideally, I would have something like:

lyr = \lyricmode { Word \LyRep #5 next word }

And the LyRep command would use the commands above to draw the repeat sign 
and add 5 skips.  Problem is, I can't currently get close to making this 
work.  I can draw the symbol with a define-markup-command, but don't know 
how to deal with the skips.

Help appreciated.


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


Re: Haipins ending with text: scheme help

2014-07-29 Thread Thomas Morley
2014-07-29 6:59 GMT+02:00 Antonio Gervasoni agervas...@gmail.com:
 Hi everyone,

 I'm working on a score where I need hairpins to end on a specific text. I do
 this because I don't really like the hairpins with a circle tip. I prefer to
 use n. for niente and pd. for perdendosi (the first one for strings, the
 second one for winds).

 Now, on some occasions the hairpin must end with the text placed just before
 the bar line, like this:

All links to images are broken in your _mail_
I can follow them only on nabble.

 http://lilypond.1069038.n5.nabble.com/file/n165055/Screen_Shot_2014-07-28_at_11.png

 As I find the typical solution of creating a second voice with spacers
 rather clumsy, I managed to come up with a better one by tweaking the
 snippet for placing text under a hairpin. However, I'm know nothing of
 scheme so my solution is far from perfect. The code is here:
[...]


How about the code below. Works with linebreaking hairpins as well.
Needs some real life testing though.

\version 2.18.0

%% from output-lib.scm, extended to get the possibility to return other
%% hairpin-length than default
#(define ((elbowed-hairpin coords x-length-corr mirrored?) grob)
  Create hairpin based on a list of @var{coords} in @code{(cons x y)}
form.  @code{x} is the portion of the width consumed for a given line
and @code{y} is the portion of the height.  For example,
@code{'((0.3 . 0.7) (0.8 . 0.9) (1.0 . 1.0))} means that at the point
where the hairpin has consumed 30% of its width, it must
be at 70% of its height.  Once it is to 80% width, it
must be at 90% height.  It finishes at
100% width and 100% height.  @var{mirrored?} indicates if the hairpin
is mirrored over the Y-axis or if just the upper part is drawn.
Returns a function that accepts a hairpin grob as an argument
and draws the stencil based on its coordinates.
The length of that hairpin may be adjusted with @var{x-length-corr}
@lilypond[verbatim,quote]
#(define simple-hairpin
  (elbowed-hairpin '((1.0 . 1.0)) #t))

\\relative c' {
  \\override Hairpin #'stencil = #simple-hairpin
  a\\p\\ a a a\\f
}
@end lilypond

  (define (pair-to-list pair)
(list (car pair) (cdr pair)))
  (define (normalize-coords goods x y)
(map
 (lambda (coord)
   (cons (* x (car coord)) (* y (cdr coord
 goods))
  (define (my-c-p-s points thick decresc?)
(make-connected-path-stencil
 points
 thick
 (if decresc? -1.0 1.0)
 1.0
 #f
 #f))
  ;; outer let to trigger suicide
  (let ((sten (ly:hairpin::print grob)))
(if (grob::is-live? grob)
(let* ((decresc? (eq? (ly:grob-property grob 'grow-direction) LEFT))
   (thick (ly:grob-property grob 'thickness 0.1))
   (thick (* thick (layout-line-thickness grob)))
   (x-ext (ly:stencil-extent sten X))
   (xex (cons (car x-ext) (- (cdr x-ext) x-length-corr)))
   (lenx (interval-length xex))
   (yex (ly:stencil-extent sten Y))
   (leny (interval-length yex))
   (xtrans (+ (car xex) (if decresc? lenx 0)))
   (ytrans (car yex))
   (uplist (map pair-to-list
(normalize-coords coords lenx (/ leny 2
   (downlist (map pair-to-list
  (normalize-coords coords lenx (/ leny -2)
  (ly:stencil-translate
   (ly:stencil-add
(my-c-p-s uplist thick decresc?)
(if mirrored? (my-c-p-s downlist thick decresc?) empty-stencil))
   (cons xtrans ytrans)))
'(

#(define (shortened-hairpin corr)
  (elbowed-hairpin '((0 . 0) (1.0 . 1.0)) corr #t))

#(define (hairpin-with-right-text text grob)
  Rebuild a hairpin and add @var{text} to the right.
  The hairpin is shortened by the length of @var{text},
  @code{bound-padding} is taken into account
  (let* ((text-stil (grob-interpret-markup grob text))
 (text-stil-x-extent (ly:stencil-extent text-stil X))
 (text-stil-length (interval-length text-stil-x-extent))
 (staff-space
   (ly:output-def-lookup (ly:grob-layout grob) 'staff-space))
 (bound-padding
   (ly:grob-property grob 'bound-padding staff-space))
 (x-corr (+ text-stil-length (/ bound-padding 2

  (ly:grob-set-property! grob 'stencil (shortened-hairpin x-corr))

(let* ((stencil (ly:grob-property grob 'stencil))
   (stil-x-ext
 (ordered-cons
   (car (ly:stencil-extent stencil X))
   (cdr (ly:stencil-extent stencil X
   (new-stencil
 (ly:stencil-add
   (ly:stencil-aligned-to stencil Y CENTER)
   (ly:stencil-translate-axis
 (ly:stencil-aligned-to text-stil Y CENTER)
 (+ (cdr stil-x-ext) bound-padding)
 X

(ly:grob-set-property! grob 'stencil new-stencil

#(define 

Re: Haipins ending with text: scheme help

2014-07-29 Thread Antonio Gervasoni
Thank you so much, Thomas! I'll try it right away and will post the results.

Yes, I'm aware of the broken links. I was unable to upload the images on my
first attempt (on Nabble) so I modified my post and included links to files
in my Dopbox instead. I couldn't find a way to do the same on Gmane.

For anyone else that might follow this thread, the images are  here
https://dl.dropboxusercontent.com/u/4857747/a.png  ,  here
https://dl.dropboxusercontent.com/u/4857747/b.png   and  here
https://dl.dropboxusercontent.com/u/4857747/c.png  .

Thanks again!

Antonio



--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Haipins-ending-with-text-scheme-help-tp165055p165079.html
Sent from the User mailing list archive at Nabble.com.

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


Re: Haipins ending with text: scheme help

2014-07-29 Thread Antonio Gervasoni
Thomas,

I tried your solution. It's definitely far better than mine. Works
flawlessly with pd. but not so well with n., which now experiences the
same vertical displacement.  Here
https://dl.dropboxusercontent.com/u/4857747/d.png   is how it looks when
the n. is placed as a dynamic text attached to a rest, and  here
https://dl.dropboxusercontent.com/u/4857747/e.png   how it looks with the
code you provided.

Of course, the difference is minimal, it's not so disturbing as the
other one, so I suppose I can live with that. LOL

On the other hand, is there a way to increase a little bit the space before
the bar line? I feel the text is too close to it.

Also, could you recommend a good source to learn Scheme?

Thank you very much for your help!

Sincerely,

Antonio



--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Haipins-ending-with-text-scheme-help-tp165055p165082.html
Sent from the User mailing list archive at Nabble.com.

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


Re: Haipins ending with text: scheme help

2014-07-29 Thread Antonio Gervasoni
Oops... I did ir again! The order of the images is inverted... so sorry!

Antonio



--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Haipins-ending-with-text-scheme-help-tp165055p165083.html
Sent from the User mailing list archive at Nabble.com.

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


Re: Haipins ending with text: scheme help

2014-07-29 Thread Thomas Morley
2014-07-29 20:56 GMT+02:00 Antonio Gervasoni agervas...@gmail.com:
 Thomas,

 I tried your solution. It's definitely far better than mine. Works
 flawlessly with pd. but not so well with n., which now experiences the
 same vertical displacement.  Here
 https://dl.dropboxusercontent.com/u/4857747/d.png   is how it looks when
 the n. is placed as a dynamic text attached to a rest, and  here
 https://dl.dropboxusercontent.com/u/4857747/e.png   how it looks with the
 code you provided.

 Of course, the difference is minimal, it's not so disturbing as the
 other one, so I suppose I can live with that. LOL

 On the other hand, is there a way to increase a little bit the space before
 the bar line? I feel the text is too close to it.

 Also, could you recommend a good source to learn Scheme?

 Thank you very much for your help!

 Sincerely,

 Antonio

Hi Antonio,

could you provide tiny code-examples causing the difference?
No need to reinclude my scheme-coding. Just how you use it.

Cheers,
  Harm

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


Re: Haipins ending with text: scheme help

2014-07-29 Thread Antonio Gervasoni
Hi Thomas,

Sure! Here it is:


%%% Definition of the two types of hairpin


hairpinN = \hairpinWithRightText \markup \italic n.

hairpinPD = \hairpinWithRightText \markup \italic pd.


%%% Example


{

\new Staff \relative c''' {

a1(\p\

gis2.)\mf\ r4\n

a1(\p\

dis2.)\mf\ r4\n

e2(\p\ dis4 e \break

f2 g

\hairpinN

gis1\mp\)

R1\!

R1

}

}


Best,


Antonio


On Tue, Jul 29, 2014 at 2:28 PM, Thomas Morley-2 [via Lilypond] 
ml-node+s1069038n165085...@n5.nabble.com wrote:

 2014-07-29 20:56 GMT+02:00 Antonio Gervasoni [hidden email]
 http://user/SendEmail.jtp?type=nodenode=165085i=0:

  Thomas,
 
  I tried your solution. It's definitely far better than mine. Works
  flawlessly with pd. but not so well with n., which now experiences
 the
  same vertical displacement.  Here
  https://dl.dropboxusercontent.com/u/4857747/d.png   is how it looks
 when
  the n. is placed as a dynamic text attached to a rest, and  here
  https://dl.dropboxusercontent.com/u/4857747/e.png   how it looks with
 the
  code you provided.
 
  Of course, the difference is minimal, it's not so disturbing as the
  other one, so I suppose I can live with that. LOL
 
  On the other hand, is there a way to increase a little bit the space
 before
  the bar line? I feel the text is too close to it.
 
  Also, could you recommend a good source to learn Scheme?
 
  Thank you very much for your help!
 
  Sincerely,
 
  Antonio

 Hi Antonio,

 could you provide tiny code-examples causing the difference?
 No need to reinclude my scheme-coding. Just how you use it.

 Cheers,
   Harm

 ___
 lilypond-user mailing list
 [hidden email] http://user/SendEmail.jtp?type=nodenode=165085i=1
 https://lists.gnu.org/mailman/listinfo/lilypond-user


 --
  If you reply to this email, your message will be added to the discussion
 below:

 http://lilypond.1069038.n5.nabble.com/Haipins-ending-with-text-scheme-help-tp165055p165085.html
  To unsubscribe from Haipins ending with text: scheme help, click here
 http://lilypond.1069038.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=165055code=YWdlcnZhc29uaUBnbWFpbC5jb218MTY1MDU1fDIwMjE3MTg3NzQ=
 .
 NAML
 http://lilypond.1069038.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml





--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Haipins-ending-with-text-scheme-help-tp165055p165086.html
Sent from the User mailing list archive at Nabble.com.___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Haipins ending with text: scheme help

2014-07-29 Thread Thomas Morley
2014-07-29 21:44 GMT+02:00 Antonio Gervasoni agervas...@gmail.com:
 Hi Thomas,

 Sure! Here it is:


Hi Antonio,

your example is not very helpful, because it does not show a dynamic
text attached to a rest.
And it does not compile, because of the unknown \n


 %%% Definition of the two types of hairpin


 hairpinN = \hairpinWithRightText \markup \italic n.

 hairpinPD = \hairpinWithRightText \markup \italic pd.


 %%% Example


 {

 \new Staff \relative c''' {

 a1(\p\

  gis2.)\mf\ r4\n -- ??

 a1(\p\

 dis2.)\mf\ r4\n

 e2(\p\ dis4 e \break

 f2 g

 \hairpinN

 gis1\mp\)

 R1\!

 R1

 }

 }


Anyway, I added some code, so that the added _text_ is always
vertically aligned to the _hairpin_ in the same manner (regarding its
baseline). At least for most european languages.

See attached.

HTH,
  Harm
\version 2.18.0

%% from output-lib.scm, extended to get the possibility to return other
%% hairpin-length than default
#(define ((elbowed-hairpin coords x-length-corr mirrored?) grob)
  Create hairpin based on a list of @var{coords} in @code{(cons x y)}
form.  @code{x} is the portion of the width consumed for a given line
and @code{y} is the portion of the height.  For example,
@code{'((0.3 . 0.7) (0.8 . 0.9) (1.0 . 1.0))} means that at the point
where the hairpin has consumed 30% of its width, it must
be at 70% of its height.  Once it is to 80% width, it
must be at 90% height.  It finishes at
100% width and 100% height.  @var{mirrored?} indicates if the hairpin
is mirrored over the Y-axis or if just the upper part is drawn.
Returns a function that accepts a hairpin grob as an argument
and draws the stencil based on its coordinates.
The length of that hairpin may be adjusted with @var{x-length-corr}
@lilypond[verbatim,quote]
#(define simple-hairpin
  (elbowed-hairpin '((1.0 . 1.0)) #t))

\\relative c' {
  \\override Hairpin #'stencil = #simple-hairpin
  a\\p\\ a a a\\f
}
@end lilypond

  (define (pair-to-list pair)
(list (car pair) (cdr pair)))
  (define (normalize-coords goods x y)
(map
 (lambda (coord)
   (cons (* x (car coord)) (* y (cdr coord
 goods))
  (define (my-c-p-s points thick decresc?)
(make-connected-path-stencil
 points
 thick
 (if decresc? -1.0 1.0)
 1.0
 #f
 #f))
  ;; outer let to trigger suicide
  (let ((sten (ly:hairpin::print grob)))
(if (grob::is-live? grob)
(let* ((decresc? (eq? (ly:grob-property grob 'grow-direction) LEFT))
   (thick (ly:grob-property grob 'thickness 0.1))
   (thick (* thick (layout-line-thickness grob)))
   (x-ext (ly:stencil-extent sten X))
   (xex (cons (car x-ext) (- (cdr x-ext) x-length-corr)))
   (lenx (interval-length xex))
   (yex (ly:stencil-extent sten Y))
   (leny (interval-length yex))
   (xtrans (+ (car xex) (if decresc? lenx 0)))
   (ytrans (car yex))
   (uplist (map pair-to-list
(normalize-coords coords lenx (/ leny 2
   (downlist (map pair-to-list
  (normalize-coords coords lenx (/ leny -2)
  (ly:stencil-translate
   (ly:stencil-add
(my-c-p-s uplist thick decresc?)
(if mirrored? (my-c-p-s downlist thick decresc?) empty-stencil))
   (cons xtrans ytrans)))
'(

#(define (shortened-hairpin corr)
  (elbowed-hairpin '((1.0 . 1.0)) corr #t))
  
#(define-markup-command (vstrut layout props)
  ()
  #:category other
  
@cindex creating vertical space in text

Create a box of the same height as the current font, using the \fp\ as
a reference.

  (let ((ref-mrkp (interpret-markup layout props fp)))
(ly:make-stencil (ly:stencil-expr empty-stencil)
 empty-interval
 (ly:stencil-extent ref-mrkp Y
  
#(define (hairpin-with-right-text text grob)
  Rebuild a hairpin and add @var{text} to the right.
  The hairpin is shortened by the length of @var{text}, 
  @code{bound-padding} is taken into account
  (let* ((text-stil (grob-interpret-markup grob (markup #:vstrut text)))
 (text-stil-x-extent (ly:stencil-extent text-stil X))
 (text-stil-length (interval-length text-stil-x-extent))
 (staff-space 
   (ly:output-def-lookup (ly:grob-layout grob) 'staff-space))
 (x-corr (+ text-stil-length (/ staff-space 2
 
  (ly:grob-set-property! grob 'stencil (shortened-hairpin x-corr))
  
(let* ((stencil (ly:grob-property grob 'stencil))
   (stil-x-ext 
 (ordered-cons 
   (car (ly:stencil-extent stencil X))
   (cdr (ly:stencil-extent stencil X
   (new-stencil 
 (ly:stencil-add
   (ly:stencil-aligned-to stencil Y CENTER)
   (ly:stencil-translate-axis
 (ly:stencil-aligned-to text-stil Y 

Re: Haipins ending with text: scheme help

2014-07-29 Thread Antonio Gervasoni
 your example is not very helpful, because it does not show a dynamic
 text attached to a rest.
 And it does not compile, because of the unknown \n

Aw! I forgot that! It's on the file called by \include. Both dynamics are
defined on this way:

n = #(make-dynamic-script #{ \markup \line { \normal-text \normalsize
\italic n. } #})

pd = #(make-dynamic-script #{ \markup \line { \normal-text \normalsize
\italic pd. } #})


After that, the \n will appear under a rest, on the second and fourth bars.
I apologise for the mistake.


Thank you so much. I'll try it now.


Best,


Antonio


On Tue, Jul 29, 2014 at 3:58 PM, Thomas Morley-2 [via Lilypond] 
ml-node+s1069038n165091...@n5.nabble.com wrote:

 2014-07-29 21:44 GMT+02:00 Antonio Gervasoni [hidden email]
 http://user/SendEmail.jtp?type=nodenode=165091i=0:
  Hi Thomas,
 
  Sure! Here it is:
 

 Hi Antonio,

 your example is not very helpful, because it does not show a dynamic
 text attached to a rest.
 And it does not compile, because of the unknown \n

 
  %%% Definition of the two types of hairpin
 
 
  hairpinN = \hairpinWithRightText \markup \italic n.
 
  hairpinPD = \hairpinWithRightText \markup \italic pd.
 
 
  %%% Example
 
 
  {
 
  \new Staff \relative c''' {
 
  a1(\p\
 
   gis2.)\mf\ r4\n -- ??

 
  a1(\p\
 
  dis2.)\mf\ r4\n
 
  e2(\p\ dis4 e \break
 
  f2 g
 
  \hairpinN
 
  gis1\mp\)
 
  R1\!
 
  R1
 
  }
 
  }
 
 Anyway, I added some code, so that the added _text_ is always
 vertically aligned to the _hairpin_ in the same manner (regarding its
 baseline). At least for most european languages.

 See attached.

 HTH,
   Harm

 ___
 lilypond-user mailing list
 [hidden email] http://user/SendEmail.jtp?type=nodenode=165091i=1
 https://lists.gnu.org/mailman/listinfo/lilypond-user

 *hairpin-with-text-right.ly http://hairpin-with-text-right.ly* (7K) Download
 Attachment
 http://lilypond.1069038.n5.nabble.com/attachment/165091/0/hairpin-with-text-right.ly


 --
  If you reply to this email, your message will be added to the discussion
 below:

 http://lilypond.1069038.n5.nabble.com/Haipins-ending-with-text-scheme-help-tp165055p165091.html
  To unsubscribe from Haipins ending with text: scheme help, click here
 http://lilypond.1069038.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=165055code=YWdlcnZhc29uaUBnbWFpbC5jb218MTY1MDU1fDIwMjE3MTg3NzQ=
 .
 NAML
 http://lilypond.1069038.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml





--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Haipins-ending-with-text-scheme-help-tp165055p165096.html
Sent from the User mailing list archive at Nabble.com.___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Haipins ending with text: scheme help

2014-07-29 Thread Antonio Gervasoni
Works perfectly! You are a genius!

Thanks again!

You should publish it on the snippet repository. It's far better than
creating a second voice with spacers, as is suggested there (or somewhere
else... I can't remember now)

Best regards,

Antonio


On Tue, Jul 29, 2014 at 5:25 PM, Antonio Gervasoni agervas...@gmail.com
wrote:

  your example is not very helpful, because it does not show a dynamic
   text attached to a rest.
  And it does not compile, because of the unknown \n

 Aw! I forgot that! It's on the file called by \include. Both dynamics are
 defined on this way:

 n = #(make-dynamic-script #{ \markup \line { \normal-text \normalsize
 \italic n. } #})

 pd = #(make-dynamic-script #{ \markup \line { \normal-text \normalsize
 \italic pd. } #})


 After that, the \n will appear under a rest, on the second and fourth
 bars. I apologise for the mistake.


 Thank you so much. I'll try it now.


 Best,


 Antonio


 On Tue, Jul 29, 2014 at 3:58 PM, Thomas Morley-2 [via Lilypond] 
 ml-node+s1069038n165091...@n5.nabble.com wrote:

 2014-07-29 21:44 GMT+02:00 Antonio Gervasoni [hidden email]
 http://user/SendEmail.jtp?type=nodenode=165091i=0:
  Hi Thomas,
 
  Sure! Here it is:
 

 Hi Antonio,

 your example is not very helpful, because it does not show a dynamic
 text attached to a rest.
 And it does not compile, because of the unknown \n

 
  %%% Definition of the two types of hairpin
 
 
  hairpinN = \hairpinWithRightText \markup \italic n.
 
  hairpinPD = \hairpinWithRightText \markup \italic pd.
 
 
  %%% Example
 
 
  {
 
  \new Staff \relative c''' {
 
  a1(\p\
 
   gis2.)\mf\ r4\n -- ??

 
  a1(\p\
 
  dis2.)\mf\ r4\n
 
  e2(\p\ dis4 e \break
 
  f2 g
 
  \hairpinN
 
  gis1\mp\)
 
  R1\!
 
  R1
 
  }
 
  }
 
 Anyway, I added some code, so that the added _text_ is always
 vertically aligned to the _hairpin_ in the same manner (regarding its
 baseline). At least for most european languages.

 See attached.

 HTH,
   Harm

 ___
 lilypond-user mailing list
 [hidden email] http://user/SendEmail.jtp?type=nodenode=165091i=1
 https://lists.gnu.org/mailman/listinfo/lilypond-user

 *hairpin-with-text-right.ly http://hairpin-with-text-right.ly* (7K) 
 Download
 Attachment
 http://lilypond.1069038.n5.nabble.com/attachment/165091/0/hairpin-with-text-right.ly


 --
  If you reply to this email, your message will be added to the
 discussion below:

 http://lilypond.1069038.n5.nabble.com/Haipins-ending-with-text-scheme-help-tp165055p165091.html
  To unsubscribe from Haipins ending with text: scheme help, click here
 http://lilypond.1069038.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=165055code=YWdlcnZhc29uaUBnbWFpbC5jb218MTY1MDU1fDIwMjE3MTg3NzQ=
 .
 NAML
 http://lilypond.1069038.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml







--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Haipins-ending-with-text-scheme-help-tp165055p165097.html
Sent from the User mailing list archive at Nabble.com.___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Haipins ending with text: scheme help

2014-07-29 Thread Thomas Morley
2014-07-30 0:39 GMT+02:00 Antonio Gervasoni agervas...@gmail.com:

 Works perfectly! You are a genius!

 Thanks again!


You're welcome


 You should publish it on the snippet repository.


How about you put it in youself?
http://lsr.di.unimi.it/LSR/html/contributing.html

I'm one of the LSR-editors and can promise a fast approval ;)

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


Re: Haipins ending with text: scheme help

2014-07-29 Thread Antonio Gervasoni
 How about you put it in yourself?

I just did. :-)

 I'm one of the LSR-editors and can promise a fast approval ;)

Wow! Excellent!

Best,

Antonio


On Tue, Jul 29, 2014 at 5:59 PM, Thomas Morley-2 [via Lilypond] 
ml-node+s1069038n165099...@n5.nabble.com wrote:




 2014-07-30 0:39 GMT+02:00 Antonio Gervasoni [hidden email]
 http://user/SendEmail.jtp?type=nodenode=165099i=0:

 Works perfectly! You are a genius!

 Thanks again!


 You're welcome


 You should publish it on the snippet repository.


 How about you put it in youself?
 http://lsr.di.unimi.it/LSR/html/contributing.html

 I'm one of the LSR-editors and can promise a fast approval ;)

 Cheers,
   Harm

 ___
 lilypond-user mailing list
 [hidden email] http://user/SendEmail.jtp?type=nodenode=165099i=1
 https://lists.gnu.org/mailman/listinfo/lilypond-user


 --
  If you reply to this email, your message will be added to the discussion
 below:

 http://lilypond.1069038.n5.nabble.com/Haipins-ending-with-text-scheme-help-tp165055p165099.html
  To unsubscribe from Haipins ending with text: scheme help, click here
 http://lilypond.1069038.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=165055code=YWdlcnZhc29uaUBnbWFpbC5jb218MTY1MDU1fDIwMjE3MTg3NzQ=
 .
 NAML
 http://lilypond.1069038.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml





--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Haipins-ending-with-text-scheme-help-tp165055p165103.html
Sent from the User mailing list archive at Nabble.com.___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Haipins ending with text: scheme help

2014-07-28 Thread Antonio Gervasoni
Hi everyone,

I'm working on a score where I need hairpins to end on a specific text. I do
this because I don't really like the hairpins with a circle tip. I prefer to
use n. for niente and pd. for perdendosi (the first one for strings, the
second one for winds). 

Now, on some occasions the hairpin must end with the text placed just before
the bar line, like this: 
http://lilypond.1069038.n5.nabble.com/file/n165055/Screen_Shot_2014-07-28_at_11.png
 

As I find the typical solution of creating a second voice with spacers
rather clumsy, I managed to come up with a better one by tweaking the
snippet for placing text under a hairpin. However, I'm know nothing of
scheme so my solution is far from perfect. The code is here:

hairpinWithRightText =
#(define-music-function (parser location text) (markup?)
#{
  \once \override Voice.Hairpin.after-line-breaking =
#(lambda (grob)
  (let* ((stencil (ly:hairpin::print grob))
 (new-stencil (ly:stencil-aligned-to
   (ly:stencil-combine-at-edge
 (ly:stencil-aligned-to stencil X RIGHT)
 Y CENTER
 (ly:stencil-aligned-to (grob-interpret-markup grob text) X
CENTER))
   X LEFT))
 (staff-space (ly:output-def-lookup (ly:grob-layout grob)
'staff-space))
 (staff-line-thickness
   (ly:output-def-lookup (ly:grob-layout grob) 'line-thickness))
 (grob-name (lambda (x) (assq-ref (ly:grob-property x 'meta)
'name)))
 (par-x (ly:grob-parent grob X))
 (dyn-text (eq? (grob-name par-x) 'DynamicText ))
 (dyn-text-stencil-x-length
   (if dyn-text
 (interval-length
   (ly:stencil-extent (ly:grob-property par-x 'stencil) X))
 0))
 (x-shift
   (if dyn-text
 (-
   (+ staff-space dyn-text-stencil-x-length)
   (* 0.5 staff-line-thickness)) 0)))

  (ly:grob-set-property! grob 'Y-offset 0)
  (ly:grob-set-property! grob 'stencil
 (ly:stencil-translate-axis
  new-stencil
  x-shift X
#})

hairpinN = {
\override Hairpin #'bound-padding = #2.3
\once \hairpinWithRightText \markup { \italic   n. }
}

hairpinPD = {
\override Hairpin #'bound-padding = #3.2
\once \hairpinWithRightText \markup { \italic pd. }
}

If you check the original code for this snippet, you will see that I just
changed the word dir for CENTER, on the 10th line of hairpinWithRightText.
I have then defined the two hairpins and placed a lot of spaces before each
text. Then, I have increased the padding of the hairpins so that they leave
enough space for the text. The result is here: 
http://lilypond.1069038.n5.nabble.com/file/n165055/Screen_Shot_2014-07-28_at_11.png
 

Not a bad result, but the pd. is not properly aligned (verticaly). See how
the pd. is placed when attached to a rest: 
http://lilypond.1069038.n5.nabble.com/file/n165055/Screen_Shot_2014-07-28_at_11.png
 

You can see the vertical alignment is not the same. It's a tiny difference
but I would like it to be perfect. Also, my solution is not really very
elegant, is it? Can anyone who knows scheme find a better way to do this?
Something simple, effective and accurate? I would appreciate very much any
help on this.

Antonio
P.S.: this could also be used to end hairpins with normal dynamic text, thus
avoiding the tiresome solution of writing a second voice with spacers.



--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Haipins-ending-with-text-scheme-help-tp165055.html
Sent from the User mailing list archive at Nabble.com.

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


complex time signatures: scheme help

2009-08-14 Thread James E. Bailey

Look at that, even I need scheme. I wanted to have the time signature be

3+3+2
 8

Apparently this is where Scheme is necessary. I've found the one that  
makes it

3+3+2
8  8   8

in the documentation but I don't understand how to make the change.

#(define ((compound-time one two num) grob)
  (grob-interpret-markup grob
(markup #:override '(baseline-skip . 0) #:number
  (#:line (
  (#:column (one num))
  #:vcenter +
  (#:column (two num
  )))


Can someone just do that for me?

James E. Bailey



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


Re: complex time signatures: scheme help

2009-08-14 Thread Mark Polesky
James E. Bailey wrote:
 Apparently this is where Scheme is necessary. I've found the one
 that makes it
 3+3+2
 8 8 8

 in the documentation but I don't understand how to make the change.

 Can someone just do that for me?

Umm, that's probably not the best way of asking for help... We
usually prefer can someone point me in the right direction or
something like that...

The example you're referring to is called Compound time
signatures on this page:
http://lilypond.org/doc/v2.12/Documentation/user/lilypond/Displaying-rhythms#Time-signature

Anyway, look at the scheme code. The compound-time procedure takes
three arguments, one two and num. In the doc example, the stencil
override is:
#(compound-time 2 3 8)
That means one is 2, two is 3, and num is 8.

You see where it says (#:column (one num)) in the scheme
procedure? That means that those two arguments (one and num) are
put in a column:
2
8

You see where it says #:vcenter +? That means that the + is
put in the vertical center. You can see what happens when you
remove the #:vcenter command.

So, you have to make a couple of changes.

1) you need another argument in your scheme procedure (3+2+2 as
   compared to 2+3).
   * you might call this additional argument three
   * logically, you should probably put it between two and num

2) so now you need to make sure you pass four values to the
   procedure within your music expression, instead of the 3 values
   there now.
   (you need to change this)... #(compound-time 2 3 8)

3) decide if you want
   (#:column (one num))
   ...or just...
   one
   etc.

4) decide if you want to keep the #:vcenter command

5) somehow incorporate your new argument (three) in with the rest
   of the arguments.


Let me know if you're still having trouble after trying this.
- Mark


  


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


Re: complex time signatures: scheme help

2009-08-14 Thread James E. Bailey


On 14.08.2009, at 23:59, Mark Polesky wrote:


Umm, that's probably not the best way of asking for help... We
usually prefer can someone point me in the right direction or
something like that...


Usually I do, except here, a point in the right direction wouldn't be  
sufficient for me. I kinda need templates with easy to figure out  
changes when it comes to Scheme hacks.



Anyway, look at the scheme code. The compound-time procedure takes
three arguments, one two and num. In the doc example, the stencil
override is:
#(compound-time 2 3 8)
That means one is 2, two is 3, and num is 8.

You see where it says (#:column (one num)) in the scheme
procedure? That means that those two arguments (one and num) are
put in a column:
2
8

You see where it says #:vcenter +? That means that the + is
put in the vertical center. You can see what happens when you
remove the #:vcenter command.

So, you have to make a couple of changes.

1) you need another argument in your scheme procedure (3+2+2 as
   compared to 2+3).
   * you might call this additional argument three
   * logically, you should probably put it between two and num

Got it, #(define ((compound-time one two three num) grob)


2) so now you need to make sure you pass four values to the
   procedure within your music expression, instead of the 3 values
   there now.
   (you need to change this)... #(compound-time 2 3 8)
Got it,   \override Staff.TimeSignature #'stencil = #(compound-time  
3 3 2 8)


3) decide if you want
   (#:column (one num))
   ...or just...
   one
   etc.
This bit I don't understand. (#:column (one num)) would be the  
equivalent of \markup \center-column { one num }, right? How would I  
do \markup \center-column {\line {one + two + three} num }?




4) decide if you want to keep the #:vcenter command

Probably not. I'm guessing.


5) somehow incorporate your new argument (three) in with the rest
   of the arguments.
This bit confuses me. Isn't it incorporated by adding three  
everywhere?


Thank you

James E. Bailey



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


Re: complex time signatures: scheme help

2009-08-14 Thread Carl Sorensen



On 8/14/09 4:12 PM, James E. Bailey derhindem...@googlemail.com wrote:

 
 On 14.08.2009, at 23:59, Mark Polesky wrote:
 
 Umm, that's probably not the best way of asking for help... We
 usually prefer can someone point me in the right direction or
 something like that...
 
 Usually I do, except here, a point in the right direction wouldn't be
 sufficient for me. I kinda need templates with easy to figure out changes when
 it comes to Scheme hacks.
 
 Anyway, look at the scheme code. The compound-time procedure takes
 three arguments, one two and num. In the doc example, the stencil
 override is:
 #(compound-time 2 3 8)
 That means one is 2, two is 3, and num is 8.
 
 You see where it says (#:column (one num)) in the scheme
 procedure? That means that those two arguments (one and num) are
 put in a column:
 2
 8
 
 You see where it says #:vcenter +? That means that the + is
 put in the vertical center. You can see what happens when you
 remove the #:vcenter command.
 
 So, you have to make a couple of changes.
 
 1) you need another argument in your scheme procedure (3+2+2 as
compared to 2+3).
* you might call this additional argument three
* logically, you should probably put it between two and num
 Got it, #(define ((compound-time one two three num) grob)
 
 2) so now you need to make sure you pass four values to the
procedure within your music expression, instead of the 3 values
there now.
(you need to change this)... #(compound-time 2 3 8)
 Got it,   \override Staff.TimeSignature #'stencil = #(compound-time 3 3
 2 8)
 
 3) decide if you want
(#:column (one num))
...or just...
one
etc.
 This bit I don't understand. (#:column (one num)) would be the equivalent of
 \markup \center-column { one num }, right? How would I do \markup
 \center-column {\line {one + two + three} num }?

See Notation Reference 6.4.1 Markup construction in Scheme

(markup #:center-column ((#:line (one two three)) num))

 
 
 4) decide if you want to keep the #:vcenter command
 Probably not. I'm guessing.
 
 5) somehow incorporate your new argument (three) in with the rest
of the arguments.
 This bit confuses me. Isn't it incorporated by adding three everywhere?

Yep, you seem to have it right.

Carl



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


Re: complex time signatures: scheme help

2009-08-14 Thread Mark Polesky
James E. Bailey wrote:
  3) decide if you want
 (#:column (one num))
 ...or just...
 one
 etc.
 This bit I don't understand. (#:column (one num)) would be the
 equivalent of \markup \center-column { one num }, right?
 How would I do
 \markup \center-column {\line {one + two + three} num }? 

I think it's better to line it up this way instead:
\markup { \line { one + \center-column { two num } + three} }


  4) decide if you want to keep the #:vcenter command.
 Probably not. I'm guessing.

Well, the usual placement of + is on the middle line when all
the denominators are present, but if only one denominator is
there, the plus signs usually get centered between the numerators.


  5) somehow incorporate your new argument (three) in with the rest
 of the arguments.
 This bit confuses me. Isn't it incorporated by adding three
 everywhere?

I meant specifically in this part of the code:

(#:line ((#:column (one num))
 #:vcenter +
 (#:column (two num

I was just spelling it out. You probably just figured it out
before reading that far.

Let me know once you get it.
- Mark


  


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


Re: complex time signatures: scheme help

2009-08-14 Thread James E. Bailey


On 15.08.2009, at 00:30, Carl Sorensen wrote:


3) decide if you want
   (#:column (one num))
   ...or just...
   one
   etc.
This bit I don't understand. (#:column (one num)) would be the  
equivalent of

\markup \center-column { one num }, right? How would I do \markup
\center-column {\line {one + two + three} num }?


See Notation Reference 6.4.1 Markup construction in Scheme

(markup #:center-column ((#:line (one two three)) num))





4) decide if you want to keep the #:vcenter command

Probably not. I'm guessing.


5) somehow incorporate your new argument (three) in with the rest
   of the arguments.
This bit confuses me. Isn't it incorporated by adding three  
everywhere?


Yep, you seem to have it right.

Carl




Okay, now I have
#(define ((compound-time one two three num) grob)
  (grob-interpret-markup grob
(markup #:override '(baseline-skip . 0) #:number
(markup #:center-column ((#:line (one + two + three)) num))
  )))

Which looks like just a really complicated way of doing

 \override Staff.TimeSignature #'stencil = #ly:text- 
interface::print

 \override Staff.TimeSignature #'text = \markup {
\center-column {
   \line { \musicglyph #three \musicglyph #plus  
\musicglyph #three \musicglyph #plus \musicglyph #two }

   \line { \musicglyph #eight }
}
(my initial attempt)

Neither of which moves the Time signature to adjust for the wider  
space of 3+3+2. So, is there a better way of achieving this?


James E. Bailey



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


Re: complex time signatures: scheme help

2009-08-14 Thread Mark Polesky
James E. Bailey wrote:
  3) decide if you want
 (#:column (one num))
 ...or just...
 one
 etc.
 This bit I don't understand. (#:column (one num)) would be the
 equivalent of \markup \center-column { one num }, right?
 How would I do
 \markup \center-column {\line {one + two + three} num }? 


Now I think I understand your confusion. Without columns,
time-signature markups get placed in the *top* half of the staff,
not the center. With columns, subsequent markups are placed below
the preceding markup. You can try (#:column (1 2 3)) to
observe this.

- Mark


  


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


Re: complex time signatures: scheme help

2009-08-14 Thread Reinhold Kainhofer
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Am Freitag, 14. August 2009 23:13:18 schrieb James E. Bailey:
 Look at that, even I need scheme. I wanted to have the time signature be

 3+3+2
   8

 Apparently this is where Scheme is necessary. I've found the one that
 makes it
 3+3+2
 8  8   8

 in the documentation 

Attached is my current code for general complex time signatures (arbitrary # 
of fractions, arbitrary # of numerators). I have not yet tried to get it into 
master, because the auto-beaming does not yet follow the signature.


Cheers,
Reinhold

- -- 
- --
Reinhold Kainhofer, reinh...@kainhofer.com, http://reinhold.kainhofer.com/
 * Financial  Actuarial Math., Vienna Univ. of Technology, Austria
 * http://www.fam.tuwien.ac.at/, DVR: 0005886
 * LilyPond, Music typesetting, http://www.lilypond.org
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)

iD8DBQFKhelCTqjEwhXvPN0RAu0NAKCrYbZ4HAD73AHH8w3eNYmYSXvQ4QCfRQAd
yoTlxbPOM/e6ZJgxzuCRTk0=
=rHjY
-END PGP SIGNATURE-
\version 2.11.65

%
% Formatting of (possibly complex) compound time signatures
%

#(define-public (insert-markups l m)
  (let* ((ll (reverse l)))
(let join-markups ((markups (list (car ll)))
   (remaining (cdr ll)))
  (if (pair? remaining)
(join-markups (cons (car remaining) (cons m markups)) (cdr remaining))
markups

% Use a centered-column inside a left-column, because the centered column
% moves its reference point to the center, which the left-column undoes.
% The center-column also aligns its contented centered, which is not undone...
#(define-public (format-time-fraction time-sig-fraction)
  (let* ((revargs (reverse (map number-string time-sig-fraction)))
 (den (car revargs))
 (nums (reverse (cdr revargs
(make-override-markup '(baseline-skip . 0)
  (make-number-markup 
(make-left-column-markup (list
  (make-center-column-markup (list
(make-line-markup (insert-markups nums +))
den

#(define-public (format-complex-compound-time time-sig)
  (let* ((sigs (map format-time-fraction time-sig)))
(make-override-markup '(baseline-skip . 0)
  (make-number-markup
(make-line-markup 
  (insert-markups sigs (make-vcenter-markup +)))

#(define-public (format-compound-time time-sig)
  (cond
((not (pair? time-sig)) (null-markup))
((pair? (car time-sig)) (format-complex-compound-time time-sig))
(else (format-time-fraction time-sig


%
% Measure length calculation of (possibly complex) compound time signatures
%

#(define-public (calculate-time-fraction time-sig-fraction)
  (let* ((revargs (reverse time-sig-fraction))
 (den (car revargs))
 (nums (cdr revargs)))
(ly:make-moment (apply + nums) den)))

#(define-public (calculate-complex-compound-time time-sig)
  (let* ((sigs (map calculate-time-fraction time-sig)))
(let add-moment ((moment ZERO-MOMENT)
 (remaining sigs))
  (if (pair? remaining)
(add-moment (ly:moment-add moment (car remaining)) (cdr remaining))
moment

#(define-public (calculate-compound-measure-length time-sig)
  (cond
((not (pair? time-sig)) (ly:make-moment 4 4))
((pair? (car time-sig)) (calculate-complex-compound-time time-sig))
(else (calculate-time-fraction time-sig


%
% Beat Grouping
%

% #(define-public (calculate-compound-base-beat-full time-sig)
%   (let* ((den (map last time-sig)))
% (apply max den)))

% #(define-public (calculate-compound-beat-grouping time-sig beat)
%   (cond
% ((not (pair? time-sig)) 4)
% ((pair? (car time-sig)) (calculate-compound-base-beat-full time-sig))
% (else (calculate-compound-base-beat-full (list time-sig))




%
% Base beat lenth
%

#(define-public (calculate-compound-base-beat-full time-sig)
  (let* ((den (map last time-sig)))
(apply max den)))

#(define-public (calculate-compound-base-beat time-sig)
  (ly:make-moment 1 (cond
((not (pair? time-sig)) 4)
((pair? (car time-sig)) (calculate-compound-base-beat-full time-sig))
(else (calculate-compound-base-beat-full (list time-sig))


%
% The music function to set the complex time signature

Re: complex time signatures: scheme help

2009-08-14 Thread Carl Sorensen



On 8/14/09 4:46 PM, Reinhold Kainhofer reinh...@kainhofer.com wrote:

 
 Attached is my current code for general complex time signatures (arbitrary #
 of fractions, arbitrary # of numerators). I have not yet tried to get it into
 master, because the auto-beaming does not yet follow the signature.

How should auto-beaming respond to a compound time signature?

In particular, how should ((2 3 8) (4 8)) be different from (2 3 4 8)?

I think with the new autobeaming code it would not be hard to get the
top-level beaming right.

BeatLength, on the other hand, probably doesn't have sufficient structure
built into it to handle ((1 2 3 4 8) (2 4) (2 3 8)), because for that time
signature, beatLength should vary with measure position.

I'm willing to take a shot at fixing the auto-beaming, if you'd like.

Carl



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


Re: complex time signatures: scheme help

2009-08-14 Thread James E. Bailey


On 15.08.2009, at 00:46, Reinhold Kainhofer wrote:


-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Am Freitag, 14. August 2009 23:13:18 schrieb James E. Bailey:
Look at that, even I need scheme. I wanted to have the time  
signature be


3+3+2
  8

Apparently this is where Scheme is necessary. I've found the one that
makes it
3+3+2
8  8   8

in the documentation


Attached is my current code for general complex time signatures  
(arbitrary #
of fractions, arbitrary # of numerators). I have not yet tried to  
get it into

master, because the auto-beaming does not yet follow the signature.


Cheers,
Reinhold

- --


Wow, thank you. That's amazing! I hope that it one day makes it into  
the current code.


James E. Bailey



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


Re: complex time signatures: scheme help

2009-08-14 Thread Graham Percival
On Fri, Aug 14, 2009 at 11:13:18PM +0200, James E. Bailey wrote:
 Look at that, even I need scheme. I wanted to have the time signature be
 
 3+3+2
  8

Great!  Search the archives for this list, last Oct or Nov or
maybe even Dec, to find the solution.  lilypond elegance will
help the search.


And yes, getting it included in the main lilypond is Yet Another
Cool Thing (tm) that isn't happening because I'm busy doing other
stuff that other people could be helping with.

Cheers,
- Graham


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


Re: complex time signatures: scheme help

2009-08-14 Thread Reinhold Kainhofer
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Am Samstag, 15. August 2009 01:06:40 schrieb Carl Sorensen:
 On 8/14/09 4:46 PM, Reinhold Kainhofer reinh...@kainhofer.com wrote:
  Attached is my current code for general complex time signatures
  (arbitrary # of fractions, arbitrary # of numerators). I have not yet
  tried to get it into master, because the auto-beaming does not yet follow
  the signature.

 How should auto-beaming respond to a compound time signature?

 In particular, how should ((2 3 8) (4 8)) be different from (2 3 4 8)?

That's one of the reasons why I haven't attacked that problem yet ;-)

 I think with the new autobeaming code it would not be hard to get the
 top-level beaming right.

yeah, I simply never managed to read the docs..

 BeatLength, on the other hand, probably doesn't have sufficient structure
 built into it to handle ((1 2 3 4 8) (2 4) (2 3 8)), because for that time
 signature, beatLength should vary with measure position.

I currently simply take the largest denominator ad common beatLength, so in 
this case the beatLength will be 8. I also don't know enough about the beaming 
rules to know how 2/4 and 4/8 behave differently.

 I'm willing to take a shot at fixing the auto-beaming, if you'd like.

Yeah, that would  be great!

Currently, the code I sent (albeit not perfect yet) is already used in 
musicxml2ly (where it is copied verbatim to the output file), but it should 
become part of master sooner or later, so that lilypond also supports complex 
time signatures properly.

Cheers,
Reinhold
- -- 
- --
Reinhold Kainhofer, reinh...@kainhofer.com, http://reinhold.kainhofer.com/
 * Financial  Actuarial Math., Vienna Univ. of Technology, Austria
 * http://www.fam.tuwien.ac.at/, DVR: 0005886
 * LilyPond, Music typesetting, http://www.lilypond.org
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)

iD8DBQFKhfnUTqjEwhXvPN0RAt5EAJ4ot7fHua+hmvuQ2moKNT1/Z7VZtwCgoPfb
4ZzCTmAC5WUVwIdT0q9ZLHc=
=4Ocb
-END PGP SIGNATURE-


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


Re: complex time signatures: scheme help

2009-08-14 Thread Carl Sorensen



On 8/14/09 5:57 PM, Reinhold Kainhofer reinh...@kainhofer.com wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 Am Samstag, 15. August 2009 01:06:40 schrieb Carl Sorensen:
 On 8/14/09 4:46 PM, Reinhold Kainhofer reinh...@kainhofer.com wrote:
 Attached is my current code for general complex time signatures
 (arbitrary # of fractions, arbitrary # of numerators). I have not yet
 tried to get it into master, because the auto-beaming does not yet follow
 the signature.
 
 How should auto-beaming respond to a compound time signature?
 
 In particular, how should ((2 3 8) (4 8)) be different from (2 3 4 8)?
 
 That's one of the reasons why I haven't attacked that problem yet ;-)

My intended approach for right now will be to create a default beaming rule

(((9 . 8) end) .
 ((* . (2 3 4)))

It will use the largest denominator (i.e. the smallest time value) as the
beatlength, and then group according to the numerators.

I would handle ((1 2 3 4 8) (2 4) (2 3 8)) as

(((19 . 8) end) .
 ((* . (1 2 3 4 4 2 3)))

I think this is a good rough start; somebody who wants it another way can
tweak it as they wish.

If you see problems with this, please let me know.

Thanks,

Carl



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