]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scm/music-functions.scm (set-octavation): new function.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 17 May 2003 23:26:30 +0000 (23:26 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 17 May 2003 23:26:30 +0000 (23:26 +0000)
* input/regression/ottava.ly: new file

* lily/translator-scheme.cc (LY_DEFINE): new function
ly:unset-context-property
(LY_DEFINE) new function ly:context-property-where-defined:

13 files changed:
ChangeLog
Documentation/user/refman.itely
NEWS
input/regression/ottava.ly [new file with mode: 0644]
input/test/ottava.ly [deleted file]
lily/parser.yy
lily/translator-scheme.cc
ly/engraver-init.ly
scm/define-grobs.scm
scm/define-translator-properties.scm
scm/lily.scm
scm/music-functions.scm
scm/translation-functions.scm [new file with mode: 0644]

index f3ba098a70d97b8fbad9dadc543cd3044976cdad..0c9b58af7f5e6184e3b4c53b36ebc7cba84e9e24 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2003-05-18  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
+
+       * scm/music-functions.scm (set-octavation): new function.
+
+       * input/regression/ottava.ly: new file
+
+       * lily/translator-scheme.cc (LY_DEFINE): new function
+       ly:unset-context-property
+       (LY_DEFINE) new function ly:context-property-where-defined: 
+
 2003-05-18  Heikki Junes  <hjunes@cc.hut.fi>
 
        * lilypond-font-lock.el: Add postfix syntax for horizontal groups.
 
        * scm/music-functions.scm (make-multi-measure-rest): set input
        locations for multimeasure rests.
-       
 
 2003-03-31  Juergen Reuter  <reuter@ipd.uka.de>
 
index 34f0e6141fbd30b2c1d5b4562d3f9384b9534c8f..131f8e81f6b5e733c06a9ca324a57984069a3764 100644 (file)
@@ -661,6 +661,7 @@ such as keys, clefs and time signatures.
 * Staff symbol::                
 * Key signature::               
 * Clef::                        
+* Ottava brackets::             
 * Time signature::              
 * Unmetered music::             
 * Bar lines::                   
@@ -803,6 +804,37 @@ The object for this symbol is @internalsref{Clef}.
 
 
 
+@node Ottava brackets
+@subsection Ottava brackets
+
+``Ottava'' brackets introduce an extra transposition of an octave for
+the staff. They are created by invoking the function
+@code{set-octavation}
+
+@cindex ottava
+@cindex 15ma
+@cindex octavation
+
+@lilypond[verbatim,fragment]
+\relative c''' {
+  a2 b
+  #(set-octavation 1)
+  a b 
+  #(set-octavation 0)
+  a b }
+@end lilypond
+
+Internally the @code{set-octavation} sets @code{ottavation} (eg. to
+@code{"8va"}) and @code{centralCPosition} properties.
+
+@seealso
+
+@internalsref{OttavaBracket}
+
+@refbugs
+
+@code{set-octavation} will get confused when clef changes happen
+during an octavation bracket.
 
 @node Time signature
 @subsection Time signature
@@ -1655,17 +1687,11 @@ start and ending note of the spanner.
 The string to be printed, as well as the style, is set through object
 properties.
 
-[TODO: 8va engraver.]
-
-An application is to fake octavation indications.
-
 @lilypond[fragment,relative,verbatim]
- \relative c' {  a''' b c a
-  \property Voice.TextSpanner \set #'type = #'dotted-line
-  \property Voice.TextSpanner \set #'edge-height = #'(0 . 1.5)
-  \property Voice.TextSpanner \set #'edge-text = #'("8va " . "")
-  \property Staff.centralCPosition = #-13
-  a-\startTextSpan b c a-\stopTextSpan }
+ \relative c' {  c1 
+  \property Voice.TextSpanner \set #'direction = #-1
+  \property Voice.TextSpanner \set #'edge-text = #'("rall " . "")
+  c2-\startTextSpan b c-\stopTextSpan a }
 @end lilypond
 
 
diff --git a/NEWS b/NEWS
index e42418d7537551188f89a79c46c06afa59e16df2..e90f60eb17f83cd576f49c5e84db1473e03e85d7 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -53,14 +53,16 @@ and
 
 * NOTATION
 
+
+
 ** Ancient notation ... ?? ...  (Jurgen?)
 
-** Completely rewritten text formatting support. It is implemented in a
+** Completely rewritten text formatting support, implemented in a
 completely modular way.
 
 ** Chord name formatting completely rewritten.
 
-** Texts on multimeasure rests can be set by the user.
+** Texts can be added to multimeasure rests
 
 ** Zigzagged glissandi
 
@@ -77,14 +79,15 @@ completely modular way.
 
 ** Nested horizontal brackets for music analysis.
 
-       NOTE-\groupOpen
+       NOTE-\startGroup
                ..
-       NOTE-\groupClose
+       NOTE-\stopGroup
 
 ** Gregorian ligatures.
 
-** Texts on multi-measure rests.
+** Ottava brackets. Syntax: #(set-octavation 1)
 
+** Metronome markings. 
 
 
 New features in 1.6 since 1.4
diff --git a/input/regression/ottava.ly b/input/regression/ottava.ly
new file mode 100644 (file)
index 0000000..fbadf82
--- /dev/null
@@ -0,0 +1,22 @@
+\header
+{
+texidoc = "ottava brackets are supported, through the
+use of the scheme function @code{set-octavation}. 
+"
+
+}
+\version "1.7.18"
+
+
+\paper { raggedright = ##t} 
+\score {
+  \notes\relative c''' \notes {
+  a b c a
+  #(set-octavation 1)
+  a b c a
+  #(set-octavation 0)
+
+  a b c a 
+}
+}
+
diff --git a/input/test/ottava.ly b/input/test/ottava.ly
deleted file mode 100644 (file)
index 87579eb..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-\version "1.7.16"
-
-
-fragment = \notes {
-  a'''' b c a
-  \property Voice.TextSpanner \set #'type = #'dotted-line
-  \property Voice.TextSpanner \set #'edge-height = #'(0 . 1.5)
-  \property Voice.TextSpanner \set #'edge-text = #'("8va " . "")
-  \property Staff.centralCPosition = #-13
-  a-\startTextSpan b c a-\stopTextSpan
-}
-
-\paper { raggedright = ##t} 
-
-\score {
-  \notes\relative c \fragment
-  \paper { }  
-}
-%% new-chords-done %%
index f4eeeca5b318d4aade063e6303bbeae0f410f4c6..72086b41a899d963e767ab706fd98ca1b0d7cc6a 100644 (file)
@@ -133,7 +133,6 @@ set_music_properties (Music *p, SCM a)
        }
 }
 
-
 SCM
 make_chord_step (int step, int alter)
 {
@@ -157,7 +156,15 @@ make_chord (SCM pitch, SCM dur, SCM modification_list)
        return ch;
 }
 
-
+/*
+  Todo: actually also use apply iso. call too ... 
+*/
+bool
+ly_input_procedure_p (SCM x)
+{
+       return gh_procedure_p (x)
+               || (gh_pair_p (x) && gh_procedure_p (gh_car (x)));
+}
 
 Music* 
 set_property_music (SCM sym, SCM value)
@@ -835,14 +842,14 @@ Simultaneous_music:
 Simple_music:
        event_chord             { $$ = $1; }
        | APPLYOUTPUT embedded_scm {
-               if (!gh_procedure_p ($2))
+               if (!ly_input_procedure_p ($2))
                        THIS->parser_error (_ ("\applycontext takes function argument"));
                $$ = MY_MAKE_MUSIC ("ApplyOutputEvent");
                $$->set_mus_property ("procedure", $2);
                $$->set_spot (THIS->here_input());
        }
        | APPLYCONTEXT embedded_scm {
-               if (!gh_procedure_p ($2))
+               if (!ly_input_procedure_p ($2))
                        THIS->parser_error (_ ("\applycontext takes function argument"));
                $$ = MY_MAKE_MUSIC ("ApplyContext");
                $$->set_mus_property ("procedure", $2);
@@ -983,6 +990,9 @@ Composite_music:
                scm_gc_unprotect_object (p->self_scm ());
        }
        | APPLY embedded_scm Music  {
+               if (!ly_input_procedure_p ($2))
+                       THIS->parser_error (_ ("\apply takes function argument"));
+               
                SCM ret = gh_call1 ($2, $3->self_scm ());
                Music *m = unsmob_music (ret);
                if (!m) {
index 7cf9b8ed71079b36b86b17c50dcb57ddb7613715..2ced54dbf190604829883a751fc5c7bbbc32b78c 100644 (file)
@@ -36,12 +36,44 @@ LY_DEFINE(ly_set_context_property,
   Translator_group* tr=   dynamic_cast<Translator_group*> (t);
 
   SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context");
+  SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol");
+
   tr->internal_set_property (name, val);
 
   return SCM_UNSPECIFIED;
 }
 
 
+LY_DEFINE(ly_context_property_where_defined,
+         "ly:context-property-where-defined", 2, 0, 0,
+         (SCM context, SCM name),
+         "Return the context above @var{context} where @var{name}  is defined.")
+{
+  Translator *t = unsmob_translator (context);
+  Translator_group* tr = dynamic_cast<Translator_group*> (t);
+  SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context");
+  SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol");
+
+  return tr->where_defined (name)->self_scm();
+}
+
+LY_DEFINE(ly_unset_context_property,
+         "ly:unset-context-property", 2, 0, 0,
+         (SCM context, SCM name),
+         "Unset value of property @var{name} in context @var{context}.")
+{
+  Translator *t = unsmob_translator (context);
+  Translator_group* tr = dynamic_cast<Translator_group*> (t);
+  SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context");
+  SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol");
+
+  tr->unset_property (name);
+
+  return SCM_UNSPECIFIED;
+}
+
+
+
 LY_DEFINE(ly_context_parent,
          "ly:context-parent", 1, 0, 0,
          (SCM context),
index da047f56583479d365c822be5af66548c17548ae..bd8d69925fbe4350da13f1423a393b0bd37e9781 100644 (file)
@@ -72,7 +72,6 @@ StaffContainerContext = \translator {
 InnerChoirStaffContext = \translator {
        \type "Engraver_group_engraver"
        \name InnerChoirStaff
-       %% alignmentReference = #0 FIXME
        \consists "System_start_delimiter_engraver"
        systemStartDelimiter = #'SystemStartBracket
        localKeySignature = #'()
@@ -84,6 +83,7 @@ InnerChoirStaffContext = \translator {
        \accepts "Lyrics"
        \accepts "ChordNames"
 }
+
 ChoirStaffContext = \translator {
        \InnerChoirStaffContext
        \name ChoirStaff
@@ -103,8 +103,7 @@ RhythmicStaffContext=\translator{
 
 \description  "
     A context like @code{Staff} but for printing rhythms.  Pitches are
-    ignored; the notes are printed on one line.  It can contain
-    @code{Voice} contexts.
+    ignored; the notes are printed on one line.  
 "
        minimumVerticalExtent = ##f
        extraVerticalExtent = ##f
@@ -218,11 +217,10 @@ GrandStaffContext=\translator{
        \type "Engraver_group_engraver"
        \name GrandStaff
        localKeySignature = #'()
-       \description "
-    Contains @code{Staff} or @code{RhythmicStaff} contexts.  It adds a
-    brace on the left side, grouping the staves together.  The bar
-    lines of the contained staves are connected vertically.  It can
-    contain @code{Staff} contexts."
+       
+       \description " A group of staffs, with a brace on the left
+    side, grouping the staves together.  The bar lines of the
+    contained staves are connected vertically.  "
 
        \consists "Span_bar_engraver"
        \consists "Span_arpeggio_engraver"
@@ -276,12 +274,12 @@ InnerStaffGroupContext= \translator {
 StaffGroupContext = \translator {
        \InnerStaffGroupContext
        \name StaffGroup
-       \description "
-    Contains @code{Staff} or @code{RhythmicStaff} contexts.  Adds a
-    bracket on the left side, grouping the staves together.  The bar
-    lines of the contained staves are connected vertically.  It can
-    contain @code{Staff}, @code{RhythmicStaff}, @code{GrandStaff}, or
-    @code{Lyrics} contexts.
+       
+       \description
+
+       " Groups staffs while adding a bracket on the left side,
+       grouping the staves together.  The bar lines of the contained
+       staves are connected vertically.
 "
        
        \accepts "InnerChoirStaff"
@@ -391,9 +389,7 @@ ScoreContext = \translator {
     other context can contain a @code{Score} context.  This context
     handles the administration of time signatures.  It also makes sure
     that items such as clefs, time signatures, and key-signatures are
-    aligned across staves.  It can contain @code{Lyrics},
-    @code{Staff}, @code{RhythmicStaff}, @code{GrandStaff},
-    @code{StaffGroup}, and @code{ChoirStaff} contexts.
+    aligned across staves.
 
     You cannot explicitly instantiate a Score context (since it is
     not contained in any other context).  It is instantiated
index de352b2d256dcfa5717a7b21178aba69a278f1a5..c08e3f955c5a3d1d7829b9f08a381e904345bff2 100644 (file)
        (type . line)
        (if-text-padding . 1.0)
        (width-correct . 0)
-       (outer . #t)
+       (enclose-bounds . #t)
        (direction . -1)
        (edge-widen . (0.5 . 0.5))
        (edge-height . (1.0 . 1.0))
        (Y-offset-callbacks . (,Side_position_interface::aligned_side))
        (molecule-callback . ,Text_spanner::brew_molecule)
        (font-family . roman)
-       (outer . #t)
+       (enclose-bounds . #t)
        (width-correct . 0.0)
        (type . dotted-line)
        (edge-height . (0 . 1.5))
index ba4eb742af6af765c1eb28b0cad78b050e01877c..f76d179acde1b7faec6a027c870502cac7a3681a 100644 (file)
@@ -313,6 +313,9 @@ not less than minimumFret")
 then beams are generated automatically.")
 (translator-property-description 'noDirection boolean? "Don't set directions by a2-engraver when part-combining.")
 (translator-property-description 'oneBeat ly:moment? "  How long does one beat in the current time signature last?")
+(translator-property-description
+ 'originalCentralCPosition integer?
+ "Used for temporary overriding central C in octavation brackets. ")
 (translator-property-description 'othersolo boolean? "FIXME")
 (translator-property-description 'ottavation string? "If set, the text
 for an 8va spanner. Changing this implies a new text spanner. ")
index 4add9c25c440e6c09f2d2095f0704e268fa8b54f..642904e4b923292871a359d58e1bcb5e4831b35a 100644 (file)
@@ -392,7 +392,9 @@ is the  first to satisfy CRIT
        "define-music-properties.scm"
        "auto-beam.scm"
        "chord-name.scm"
+       
        "define-translator-properties.scm"
+       "translation-functions.scm"
        "script.scm"
        "drums.scm"
        "midi.scm"
index 5ca516c5bcbb4544520ea317bd39bd88f799b044..4d99d86e3e19db52b9f8e9f9e80f2048689200aa 100644 (file)
@@ -1,33 +1,3 @@
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; tuplets.
-
-(define-public (denominator-tuplet-formatter mus)
-  (number->string (ly:get-mus-property mus 'denominator)))
-
-(define-public (fraction-tuplet-formatter mus)
-  (string-append (number->string (ly:get-mus-property mus 'numerator))
-                ":"
-                (number->string (ly:get-mus-property mus 'denominator))
-                ))
-
-;; metronome marks
-(define-public (make-metronome-markup event context)
-  (let*
-      ((dur  (ly:get-mus-property event 'tempo-unit))
-       (count (ly:get-mus-property event 'metronome-count))
-       (note-mark     (make-note-markup (ly:duration-log dur)
-                                       (ly:duration-dot-count dur)
-                                       1)
-                     )
-       )
-
-    (make-line-markup
-     (list
-      note-mark
-      (make-simple-markup  "=")
-      (make-simple-markup (number->string count))
-      
-  ))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
             music))
   
 
+
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; repeats.
 
@@ -245,7 +217,8 @@ i.e.  this is not an override"
     m
     ))
 
-
+;;;;;;;;;;;;;;;;
+;; mmrest
 (define-public (make-multi-measure-rest duration location)
   (let*
       (
@@ -322,6 +295,57 @@ a property set for MultiMeasureRestNumber."
     m
   ))
 
+
+
+(define-public (make-ottava-set octavation)
+  (let*
+      (
+       (m (make-music-by-name 'ApplyContext))
+       )
+    
+  
+  (define (ottava-modify context)
+    "Either reset centralCPosition to the stored original,
+or remember old centralCPosition, add OCTAVATION to centralCPosition,
+and set OTTAVATION to `8va', or whatever appropriate.  
+"
+    (if (= octavation 0)
+       (let*
+           ((where (ly:context-property-where-defined context 'centralCPosition))
+            (oc0 (ly:get-context-property context 'originalCentralCPosition))
+
+            )
+         
+         (ly:set-context-property context 'centralCPosition oc0)
+         (ly:unset-context-property where 'originalCentralCPosition)
+         (ly:unset-context-property where 'ottavation)
+         )
+       
+       (let*
+           ((where (ly:context-property-where-defined context 'centralCPosition))
+            (c0 (ly:get-context-property context 'centralCPosition))
+            (new-c0 (+ c0 (* -7 octavation)))
+            (string (cdr
+                     (assoc octavation '((2 . "15ma")
+                                         (1 . "8va")
+                                         (0 . #f)
+                                         (-1 . "8va bassa")
+                                         (-2 . "15ma bassa")))))
+            )
+
+         (ly:set-context-property where 'centralCPosition new-c0)
+         (ly:set-context-property where 'originalCentralCPosition c0)
+         (ly:set-context-property where 'ottavation string)
+         
+         )))
+
+  (ly:set-mus-property! m 'procedure  ottava-modify)
+  m
+  ))
+
+(define-public (set-octavation ottavation)
+  (ly:export (make-ottava-set ottavation)))
+
 (define-public (make-time-signature-set num den . rest)
   " Set properties for time signature NUM/DEN.
 Rest can contain a list of beat groupings 
diff --git a/scm/translation-functions.scm b/scm/translation-functions.scm
new file mode 100644 (file)
index 0000000..fc3dd63
--- /dev/null
@@ -0,0 +1,32 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; tuplets.
+
+(define-public (denominator-tuplet-formatter mus)
+  (number->string (ly:get-mus-property mus 'denominator)))
+
+(define-public (fraction-tuplet-formatter mus)
+  (string-append (number->string (ly:get-mus-property mus 'numerator))
+                ":"
+                (number->string (ly:get-mus-property mus 'denominator))
+                ))
+
+
+;; metronome marks
+(define-public (make-metronome-markup event context)
+  (let*
+      ((dur  (ly:get-mus-property event 'tempo-unit))
+       (count (ly:get-mus-property event 'metronome-count))
+       (note-mark     (make-note-markup (ly:duration-log dur)
+                                       (ly:duration-dot-count dur)
+                                       1)
+                     )
+       )
+
+    (make-line-markup
+     (list
+      note-mark
+      (make-simple-markup  "=")
+      (make-simple-markup (number->string count))
+      
+  ))))
+