]> git.donarmstrong.com Git - lilypond.git/commitdiff
* Documentation/user/changing-defaults.itely (Changing context
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 22 Mar 2004 14:42:43 +0000 (14:42 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 22 Mar 2004 14:42:43 +0000 (14:42 +0000)
default settings): new node.
(Defining new  contexts): new node.

* scripts/lilypond-book.py (is_derived_class): use numbers
iso. booleans.

* scripts/lilypond-book.py (is_derived_class): new function. Take
class arg iso. object.
(to_eps): make a non EPS file if EPS contains %%Pages. Workaround
for bug in GS/dvips.

ChangeLog
Documentation/user/changing-defaults.itely
scripts/lilypond-book.py

index d9ebd8cfaaaa949f19defc4f9a99733b67890b65..89480c35d3d4a9acb880298be17dd085f741fbff 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2004-03-22  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
+       * Documentation/user/changing-defaults.itely (Changing context
+       default settings): new node.
+       (Defining new  contexts): new node.
+
        * scripts/lilypond-book.py (is_derived_class): use numbers
        iso. booleans.
 
index 16f32d9afdc99819561ff9c0b1531f84fc3d84e1..2e9840019e66818e3da9aa2c7bb42f287a0bb0ea 100644 (file)
@@ -662,8 +662,8 @@ Cyclic references in Scheme values for properties can cause hangs
 and/or crashes.
 
 
-@node Defining context defaults 
-@subsection Defining context defaults
+@node Changing context default settings
+@subsection Changing context default settings
 
 The adjustments of the previous chapters can also be entered separate
 from the music, in the @code{\paper} block,
@@ -687,32 +687,169 @@ This
 @end example
 
 @noindent
-takes the existing definition @context{Staff}, and adds
-changes some settings,
+takes the existing definition @context{Staff} from the identifier
+@code{StaffContext}. This works analogously other contexts, so the
+existing definition  of @code{Voice} is in 
+@code{\VoiceContext}.
 
+The statements
 @example
         \set fontSize = #-2
         \override Stem #'thickness
         \remove "Time_signature_engraver"
 @end example
 
+@noindent
+affect all staves in the score.
+
+The @code{\set} keyword is optional within the @code{\paper} block, so
+
+@example
+  fontSize = #-2
+@end example
+
+@noindent
+will also work.
+
+
+
+
+@node Defining new  contexts
+@subsection Defining new  contexts
+
+Specific contexts, like @context{Staff} and @code{Voice} are made of
+simple building blocks, and it is possible to compose engraver
+plug-ins in different combinations, thereby creating new types of
+contexts.
+
+The next example shows how to build a different type of
+@context{Voice} context from scratch.  It will be similar to
+@code{Voice}, but print centered slash noteheads only. It can be used
+to indicate improvisation in Jazz pieces,
+
+@lilypond[raggedright]
+  \paper { \context {
+    \name ImproVoice
+    \type "Engraver_group_engraver"
+    \consists "Note_heads_engraver"
+    \consists "Text_script_engraver"
+    \consists Pitch_squash_engraver
+    squashedPosition = #0
+    \override NoteHead #'style = #'slash
+    \override Stem #'transparent = ##t
+    \alias Voice
+  }
+  \context { \StaffContext
+    \accepts "ImproVoice"
+  }
+  \score { \notes \relative c'' {
+    a4 d8 bes8 \new ImproVoice { c4^"ad lib" 4 
+     c4 c^"undress"  c c_"while playing :)"  } 
+    a1 
+  }
+@end lilypond
+
+
+These settings are again done within a @code{\context} block inside a
+@code{\paper} block,
+
+@example
+  \paper  {
+    \context {
+      @dots{}
+    }
+  }
+@end example
+
+In the following discussion, the example input shown should go on the
+@dots{} of the previous fragment.
+
+First, name the context gets a name. Instead of @context{Voice} it
+will be called @context{ImproVoice},
 
+@verbatim
+  \name ImproVoice
+@end verbatim
 
-Context properties can be set as defaults, within the
-@code{\paper} block. For example, 
+Since it is similar to the @context{Voice}, we want commands that work
+on (existing) @context{Voice}s to remain working. This is achieved by
+giving the new context an alias @context{Voice},
+
+@verbatim
+  \alias Voice
+@end verbatim
+
+The context will print notes, and instructive texts
+
+@verbatim
+  \consists Note_heads_engraver
+  \consists Text_script_engraver
+@end verbatim
+
+but only on the center line,
+
+@verbatim
+  \consists Pitch_squash_engraver
+  squashedPosition = #0
+@end verbatim
+
+The @internalsref{Pitch_squash_engraver} modifies note heads (created
+by @internalsref{Note_heads_engraver}) and sets their vertical
+position to the value of @code{squashedPosition}, in this case
+@code{0}, the center line.
+
+The notes look like a  slash, without a stem,
+
+@verbatim
+    \override NoteHead #'style = #'slash
+    \override Stem #'transparent = ##t
+@end verbatim
+
+
+All these plug-ins have to cooperate, and this is achieved with a
+special plug-in, which must be marked with the keyword @code{\type}.
+This should always be @internalsref{Engraver_group_engraver},
+
+@example
+ \type "Engraver_group_engraver"
+@end example
+
+Put together, we get
 
 @verbatim
-\paper {
   \context {
-    \ScoreContext
-    skipBars = ##t
+    \name ImproVoice
+    \type "Engraver_group_engraver"
+    \consists "Note_heads_engraver"
+    \consists "Text_script_engraver"
+    \consists Pitch_squash_engraver
+    squashedPosition = #0
+    \override NoteHead #'style = #'slash
+    \override Stem #'transparent = ##t
+    \alias Voice
   }
-}
 @end verbatim
 
-@noindent
-will set skipBars default 
+Contexts form hierarchies. We want to hang the @consists{ImproVoice}
+under @consists{Staff}, just like normal @code{Voice}s. Therefore, we
+modify the @code{Staff} definition with the @code{\accepts}
+command,@footnote{The opposite of @code{\accepts} is @code{\denies},
+which is sometimes when reusing existing context definitions. }
+
+
+
+@verbatim
+  \context {
+    \StaffContext
+    \accepts ImproVoice    
+  }
+@end verbatim 
+
+
+@example
+
 
+    
 @node Which properties to change
 @subsection Which properties to change
 
index 622396b8b0b0f317b44e7da7e2f4871b16a8a351..4f90a8efd6235ca24dc42da98be1833f6206fdcd 100644 (file)
@@ -737,7 +737,7 @@ def run_filter (s):
 
 def is_derived_class (cl,  baseclass):
        if cl == baseclass:
-               return 0
+               return 1
        for b in cl.__bases__:
                if is_derived_class (b, baseclass):
                        return 1