lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: absolute pitch entry: accept an offset octave (issue 235010043 by ad


From: k-ohara5a5a
Subject: Re: absolute pitch entry: accept an offset octave (issue 235010043 by address@hidden)
Date: Mon, 04 May 2015 03:10:44 +0000

Reviewers: dak, lemzwerg, Trevor Daniels, Dan Eble, pwm,

Message:
On 2015/05/03 08:20:03, Trevor Daniels wrote:
I'd prefer the syntax and options to parallel those of
\relative.  That is, an optional prefix pitch to indicate
the starting octave, and taking the starting octave from
the first contained note if the prefix is omitted.  That
would then become an attractive alternative to \relative.

I thought about this, but
1) \absolute { f'' g'' } is already documented to mean {f'' g''}
2) in contrast to \relative, which defines an order of the pitches
anyway (order of appearance in a depth-first search of the music
expression) and which needs a concept of a starting pitch so it had
might as well be the first pitch,
  aa = \new Voice { \voiceOne r2 c''2}
  bb = \new Voice { \voiceTwo c,4 e g c}
  \new Staff \relative << \aa \bb g4 >>
a goal of \absolute was to allow re-ordering of contents without
changing the pitches.


Description:
absolute pitch entry: accept an offset octave; issue 4366

Please review this at https://codereview.appspot.com/235010043/

Affected files (+23, -5 lines):
  A input/regression/relative.ly
  M ly/music-functions-init.ly


Index: input/regression/relative.ly
diff --git a/input/regression/relative.ly b/input/regression/relative.ly
new file mode 100644
index 0000000000000000000000000000000000000000..a1dfed55d7a796b91b0f391c42eb4975115772fb
--- /dev/null
+++ b/input/regression/relative.ly
@@ -0,0 +1,12 @@
+\header {
+  texidoc = "Notes are entered using absolute octaves,
+or octaves relative to the previous note."
+  }
+\version "2.19.20"
+
+\new Staff {
+  \relative c'' { c4 g c e g1 }
+  \absolute c'' { c4 g, c e g1 }
+  \clef bass \absolute c { c4 g, c e g1 }
+  \absolute { c4 g, c e g1 }
+}
Index: ly/music-functions-init.ly
diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly
index cbba26a65256a366e3c2793cebb641e91d18266b..22e1a2dccb6417e6672bb9259d04224130946796 100644
--- a/ly/music-functions-init.ly
+++ b/ly/music-functions-init.ly
@@ -32,12 +32,18 @@
 %% TODO: using define-music-function in a .scm causes crash.

 absolute =
-#(define-music-function (parser location music)
-   (ly:music?)
-   (_i "Make @var{music} absolute.  This does not actually change the
-music itself but rather hides it from surrounding @code{\\relative}
+#(define-music-function (parser location pitch music)
+   ((ly:pitch?) ly:music?)
+   (_i "Make @var{music} absolute, optionally raised or lowered
+by the nubmer of octave marks on @var{pitch}.  Wrapping as
address@hidden hides it from surrounding @code{\\relative}
 commands.")
-   (make-music 'RelativeOctaveMusic 'element music))
+   (let ((m (if pitch
+                (ly:music-transpose
+                    music
+                    (ly:make-pitch (1+ (ly:pitch-octave pitch)) 0 0))
+                music)))
+     (make-music 'RelativeOctaveMusic 'element m)))

 acciaccatura =
 #(def-grace-function startAcciaccaturaMusic stopAcciaccaturaMusic





reply via email to

[Prev in Thread] Current Thread [Next in Thread]