]> git.donarmstrong.com Git - lilypond.git/blob - scm/output-lib.scm
Merge branch 'master' of ssh+git://hanwen@git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / scm / output-lib.scm
1 ;;;; output-lib.scm -- implement Scheme output helper functions
2 ;;;;
3 ;;;;  source file of the GNU LilyPond music typesetter
4 ;;;; 
5 ;;;; (c) 1998--2006 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;;; Han-Wen Nienhuys <hanwen@xs4all.nl>
7
8
9
10
11 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12 ;; general
13 (define-public (grob::has-interface grob iface)
14   (memq iface (ly:grob-interfaces grob)))
15
16 (define-public (make-stencil-boxer thickness padding callback)
17
18   "Return function that adds a box around the grob passed as argument."
19   (lambda (grob)
20     
21     (box-stencil (callback grob) thickness padding)))
22
23 (define-public (make-stencil-circler thickness padding callback)
24   "Return function that adds a circle around the grob passed as argument."
25   
26   (lambda (grob) (circle-stencil (callback grob) thickness padding)))
27
28 (define-public (print-circled-text-callback grob)
29   (let* ((text (ly:grob-property grob 'text))
30          
31          (layout (ly:grob-layout grob))
32          (defs (ly:output-def-lookup layout 'text-font-defaults))
33          (props (ly:grob-alist-chain grob defs))
34          (circle (ly:text-interface::interpret-markup
35                   layout props (make-circle-markup text))))
36     circle))
37
38 (define-public (music-cause grob)
39   (let*
40       ((event (event-cause grob)))
41
42     (if (ly:stream-event? event)
43         (ly:event-property event 'music-cause)
44         #f)))
45
46 (define-public (event-cause grob)
47   (let*
48       ((cause (ly:grob-property  grob 'cause)))
49     
50     (cond
51      ((ly:stream-event? cause) cause)
52      ((ly:grob? cause) (event-cause cause))
53      (else #f))))
54
55 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
56 ;; tablature
57
58 ;; The TabNoteHead tablatureFormat callback.
59 ;; Compute the text grob-property
60 (define-public (fret-number-tablature-format string
61                                              context event)
62   (let*
63       ((tuning (ly:context-property context 'stringTunings))
64        (pitch (ly:event-property event 'pitch))
65        (is-harmonic (apply
66                      functional-or
67                      (map
68                       (lambda (ev)
69                         (eq? 'harmonic-event (ly:event-property ev 'class)))
70                       (ly:event-property event 'articulations)))))
71
72     
73     (make-whiteout-markup
74      (make-vcenter-markup
75       (format
76        "~a"
77        (- (ly:pitch-semitones pitch)
78           (list-ref tuning
79                     ;; remove 1 because list index starts at 0 and guitar string at 1. 
80                     (- string 1))))))
81     ))
82
83 ;; The 5-string banjo has got a extra string, the fifth (duh), wich
84 ;; starts at the fifth fret on the neck. Frets on the fifth string
85 ;; are referred to relative to the other frets:
86 ;;   the "first fret" on the fifth string is really the sixth fret
87 ;;   on the banjo neck.
88 ;; We solve this by defining a new fret-number-tablature function:
89 (define-public (fret-number-tablature-format-banjo string 
90                                              context event)
91   (let*
92       ((tuning (ly:context-property context 'stringTunings))
93        (pitch (ly:event-property event 'pitch))
94         )
95   (make-whiteout-markup
96    (make-vcenter-markup  
97     (let ((fret (- (ly:pitch-semitones pitch) (list-ref tuning (- string 1)))))
98       (number->string (cond
99                        ((and (> fret 0) (= string 5))
100                         (+ fret 5))
101                        (else fret))))))
102   ))
103
104
105 ; default tunings for common string instruments
106 (define-public guitar-tuning '(4 -1 -5 -10 -15 -20))
107 (define-public guitar-open-g-tuning '(2 -1 -5 -10 -17 -22))
108 (define-public bass-tuning '(-17 -22 -27 -32))
109 (define-public mandolin-tuning '(16 9 2 -5))
110
111 ;; tunings for 5-string banjo
112 (define-public banjo-open-g-tuning '(2 -1 -5 -10 7))
113 (define-public banjo-c-tuning '(2 -1 -5 -12 7))
114 (define-public banjo-modal-tuning '(2 0 -5 -10 7))
115 (define-public banjo-open-d-tuning '(2 -3 -6 -10 9))
116 (define-public banjo-open-dm-tuning '(2 -3 -6 -10 9))
117 ;; convert 5-string banjo tuning to 4-string by removing the 5th string
118 (define-public (four-string-banjo tuning)
119   (reverse (cdr (reverse tuning))))
120
121 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
122 ;; note heads
123
124
125 (define-public (stem::calc-duration-log grob)
126   (ly:duration-log
127    (ly:event-property (event-cause grob) 'duration)))
128
129 (define-public (note-head::calc-duration-log grob)
130   (min 2 
131        (ly:duration-log
132         (ly:event-property (event-cause grob) 'duration))))
133
134 (define-public (dots::calc-dot-count grob)
135   (ly:duration-dot-count
136    (ly:event-property (event-cause grob) 'duration)))
137
138 (define (note-head::calc-tablature-stem-attachment grob)
139   (cons 0.0 1.35))
140
141
142
143 ;; silly, use alist? 
144 (define-public (note-head::calc-glyph-name grob)
145   (let*
146       ((style (ly:grob-property grob 'style))
147        (log (min 2 (ly:grob-property grob 'duration-log))))
148     
149     (case style
150       ;; "default" style is directly handled in note-head.cc as a
151       ;; special case (HW says, mainly for performance reasons).
152       ;; Therefore, style "default" does not appear in this case
153       ;; statement.  -- jr
154       ((xcircle) "2xcircle")
155       ((harmonic) "0harmonic")
156       ((baroque) 
157        ;; Oops, I actually would not call this "baroque", but, for
158        ;; backwards compatibility to 1.4, this is supposed to take
159        ;; brevis, longa and maxima from the neo-mensural font and all
160        ;; other note heads from the default font.  -- jr
161        (if (< log 0)
162            (string-append (number->string log) "neomensural")
163            (number->string log)))
164       ((mensural)
165        (string-append (number->string log) (symbol->string style)))
166       ((petrucci)
167        (if (< log 0)
168            (string-append (number->string log) "mensural")
169            (string-append (number->string log) (symbol->string style))))
170       ((neomensural)
171        (string-append (number->string log) (symbol->string style)))
172       (else
173        (if (string-match "vaticana*|hufnagel*|medicaea*" (symbol->string style))
174            (symbol->string style)
175            (string-append (number->string (max 0 log))
176                           (symbol->string style)))))))
177
178 ;; TODO junk completely?
179 (define (note-head-style->attachment-coordinates grob axis)
180   "Return pair (X . Y), containing multipliers for the note head
181 bounding box, where to attach the stem. e.g.: X==0 means horizontally
182 centered, X==1 is at the right, X == -1 is at the left."
183
184   '(1.0 . 0.0))
185
186
187 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
188 ;; bar numbers
189
190 (define-public ((every-nth-bar-number-visible n) barnum) (= 0 (modulo barnum n)))
191
192 (define-public ((modulo-bar-number-visible n m) barnum) (and (> barnum 1) (= m (modulo barnum n))))
193
194 (define-public ((set-bar-number-visibility n) tr)
195   (let* ((bn (ly:context-property tr 'currentBarNumber)))
196     (ly:context-set-property! tr 'barNumberVisibility (modulo-bar-number-visible n (modulo bn n)))))
197
198 (define-public (first-bar-number-invisible barnum) (> barnum 1))
199
200 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
201 ;; break visibility
202
203 (define-public begin-of-line-visible
204   #(#f #f #t))
205 (define-public end-of-line-visible
206   #(#t #f #f))
207 (define-public end-of-line-invisible
208   #(#f #t #t))
209 (define-public spanbar-begin-of-line-invisible
210   #(#t #f #f))
211 (define-public all-visible #(#t #t #t))
212 (define-public all-invisible #(#f #f #f))
213 (define-public begin-of-line-invisible
214   #(#t #t #f))
215 (define-public center-invisible #(#t #f #t))
216
217 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
218 ;; Bar lines.
219
220 ;;
221 ;; How should a  bar line behave at a break? 
222 ;;
223 ;; Why prepend `default-' to every scm identifier?
224 (define-public (bar-line::calc-glyph-name grob)
225   (let* (
226          (glyph (ly:grob-property grob 'glyph))
227          (dir (ly:item-break-dir grob))
228          (result (assoc glyph 
229                        '((":|:" . (":|" . "|:"))
230                          ("||:" . ("||" . "|:"))
231                          ("dashed" . ("dashed" . '())) 
232                          ("|" . ("|" . ()))
233                          ("||:" . ("||" . "|:"))
234                          ("|s" . (() . "|"))
235                          ("|:" . ("|" . "|:"))
236                          ("|." . ("|." . ()))
237
238                          ;; hmm... should we end with a bar line here?
239                          (".|" . ("|" . ".|"))
240                          (":|" . (":|" . ()))
241                          ("||" . ("||" . ()))
242                          (".|." . (".|." . ()))
243                          ("" . ("" . ""))
244                          (":" . (":" . ""))
245                          ("." . ("." . ()))
246                          ("empty" . (() . ()))
247                          ("brace" . (() . "brace"))
248                          ("bracket" . (() . "bracket"))  )))
249          (glyph-name (if (= dir CENTER)
250                          glyph
251                          (if (and result (string? (index-cell (cdr result) dir)))
252                              (index-cell (cdr result) dir)
253                              #f)))
254          )
255
256     (if (not glyph-name)
257         (ly:grob-suicide! grob))
258
259     glyph-name))
260
261
262 (define-public (shift-right-at-line-begin g)
263   "Shift an item to the right, but only at the start of the line."
264   (if (and (ly:item? g)
265            (equal? (ly:item-break-dir g) RIGHT))
266       (ly:grob-translate-axis! g 3.5 X)))
267
268
269 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
270 ;; Tuplets
271
272 (define-public (tuplet-number::calc-denominator-text grob)
273   (number->string (ly:event-property (event-cause grob) 'denominator)))
274
275 (define-public (tuplet-number::calc-fraction-text grob)
276   (let*
277       ((ev (event-cause grob)))
278
279     (format "~a:~a" 
280             (ly:event-property ev 'denominator)
281             (ly:event-property ev 'numerator))))
282
283 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
284 ;; Color
285
286 (define-public color? list?)
287
288 ; predefined colors
289 (define-public black       '(0.0 0.0 0.0))
290 (define-public white       '(1.0 1.0 1.0))
291 (define-public red         '(1.0 0.0 0.0))
292 (define-public green       '(0.0 1.0 0.0))
293 (define-public blue        '(0.0 0.0 1.0))
294 (define-public cyan        '(0.0 1.0 1.0))
295 (define-public magenta     '(1.0 0.0 1.0))
296 (define-public yellow      '(1.0 1.0 0.0))
297
298 (define-public grey        '(0.5 0.5 0.5))
299 (define-public darkred     '(0.5 0.0 0.0))
300 (define-public darkgreen   '(0.0 0.5 0.0))
301 (define-public darkblue    '(0.0 0.0 0.5))
302 (define-public darkcyan    '(0.0 0.5 0.5))
303 (define-public darkmagenta '(0.5 0.0 0.5))
304 (define-public darkyellow  '(0.5 0.5 0.0))
305
306 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
307 ;; key signature
308
309
310 (define-public (key-signature-interface::alteration-position step alter c0-position)
311   ;; TODO: memoize - this is mostly constant.
312   
313   ;; fes, ges, as and bes typeset in lower octave
314   (define FLAT_TOP_PITCH 2)
315   
316   ;; ais and bis typeset in lower octave
317   (define SHARP_TOP_PITCH 4)
318
319   (if (pair? step)
320       (+ (cdr step) (* (car step) 7)  c0-position)
321       (let*
322           ((from-bottom-pos (modulo (+ 4 49 c0-position)  7))
323            (p step)
324            (c0 (- from-bottom-pos  4)))
325         
326         (if
327          (or (and (< alter 0) (or (> p FLAT_TOP_PITCH) (> (+ p c0) 4)) (> (+ p c0) 1))
328              (and (> alter 0) (or (> p SHARP_TOP_PITCH) (> (+ p c0) 5)) (> (+ p c0) 2))
329              )
330
331          ;; Typeset below c_position 
332          (set! p (- p 7)))
333
334         ;; Provide for the four cases in which there's a glitch
335         ;; it's a hack, but probably not worth
336         ;; the effort of finding a nicer solution.
337         ;; --dl. 
338         (cond
339          ((and (= c0 2) (= p 3) (> alter 0))
340           (set! p (- p 7)))
341          ((and (= c0 -3) (= p -1) (> alter 0))
342           (set! p (+ p 7)))
343          ((and (= c0 -4) (= p -1) (< alter 0))
344           (set! p (+ p 7)))
345          ((and (= c0 -2) (= p -3) (< alter 0))
346           (set! p (+ p 7))))
347
348         (+ c0 p))))
349
350
351 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
352 ;; accidentals
353
354 (define-public (accidental-interface::calc-alteration grob)
355   (ly:pitch-alteration  (ly:event-property (event-cause grob) 'pitch)))
356
357
358 (define-public cancellation-glyph-name-alist
359   '((0 . "accidentals.natural")))
360
361 (define-public standard-alteration-glyph-name-alist
362      '(
363        ;; ordered for optimal performance.
364        (0 . "accidentals.natural")
365        (-1/2 . "accidentals.flat")
366        (1/2 . "accidentals.sharp")
367
368        (1 . "accidentals.doublesharp")
369        (-1 . "accidentals.flatflat")
370        
371        (3/4 . "accidentals.sharp.slashslash.stemstemstem")
372        (1/4 . "accidentals.sharp.slashslash.stem")
373        (-1/4 . "accidentals.mirroredflat")
374        (-3/4 . "accidentals.mirroredflat.flat")
375        ))
376
377 (define-public makam-alteration-glyph-name-alist
378      '((1 . "accidentals.doublesharp")
379        (8/9 . "accidentals.sharp.slashslashslash.stemstem")
380        (5/9 . "accidentals.sharp.slashslashslash.stem")
381        (4/9 . "accidentals.sharp")
382        (1/9 . "accidentals.sharp.slashslash.stem")
383        (0 . "accidentals.natural")
384        (-1/9 . "accidentals.mirroredflat")
385        (-4/9 . "accidentals.flat.slash")
386        (-5/9 . "accidentals.flat")
387        (-8/9 . "accidentals.flat.slashslash")
388        (-1 . "accidentals.flatflat")
389        ))
390   
391 (define-public alteration-hufnagel-glyph-name-alist
392    '((1/2 . "accidentals.hufnagel-1")
393      (0 . "accidentals.vaticana0")
394      (-1/2 . "accidentals.mensural1")))
395
396 (define-public alteration-medicae-glyph-name-alist
397    '((1/2 . "accidentals.medicaea-1")
398      (0 . "accidentals.vaticana0")
399      (-1/2 . "accidentals.mensural1")))
400
401 (define-public alteration-vaticana-glyph-name-alist
402    '((1/2 . "accidentals.vaticana-1")
403      (0 . "accidentals.vaticana0")
404      (-1/2 . "accidentals.mensural1")))
405
406 (define-public alteration-mensural-glyph-name-alist
407    '((1/2 . "accidentals.mensural-1")
408      (0 . "accidentals.vaticana0")
409      (-1/2 . "accidentals.mensural1")))
410
411
412 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
413 ;; * Pitch Trill Heads
414 ;; * Parentheses
415
416 (define-public (parentheses-item::calc-parenthesis-stencils grob)
417   (let* ((font (ly:grob-default-font grob))
418          (lp (ly:font-get-glyph font "accidentals.leftparen"))
419          (rp (ly:font-get-glyph font "accidentals.rightparen")))
420
421     (list lp rp)))
422
423
424 (define (grob-text grob text)
425   (let*
426       ((layout (ly:grob-layout grob))
427        (defs (ly:output-def-lookup layout 'text-font-defaults))
428        (props (ly:grob-alist-chain grob defs)))
429
430     (ly:text-interface::interpret-markup
431      layout props text)))
432
433 (define-public (parentheses-item::calc-angled-bracket-stencils grob)
434   (let* (
435          (font (ly:grob-default-font grob))
436          (lp (ly:stencil-aligned-to (ly:stencil-aligned-to (grob-text grob (ly:wide-char->utf-8 #x2329))
437                                                            Y CENTER)  X RIGHT))
438          (rp (ly:stencil-aligned-to (ly:stencil-aligned-to (grob-text grob (ly:wide-char->utf-8 #x232A))
439                                                            Y CENTER) X LEFT))
440          )
441
442     (list (stencil-whiteout lp)
443           (stencil-whiteout rp))))
444
445 (define (parenthesize-elements grob . rest)
446   (let*
447       ((refp (if (null? rest)
448                  grob
449                  (car rest)))
450        (elts (ly:grob-object grob 'elements))
451        (x-ext (ly:relative-group-extent elts refp X))
452        (stencils (ly:grob-property grob 'stencils))
453        (lp (car stencils))
454        (rp (cadr stencils))
455        (padding (ly:grob-property grob 'padding 0.1)))
456     
457     (ly:stencil-add
458      (ly:stencil-translate-axis lp (- (car x-ext) padding) X)
459      (ly:stencil-translate-axis rp (+ (cdr x-ext) padding) X))
460   ))
461
462
463 (define (parentheses-item::print me)
464   (let*
465       ((elts (ly:grob-object me 'elements))
466        (y-ref (ly:grob-common-refpoint-of-array me elts Y))
467        (x-ref (ly:grob-common-refpoint-of-array me elts X))
468        (stencil (parenthesize-elements me x-ref))
469        (elt-y-ext  (ly:relative-group-extent elts y-ref Y))
470        (y-center (interval-center elt-y-ext)))
471
472     (ly:stencil-translate
473      stencil
474      (cons
475       (-
476        (ly:grob-relative-coordinate me x-ref X))
477       (-
478        y-center
479        (ly:grob-relative-coordinate me y-ref Y))))
480     ))
481
482
483
484 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
485 ;; 
486
487 (define-public (chain-grob-member-functions grob value . funcs)
488   (for-each
489    (lambda (func)
490      (set! value (func grob value)))
491    funcs)
492
493   value)
494
495 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
496 ;; falls/doits
497
498 (define-public (bend::print spanner)
499   (define (close  a b)
500     (< (abs (- a b)) 0.01))
501   
502   (let*
503       ((delta-y (* 0.5 (ly:grob-property spanner 'delta-position)))
504        (left-span (ly:spanner-bound spanner LEFT))
505        (dots (if (and (grob::has-interface left-span 'note-head-interface)
506                       (ly:grob? (ly:grob-object left-span 'dot)))
507                  (ly:grob-object left-span 'dot) #f))
508                  
509        (right-span (ly:spanner-bound spanner RIGHT))
510        (thickness (* (ly:grob-property spanner 'thickness)
511                      (ly:output-def-lookup (ly:grob-layout spanner)
512                                            'line-thickness)))
513        (padding (ly:grob-property spanner 'padding 0.5))
514        (common (ly:grob-common-refpoint right-span
515                                         (ly:grob-common-refpoint spanner
516                                                                  left-span X)
517                                         X))
518        (common-y (ly:grob-common-refpoint spanner left-span Y))
519        (left-x (+ padding
520                   (max (interval-end (ly:grob-robust-relative-extent
521                                       left-span common X))
522                         (if (and
523                              dots
524                              (close (ly:grob-relative-coordinate dots common-y Y)
525                                         (ly:grob-relative-coordinate spanner common-y Y)))
526                             (interval-end (ly:grob-robust-relative-extent dots common X))
527                             -10000) ;; TODO: use real infinity constant.
528                         )))
529        (right-x (- (interval-start
530                     (ly:grob-robust-relative-extent right-span common X))
531                    padding))
532        (self-x (ly:grob-relative-coordinate spanner common X))
533        (dx (- right-x left-x))
534        (exp (list 'path thickness 
535                   `(quote
536                     (rmoveto
537                      ,(- left-x self-x) 0
538
539                      rcurveto                
540                      ,(/ dx 3)
541                      0
542                      ,dx ,(* 0.66 delta-y)
543                      ,dx ,delta-y
544                      )))))
545
546     (ly:make-stencil
547      exp
548      (cons (- left-x self-x) (- right-x self-x))
549      (cons (min 0 delta-y)
550            (max 0 delta-y)))))
551
552 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
553 ;; grace spacing
554
555
556 (define-public (grace-spacing::calc-shortest-duration grob)
557   (let*
558      ((cols (ly:grob-object grob 'columns))
559       (get-difference
560        (lambda (idx)
561          (ly:moment-sub (ly:grob-property
562                          (ly:grob-array-ref cols (1+ idx)) 'when)
563                         (ly:grob-property
564                          (ly:grob-array-ref cols idx) 'when))))
565       
566       (moment-min (lambda (x y)
567                     (cond
568                      ((and x y)
569                       (if (ly:moment<? x y)
570                             x
571                             y))
572                      (x x)
573                      (y y)))))
574                      
575     (fold moment-min #f (map get-difference
576                              (iota (1- (ly:grob-array-length cols)))))))
577
578
579
580 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
581 ;; fingering
582
583 (define-public (fingering::calc-text grob)
584   (let*
585       ((event (event-cause grob))
586        (digit (ly:event-property event 'digit)))
587     
588     (if (> digit 5)
589         (ly:input-message (ly:event-property event 'origin)
590                           "Warning: Fingering notation for finger number ~a" digit))
591
592     (number->string digit 10)
593   ))
594
595 (define-public (string-number::calc-text grob)
596   (let*
597       ((digit (ly:event-property (event-cause  grob) 'string-number)))
598     
599     (number->string digit 10)
600   ))
601
602
603 (define-public (stroke-finger::calc-text grob)
604   (let*
605       ((digit (ly:event-property (event-cause grob) 'digit))
606        (text (ly:event-property (event-cause grob) 'text)))
607
608     (if (string? text)
609         text
610         (vector-ref (ly:grob-property grob 'digit-names)  (1- (max (min 5 digit) 1))))))
611
612 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
613 ;; dynamics
614 (define-public (hairpin::calc-grow-direction grob)
615   (if (eq? (ly:event-property (event-cause grob) 'class) 'decrescendo-event)
616       START
617       STOP
618       ))
619
620 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
621 ;; lyrics
622
623 (define-public (lyric-text::print grob)
624   "Allow interpretation of tildes as lyric tieing marks."
625   
626   (let*
627       ((text (ly:grob-property grob 'text))
628        (layout (ly:grob-layout grob))
629        (defs (ly:output-def-lookup layout 'text-font-defaults))
630        (props (ly:grob-alist-chain grob defs)))
631
632     (ly:text-interface::interpret-markup layout
633                                          props
634                                          (if (string? text)
635                                              (make-tied-lyric-markup text)
636                                              text))))
637
638 (define-public ((grob::calc-property-by-copy prop) grob)
639   (ly:event-property (event-cause grob) prop))
640
641 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
642 ;; fret boards
643
644 (define (string-frets->description string-frets string-count)
645   (let*
646       ((desc (list->vector
647               (map (lambda (x) (list 'mute  (1+ x)))
648                    (iota string-count)))))
649        
650        (for-each (lambda (sf)
651                    (let*
652                        ((string (car sf))
653                         (fret (cadr sf))
654                         (finger (caddr sf)))
655
656                      
657                      (vector-set! desc (1- string)
658                                   (if (= 0 fret)
659                                       (list 'open string)
660                                       (if finger
661                                           (list 'place-fret string fret finger) 
662                                           (list 'place-fret string fret))
663                                           
664
665                                       ))
666                      ))
667                  string-frets)
668
669        (vector->list desc)))
670
671 (define-public (fret-board::calc-stencil grob)
672   (let* ((string-frets (ly:grob-property grob 'string-fret-finger-combinations))
673          (string-count (ly:grob-property grob 'string-count))
674          (layout (ly:grob-layout grob))
675          (defs (ly:output-def-lookup layout 'text-font-defaults))
676          (props (ly:grob-alist-chain grob defs)))
677
678     (make-fret-diagram layout props
679                        (string-frets->description string-frets 6))))