RE: "Text spanner"-ish thing with text in the middle
HI Nathan, Indeed yes. This is clever, and short, but it is a hack, no disrespect intended. As you say, it hijacks the tuplet concept and introduces tuplet semantics where there are none. Whether this bothers people or not is entirely up to them, but I prefer my solution as it keeps the semantics purely at the text spanner level. Andrew ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
RE: "Text spanner"-ish thing with text in the middle
Hi James, This comes up so frequently it puzzles me why it is not considered for addition to the lilypond baseline. Here's my function. Andrew === snip \version "2.19.39" % Annotation bracket with centred text. % Andrew Bernard and Thomas Morley TextSpannerCentredText = #(define-music-function (text extra-length) (string? pair?) "Use TextSpanner semantics to create spanner brackets with centred text" #{ \once \override TextSpanner.after-line-breaking = #(lambda (grob) (let* ( ;; get stencil of grob (stil (ly:grob-property grob 'stencil)) ;; get spanner length (spanner-len (interval-length (ly:stencil-extent stil X))) ;; make stencil from text arg (text-stil (grob-interpret-markup grob (markup #:sans #:upright text))) ;; get text length (text-len (interval-length (ly:stencil-extent text-stil X ;; if text length exceeds the spanner length we cannot really proceed. ;; do nothing - make an ordinary text spanner and warn. (if (>= text-len spanner-len) (begin (ly:warning "text length longer than spanner") #f ) (let* ( ;; get direction, up or down (dir (ly:grob-property grob 'direction)) ;; some padding (padding 1) ;; line thickness (thickness 0.25) ;; extra length on left, negative values shorten (left-ext (car extra-length)) ;; extra length on right, negative values shorten (right-ext (cdr extra-length)) ;; calculate length considering text length (path-part-len (/ (- spanner-len text-len) 2)) ;; make left bracket stencil (path-left-part-stil (make-path-stencil `( moveto ,(- left-ext) ,(* -1 dir) lineto ,(- left-ext) 0 lineto ,path-part-len 0 ) thickness 1 1 #f)) ;; make right bracket stencil (path-right-part-stil (make-path-stencil `( moveto ,(+ path-part-len right-ext) ,(* -1 dir) lineto ,(+ path-part-len right-ext) 0 lineto 0 0 ) thickness 1 1 #f)) ;; make complete stencil combining left and right parts ;; and text (full-stil (stack-stencils X RIGHT padding (list path-left-part-stil (centered-stencil text-stil) path-right-part-stil))) ) ;; set grob stencil to fully constructed stencil (ly:grob-set-property! grob 'stencil full-stil) #} ) { c' d' ees' fis' \once \override TextSpanner.direction = #DOWN \TextSpannerCentredText "6\"" #'(0 . 0) g' \startTextSpan a' bes' c'' \stopTextSpan \TextSpannerCentredText "x3" #'(2 . 1) bes'\startTextSpan a' g' c'\stopTextSpan \TextSpannerCentredText "x3" #'(2 . 3.5) c''1\startTextSpan c''1\stopTextSpan \break c''1\startTextSpan c''1\stopTextSpan } === snip ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: "Text spanner"-ish thing with text in the middle
On Sat, 28 Oct 2017 13:55:49 +0800 Nathan Ho wrote > On 2017-10-27 21:37, James Harkins wrote: > > I couldn't find this quickly: for an unmetered section, I'd like to > > indicate duration by tuplet-style brackets, only not a tuplet (no > > change to note durations) and with arbitrary text markup in the > > middle... > > you can hijack an ordinary tuplet by setting the duration ratio to 1/1 > and modifying the text: Nathan? *blinks* Of course there is some overlap between the LilyPond and SuperCollider communities ;) That's a neat trick, to use a tuplet like that -- I'll give it a try. Otherwise, Andrew's approach looks good too. I've got one more question -- separate question, separate thread. BTW all this is for a new piece that will be premiered in San Diego this coming Thursday, on a recital of modern pieces for the khaen. The khaen is a free-reed mouth organ from Laos and northeast Thailand. My friend and grad school colleague Chris Adler has been playing and writing for the instrument for, oh, 20 years now. Thursday, November 2, 7:30 p.m. USD: University of San Diego Founders Chapel 5998 Alcala Park, San Diego My piece is engraved in LilyPond, with electronics in SuperCollider. (I'm only cleaning up the notation of the electronic cues now -- the khaen music is already in Chris's hands.) If you live within easy driving distance, this will be well worth the effort. Thanks! James ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Rhythmic clusters (i.e. *not* \makeClusters)
That other question... I would like to notate some clusters, but articulated: blocks instead of notes, but showing repeated, re-articulated blocks. \makeClusters doesn't do it. Even if I put a "s"kip in between, it still connects them into one massive gesture. Plus, I need rhythmic notation. Temporarily, I'll use \improvisationOn, but I think that's not right. The idea in my mind is to replace the note column with a filled rectangle. Thanks, James ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Rhythmic clusters (i.e. *not* \makeClusters)
James Harkins writes: > That other question... > > I would like to notate some clusters, but articulated: blocks instead > of notes, but showing repeated, re-articulated blocks. > > \makeClusters doesn't do it. Even if I put a "s"kip in between, it > still connects them into one massive gesture. Plus, I need rhythmic > notation. \chordmode { \makeClusters g4 \omit r4 \makeClusters c2 } Makes two separate clusters here. I agree that this isn't optimal. -- David Kastrup ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Rhythmic clusters (i.e. *not* \makeClusters)
Am 28.10.2017 um 10:01 schrieb David Kastrup: James Harkins writes: That other question... I would like to notate some clusters, but articulated: blocks instead of notes, but showing repeated, re-articulated blocks. \makeClusters doesn't do it. Even if I put a "s"kip in between, it still connects them into one massive gesture. Plus, I need rhythmic notation. \chordmode { \makeClusters g4 \omit r4 \makeClusters c2 } Makes two separate clusters here. I agree that this isn't optimal. Another sub-optimal solution can be found here: http://lilypondblog.org/2014/04/using-special-characters-from-smufl-fonts/ Maybe one could make a function that takes a chord and builds a stencil of correct height? ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Made In The Pond™ update
Hi Kieren, thanks a lot! > but I suppose I do slam out a lot of scores fairly quickly, and I have pretty > high aesthetic standards. I like very much what Lilypond offers by default. And I have my own styles and tweaks to get what I consider more beautiful. But your scores look so much better! The choice of fonts is surely one part (music and text fonts). And then there are probably tweaks for spacing/positioning etc. What would you call the most important tweaks. Or would you say it's not so much general tweaks but more often the specific situation in a score that require particular tweaks? > Hope this helps! A lot. Thank you! Joram ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Cross-staff beam slope - can it be specified?
On 10/27/2017 1:33 PM, David Sumbler wrote: In the above rather silly example, the beam between the 2 cross-staff notes slopes slightly upwards. If I add a dynamic, say \f , after 2. in line 7, the staves are forced further apart, and the beam slopes slightly downwards. If I now add a further dynamic, say ^\p , to the lower staff after 2. in line 9, the staves are forced still further apart and the beam now has a large downward slope. The problem I have is that, in "real life", I don't know how far apart the staves will be because of the space requirements of other parts of the music. Generally I would prefer to allow Lilypond to determine where line ends etc. should be, so I don't even know which bits of the music will affect the slope of the beam. And even if I did know, an alteration to the music in the closely preceding and following bars might well affect the spacing of the staves and hence the slope of the beam. Is there any way of ensuring that the beam always has a predetermined slope - say 10° downwards - and that the stem lengths will automatically be adjusted to allow for this? David Hello, Check out this older post here, it deals with cross beam slopes: http://lilypond.1069038.n5.nabble.com/Adjusting-beam-slope-with-cross-staff-notes-td140283.html David Nalesnik wrote a function where instead of specifying the absolute values for positions, it allows you to indicate *displacements *from the values LilyPond would use by *default*. It sounds like that's what you are looking for, does this help? \version "2.16.1" %%% generalized offsetter %%% #(define (pair-list? x) (and (pair? x) (every number-pair? x))) #(define (offset-general arg offsets) (cond ((null? offsets) arg) ((number? arg) (+ arg offsets)) ((number-pair? arg) (coord-translate arg offsets)) ((pair-list? arg) (map (lambda (x y) (coord-translate x y)) arg offsets #(define ((offsetter property offsets) grob) (let* ((immutable (ly:grob-basic-properties grob)) (target (assoc-get property (reverse immutable))) (vals (if (procedure? target) (if (procedure-name target) ; check for # (target grob) '()) target))) (if (or (number? vals) (number-pair? vals) (pair-list? vals)) (let* ((orig (ly:grob-original grob)) (siblings (if (ly:spanner? grob) (ly:spanner-broken-into orig) '())) (total-found (length siblings))) (define (helper sibs offs) (if (pair? offs) (if (eq? (car sibs) grob) (offset-general vals (car offs)) (helper (cdr sibs) (cdr offs))) vals)) ;; standardize form of offsets (if (or (null? offsets) (and (number? offsets) (number? vals)) (and (number-pair? offsets) (number-pair? vals)) (and (pair-list? offsets) (pair-list? vals))) (set! offsets (list offsets))) (if (>= total-found 2) (helper siblings offsets) (offset-general vals (car offsets vals))) offset = #(define-music-function (parser location name property offsets) (string? scheme? scheme?) (let* ((name (string-regexp-substitute " " "" name)) ; remove any spaces (name-components (string-split name #\.)) (context-name "Voice") (grob-name #f)) (if (> 2 (length name-components)) (set! grob-name (car name-components)) (begin (set! grob-name (cadr name-components)) (set! context-name (car name-components #{ \override $context-name . $grob-name $property = #(lambda (grob) ((offsetter property offsets) grob)) #})) staffUp = \change Staff = "upper" staffDown = \change Staff = "lower" soprano= \relative c'{ \time 2/4 s2 \once \offset Beam #'positions #'(1.75 . -1.5) % For broken beams, you would use something like the following: % \once \offset Beam #'positions #'((-1 . -2) (-3 . -2)) %\override Beam #'positions = #'(1 . 0.7) %can't adjust beam relative to upper staff centerline (desired) %\override Beam #'positions = #'(10.5 . 9.5) %values relative to lower staff centerline subject to between-staff distance \staffDown g8[ \staffUp e'd c] } bass = \relative c{ \clef bass s2 2} \score{ \new PianoStaff << \new Staff = "upper" \soprano \new Staff = "lower" \bass >> \layout{} } ___ lilypond-user mailing list lilypond-user@g
Re: "Text spanner"-ish thing with text in the middle
Hi, On Sat, Oct 28, 2017 at 2:23 AM, James Harkins wrote: > On Sat, 28 Oct 2017 13:55:49 +0800 Nathan Ho wrote > >> On 2017-10-27 21:37, James Harkins wrote: >> > I couldn't find this quickly: for an unmetered section, I'd like to >> > indicate duration by tuplet-style brackets, only not a tuplet (no >> > change to note durations) and with arbitrary text markup in the >> > middle... >> >> you can hijack an ordinary tuplet by setting the duration ratio to 1/1 >> and modifying the text: > > That's a neat trick, to use a tuplet like that -- I'll give it a try. > Otherwise, Andrew's approach looks good too. I'm a little late to the party, but attached is a very generalized solution which offers a fully functional TextSpanner -- well, minus arrows at this point -- with as many inner texts as you want. A single text will be centered. The code is copied from the repository at https://github.com/davidnalesnik/lilypond-text-spanner-inner-texts, which contains instructions and a file of examples. Best, David \version "2.19.46" #(define (offset-subtract a b) (cons (- (car b) (car a)) (- (cdr b) (cdr a % Rewrite of Offset::direction in LilyPond source file 'flower/offset.cc' #(define (offset-direction o) (cond ((and (inf? (car o)) (not (inf? (cdr o (cons (if (> (car o) 0.0) 1.0 -1.0) 0.0)) ((inf? (cdr o)) (cons 0.0 (if (> (cdr o) 0.0) 1.0 -1.0))) ((and (= (car o) 0.0) (= (cdr o) 0.0)) o) (else (let ((len (sqrt (+ (* (car o)(car o)) (* (cdr o)(cdr o)) (cons (/ (car o) len) (/ (cdr o) len)) %% CUSTOM GROB PROPERTIES % Taken from http://www.mail-archive.com/lilypond-user%40gnu.org/msg97663.html % (Paul Morris) % function from "scm/define-grob-properties.scm" (modified) #(define (cn-define-grob-property symbol type?) (set-object-property! symbol 'backend-type? type?) (set-object-property! symbol 'backend-doc "custom grob property") symbol) % Count of _inner_ texts per line; does not include bound-details.left.text % and bound-details.right.text. This is set automatically but may be % overridden. #(cn-define-grob-property 'inner-text-count-by-line number-list?) % How much space between line and object to left and right? % Default is '(0.0 . 0.0). #(cn-define-grob-property 'line-X-offset number-pair?) % Vertical shift of connector line, independenf of texts. #(cn-define-grob-property 'line-Y-offset number?) % Turn a list of lengths into contiguous extents % '(10 20 5) -> '((0 . 10) (10 . 30) (30 . 35)) % Used with line lengths to decide where to place an inner text #(define (lengths->cumulative-extent-list ls) (let inner ((ls ls) (prev 0) (result '())) (if (null? ls) (reverse result) (inner (cdr ls) (+ prev (car ls)) (cons (cons prev (+ (car ls) prev)) result) % Place a text by x coordinate within a list of contiguous extents % representing lines #(define (assign-line my-X line-exts) (let inner ((line-exts line-exts) (idx 0)) (cond ((null? line-exts) #f) ((and (<= (caar line-exts) my-X) (<= my-X (cdar line-exts))) idx) (else (inner (cdr line-exts) (1+ idx)) % count adjacent duplicates. Used to determine count of the inner texts assigned to % each line of our spanner. #(define (text-count-per-line ls line-count) (define (inner ls counter lines result) (cond ((null? lines) (reverse result)) ((null? ls) (inner ls 0 (cdr lines) (cons counter result))) ((eq? (car ls) (car lines)) (inner (cdr ls) (1+ counter) lines result)) (else (inner ls 0 (cdr lines) (cons counter result) (if (null? ls) '() (inner ls 0 (iota line-count) '( % Spread texts evenly over available lines taking into account line lengths. Return % a list showing number of texts per line. % TODO: take into account the extent of texts, rather than assuming them to be % dimensionless #(define (get-text-distribution text-list line-extents) (let ((line-count (length line-extents)) (text-count (length text-list))) (if (= 0 text-count) (make-list line-count 0) (let* ((line-lengths (map (lambda (line) (interval-length line)) line-extents)) (total-line-length (apply + line-lengths)) (space-between (/ total-line-length (1+ text-count))) (positions (map (lambda (e) (* e space-between)) (iota text-count 1))) (segment-exts (lengths->cumulative-extent-list line-lengths)) (line-assignments (map (lambda (x) (assign-line x segment-exts)) positions)) (count-per-line (text-count-per-line line-assignments line-count))) count-per-line %% Adapted from 'justify-line-helper' in scm/define-markup-commands.scm. #(define (inner-te
Re: "Text spanner"-ish thing with text in the middle
On 10/28/2017 1:43 AM, Andrew Bernard wrote: Hi James, This comes up so frequently it puzzles me why it is not considered for addition to the lilypond baseline. Here's my function. Andrew === snip \version "2.19.39" % Annotation bracket with centred text. % Andrew Bernard and Thomas Morley TextSpannerCentredText = #(define-music-function (text extra-length) (string? pair?) "Use TextSpanner semantics to create spanner brackets with centred text" #{ \once \override TextSpanner.after-line-breaking = #(lambda (grob) (let* ( ;; get stencil of grob (stil (ly:grob-property grob 'stencil)) ;; get spanner length (spanner-len (interval-length (ly:stencil-extent stil X))) ;; make stencil from text arg (text-stil (grob-interpret-markup grob (markup #:sans #:upright text))) ;; get text length (text-len (interval-length (ly:stencil-extent text-stil X ...etc Andrew, Thank you so much for sharing this function. It will come in handy for a project I'll be working on shortly. However, I had one question for you. I just went to try to use the function 'as is' and I'm seeing an error. I cannot use the function at the moment. Do you know what this means, and how I can fix it? (I just simply copied and pasted it into Frescobaldi and attempted to use it - no tweaks) Thanks! / Drawing systems...// // line:31 32:15: In procedure memoization in expression (let* (# # # ...) (ly:grob-set-property! grob # ...))// //* Bad binding parts in expression*//(let* ((dir (ly:grob-property grob (quote direction))) (padding 1) (thickness 0.25) (left-ext (car extra-length)) (right-ext (cdr extra-length)) (path-part-len (/ (- spanner-len text-len) 2)) (path-left-part-stil (make-path-stencil (quasiquote (moveto (unquote #) (unquote #) lineto (unquote #) 0 lineto (unquote path-part-len) 0)) thickness 1 1 #f)) (path-right-part-stil (make-path-stencil (quasiquote (moveto (unquote #) (unquote #) lineto (unquote #) 0 lineto 0 0)) thickness 1 1 #f)) parts (full-stil (stack- stencils X RIGHT padding (list path-left-part-stil (centered-stencil text-stil) path-right-part-stil (ly:grob-set-property! grob (quote stencil) full-stil))...etc./ ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: "Text spanner"-ish thing with text in the middle
Ben writes: > Thank you so much for sharing this function. It will come in handy for > a project I'll be working on shortly. > However, I had one question for you. > I just went to try to use the function 'as is' and I'm seeing an > error. I cannot use the function at the moment. > Do you know what this means, and how I can fix it? > (I just simply copied and pasted it into Frescobaldi and attempted to > use it - no tweaks) > > Thanks! > > / Drawing systems...// > // line:31 32:15: In procedure memoization in expression (let* (# # > # ...) (ly:grob-set-property! grob # ...))// > //* Bad binding parts in expression*//(let* ((dir (ly:grob-property > grob (quote direction))) (padding 1) (thickness 0.25) (left-ext (car > extra-length)) (right-ext (cdr extra-length)) (path-part-len (/ (- > spanner-len text-len) 2)) (path-left-part-stil (make-path-stencil > (quasiquote (moveto (unquote #) (unquote #) lineto (unquote #) 0 > lineto (unquote path-part-len) 0)) thickness 1 1 #f)) > (path-right-part-stil (make-path-stencil (quasiquote (moveto (unquote > #) (unquote #) lineto (unquote #) 0 lineto 0 0)) thickness 1 1 #f)) > parts (full-stil (stack- stencils X RIGHT padding (list > path-left-part-stil (centered-stencil text-stil) > path-right-part-stil (ly:grob-set-property! grob (quote stencil) > full-stil))...etc./ Two comment lines were wrapped in the mail and thus the end of them became a non-comment. -- David Kastrup ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: "Text spanner"-ish thing with text in the middle
On 10/28/2017 10:30 AM, David Kastrup wrote: Ben writes: Thank you so much for sharing this function. It will come in handy for a project I'll be working on shortly. However, I had one question for you. I just went to try to use the function 'as is' and I'm seeing an error. I cannot use the function at the moment. Do you know what this means, and how I can fix it? (I just simply copied and pasted it into Frescobaldi and attempted to use it - no tweaks) Thanks! / Drawing systems...// // line:31 32:15: In procedure memoization in expression (let* (# # # ...) (ly:grob-set-property! grob # ...))// //* Bad binding parts in expression*//(let* ((dir (ly:grob-property grob (quote direction))) (padding 1) (thickness 0.25) (left-ext (car extra-length)) (right-ext (cdr extra-length)) (path-part-len (/ (- spanner-len text-len) 2)) (path-left-part-stil (make-path-stencil (quasiquote (moveto (unquote #) (unquote #) lineto (unquote #) 0 lineto (unquote path-part-len) 0)) thickness 1 1 #f)) (path-right-part-stil (make-path-stencil (quasiquote (moveto (unquote #) (unquote #) lineto (unquote #) 0 lineto 0 0)) thickness 1 1 #f)) parts (full-stil (stack- stencils X RIGHT padding (list path-left-part-stil (centered-stencil text-stil) path-right-part-stil (ly:grob-set-property! grob (quote stencil) full-stil))...etc./ Two comment lines were wrapped in the mail and thus the end of them became a non-comment. David, You're right :) How could my eyes have missed that, sorry! All fixed now. /Line 63/64 --> ;; make complete stencil combining left and right parts// / Thank you! ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
non-triplet tuplets collide with staff
Lilypond by default seems to place all tuplet numbers/brackets so that they collide with the staff, with the exception of triplets, which it places outside the staff. I would like all tuplets outside of the staff like triplets. \override Staff.TupletNumber #'outside-staff-priority = #1 fixes tuplets with no bracket, but for tuplets with a bracket only the number appears outside the staff; the bracket still collides with the staff. \override Staff.TupletBracket #'outside-staff-priority = #1 fixes tuplets with a bracket, but for tuplets with no bracket the number still collides with the staff. If I do both \override Staff.TupletNumber #'outside-staff-priority = #1 \override Staff.TupletBracket #'outside-staff-priority = #1 I get an error: "warning: Cannot set outside-staff-priority for element and elements' Y parent." How can I avoid collisions with the staff for all tuplets, whether or not they have a bracket? Thanks, Mason ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: non-triplet tuplets collide with staff
On 10/28/2017 5:38 PM, Mason Hock wrote: Lilypond by default seems to place all tuplet numbers/brackets so that they collide with the staff, with the exception of triplets, which it places outside the staff. I would like all tuplets outside of the staff like triplets. /\override Staff.TupletNumber #'outside-staff-priority = #1/ /\override Staff.TupletBracket #'outside-staff-priority = #1/ I get an error: "warning: Cannot set outside-staff-priority for element and elements' Y parent." How can I avoid collisions with the staff for all tuplets, whether or not they have a bracket? Thanks, Mason Mason, Have you tried first deciding how to control bracket *visibility *in general? It sounds like you have a very specific preference for this, maybe you could begin there and then do an outside staff priority override as needed for only the number? That should avoid the error you're seeing due to the 'double' overrides. http://lilypond.org/doc/v2.19/Documentation/snippets/rhythms#rhythms-controlling-tuplet-bracket-visibility Just an idea... ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Cannot include # in URL?
Can't figure out how to include # in a URL. When I do something like this: \markup { For more, see http://lilypond.org/doc/v2.18/Documentation/notation/ writing-rhythms#durations } I get the following message: error: GUILE signaled an error for the expression beginning here For more, see http://lilypond.org/doc/v2.18/Documentation/notation/ writing-rhythms# durations How should I include # in a URL in text markup? (Sent to bug-lilypond by mistake-sorry) ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user