From: Valentin Villenave Date: Sun, 28 Sep 2008 10:26:11 +0000 (+0200) Subject: New 'teaching accidental style (Issue #429) X-Git-Tag: release/2.11.61-1~42 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=d7ceaf3abf837e62adb4ae415745b9005f7e8d3c;p=lilypond.git New 'teaching accidental style (Issue #429) 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. --- diff --git a/Documentation/user/pitches.itely b/Documentation/user/pitches.itely index 8a6f20d540..5fb2b29083 100644 --- a/Documentation/user/pitches.itely +++ b/Documentation/user/pitches.itely @@ -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 8 f bis4 | + cis2. 4 | + } + \\ + \relative c' { + ais'2 cis, | + fis8 b a4 cis2 | + } + >> +} + +musicB = { + \clef bass + \new Voice { + \voiceTwo \relative c' { + 4 + \change Staff = up + cis' + \change Staff = down + + \change Staff = up + dis' | + \change Staff = down + 4 gis 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 diff --git a/input/regression/accidental-contemporary.ly b/input/regression/accidental-contemporary.ly index 926c9ffc62..d92ecacf26 100644 --- a/input/regression/accidental-contemporary.ly +++ b/input/regression/accidental-contemporary.ly @@ -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 } } diff --git a/scm/music-functions.scm b/scm/music-functions.scm index 0344e4bf58..490cafe92c 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -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.