[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: parentheses for dynamics
From: |
Nicolas Sceaux |
Subject: |
Re: parentheses for dynamics |
Date: |
Sun, 29 Aug 2004 16:06:53 +0200 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
Nicolas Sceaux <address@hidden> writes:
> Han-Wen Nienhuys <address@hidden> writes:
>
> [answers to questions]
>
> Thank you!
> I can go on.
Here is a second try. The parenthesization(!?) is naive, thus the
result is not terrific.
\version "2.3.13"
parenthesize=#(def-music-function (location grob-type music) (symbol? ly:music?)
"Add parentheses around the grobs of type `grob-type' in
`music'."
(define (parenthesize-print-function print-function)
(lambda (grob)
(let* ((subject (print-function grob))
(subject-dim-x (ly:stencil-extent subject 0))
(subject-dim-y (ly:stencil-extent subject 1)))
(set! (ly:grob-property grob 'font-encoding) 'fetaMusic)
(let* ((fn (ly:get-default-font grob))
(pclose (ly:find-glyph-by-name fn
"accidentals-rightparen"))
(popen (ly:find-glyph-by-name fn
"accidentals-leftparen")))
;; add parens
(set! subject
(ly:stencil-combine-at-edge
(ly:stencil-combine-at-edge subject 0 1 pclose 0.2)
0 -1 popen 0.2))
;; revert old size.
(ly:stencil-set-extent! subject 0 subject-dim-x)
(ly:stencil-set-extent! subject 1 subject-dim-y)
subject))))
(make-sequential-music
(list (make-music 'ApplyContext
'procedure (lambda (context)
(let ((print-function (cdr
(assoc 'print-function (ly:context-grob-definition context grob-type)))))
(ly:context-pushpop-property
context grob-type 'print-function (parenthesize-print-function
print-function)))))
music
(make-music 'ApplyContext
'procedure (lambda (context)
(ly:context-pushpop-property context
grob-type 'print-function))))))
\paper { raggedright = ##t }
\relative c' {
\context Voice
\parenthesize #'NoteHead { c^"NoteHead" d } e f
\parenthesize #'DynamicText { c^"DynamicText"\mp d } e\mp f
}
nicolas