]> git.donarmstrong.com Git - lilypond.git/commitdiff
Improving \harmonicBy... functions
authorMarc Hohl <marc@hohlart.de>
Fri, 17 Feb 2012 08:59:58 +0000 (09:59 +0100)
committerDavid Kastrup <dak@gnu.org>
Thu, 1 Mar 2012 20:46:49 +0000 (21:46 +0100)
These functions work now as expected for guitar music.
We have dotted harmonics and mixed harmonic note heads.

ly/music-functions-init.ly

index 3b272121175121e7eec84cbc7af0310155ec1fe0..7adb1b7c788ae98db097585eed68c31382007d8e 100644 (file)
@@ -374,37 +374,43 @@ in the format of @code{all-grob-descriptions}.")
         descriptions)))
 
 harmonicByFret = #(define-music-function (parser location fret music) (number? ly:music?)
-  (_i "Convert @var{music} into harmonics; the resulting notes resemble
-harmonics played on a fretted instrument by touching the strings above @var{fret}.")
-  (let* ((fret (number->string fret))
-         (pitch (fret->pitch fret)))
-        (make-sequential-music
-         (list
-          #{
-            \override TabNoteHead #'stencil = #(tab-note-head::print-custom-fret-label fret)
-          #}
-          (make-harmonic
-            (calc-harmonic-pitch pitch music))
-          #{
-            \revert TabNoteHead #'stencil
-          #}))))
+  (_i "Convert @var{music} into mixed harmonics; the resulting notes resemble
+harmonics played on a fretted instrument by touching the strings at @var{fret}.")
+  #{
+    \set harmonicDots = ##t
+    \override TabNoteHead #'stencil = #(tab-note-head::print-custom-fret-label (number->string fret))
+    \override NoteHead #'Y-extent = #(ly:make-unpure-pure-container ly:grob::stencil-height
+                                       (lambda (grob start end)
+                                               (ly:grob::stencil-height grob)))
+    \override NoteHead #'stencil = #(lambda (grob) (ly:grob-set-property! grob 'style 'harmonic-mixed)
+                                            (ly:note-head::print grob))
+    $(make-harmonic
+       (calc-harmonic-pitch (fret->pitch (number->string fret)) music))
+    \unset harmonicDots
+    \revert TabNoteHead #'stencil
+    \revert NoteHead #'Y-extent
+    \revert NoteHead #'stencil
+  #})
 
 harmonicByRatio = #(define-music-function (parser location ratio music) (number? ly:music?)
-    (_i "Convert @var{music} into harmonics; the resulting notes resemble
-harmonics played on a fretted instrument by touching the strings above the point
+    (_i "Convert @var{music} into mixed harmonics; the resulting notes resemble
+harmonics played on a fretted instrument by touching the strings at the point
 given through @var{ratio}.")
-  (let ((pitch (ratio->pitch ratio))
-        (fret (ratio->fret ratio)))
-       (make-sequential-music
-        (list
-         #{
-           \override TabNoteHead #'stencil = #(tab-note-head::print-custom-fret-label fret)
-         #}
-         (make-harmonic
-           (calc-harmonic-pitch pitch music))
-         #{
-            \revert TabNoteHead #'stencil
-         #}))))
+  #{
+    \set harmonicDots = ##t
+    \override TabNoteHead #'stencil = #(tab-note-head::print-custom-fret-label (ratio->fret ratio))
+    \override NoteHead #'Y-extent = #(ly:make-unpure-pure-container ly:grob::stencil-height
+                                       (lambda (grob start end)
+                                               (ly:grob::stencil-height grob)))
+    \override NoteHead #'stencil = #(lambda (grob) (ly:grob-set-property! grob 'style 'harmonic-mixed)
+                                            (ly:note-head::print grob))
+    $(make-harmonic
+      (calc-harmonic-pitch (ratio->pitch ratio) music))
+    \unset harmonicDots
+    \revert TabNoteHead #'stencil
+    \revert NoteHead #'Y-extent
+    \revert NoteHead #'stencil
+  #})
 
 instrumentSwitch =
 #(define-music-function