Re: performance marks

2024-02-06 Thread Curt McDowell

Thank you, Valentin. It took me a couple hours to convert some
PostScript in one of my big projects to native \path commands, mainly
because the PostScript needed to draw outside the page margins, but I
got it done! I haven't tried it in SVG yet.

https://www.fishlet.com/wp-content/uploads/2018/09/LeCheminDeFer.pdf

Cheers,
Curt

On 2/3/24 16:18, Valentin Petzel wrote:

rather than postscript you should probably use the high level path command.
This will work with other outputs than just SVG.

So instead of

\markup\postscript #"0.17 setlinewidth -1.50 1.25 moveto 0 1.0 rlineto stroke"

do

\markup\path #0.17 #'((moveto -1.5 1.25) (rlineto 0 1))

Cheers,
Valentin


Re: performance marks

2024-02-03 Thread Valentin Petzel
Am Donnerstag, 1. Februar 2024, 00:03:00 CET schrieb Curt McDowell:
> Stan,
> 
> Here is a brute force way by embedding PostScript – although it can be a
> bit tedious.
> 
> \version "2.22.1"
> 
> %% Custom dynamic marks using embedded PostScript
> 
> %% If a particular mark is needed repeatedly, you can define a dynamic:
> vmark = #(make-dynamic-script
>(markup #:postscript
> "0.17 setlinewidth -1.50 1.25 moveto 0 1.0 rlineto stroke"))
> 

Hello Curt,

rather than postscript you should probably use the high level path command. 
This will work with other outputs than just SVG.

So instead of

\markup\postscript #"0.17 setlinewidth -1.50 1.25 moveto 0 1.0 rlineto stroke"

do

\markup\path #0.17 #'((moveto -1.5 1.25) (rlineto 0 1))

Cheers,
Valentin



signature.asc
Description: This is a digitally signed message part.


Re: performance marks

2024-01-31 Thread Stanton Sanderson
Many thanks to Robin, Curt and Leo for their suggestions, examples and the link 
to Harm’s code. 

The examples which were provided will provide exactly what I was looking for.


Stan




Re: performance marks

2024-01-31 Thread Leo Correia de Verdier
There is also some code in the list archives:
https://lists.gnu.org/archive/html/lilypond-user/2018-05/msg00167.html

> 1 feb. 2024 kl. 00:49 skrev Robin Bannister :
> 
> Stan Sanderson wrote:
>> Certain marks are used to indicate emphasis (phrase breaking) and 
>> across-staff fingering. 
> 
> 
> I don't know about the phrase breaking, but you could try doing the 
> across-staff fingering with my undocumented code, called thumbBracket.
> 
> Look at the Reger 17 and 60 examples in the demo.
> 
> The .ily file provides the \thumbBracket funtion which the demo file 
> abbreviates to \thBr.  You call this with a string parameter which starts 
> with the letter R or L, for right or left.  You can then append a digit to 
> make the stem longer.
> 
> The attached files are updated versions which need 2.24 and should be ok with 
> Guile3.
> 
> 
> Cheers,
> Robin
> 
> 
> 
> 
> 
\version "2.24.0"

% compatibility changes: u15k0830 u23k0114

%% +thumb bracket

#(define (make-thumb-bracket-props location spec-str settings-alist) 
  (define (inchar? index) (> (string-length spec-str) index))
  (define (inchar  index) (string-ref spec-str index))
  (define (char->dir ch) 
   (case (char-upcase ch) ((#\R) 1) ((#\L) -1) (else 0))) 
  (define (char->digit ch)
   (if (char-numeric? ch) (- (char->integer ch) (char->integer #\0)) 0))
  (define (inhit->1 key-str) (if (string-contains spec-str key-str) 1 0))
  (define (get key) (assq-ref settings-alist key))
  (define (warn p1 p2) (ly:input-warning location 
   (G_ " bad thumb-bracket:   ~a ~a~a~a") p1 "\"" p2 "\"")) ; cf 
  (let* ( ;% decode spec 
(vdir(if (inchar? 0) (char->dir   (inchar 0)) 0))
(vbigger  (* 0.5 (if (inchar? 1) (char->digit (inchar 1)) 0)))
(vfurther (* 0.5 (if (inchar? 2) (char->digit (inchar 2)) 0)))
(hcloser  (* 0.5 (if (inchar? 3) (char->digit (inchar 3)) 0)))
(hrear(* 0.5 (if (inchar? 4) (char->digit (inchar 4)) 0)))
(vbigger+ (* 5 (string-count spec-str #\|)))
(posdir   ((if (string-contains spec-str "*") - +) vdir))
(hcloser? (eq? (string-contains spec-str "!") #f))
(vtip=?   (string-contains spec-str "="))
(hdir-req (- (inhit->1 "]") (inhit->1 "[")))
(closed? (char-lower-case? (inchar 0
   (if (zero? vdir) (begin (warn "first char in" spec-str) '())
   (let* ( ;% collect settings
(hdir-init (get 'hdir-init))   (htip (get 'htip)) 
(vtip (get (if vtip=? 'vtip= 'vtip)))  
(vstem (get 'vstem))   (vmin (get 'vmin))   (hvernier (get 'hvernier))
(vO 0) (hO 0) (hpad-base 0.5) ;% givens
(hdir (if (zero? hdir-req) hdir-init hdir-req))
(hflip? (positive? hdir))
(h-interval 
 (if (positive? hdir) (cons hO (+ htip hrear)) (cons (- hrear) htip)))
(vsize (+ vtip (if closed? vtip vstem) vbigger vbigger+))
(vsize+ (if (and closed? (< vsize vmin)) (- vmin vsize) 0))
(vshift (+ vfurther vtip (* 0.5 vsize+)))
(bracket (lambda (grob) (let* ( ;% collect chord range from grob
  (vnote-lo-hi (ly:grob-property grob 'positions))
  (vnote ((if (eq? posdir 1) cdr car) vnote-lo-hi)))
 (grob-interpret-markup grob (markup #:translate (cons 
((if (positive? hdir) - +) hvernier) (- vnote (* vdir vshift)))
   #:combine #:draw-line (cons htip vO) #:combine 
#:translate (cons hO (if closed? (* vdir (+ vsize vsize+)) vO))
 #:draw-line (cons htip vO)
#:translate (cons (if (positive? hdir) htip hO) vO)
 #:draw-line (cons hO (* vdir (+ vsize vsize+)
;% alist of props for misusing Arpeggio as a thumb bracket
`((stencil . ,bracket) 
  (X-extent . ,h-interval) 
  (padding . ,((if hcloser? - +) hpad-base hcloser)) 
  (direction . ,hdir) 
  (thickness . ,(get 'weight)))

thumbBracketEx = #(define-music-function 
  (spec settings) (string? list?)
 (let* (
   (props (make-thumb-bracket-props (*location*) spec settings)))
   (define (get key) (assq-ref props key))
  (if (null? props) #{ #} ;% abort without bracket
   #{
 \once \override Arpeggio.stencil   = #(get 'stencil)
 \once \override Arpeggio.X-extent  = #(get 'X-extent)
 \once \override Arpeggio.padding   = #(get 'padding)
 \once \override Arpeggio.direction = #(get 'direction) 
 \once \override Arpeggio.thickness = #(get 'thickness)
 $(make-music 'EventChord 'elements (list (make-music 'ArpeggioEvent)))
   #})))

thumbBracket = #(define-music-function (spec) (string?)
 (let ((settings thumbBracketSettings)) ;% as Defaults, or user defined
#{ \thumbBracketEx $spec $settings #}))

thumbBracketDefaults = #(quasiquote( 
  (hdir-init . ,LEFT) ;% usual placement wrt note: on RIGHT or LEFT
  (weight. 1.5  ) ;% line thickness
  (htip  . 0.8  ) ;% horizontal length of bracket tip
  (vtip  . 0.75 ) ;% usual vertical overlap beyond notehead centre 
  (vtip= . 0.30 ) ;% alternative vertical 

Re: performance marks

2024-01-31 Thread Robin Bannister

Stan Sanderson wrote:
Certain marks are used to indicate emphasis (phrase breaking) and across-staff fingering. 



I don't know about the phrase breaking, but you could try doing the 
across-staff fingering with my undocumented code, called thumbBracket.


Look at the Reger 17 and 60 examples in the demo.

The .ily file provides the \thumbBracket funtion which the demo file 
abbreviates to \thBr.  You call this with a string parameter which 
starts with the letter R or L, for right or left.  You can then append a 
digit to make the stem longer.


The attached files are updated versions which need 2.24 and should be ok 
with Guile3.



Cheers,
Robin





\version "2.24.0"

% compatibility changes: u15k0830 u23k0114

%% +thumb bracket

#(define (make-thumb-bracket-props location spec-str settings-alist) 
  (define (inchar? index) (> (string-length spec-str) index))
  (define (inchar  index) (string-ref spec-str index))
  (define (char->dir ch) 
   (case (char-upcase ch) ((#\R) 1) ((#\L) -1) (else 0))) 
  (define (char->digit ch)
   (if (char-numeric? ch) (- (char->integer ch) (char->integer #\0)) 0))
  (define (inhit->1 key-str) (if (string-contains spec-str key-str) 1 0))
  (define (get key) (assq-ref settings-alist key))
  (define (warn p1 p2) (ly:input-warning location 
   (G_ " bad thumb-bracket:   ~a ~a~a~a") p1 "\"" p2 "\"")) ; cf 
  (let* ( ;% decode spec 
(vdir(if (inchar? 0) (char->dir   (inchar 0)) 0))
(vbigger  (* 0.5 (if (inchar? 1) (char->digit (inchar 1)) 0)))
(vfurther (* 0.5 (if (inchar? 2) (char->digit (inchar 2)) 0)))
(hcloser  (* 0.5 (if (inchar? 3) (char->digit (inchar 3)) 0)))
(hrear(* 0.5 (if (inchar? 4) (char->digit (inchar 4)) 0)))
(vbigger+ (* 5 (string-count spec-str #\|)))
(posdir   ((if (string-contains spec-str "*") - +) vdir))
(hcloser? (eq? (string-contains spec-str "!") #f))
(vtip=?   (string-contains spec-str "="))
(hdir-req (- (inhit->1 "]") (inhit->1 "[")))
(closed? (char-lower-case? (inchar 0
   (if (zero? vdir) (begin (warn "first char in" spec-str) '())
   (let* ( ;% collect settings
(hdir-init (get 'hdir-init))   (htip (get 'htip)) 
(vtip (get (if vtip=? 'vtip= 'vtip)))  
(vstem (get 'vstem))   (vmin (get 'vmin))   (hvernier (get 'hvernier))
(vO 0) (hO 0) (hpad-base 0.5) ;% givens
(hdir (if (zero? hdir-req) hdir-init hdir-req))
(hflip? (positive? hdir))
(h-interval 
 (if (positive? hdir) (cons hO (+ htip hrear)) (cons (- hrear) htip)))
(vsize (+ vtip (if closed? vtip vstem) vbigger vbigger+))
(vsize+ (if (and closed? (< vsize vmin)) (- vmin vsize) 0))
(vshift (+ vfurther vtip (* 0.5 vsize+)))
(bracket (lambda (grob) (let* ( ;% collect chord range from grob
  (vnote-lo-hi (ly:grob-property grob 'positions))
  (vnote ((if (eq? posdir 1) cdr car) vnote-lo-hi)))
 (grob-interpret-markup grob (markup #:translate (cons 
((if (positive? hdir) - +) hvernier) (- vnote (* vdir vshift)))
   #:combine #:draw-line (cons htip vO) #:combine 
#:translate (cons hO (if closed? (* vdir (+ vsize vsize+)) vO))
 #:draw-line (cons htip vO)
#:translate (cons (if (positive? hdir) htip hO) vO)
 #:draw-line (cons hO (* vdir (+ vsize vsize+)
;% alist of props for misusing Arpeggio as a thumb bracket
`((stencil . ,bracket) 
  (X-extent . ,h-interval) 
  (padding . ,((if hcloser? - +) hpad-base hcloser)) 
  (direction . ,hdir) 
  (thickness . ,(get 'weight)))

thumbBracketEx = #(define-music-function 
  (spec settings) (string? list?)
 (let* (
   (props (make-thumb-bracket-props (*location*) spec settings)))
   (define (get key) (assq-ref props key))
  (if (null? props) #{ #} ;% abort without bracket
   #{
 \once \override Arpeggio.stencil   = #(get 'stencil)
 \once \override Arpeggio.X-extent  = #(get 'X-extent)
 \once \override Arpeggio.padding   = #(get 'padding)
 \once \override Arpeggio.direction = #(get 'direction) 
 \once \override Arpeggio.thickness = #(get 'thickness)
 $(make-music 'EventChord 'elements (list (make-music 'ArpeggioEvent)))
   #})))

thumbBracket = #(define-music-function (spec) (string?)
 (let ((settings thumbBracketSettings)) ;% as Defaults, or user defined
#{ \thumbBracketEx $spec $settings #}))

thumbBracketDefaults = #(quasiquote( 
  (hdir-init . ,LEFT) ;% usual placement wrt note: on RIGHT or LEFT
  (weight. 1.5  ) ;% line thickness
  (htip  . 0.8  ) ;% horizontal length of bracket tip
  (vtip  . 0.75 ) ;% usual vertical overlap beyond notehead centre 
  (vtip= . 0.30 ) ;% alternative vertical overlap 
  (vstem . 1.25 ) ;% length of an unextended open bracket (excl. tip)
  (vmin  . 0.6  ) ;% minimum length of a closed bracket
  (hvernier  . 0.2  ) ;% horizontal quasi-extra-offset
  ))