]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scm/define-translator-properties.scm
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 18 Feb 2004 11:32:39 +0000 (11:32 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 18 Feb 2004 11:32:39 +0000 (11:32 +0000)
(all-user-translation-properties): add printOctaveNames

* ly/engraver-init.ly: remove Note_event_swallower.

* lily/note-name-engraver.cc (process_music): new property
printOctaveNames

* lily/context.cc (find_existing_context): remove support for
Current.

* scm/music-functions.scm (set-accidental-style): new function;
duplicate accidental macros.

* ly/property-init.ly (hideStaffSwitch): remove accidental macros.

* lily/note-name-engraver.cc (process_music):
process_acknowledged_grobs () -> process_music ()

14 files changed:
ChangeLog
Documentation/user/refman.itely
input/regression/accidental-octave.ly
input/regression/accidental-voice.ly
input/regression/accidentals.ly
lily/context.cc
lily/note-name-engraver.cc
ly/engraver-init.ly
ly/init.ly
ly/property-init.ly
scm/define-translator-properties.scm
scm/lily.scm
scm/music-functions.scm
scripts/convert-ly.py

index 1582689bd309d3156b31b79ca30b30e8dcb0dc42..10940a351dc54cf43ff696a498d16cd143af8502 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
 2004-02-18  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
+       * scm/define-translator-properties.scm
+       (all-user-translation-properties): add printOctaveNames
+
+       * ly/engraver-init.ly: remove Note_event_swallower.
+
+       * lily/note-name-engraver.cc (process_music): new property
+       printOctaveNames
+
+       * lily/context.cc (find_existing_context): remove support for
+       Current.
+
+       * scm/music-functions.scm (set-accidental-style): new function;
+       duplicate accidental macros.
+
+       * ly/property-init.ly (hideStaffSwitch): remove accidental macros.
+
+       * lily/note-name-engraver.cc (process_music):
+       process_acknowledged_grobs () -> process_music ()
+
        * scm/part-combiner.scm (determine-split-list): robustification.
 
 2004-02-17  Han-Wen Nienhuys   <hanwen@xs4all.nl>
@@ -27,8 +46,8 @@
 2004-02-17  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
        * lily/accidental-engraver.cc (process_acknowledged_grobs): use
-       properties from Voice context. This fixes staff-switches during
-       grace contexts.
+       properties from Voice context. This fixes accidental size for
+       staff-switches during grace contexts.
 
        * lily/note-collision.cc (check_meshing_chords): only wipe heads
        if necessary. Else, simply wipe dots.
index ac1b83d0736768e463d7bca24472d086d740ba38..36563253f244ea8f1b3ece026dcbeac6d992d7f2 100644 (file)
@@ -1530,67 +1530,34 @@ inserted automatically before the running notes.
 @node Using the predefined accidental variables
 @subsection Using the predefined accidental variables
 
-The constructs for describing the accidental typesetting rules are
-quite hairy, so non-experts should stick to the variables
-defined in @file{ly/property-init.ly}.
-@cindex @file{property-init.ly}
-
-The variables set properties in the ``@code{Current}'' context (see
-@ref{Context properties}). This means that the variables should
-normally be added right after the creation of the context in which the
-accidental typesetting described by the variable is to take
-effect. For example, if you want to use piano-accidentals in a piano
-staff, then issue @code{\pianoAccidentals} first thing after the
-creation of the piano staff:
+
+Common rules for typesetting macros have been canned in a
+function. This function is called as follows:
+
+@cindex @code{set-accidental-style}
 @example
-\score @{
-    \notes \relative c'' <<
-        \new Staff @{ cis4 d e2 @}
-        \context GrandStaff <<
-            \pianoAccidentals
-            \new Staff @{ cis4 d e2 @}
-            \new Staff @{ es2 c @}
-        >>
-        \new Staff @{ es2 c @}
-    >>
-@}
+  #(set-accidental-style 'modern 'Voice)
 @end example
-@lilypond[raggedright]
-\score {
-    \notes \relative c'' <<
-        \new Staff { cis4 d e2 }
-        \context GrandStaff <<
-            \pianoAccidentals
-            \new Staff { cis4 d e2 }
-            \new Staff { es2 c }
-        >>
-        \new Staff { es2 c }
-    >>
-    \paper {
-        \translator {
-            \StaffContext
-            minimumVerticalExtent = #'(-4.0 . 4.0)
-        }
-    }
-}
-@end lilypond
 
-The variables are:
+The function takes two arguments: a symbol that denotes the style (in
+the example, @code{modern}), and another symbol that denotes the
+context name (in this example, @code{Staff}). If no context name is
+supplied, @code{Staff} is the default.
+
+The following styles are supported:
 @table @code
-@item \defaultAccidentals
-      @cindex @code{\defaultAccidentals}
+@item default
       This is the default typesetting behaviour. It should correspond
       to 18th century common practice: Accidentals are
       remembered to the end of the measure in which they occur and
       only on their own octave.
 
-@item \voiceAccidentals
-      @cindex @code{\voiceAccidentals}
+@item voice
 @c
-      The normal behaviour is to
-remember the accidentals on Staff-level.  This variable, however,
-typesets accidentals individually for each voice.  Apart from that the
-rule is similar to @code{\defaultAccidentals}.
+      The normal behaviour is to remember the accidentals on
+Staff-level.  This variable, however, typesets accidentals
+individually for each voice.  Apart from that, the rule is similar to
+@code{code}.
 
       This leads to some weird and often unwanted results
       because accidentals from one voice do not get cancelled in other
@@ -1603,78 +1570,79 @@ rule is similar to @code{\defaultAccidentals}.
          { c, e }
      >> >>
 @end lilypond
-      Hence you should only use @code{\voiceAccidentals} if the voices
+      Hence you should only use @code{voice} if the voices
 are to be read solely by individual musicians. If the staff is to be
 used by one musician (e.g. a conductor) then you use
-@code{\modernVoiceAccidentals} or @code{\modernVoiceCautionaries}
+@code{modern} or @code{modern-cautionary}
 instead.
 
-@item \modernAccidentals
-      @cindex @code{\modernAccidentals}
+@item modern
+@cindex @code{modern} style accidentals
       This rule  corresponds to the common practice in the 20th
       century.
-      The rule is  more complex than @code{\defaultAccidentals}.
-      You get all the same accidentals, but temporary
-      accidentals also get cancelled in other octaves. Furthermore,
-      in the same octave, they also get cancelled in the following measure:
+      This rule prints the same accidentals as @code{default},  but temporary
+      accidentals also are cancelled in other octaves. Furthermore,
+      in the same octave, they also get cancelled in the following
+      measure:
+
 @lilypond[raggedright,fragment,verbatim]
       \modernAccidentals
       cis' c'' cis'2 | c'' c'
 @end lilypond
 
-@item \modernCautionaries
-      @cindex @code{\modernCautionaries}
-     This rule is similar to @code{\modernAccidentals}, but the
+@item @code{modern-cautionary}
+      @cindex @code{modern-cautionary}
+     This rule is similar to @code{modern}, but the
      ``extra'' accidentals (the ones not typeset by
-     @code{\defaultAccidentals}) are typeset as cautionary accidentals.
+     @code{default}) are typeset as cautionary accidentals.
      They are printed in reduced size or with parentheses:
 @lilypond[raggedright,fragment,verbatim]
-      \modernCautionaries
+      modern-cautionary
       cis' c'' cis'2 | c'' c'
 @end lilypond
 
-      @cindex @code{\modernVoiceAccidentals}
-@item \modernVoiceAccidentals
+      @cindex @code{modern-voice}
+@item modern-voice
 is used for multivoice accidentals to be read both by musicians
 playing one voice and musicians playing all voices.  Accidentals are
 typeset for each voice, but they @emph{are} cancelled across voices in
 the same @internalsref{Staff}.
 
-      @cindex @code{\modernVoiceCautionaries}
-@item \modernVoiceCautionaries
-is the same as @code{\modernVoiceAccidentals}, but with the extra
-accidentals (the ones not typeset by @code{\voiceAccidentals}) typeset
+      @cindex @code{modern-voice-cautionary}
+@item modern-voice-cautionary
+is the same as @code{modern-voice}, but with the extra
+accidentals (the ones not typeset by @code{voice}) typeset
 as cautionaries.  Even though all accidentals typeset by
-@code{\defaultAccidentals} @emph{are} typeset by this variable then
+@code{default} @emph{are} typeset by this variable then
 some of them are typeset as cautionaries.
 
-@item \pianoAccidentals
-      @cindex @code{\pianoAccidentals}
+@item piano
+      @cindex @code{piano} accidentals
       20th century practice for piano notation. Very similar to
-      @code{\modernAccidentals} but accidentals also get cancelled
+      @code{modern} but accidentals also get cancelled
       across the staves in the same @internalsref{GrandStaff} or
       @internalsref{PianoStaff}.
 
-@item \pianoCautionaries
+@item piano-cautionary
       @cindex @code{\pianoCautionaries}
       As @code{\pianoAccidentals} but with the extra accidentals
       typeset as cautionaries.
 
-@item \noResetKey
-      @cindex @code{\noResetKey}
-      Same as @code{\defaultAccidentals} but with accidentals lasting
+@item no-reset
+      @cindex @code{no-reset} accidental style
+      Same as @code{default} but with accidentals lasting
       ``forever'' and not only until the next measure:
 @lilypond[raggedright,fragment,verbatim,relative]
       \noResetKey
       c1 cis cis c
 @end lilypond
 
-@item \forgetAccidentals
-      @cindex @code{\forgetAccidentals}
-      This is sort of the opposite of @code{\noResetKey}: Accidentals
+@item forget
+      This is sort of the opposite of @code{no-reset}: Accidentals
       are not remembered at all---and hence all accidentals are
       typeset relative to the key signature, regardless of what was
       before in the music:
+      
 @lilypond[raggedright,fragment,verbatim,relative]
       \forgetAccidentals
       \key d\major c4 c cis cis d d dis dis
@@ -1719,29 +1687,6 @@ voices in the same staff share accidentals, but staves do not.
 @end table
 
 
-@refcommands
-
-@cindex @code{\defaultAccidentals}
-@code{\defaultAccidentals}, 
-@cindex @code{\voiceAccidentals}
-@code{\voiceAccidentals}, 
-@cindex @code{\modernAccidentals}
-@code{\modernAccidentals}, 
-@cindex @code{\modernCautionaries}
-@code{\modernCautionaries}, 
-@cindex @code{\modernVoiceAccidentals}
-@code{\modernVoiceAccidentals}, 
-@cindex @code{\modernVoiceCautionaries}
-@code{\modernVoiceCautionaries}, 
-@cindex @code{\pianoAccidentals}
-@code{\pianoAccidentals}, 
-@cindex @code{\pianoCautionaries}
-@code{\pianoCautionaries}, 
-@cindex @code{\noResetKey}
-@code{\noResetKey}, 
-@cindex @code{\forgetAccidentals}
-@code{\forgetAccidentals}.
-
 @seealso
 
 Internals: @internalsref{Accidental_engraver},
index eda701480220f30385771a00d934bf5d0e551e14..118bacaa34f9c5b5c3ce5614e9e7b207fc7c3187 100644 (file)
@@ -10,34 +10,6 @@ This shows how accidentals in different octaves are handled.
 
 }
 
-#(define  (lo-octave p)
-  (let* ((a (ly:pitch-alteration p))
-         (n (ly:pitch-notename p)))
-    (ly:make-pitch -1 n a)))
-
-#(define (no-octaves music)
-  (let* ((es (ly:get-mus-property music 'elements))
-         (e (ly:get-mus-property music 'element))
-         (p (ly:get-mus-property music 'pitch)))
-
-    (if (pair? es)
-        (ly:set-mus-property!
-         music 'elements
-         (map no-octaves es)))
-
-    (if (ly:music? e)
-        (ly:set-mus-property!
-         music 'element
-         (no-octaves e)))
-
-    (if (ly:pitch? p)
-        (begin
-          (set! p (lo-octave p))
-          (ly:set-mus-property! music 'pitch p)))
-
-
-    music))
-
 
 
 mel = \notes \transpose c c' {
@@ -49,7 +21,10 @@ mel = \notes \transpose c c' {
 
 \score {
   << \context Staff \mel
-     \context NoteNames \apply #no-octaves \mel
+     \context NoteNames{
+        \set printOctaveNames= ##f
+        \mel
+        }
   >>
 }
 
index f735632933d8f06db2db753fea77352a9d8664fe..7f70f9adf181e745fbe17c07ce52d2b65324591f 100644 (file)
@@ -9,33 +9,7 @@ The last f gets cautionary natural because fis was only in the other voice.
 "
 }
 
-#(define  (lo-octave p)
-  (let* ((a (ly:pitch-alteration p))
-         (n (ly:pitch-notename p)))
-    (ly:make-pitch -1 n a)))
 
-#(define (no-octaves music)
-  (let* ((es (ly:get-mus-property music 'elements))
-         (e (ly:get-mus-property music 'element))
-         (p (ly:get-mus-property music 'pitch)))
-
-    (if (pair? es)
-        (ly:set-mus-property!
-         music 'elements
-         (map no-octaves es)))
-
-    (if (ly:music? e)
-        (ly:set-mus-property!
-         music 'element
-         (no-octaves e)))
-
-    (if (ly:pitch? p)
-        (begin
-          (set! p (lo-octave p))
-          (ly:set-mus-property! music 'pitch p)))
-
-
-    music))
 
 voicea = \notes \transpose c c' {
     \stemUp
@@ -49,13 +23,20 @@ voiceb = \notes \transpose c c' {
 \score {
     <<
        \notes
-       \new NoteNames \apply #no-octaves \voicea
+       \new NoteNames {
+           \set printOctaveNames = ##f
+            \voicea
+            }
        \context Staff << 
-           \modernVoiceCautionaries
+           #(set-accidental-style 'modern-voice-cautionary)
            \new Voice \voicea
            \new Voice \voiceb
        >>
-       \new NoteNames \apply #no-octaves \voiceb
+       \new NoteNames {
+           \set printOctaveNames = ##f
+           \voiceb
+
+                        }
     >>
 \paper { raggedright = ##t }
 }
index b4984c908bce29b021229fac23230c0ded1539e1..1256165e6130c392f8029fbd42b955bd8b0f7846 100644 (file)
@@ -5,36 +5,6 @@ texidoc="
 This shows how accidentals are handled.
 "
 }
-
-#(define  (lo-octave p)
-  (let* ((a (ly:pitch-alteration p))
-         (n (ly:pitch-notename p)))
-    (ly:make-pitch -1 n a)))
-
-#(define (no-octaves music)
-  (let* ((es (ly:get-mus-property music 'elements))
-         (e (ly:get-mus-property music 'element))
-         (p (ly:get-mus-property music 'pitch)))
-
-    (if (pair? es)
-        (ly:set-mus-property!
-         music 'elements
-         (map no-octaves es)))
-
-    (if (ly:music? e)
-        (ly:set-mus-property!
-         music 'element
-         (no-octaves e)))
-
-    (if (ly:pitch? p)
-        (begin
-          (set! p (lo-octave p))
-          (ly:set-mus-property! music 'pitch p)))
-
-
-    music))
-
-
 mel = \notes { \key d \major \time 4/4
  d4  dis dis8 dis, d4 | d dis disis8 d, dis4 | d des disis8 dis, d4 | dis deses d dis ~ | dis dis ~ dis8 d, dis4 ~ | \break
  dis dis cis c | c cis cisis cis | c ces cisis c | cis ceses c cis ~ | cis cis ~ cis cis \bar "|."  | \break
@@ -43,7 +13,10 @@ mel = \notes { \key d \major \time 4/4
 \score { \notes
  <<
   \context Staff \transpose c c'' \mel
-  \context NoteNames  \apply #no-octaves \mel
+  \context NoteNames{
+      \set printOctaveNames = ##f
+      \mel
+      }
  >>
 }
 
index 4503d1cf7ceeeb4e3bad7f4aa42043120e4002cc..6b4b71b2dc21cc00df69531caa871a7b42cf19b2 100644 (file)
@@ -97,8 +97,7 @@ Context::Context ()
 Context *
 Context::find_existing_context (SCM n, String id)
 {
-  if ((is_alias (n) && (id_string_ == id || id.is_empty ()))
-      || n == ly_symbol2scm ("Current"))
+  if ((is_alias (n) && (id_string_ == id || id.is_empty ())))
     return this;
 
   Context* r = 0;
index 47562e6e2c5b156a441c34626b28ceaf23487d11..05f6c5987e42ae93e1bbd082fc913ed7eed7a089 100644 (file)
@@ -16,10 +16,10 @@ class Note_name_engraver : public Engraver
 public:
   TRANSLATOR_DECLARATIONS(Note_name_engraver);
 
-  Link_array<Music> reqs_;
+  Link_array<Music> events_;
   Link_array<Item> texts_;
   virtual bool  try_music (Music*m);
-  virtual void process_acknowledged_grobs ();
+  virtual void process_music ();
   virtual void stop_translation_timestep ();
 };
 
@@ -28,29 +28,32 @@ Note_name_engraver::try_music (Music *m)
 {
   if (m->is_mus_type ("note-event"))
     {
-      reqs_.push (m);
+      events_.push (m);
       return true;
     }
   return false;
 }
 
 void
-Note_name_engraver::process_acknowledged_grobs ()
+Note_name_engraver::process_music ()
 {
-  if (texts_.size ())
-    return;
   String s ;
-  for (int i=0; i < reqs_.size (); i++)
+  for (int i=0; i < events_.size (); i++)
     {
       if (i)
        s += " ";
-      s += unsmob_pitch (reqs_[i]->get_mus_property ("pitch"))->to_string ();
+      Pitch p = *unsmob_pitch (events_[i]->get_mus_property ("pitch"));
+
+      if (!to_boolean (get_property ("printOctaveNames")))
+         p = Pitch (-1, p.get_notename (), p.get_alteration ());
+         
+      s += p.to_string ();
     }
   if (s.length ())
     {
       Item * t = make_item ("NoteName");
       t->set_grob_property ("text", scm_makfrom0str (s.to_str0 ()));
-      announce_grob(t, reqs_[0]->self_scm());
+      announce_grob (t, events_[0]->self_scm());
       texts_.push (t);
     }
 }
@@ -63,7 +66,7 @@ Note_name_engraver::stop_translation_timestep ()
       typeset_grob (texts_[i]);
     }
   texts_.clear () ;
-  reqs_.clear ();
+  events_.clear ();
 }
 
 
@@ -76,5 +79,5 @@ ENTER_DESCRIPTION(Note_name_engraver,
 /* creats*/       "NoteName",
 /* accepts */     "note-event",
 /* acks  */      "",
-/* reads */       "",
+/* reads */       "printOctaveNames",
 /* write */       "");
index 74c260355d371ea474b75df08bef600509d9becb..7b368fe34fccd327b408b02666022d97a9a61379 100644 (file)
@@ -350,7 +350,6 @@ printing of a single line of lyrics.  "
     \consists "Rest_swallow_translator" 
     \consists "Skip_event_swallow_translator"
     \consists "Tie_engraver"
-    \consists "Note_swallow_translator"
     \consists "Note_name_engraver"
     \consists "Separating_line_group_engraver"
 }
index ea1d75d85e2515fd3f996aebc6160e2f48448933..5894ad2c709978e1e95eea9b6e4554da0b806ba1 100644 (file)
 #(ly:set-point-and-click #f)
 
 \maininput
+% there is a problem at the end of the input file
+
+
+%%
+%% above message is to compensate for look ahead of the parser.
+%%
 
 #(if (and (ly:get-option 'old-relative)
       (not (ly:get-option 'old-relative-used)))
index 3f1a5e4261783c7e48bdd79e0a04035af93d6a56..899dd031d651bc1568c0eab5e62a6e716d38fba8 100644 (file)
@@ -117,101 +117,6 @@ emptyText = \override TextScript  #'no-spacing-rods = ##t
 showStaffSwitch = \set followVoice = ##t
 hideStaffSwitch = \set followVoice = ##f
 
-% accidentals as they were common in the 18th century.
-defaultAccidentals = {
-  \set Current.extraNatural = ##t
-  \set Current.autoAccidentals = #'(Staff (same-octave . 0))
-  \set Current.autoCautionaries = #'()
-}
-
-% accidentals in voices instead of staves.
-% Notice that accidentals from one voice do NOT get cancelled in other voices
-voiceAccidentals = {
-  \set Current.extraNatural = ##t
-  \set Current.autoAccidentals = #'(Voice (same-octave . 0))
-  \set Current.autoCautionaries = #'()
-  
-}
-
-% accidentals as suggested by Kurt Stone, Music Notation in the 20th century.
-% This includes all the default accidentals, but accidentals also needs cancelling
-% in other octaves and in the next measure.
-modernAccidentals = {
-  \set Current.extraNatural = ##f
-  \set Current.autoAccidentals = #'(Staff (same-octave . 0) (any-octave . 0) (same-octave . 1))
-  \set Current.autoCautionaries = #'()  
-}
-
-% the accidentals that Stone adds to the old standard as cautionaries
-modernCautionaries = {
-  \set Current.extraNatural = ##f
-  \set Current.autoAccidentals = #'(Staff (same-octave . 0))
-  \set Current.autoCautionaries = #'(Staff (any-octave . 0) (same-octave . 1))  
-}
-
-% Multivoice accidentals to be read both by musicians playing one voice
-% and musicians playing all voices.
-% Accidentals are typeset for each voice, but they ARE cancelled across voices.
-modernVoiceAccidentals = {
-  \set Current.extraNatural = ##f
-  \set Current.autoAccidentals = #'(
-    Voice (same-octave . 0) (any-octave . 0) (same-octave . 1)
-    Staff (same-octave . 0) (any-octave . 0) (same-octave . 1)
-  )
-  \set Current.autoCautionaries = #'()  
-}
-
-% same as modernVoiceAccidental eccept that all special accidentals are typeset
-% as cautionaries
-modernVoiceCautionaries = {
-  \set Current.extraNatural = ##f
-  \set Current.autoAccidentals = #'(
-    Voice (same-octave . 0) 
-  )
-  \set Current.autoCautionaries = #'(
-    Voice (any-octave . 0) (same-octave . 1)
-    Staff (same-octave . 0) (any-octave . 0) (same-octave . 1)
-  )  
-}
-
-% stone's suggestions for accidentals on grand staff.
-% Accidentals are cancelled across the staves in the same grand staff as well
-pianoAccidentals = {
-  \set Current.autoAccidentals = #'(
-    Staff (same-octave . 0) (any-octave . 0) (same-octave . 1)
-    GrandStaff (any-octave . 0) (same-octave . 1)
-  )
-  \set Current.autoCautionaries = #'()  
-}
-
-pianoCautionaries = {
-  \set Current.autoAccidentals = #'(
-    Staff (same-octave . 0)
-  )
-  \set Current.autoCautionaries = #'(
-    Staff (any-octave . 0) (same-octave . 1)
-    GrandStaff (any-octave . 0) (same-octave . 1)
-  )  
-}
-
-
-% Do not reset the key at the start of a measure.  Accidentals will be
-% printed only once and are in effect until overridden, possibly many
-% measures later.
-noResetKey = {
-  \set Current.autoAccidentals = #'(Staff (same-octave . #t))
-  \set Current.autoCautionaries = #'()
-}
-
-% do not set localKeySignature when a note alterated differently from
-% localKeySignature is found.
-% Causes accidentals to be printed at every note instead of
-% remembered for the duration of a measure.
-% accidentals not being remembered, causing accidentals always to be typeset relative to the time signature
-forgetAccidentals = {
-  \set Current.autoAccidentals = #'(Staff (same-octave . -1))
-  \set Current.autoCautionaries = #'()  
-}
 
 
 % To remove a Volta bracket or some other graphical object,
index a6cd485be266cbff1ebe4029c5ff0b18eaa59c0e..1b21fa39ae864dffa5ab853d9b5d9ae46694427e 100644 (file)
@@ -247,6 +247,7 @@ the string to print when this is done with the pedal.")
 sustain pedals: text, bracket or mixed (both).")
      (pedalUnaCordaStyle ,symbol? "see pedalSustainStyle.")
      (pedalSostenutoStyle ,symbol? "see pedalSustainStyle.")
+     (printOctaveNames ,boolean? "Print octave marks for the NoteNames context.")
      (rehearsalMark ,integer? "The last rehearsal mark printed.")
      (repeatCommands ,list? "This property is read to find any command of the form (volta . X), where X is a string or #f")
 
index d45195449892243b380220c6eed1850d54d6427b..ab4066cd91cac409548f92bbd3639ff2a57bf2d5 100644 (file)
@@ -503,4 +503,3 @@ L1 is copied, L2 not.
               ".scm"
               ) "w")))
 
-(set-debug-cell-accesses! 1000)
index 0f61658f52bbe28dcf8421bf0861ee8fb80feccf..e0ef92b44a8517185f0197bda650f24da6755b44 100644 (file)
@@ -789,3 +789,112 @@ Rest can contain a list of beat groupings
      ))))
 
 
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; accidentals
+
+(define-public (set-accidentals-properties
+               extra-natural
+               auto-accs auto-cauts
+               context)
+  (context-spec-music
+   (make-sequential-music
+    (append
+     (if (boolean? extra-natural) (list (make-property-set 'extraNatural extra-natural)) '())
+     (list
+      (make-property-set 'autoAccidentals auto-accs)
+      (make-property-set 'autoCautionaries auto-cauts)
+     )))
+   context))
+
+(define-public (set-accidental-style style . rest)
+  "Set accidental style to STYLE. Optionally takes a context argument,
+eg. 'Staff or 'Voice. The context defaults to Voice, except for piano styles, which
+use PianoStaff as a context. "
+
+  (let
+      ((context (if (pair? rest)
+                   (car rest) 'Staff))
+       (pcontext (if (pair? rest)
+                    (car rest) 'PianoStaff))
+       )
+       
+  (ly:export
+   
+   (cond
+    ; accidentals as they were common in the 18th century.
+    ((equal? style 'default) (set-accidentals-properties #t '(Staff (same-octave . 0)) '() context))
+
+    ; accidentals from one voice do NOT get cancelled in other voices
+    ((equal? style 'voice) (set-accidentals-properties #t '(Voice (same-octave . 0)) '() context))
+
+    ; accidentals as suggested by Kurt Stone, Music Notation in the 20th century.
+    ; This includes all the default accidentals, but accidentals also needs cancelling
+    ; in other octaves and in the next measure.
+    ((equal? style 'modern) (set-accidentals-properties #f '(Staff (same-octave . 0) (any-octave . 0) (same-octave . 1)) '()  context))
+
+    ; the accidentals that Stone adds to the old standard as cautionaries
+    ((equal? style 'modern-cautionary)
+     (set-accidentals-properties #f '(Staff (same-octave . 0))
+                    '(Staff (any-octave . 0) (same-octave . 1))
+                    context))
+
+    ; Multivoice accidentals to be read both by musicians playing one voice
+    ; and musicians playing all voices.
+    ; Accidentals are typeset for each voice, but they ARE cancelled across voices.
+    ((equal? style 'modern-voice)
+     (set-accidentals-properties  #f
+                     '(Voice (same-octave . 0) (any-octave . 0) (same-octave . 1)
+                             Staff (same-octave . 0) (any-octave . 0) (same-octave . 1))
+                     '()
+                     context))
+
+    ; same as modernVoiceAccidental eccept that all special accidentals are typeset
+    ; as cautionaries
+
+    ((equal? style 'modern-voice-cautionary)
+     (set-accidentals-properties #f
+                    '(Voice (same-octave . 0) )
+                    '(Voice (any-octave . 0) (same-octave . 1)
+                            Staff (same-octave . 0) (any-octave . 0) (same-octave . 1))
+                    context))
+
+    ; stone's suggestions for accidentals on grand staff.
+    ; Accidentals are cancelled across the staves in the same grand staff as well
+    ((equal? style 'piano)
+     (set-accidentals-properties #f
+                    '( Staff (same-octave . 0) (any-octave . 0) (same-octave . 1)
+                             PianoStaff (any-octave . 0) (same-octave . 1))
+                    '()
+                    pcontext))
+    ((equal? style 'piano-cautionary)
+     (set-accidentals-properties #f
+                    '(Staff (same-octave . 0))
+                    '(Staff (any-octave . 0) (same-octave . 1)
+                             PianoStaff (any-octave . 0) (same-octave . 1))
+                    pcontext))
+
+     ; do not set localKeySignature when a note alterated differently from
+     ; localKeySignature is found.
+     ; Causes accidentals to be printed at every note instead of
+     ; remembered for the duration of a measure.
+     ; accidentals not being remembered, causing accidentals always to be typeset relative to the time signature
+     ((equal? style 'forget)
+     (set-accidentals-properties '()
+                    '(Staff (same-octave . -1))
+                    '() context))
+
+    ; Do not reset the key at the start of a measure.  Accidentals will be
+    ; printed only once and are in effect until overridden, possibly many
+    ; measures later.
+    ((equal? style 'no-reset)
+     (set-accidentals-properties '()
+                    '(Staff (same-octave . #t))
+                    '()
+                    context))
+    (else
+     (ly:warn (string-append "Unknown accidental style: " (symbol->string style)))
+     (make-sequential-music '())
+     ))
+   )))
+
index db8c3b5ac947457c4c478d74ffa9946549a930e0..0a173719ef9283672a00f1c1f6d989817bbe0f2b 100644 (file)
@@ -1909,6 +1909,18 @@ def conv (str):
        if re.search ("ly:get-paper-variable", str):
                sys.stderr.write ('use (ly:paper-lookup (ly:grob-paper ))')
                raise FatalConversionError()
+
+       str = re.sub (r'\\defaultAccidentals', "#(set-accidental-style 'default)", str)
+       str = re.sub (r'\\voiceAccidentals', "#(set-accidental-style 'voice)", str)
+       str = re.sub (r'\\modernAccidentals', "#(set-accidental-style 'modern)", str)
+       str = re.sub (r'\\modernCautionaries', "#(set-accidental-style 'modern-cautionary)", str)
+       str = re.sub (r'\\modernVoiceAccidental', "#(set-accidental-style 'modern-voice)", str)
+       str = re.sub (r'\\modernVoiceCautionaries', "#(set-accidental-style 'modern-voice-cautionary)", str)
+       str = re.sub (r'\\pianoAccidentals', "#(set-accidental-style 'piano)' , str)", str)
+       str = re.sub (r'\\pianoCautionaries', "#(set-accidental-style 'piano-cautionary)", str)
+       str = re.sub (r'\\forgetAccidentals', "#(set-accidental-style 'forget)", str)
+       str = re.sub (r'\\noResetKey', "#(set-accidental-style 'no-reset)", str)
+       
        return str
 
 conversions.append (((2,1,25), conv, """Scheme grob function renaming"""))