]> git.donarmstrong.com Git - lilypond.git/commitdiff
New 'teaching accidental style (Issue #429)
authorValentin Villenave <valentin@villenave.net>
Sun, 28 Sep 2008 10:26:11 +0000 (12:26 +0200)
committerValentin Villenave <valentin@villenave.net>
Sun, 28 Sep 2008 10:26:11 +0000 (12:26 +0200)
This commit adds a new accidental style, as requested in
Issue #429.
Quoting the feature request:
"The teaching style would print cautionary accidentals for
all flat or sharp tones specified by the key signature."

A new teaching-accidental-rule has been added, based on Rune's
neo-modern rule.  Docs and regtests have been updated as well.

Documentation/user/pitches.itely
input/regression/accidental-contemporary.ly
scm/music-functions.scm

index 8a6f20d5408cfddde9dd5d43d242bdcd64019b37..5fb2b29083bb1ef43f6bf6213b9c14041564aca2 100644 (file)
@@ -1853,6 +1853,68 @@ musicB = {
 @end lilypond
 
 
+@item teaching
+
+@funindex teaching
+@cindex teaching accidental style
+@cindex accidental style, teaching
+
+This rule is intended for students, and makes it easy to create
+scale sheets with automagically created cautionary accidentals.
+Accidentals are printed like with @code{modern}, but cautionary
+accidentals are added for all sharp or flat tones specified by the
+key signature, except if the note is immediately repeated.
+
+@lilypond[quote]
+musicA = {
+  <<
+    \relative c' {
+      cis'8 fis, d'4 <a cis>8 f bis4 |
+      cis2. <c, g'>4 |
+    }
+    \\
+    \relative c' {
+      ais'2 cis, |
+      fis8 b a4 cis2 |
+    }
+  >>
+}
+
+musicB = {
+  \clef bass
+  \new Voice {
+    \voiceTwo \relative c' {
+      <fis, a cis>4
+      \change Staff = up
+      cis'
+      \change Staff = down
+      <fis, a>
+      \change Staff = up
+      dis' |
+      \change Staff = down
+      <fis, a cis>4 gis <f a d>2 |
+    }
+  }
+}
+
+\new PianoStaff {
+  <<
+    \context Staff = "up" {
+      \key fis \minor
+      #(set-accidental-style 'teaching)
+      \musicA
+    }
+    \context Staff = "down" {
+      \key fis \minor
+      #(set-accidental-style 'teaching)
+      \musicB
+    }
+  >>
+}
+@end lilypond
+
+
+
 @item no-reset
 
 @funindex no-reset
index 926c9ffc62328acf348ebaed52a5fdf4b1803b1a..d92ecacf269bf4d39e87c85ddffc9c486b2e9cd6 100644 (file)
@@ -32,6 +32,9 @@ Both scores should show the same accidentals.
     gis8 a gis gis g' gis gis,, a'
     #(set-accidental-style 'neo-modern-cautionary)
     eis fis eis eis g2
+    #(set-accidental-style 'teaching)
+    \key e \major
+    e8 eis fis fis gis2
   }
 }
 
@@ -42,5 +45,7 @@ Both scores should show the same accidentals.
     gis!4 a! g! gisis!
     gis!8 a gis! gis g'! gis! gis,,! a'
     eis! fis! eis? eis g?2
+    \key e \major
+    e8 eis! fis? fis gis?2
   }
 }
index 0344e4bf58fb4599cda7d7a8cf928324ea94fd3f..490cafe92c40c9cc3f3de7ed20b29541353061ea 100644 (file)
@@ -974,6 +974,23 @@ if appropriate.
          (cons #f (not (or (equal? acc key-acc)
                            (and (equal? entrybn barnum) (equal? entrymp measurepos)))))))))
 
+(define-public (teaching-accidental-rule context pitch barnum measurepos)
+  "an accidental rule that typesets a cautionary accidental
+  if it is included in the key signature AND does not directly follow
+  a note on the same staff-line."
+  (let* ((keysig (ly:context-property context 'localKeySignature))
+        (entry (find-pitch-entry keysig pitch #t #t)))
+    (if (equal? #f entry)
+       (cons #f #f)
+       (let* ((global-entry (find-pitch-entry keysig pitch #f #f))
+              (key-acc (if (equal? global-entry #f)
+                           0
+                           (key-entry-alteration global-entry)))
+              (acc (ly:pitch-alteration pitch))
+              (entrymp (key-entry-measure-position entry))
+              (entrybn (key-entry-bar-number entry)))
+         (cons #f (not (or (equal? acc key-acc)
+                           (and (equal? entrybn barnum) (equal? entrymp measurepos)))))))))
 
 (define-public (set-accidentals-properties extra-natural
                                           auto-accs auto-cauts
@@ -1095,6 +1112,15 @@ use GrandStaff as a context. "
                                           ,(make-accidental-rule 'any-octave 0)
                                           ,(make-accidental-rule 'same-octave 1))
                                   pcontext))
+
+      ;; same as modern, but cautionary accidentals are printed for all sharp or flat
+      ;; tones specified by the key signature.  
+       ((equal? style 'teaching)
+       (set-accidentals-properties #f
+                                   `(Staff ,(make-accidental-rule 'same-octave 0))
+                                   `(Staff ,(make-accidental-rule 'same-octave 1)
+                                          ,teaching-accidental-rule)
+                                  context))
       
       ;; do not set localKeySignature when a note alterated differently from
       ;; localKeySignature is found.