]> git.donarmstrong.com Git - lilypond.git/commitdiff
absolute pitch entry: accept an offset octave
authorKeith OHara <k-ohara5a5a@oco.net>
Sun, 3 May 2015 05:51:48 +0000 (22:51 -0700)
committerKeith OHara <k-ohara5a5a@oco.net>
Mon, 25 May 2015 20:29:42 +0000 (13:29 -0700)
Documentation/learning/common-notation.itely
Documentation/notation/pitches.itely
input/regression/relative.ly [new file with mode: 0644]
ly/music-functions-init.ly
scm/define-music-types.scm

index 51a2056aa30fc80adc9478e7ab69e46f9d9dc75b..d317c82147ffdd5bda34d0e36d5ae66288b7351a 100644 (file)
@@ -1467,9 +1467,21 @@ of quote @code{'} marks.  Consider this fragment from Mozart:
 }
 @end lilypond
 
-All these quotes makes the input less readable and they are a source
-of errors.  With @code{\relative}, the previous example is much
-easier to read and type:
+@funindex \fixed
+Common octave marks can be indicated just once, using the command
+@code{\fixed} followed by a reference pitch:
+
+@lilypond[verbatim,quote]
+\fixed c'' {
+  \key a \major
+  \time 6/8
+  cis8. d16 cis8 e4 e8 |
+  b,8. cis16 b,8 d4 d8 |
+}
+@end lilypond
+
+With @code{\relative}, the previous example needs no octave marks
+because this melody moves in steps no larger than three staff positions:
 
 @lilypond[verbatim,quote]
 \relative {
@@ -1499,13 +1511,15 @@ inner relative sections are independent:
 \relative { c'4 \relative { f'' g } c }
 @end lilypond
 
-@funindex \absolute
-If you are using absolute music inside of relative, you'll need to
-mark the absolute music explicitly with @code{\absolute} to stop
-it from becoming part of the relative music:
+To use absolute mode inside of @code{\relative}, put the absolute
+music inside @code{\fixed c @{ @dots{} @}} and the absolute pitches
+will not be part of the relative music:
 
 @lilypond[verbatim,quote]
-\relative { c'4 \absolute { f'' g'' } c }
+\relative c' {
+  c4 \fixed c { f'' g'' } c |
+  c4 \fixed c'' { f g } c
+}
 @end lilypond
 
 @node After the tutorial
index e8c82d8d2caa43e11c06936bad7aee77dfd86762..c706a3a95125475a47f41aff58bcdac580154601 100644 (file)
@@ -79,25 +79,38 @@ octave.
 @lilypond[verbatim,quote]
 {
   \clef treble
-  c'4 c'' e' g
-  d''4 d' d c
+  c'4 e' g' c''
+  c'4 g b c'
   \clef bass
-  c,4 c,, e, g
-  d,,4 d, d c
+  c,4 e, g, c
+  c,4 g,, b,, c,
 }
 @end lilypond
 
-@funindex absolute
-@funindex \absolute
-Music can be marked explicitly as being in absolute octave
-notation by preceding it with @code{\absolute}:
+@funindex fixed
+@funindex \fixed
+Common octave marks can be entered just once on a reference pitch
+after @code{\fixed} placed before the music.  Pitches inside
+@code{\fixed} only need @code{'} or@tie{}@code{,} marks
+when they are above or below the octave of the reference pitch.
 
-@example
-\absolute @var{musicexpr}
-@end example
+@lilypond[verbatim,quote]
+{
+  \fixed c' {
+    \clef treble
+    c4 e g c'
+    c4 g, b, c
+  }
+  \clef bass
+  \fixed c, {
+    c4 e g c'
+    c4 g, b, c
+  }
+}
+@end lilypond
 
-will be interpreted in absolute octave entry mode regardless of
-the context it appears in.
+Pitches in the music expression following @code{\fixed} are
+unaffected by any enclosing @code{\relative}, discussed next.
 
 @seealso
 Music Glossary:
diff --git a/input/regression/relative.ly b/input/regression/relative.ly
new file mode 100644 (file)
index 0000000..e5f0fae
--- /dev/null
@@ -0,0 +1,12 @@
+\header {
+  texidoc = "Notes are entered using absolute octaves,
+octaves relative to the previous note, or relative to a fixed octave."
+  }
+\version "2.19.20"
+
+\new Staff {
+  \relative c'' { c4 g \absolute { c'' } e' \fixed c'' { g1 }}
+  \fixed c'' { c4 \fixed c' { g } c e \relative c''' { g1 } }
+  \clef bass \relative c { c4 g c e g1 }
+  \fixed c { c4 g, c e g1 }
+}
index beb8bd10e497a20937066c8372f691a264928487..31e7a4d51f88dcd41a184f5ed91ca8f35413260c 100644 (file)
@@ -36,7 +36,7 @@ absolute =
    (ly:music?)
    (_i "Make @var{music} absolute.  This does not actually change the
 music itself but rather hides it from surrounding @code{\\relative}
-commands.")
+and @code{\\fixed} commands.")
    (make-music 'RelativeOctaveMusic 'element music))
 
 acciaccatura =
@@ -429,6 +429,20 @@ finger =
             (if (number? finger) 'digit 'text)
             finger))
 
+fixed =
+#(define-music-function (parser location pitch music)
+   (ly:pitch? ly:music?)
+   (_i "Use the octave of @var{pitch} as the default octave for @var{music}.")
+   (let ((octave-marks (1+ (ly:pitch-octave pitch))))
+     (cond ((not (= 0 octave-marks))
+            (ly:music-transpose music (ly:make-pitch octave-marks 0 0))
+            ;;In order to leave unchanged the notes in any enclosed
+            ;; \absolute or \fixed or \relative, make a cancelling shift
+            (map (lambda (m)
+                   (ly:music-transpose m (ly:make-pitch (- octave-marks) 0 0)))
+                 (extract-named-music music 'RelativeOctaveMusic)))))
+   (make-music 'RelativeOctaveMusic 'element music))
+
 footnote =
 #(define-music-function (parser location mark offset footnote item)
    ((markup?) number-pair? markup? symbol-list-or-music?)
index 30903edb7b0fe867b6f6319e39c6aa8dc62d659c..cb6af4538b33daec3ad8b1d532c9b3a459d4987c 100644 (file)
@@ -478,7 +478,7 @@ Syntax: @code{\\unset @var{context}.@var{prop}}")
         ))
 
     (RelativeOctaveMusic
-     . ((description . "Music that was entered in relative octave notation.")
+     . ((description . "Music in which the assignment of octaves is complete.")
         (to-relative-callback . ,ly:relative-octave-music::relative-callback)
         (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
         (length-callback . ,ly:music-wrapper::length-callback)