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