Re: drawing glissando line with (gliss) as text across line

2016-06-26 Thread Thomas Morley
2016-06-23 0:44 GMT+02:00 Thomas Morley :
> 2016-06-22 23:48 GMT+02:00 Ryan Michael :
>> Interesting. your example works perfectly in itself. But when I port it over
>> to my score I get the following error:
>>
>>  Wrong type argument in position 1 (expecting Stencil): ()
>>
>> I believe it calls it on this line:
>>
>>  (spanner-stencil-x-length (interval-length (ly:stencil-extent
>> spanner-stencil X)))
>>
>> Here is a gist of the score:
>> https://gist.github.com/ebbnormal/62a8893942a5e6f91735afdf77f2081a
>> I basically make a simple call to \glissandoTextOn as you do before I use
>> \glissando.
>>
>> Any ideas?
>
>
> If the glissando-line is _too_ short in tight layout-situations, it
> will not be printed. Thus no stencil, causing the error.
> Ensuring a reasonable minimum-length, cures the error, but the visual
> output is not convincing.
> Lemme see if I can come up with something better, but I'll likely have
> not no time to work on it before the weekend.
>
> Sorry,
>   Harm

Hi Ryan,

below next try.
I'm not really convinced though, see REMARK

\version "2.19.44"

%% REMARK
%% The code below keeps the default glissando-stencil, while adding some
%% text to it. This means the text-stencil needs to be rotated to match the
%% glissando; also some reasonable padding between them needs to be found.
%% It turned out being a pretty difficult task to do so with reasonable
%% exactness and the current code is not always convincing, although usable.
%%
%% TODO
%% Test whether constructing a glissando+text-stencil from scratch causes better
%% results

#(define (radians->degree radians)
  (/ (* radians 180) PI))

#(define (sign x)
  (if (= x 0)
  0
  (if (< x 0) -1 1)))

#(define ((gliss-plus-text text) grob)
  (if (not (ly:stencil? (ly:line-spanner::print grob)))
  #f
  (let* ((sys (ly:grob-system grob))
 (layout (ly:grob-layout grob))
 (line-thickness (ly:output-def-lookup layout 'line-thickness))
 (blot-diameter (ly:output-def-lookup layout 'blot-diameter))
 (thickness (ly:grob-property grob 'thickness))
 (thick
   (if (number? thickness)
   (/ thickness 10)
   line-thickness))
 (spanner-stencil (ly:line-spanner::print grob))
 (left-bound-info (ly:grob-property grob 'left-bound-info))
 (y-left (assoc-get 'Y left-bound-info))
 (x-left (assoc-get 'X left-bound-info))
 (left-padding (assoc-get 'padding left-bound-info))
 (right-bound-info (ly:grob-property grob 'right-bound-info))
 (y-right (assoc-get 'Y right-bound-info))
 (x-right (assoc-get 'X right-bound-info))
 (right-padding (assoc-get 'padding right-bound-info))
 (slant (sign (- y-right y-left)))
 (spanner-stencil-x-length
   (interval-length (ly:stencil-extent spanner-stencil X)))
 (spanner-stencil-y-length
   (interval-length (ly:stencil-extent spanner-stencil Y)))
 ;; TODO
 ;; fiddling around with PI and radians causes some inexactness
 (alpha
   (radians->degree
 (- (/ PI 2)
(angle
  (make-rectangular
(- spanner-stencil-y-length
   (/ (+ thick blot-diameter) 2))
(- spanner-stencil-x-length
   (/ (+ thick blot-diameter) 2)))
 (spanner-center-X
   (interval-center (ly:stencil-extent spanner-stencil X)))
 (text-stencil (grob-interpret-markup grob text))
 (rotated-text-stil
   (ly:stencil-rotate text-stencil (* slant alpha) 0 0))
 (text-center-X
   (interval-center (ly:stencil-extent rotated-text-stil X)))
 (translated-text-stencil
   (ly:stencil-translate
 rotated-text-stil
 ;; TODO
 ;; some correcting values found by try and error
 ;; how to calculate?
 (cons
   (+
 (/ (+ left-padding right-padding) 2)
 (- spanner-center-X text-center-X)
 (if (negative? slant) 0.1 -0.6))
   (+ (/ (+ y-right y-left) 2)
  (if (negative? slant) 0.5 0.6))
  (ly:stencil-add
spanner-stencil
translated-text-stencil


glissandoTextOn = {
\temporary \override Score.Glissando.springs-and-rods =
  #ly:spanner::set-spacing-rods
\temporary \override Score.Glissando.minimum-length = 7
\temporary \override Score.Glissando #'stencil =
  #(gliss-plus-text
;(markup #:with-color red #:box #:italic #:fontsize -5 "gliss.")
#{
  \markup \italic \fontsize #-5 "gliss."
#})
}

glissandoTextOff = \revert 

Re: drawing glissando line with (gliss) as text across line

2016-06-22 Thread Thomas Morley
2016-06-22 23:48 GMT+02:00 Ryan Michael :
> Interesting. your example works perfectly in itself. But when I port it over
> to my score I get the following error:
>
>  Wrong type argument in position 1 (expecting Stencil): ()
>
> I believe it calls it on this line:
>
>  (spanner-stencil-x-length (interval-length (ly:stencil-extent
> spanner-stencil X)))
>
> Here is a gist of the score:
> https://gist.github.com/ebbnormal/62a8893942a5e6f91735afdf77f2081a
> I basically make a simple call to \glissandoTextOn as you do before I use
> \glissando.
>
> Any ideas?


If the glissando-line is _too_ short in tight layout-situations, it
will not be printed. Thus no stencil, causing the error.
Ensuring a reasonable minimum-length, cures the error, but the visual
output is not convincing.
Lemme see if I can come up with something better, but I'll likely have
not no time to work on it before the weekend.

Sorry,
  Harm

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


Re: drawing glissando line with (gliss) as text across line

2016-06-22 Thread Ryan Michael
Interesting. your example works perfectly in itself. But when I port it
over to my score I get the following error:

 Wrong type argument in position 1 (expecting Stencil): ()

I believe it calls it on this line:

 (spanner-stencil-x-length (interval-length (ly:stencil-extent
spanner-stencil X)))

Here is a gist of the score:
https://gist.github.com/ebbnormal/62a8893942a5e6f91735afdf77f2081a
I basically make a simple call to \glissandoTextOn as you do before I use
\glissando.

Any ideas?

On Wed, Jun 22, 2016 at 2:15 PM, Thomas Morley 
wrote:

> 2016-06-22 22:42 GMT+02:00 Ryan Michael :
> > Hello, I am trying to engrave the following gesture:
> >
> > %
> > bes16\glissando
> > \tuplet 3/2{ aes8\glissando-\markup{\teeny"glissando between Ab and Bb"}
> > \once \hide NoteHead a8\glissando  \once \hide NoteHead a16\glissando
> > bes16~}
> > 
> >
> >
> > my idea is to draw the first 16th note, have a visible line connect that
> > 16th the the next 8th note with the word ("gliss") appear across the line
> > like the first measure of this graphic:
> >
> >
> http://sites.siba.fi/documents/705861/705966/SingleGlissando1.png/3a9d5ef5-617d-460b-bfba-e3688ca67a4b?t=1371409410781
> >
> > how can i do that?
> > currently, even using the /glissando command between the bes16 and the
> aes,
> > lilypond does not draw a visible line. Should I increase the width of the
> > bar so it is actually visible?
> >
> > Thanks!
> > Ryan.
>
> Hi Ryan,
>
> attached some old code of mine, still compiling, could likely need
> some revision, though. Maybe somebody can provide something more up to
> date.
>
> Anyway, hth,
>   Harm
>



-- 
ॐ नमः शिवाय
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: drawing glissando line with (gliss) as text across line

2016-06-22 Thread Thomas Morley
2016-06-22 22:42 GMT+02:00 Ryan Michael :
> Hello, I am trying to engrave the following gesture:
>
> %
> bes16\glissando
> \tuplet 3/2{ aes8\glissando-\markup{\teeny"glissando between Ab and Bb"}
> \once \hide NoteHead a8\glissando  \once \hide NoteHead a16\glissando
> bes16~}
> 
>
>
> my idea is to draw the first 16th note, have a visible line connect that
> 16th the the next 8th note with the word ("gliss") appear across the line
> like the first measure of this graphic:
>
> http://sites.siba.fi/documents/705861/705966/SingleGlissando1.png/3a9d5ef5-617d-460b-bfba-e3688ca67a4b?t=1371409410781
>
> how can i do that?
> currently, even using the /glissando command between the bes16 and the aes,
> lilypond does not draw a visible line. Should I increase the width of the
> bar so it is actually visible?
>
> Thanks!
> Ryan.

Hi Ryan,

attached some old code of mine, still compiling, could likely need
some revision, though. Maybe somebody can provide something more up to
date.

Anyway, hth,
  Harm
%\version "2.14.2"
\version "2.12.3"

#(define-public PI (* 4 (atan 1)))

#(define (radians->degree radians)
  (/ (* radians 180) PI))

#(define ((gliss-plus-text padding text) grob)
  (let* ((text-stencil (grob-interpret-markup grob text))
 (spanner-stencil (ly:line-spanner::print grob))
 (left-bound-info (ly:grob-property grob 'left-bound-info))
 (y-left (cdar left-bound-info))
 (right-bound-info (ly:grob-property grob 'right-bound-info))
 (y-right (cdar right-bound-info))
 (slant (if (> y-right y-left) 1 -1)) 
 (spanner-stencil-x-length (interval-length (ly:stencil-extent spanner-stencil X)))
 (spanner-stencil-y-length (interval-length (ly:stencil-extent spanner-stencil Y)))
 (alpha (radians->degree (atan (/ spanner-stencil-y-length spanner-stencil-x-length
 (spanner-center-X (interval-center (ly:stencil-extent spanner-stencil X)))
 (label-center-X (interval-center (ly:stencil-extent text-stencil X
  
  (ly:stencil-combine-at-edge 
spanner-stencil 
Y UP
(ly:stencil-translate 
  (ly:stencil-rotate text-stencil (* slant alpha) 0 0)
  (cons (- spanner-center-X label-center-X) 0)) 
;;(* -0.5 spanner-stencil-y-length)
padding
)))
   
glissandoTextOn = \override Glissando #'stencil = #(gliss-plus-text -9 (markup #:italic #:tiny "gliss"))
glissandoTextOff = \revert Glissando #'stencil

noteHeadsOff = {
\override NoteHead #'transparent = ##t
\override NoteHead #'no-ledgers = ##t
}
noteHeadsOn = {
\revert NoteHead #'transparent
\revert NoteHead #'no-ledgers 
}

% test

\paper { ragged-right = ##f }

\new PianoStaff <<
 \new Staff = "right" {
   \clef treble

   \glissandoTextOn
   e'''8\glissando s s4
   \change Staff = "left"
   \noteHeadsOff
   a,,8\glissando s s4 |
   \change Staff = "right" 
   b''8
 }
 \new Staff = "left" {
   \clef bass
   s1 s8
 }
>>
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


drawing glissando line with (gliss) as text across line

2016-06-22 Thread Ryan Michael
Hello, I am trying to engrave the following gesture:

%
bes16\glissando
\tuplet 3/2{ aes8\glissando-\markup{\teeny"glissando between Ab and Bb"}
\once \hide NoteHead a8\glissando  \once \hide NoteHead a16\glissando
bes16~}



my idea is to draw the first 16th note, have a visible line connect that
16th the the next 8th note with the word ("gliss") appear across the line
like the first measure of this graphic:

http://sites.siba.fi/documents/705861/705966/SingleGlissando1.png/3a9d5ef5-617d-460b-bfba-e3688ca67a4b?t=1371409410781

how can i do that?
currently, even using the /glissando command between the bes16 and the aes,
lilypond does not draw a visible line. Should I increase the width of the
bar so it is actually visible?

Thanks!
Ryan.
-- 
ॐ नमः शिवाय
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user