]> git.donarmstrong.com Git - lilypond.git/commitdiff
Create general facility for changing styles of note heads
authorCarl Sorensen <c_sorensen@byu.edu>
Fri, 7 Aug 2009 13:37:57 +0000 (07:37 -0600)
committerCarl Sorensen <c_sorensen@byu.edu>
Fri, 7 Aug 2009 13:40:44 +0000 (07:40 -0600)
styledNoteHeads music function allows the changing of note heads
both inside and outside of chord construct with the same syntax.

Redo deadNotes and palmMute for tablature to use the styledNoteHeads
infrastructure.

input/regression/palm-mute.ly
ly/music-functions-init.ly
ly/property-init.ly
scm/c++.scm
scm/music-functions.scm

index 33123f3f8e8c176d95d85d27662d25d2d2829066..ac730f1fac423b7663897206149d1833f1f3b25a 100644 (file)
@@ -1,8 +1,10 @@
 \version "2.13.4"
 
-\header{ texidoc = "The palm mute technique for stringed instruments
-                    is supported by triangle-shaped note heads."
-       }
+\header{
+  texidoc =
+"The palm mute technique for stringed instruments
+is supported by triangle-shaped note heads."
+}
 
 palmmute = \relative c, {
     \time 4/4
index 3f3bdca54dd9632a539b27e18d24be757d39747d..26f0e68fe4962104feede7a9bf0ebe12a4c6b16d 100644 (file)
@@ -731,6 +731,12 @@ the `parameters' assoc list.")
                (cons 'system-Y-extent (cdr (assoc 'system-Y-extent parameters))))
    #})
 
+styledNoteHeads =
+#(define-music-function
+   (parser location style heads music)
+   (symbol? list-or-symbol? ly:music?)
+   (_i "Set @var{heads} in @var{music} to @var{style}.")
+   (style-note-heads heads style music))
 
 rightHandFinger =
 #(define-music-function (parser location finger) (number-or-string?)
index f91c4b8d85dd760af497e4c99e95d66a71466b67..8759c7dad765eb61181a3db556a7d933b214cb6c 100644 (file)
@@ -3,7 +3,7 @@
 \version "2.12.0"
 
 stemUp = \override Stem #'direction = #UP
-stemDown = \override Stem #'direction = #DOWN 
+stemDown = \override Stem #'direction = #DOWN
 stemNeutral = \revert Stem #'direction
 
 slurUp = \override Slur #'direction = #UP
@@ -16,7 +16,7 @@ slurNeutral = \revert Slur #'direction
 slurDashed = {
   \override Slur #'dash-definition =  #'((0 1 0.4 0.75))
 }
-slurDashPattern = 
+slurDashPattern =
 #(define-music-function (parser location dash-fraction dash-period)
   (number? number?)
   #{
@@ -46,7 +46,7 @@ phrasingSlurNeutral = \revert PhrasingSlur #'direction
 phrasingSlurDashed = {
   \override PhrasingSlur #'dash-definition =  #'((0 1 0.4 0.75))
 }
-phrasingSlurDashPattern = 
+phrasingSlurDashPattern =
 #(define-music-function (parser location dash-fraction dash-period)
   (number? number?)
   #{
@@ -94,7 +94,7 @@ tieNeutral = \revert Tie #'direction
 tieDashed = {
   \override Tie #'dash-definition = #'((0 1 0.4 0.75))
 }
-tieDashPattern = 
+tieDashPattern =
 #(define-music-function (parser location dash-fraction dash-period)
   (number? number?)
   #{
@@ -164,7 +164,7 @@ cadenzaOff = {
   \set Timing.measurePosition = #ZERO-MOMENT
 }
 
-% dynamic ly:dir?  text script, articulation script ly:dir? 
+% dynamic ly:dir?  text script, articulation script ly:dir?
 oneVoice = #(context-spec-music (make-voice-props-revert) 'Voice)
 voiceOne = #(context-spec-music (make-voice-props-set 0) 'Voice)
 voiceTwo = #(context-spec-music (make-voice-props-set 1) 'Voice)
@@ -279,9 +279,9 @@ defaultTimeSignature = {
 
 
 % For drawing vertical chord brackets with \arpeggio
-% This is a shorthand for the value of the print-function property 
-% of either Staff.Arpeggio or PianoStaff.Arpeggio, depending whether 
-% cross-staff brackets are desired. 
+% This is a shorthand for the value of the print-function property
+% of either Staff.Arpeggio or PianoStaff.Arpeggio, depending whether
+% cross-staff brackets are desired.
 
 arpeggio = #(make-music 'ArpeggioEvent)
 
@@ -320,7 +320,7 @@ arpeggioParenthesisDashed = {
 
 glissando = #(make-music 'GlissandoEvent)
 
-fermataMarkup = \markup { \musicglyph #"scripts.ufermata" } 
+fermataMarkup = \markup { \musicglyph #"scripts.ufermata" }
 
 hideNotes = {
   % hide notes, accidentals, etc.
@@ -405,7 +405,7 @@ bassFigureStaffAlignmentNeutral = {
   \revert Staff.BassFigureAlignmentPositioning #'direction
 }
 
-predefinedFretboardsOff = {  
+predefinedFretboardsOff = {
   \set FretBoards.predefinedDiagramTable = ##f
 }
 
@@ -422,53 +422,28 @@ pointAndClickOn = #(define-music-function (parser location) ()
                       (make-music 'SequentialMusic 'void #t))
 
 palmMuteOn = {
-  \override NoteHead #'style = #'do
+ #(override-head-style 'NoteHead 'do)
 }
 
 palmMuteOff = {
-  \revert NoteHead #'style
+ #(revert-head-style 'NoteHead)
 }
 
 palmMute =
 #(define-music-function (parser location note) (ly:music?)
-  ;; are we inside a <...>?
-  (if (eq? (ly:music-property note 'name) 'NoteEvent)
-      ;; yes -> add a tweak
-      (begin (set! (ly:music-property note 'tweaks)
-                    (acons 'style 'do (ly:music-property note 'tweaks)))
-      note)
-      ;; no -> use predefined commands to switch to triangle-shaped note heads
-      #{
-        \palmMuteOn
-        $note
-        \palmMuteOff
-      #}))
+    (style-note-heads 'NoteHead 'do note))
 
 deadNotesOn = {
-  \override TabNoteHead #'style = #'cross
-  \override NoteHead #'style = #'cross
+  #(override-head-style '(TabNoteHead NoteHead) 'cross)
 }
 
 deadNotesOff = {
-  \revert TabNoteHead #'style
-  \revert NoteHead #'style
+  #(revert-head-style '(TabNoteHead NoteHead))
 }
 
 deadNote =
 #(define-music-function (parser location note) (ly:music?)
-  ;; are we inside a <...>?
-  (if (eq? (ly:music-property note 'name) 'NoteEvent)
-      ;; yes -> add a tweak
-      (begin (set! (ly:music-property note 'tweaks)
-                    (acons 'style 'cross (ly:music-property note 'tweaks)))
-       note)
-       ;; no -> use predefined commmands for changing
-       ;; note head and tablature fret signs
-       #{
-         \deadNotesOn
-         $note
-         \deadNotesOff
-       #}))
+   (style-note-heads '(TabNoteHead NoteHead) 'cross note))
 
 tabFullNotation = {
   % time signature
@@ -481,7 +456,7 @@ tabFullNotation = {
   \revert TabVoice.Tie #'stencil
   \revert TabVoice.Tie #'after-line-breaking
   \revert TabVoice.RepeatTie #'stencil
-  \revert TabVoice.RepeatTie #'after-line-braking
+  \revert TabVoice.RepeatTie #'after-line-breaking
   \revert TabVoice.LaissezVibrerTie #'stencil
   \revert TabVoice.Slur #'stencil
   \revert PhrasingSlur #'stencil
index 8db8bb96c079185d54da0b887180e0545a094227..3381a9e898888fdff0433bd1385031e0d9a46fd7 100644 (file)
 (define-public (string-or-pair? x)
   (or (string? x) (pair? x)))
 
+(define-public (cheap-list? x)
+  (or (pair? x) (null? x)))
+
+(define-public (list-or-symbol? x)
+  (or (cheap-list? x) (symbol? x)))
+
 (define-public (scheme? x) #t)
 
 
index b5dd3bb3921186c61f830156e68a9f437f48cd76..b3d58db60a916f7753fa9f2ee9542ed5da0824a8 100644 (file)
@@ -563,7 +563,42 @@ included in .ly file."
   (make-music type
              'span-direction span-dir))
 
-(define-public (set-mus-properties! m alist)
+(define-public (override-head-style heads style)
+  "Override style for @var{heads} to @var{style}."
+  (make-sequential-music
+    (if (pair? heads)
+        (map (lambda (h)
+              (make-grob-property-override h 'style style))
+         heads)
+        (list (make-grob-property-override heads 'style style)))))
+
+(define-public (revert-head-style heads)
+  "Revert style for @var{heads}."
+  (make-sequential-music
+    (if (pair? heads)
+        (map (lambda (h)
+              (make-grob-property-revert h 'style))
+         heads)
+        (list (make-grob-property-revert heads 'style)))))
+
+(define-public (style-note-heads heads style music)
+ "Set @var{style} for all @var{heads} in @var{music}.  Works both
+inside of and outside of chord construct."
+  ;; are we inside a <...>?
+  (if (eq? (ly:music-property music 'name) 'NoteEvent)
+      ;; yes -> use a tweak
+      (begin
+        (set! (ly:music-property music 'tweaks)
+              (acons 'style style (ly:music-property music 'tweaks)))
+        music)
+      ;; not in <...>, so use overrides
+      (make-sequential-music
+        (list
+          (override-head-style heads style)
+          music
+          (revert-head-style heads)))))
+
+ (define-public (set-mus-properties! m alist)
   "Set all of ALIST as properties of M."
   (if (pair? alist)
       (begin