lilypond-devel
[Top][All Lists]
Advanced

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

Re: Issue 3174: Implement \accidental markup and \pitched command for tr


From: dak
Subject: Re: Issue 3174: Implement \accidental markup and \pitched command for transposable accidental markups (issue 7323060)
Date: Thu, 14 Feb 2013 09:21:07 +0000

Reviewers: Trevor Daniels, thomasmorley65,

Message:
On 2013/02/13 23:27:55, thomasmorley65 wrote:
On 2013/02/13 22:56:30, Trevor Daniels wrote:
> I definitely prefer the alternative you suggest in para 3.
> You would not then need the warning, which is only necessary due to
the
> complicated 2-stage interface.

I'd second.

Here is the deal: I can rename the current \pitched to \withPitch
which is quite in line with \withMusicProperty.
\withPitch/\accidental is a basic mechanism for passing transposition
information from music to markups.

The questions are

a) is this mechanism sufficient for pitched ornaments?
b) are there useful applications apart from pitched ornaments?

If both answers are "no", this approach does not lead anywhere.  With
regard to question a), the main question I see here is "should this be
tied into the accidental rule system".  If it isn't, it remains the
user's task to properly distribute accidentals and cautionaries.  Now
fortunately, the question "in-scale" or "out-of-scale" remains
constant under _chromatic_ transposition (and modal transposition is
quite less complete), so while this is cumbersome, it still tackles
the basic problem of transposability.  It also begs the question
whether we should not just be passing "pitch" but also
"force-accidental" and "cautionary" and have the \accidental markup
heed them.

Actually, force-accidental does not make much sense since setting it
to #f would mean having to check whether the current accidental rules
would demand an accidental, and that is a check that is, I think,
beyond the design of this feature as long as "should this be tied into
the accidental rule system" can be answered with "no".

So at any rate, the question this patch answers is the question "can
we pass information about transposed accidentals through to markups",
and the answer is "yes".  "Is this a good interface to pitched
ornamentations" has been answered "no", and "can it be a good building
block for a good interface to pitched ornamentations" will depend on
what we agree on being a good interface to pitched ornamentations.

So the message is "we can do", but we still need to figure out _what_
we can do.  Proposals?


Description:
Issue 3174: Implement \accidental markup and \pitched command for
transposable accidental markups

This is a building block for creating pitched ornaments behaving
sensibly under transposition.

It would be arguable to define \pitched differently so that it works
only on ornaments and does the stacking itself, like
c^\pitched\trill des

and instead give the current version of \pitched a name like \pitchify.

As it stands, here are the implemented meanings:

\accidental markup:
Draw an accidental based on the @var{pitch} property of the causing
event.  This is typically set in music using the (transposable)
@code{\pitched} command, like

@lilypond[verbatim,quote]
melody = \relative c'
  { \key c\major c2^\trill^\pitched des -\markup \accidental d! }
\new Staff { \melody }
\new Staff { \transpose c' e' \melody }
@end lilypond

\pitched music function: arguments pitch and music:
"Give @var{music} a pitch of @var{pitch}.

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

Affected files:
  M ly/music-functions-init.ly
  M scm/define-markup-commands.scm


Index: ly/music-functions-init.ly
diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly
index c063b9585da50b8d9325f73aab5ebb4c0c45cd6e..f23e19a7c00d007793417ac490c23fe5063123bf 100644
--- a/ly/music-functions-init.ly
+++ b/ly/music-functions-init.ly
@@ -963,6 +963,13 @@ partial =
                         'Timing)
      'Score))

+pitched =
+#(define-music-function (parser location pitch music)
+   (ly:pitch? ly:music?)
+   (_i "Give @var{music} a pitch of @var{pitch}.")
+   (set! (ly:music-property music 'pitch) pitch)
+   music)
+
 pitchedTrill =
 #(define-music-function
    (parser location main-note secondary-note)
Index: scm/define-markup-commands.scm
diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm
index 7dd0f967ed26bea6631292e2832ad56efd5e9d98..23c2ae239e9bb83f745bdfed51ccc902bd61fd5b 100755
--- a/scm/define-markup-commands.scm
+++ b/scm/define-markup-commands.scm
@@ -2750,6 +2750,34 @@ the possible glyphs.

     glyph))

+(define-markup-command (accidental layout props)
+  ()
+  #:category music
+  #:properties ((cause))
+  "Draw an accidental based on the @var{pitch} property of the causing
+event.  This is typically set in music using the (transposable)
address@hidden command, like
+
address@hidden,quote]
+melody = \\relative c'
+  { \\key c\\major c2^\\trill^\\pitched des -\\markup \\accidental d! }
+\\new Staff { \\melody }
+\\new Staff { \\transpose c' e' \\melody }
address@hidden lilypond"
+  (let* ((event (cond ((ly:grob? cause) (event-cause cause))
+                      ((ly:stream-event? cause) cause)
+                      (else #f)))
+         (pitch (and event (ly:event-property event 'pitch))))
+    (if (ly:pitch? pitch)
+        (interpret-markup layout props
+                          (markup #:musicglyph
+                                  (assoc-get (ly:pitch-alteration pitch)
+ standard-alteration-glyph-name-alist "")))
+        (begin
+          (ly:warning (_ "No pitch found.  Have you forgot \\pitched?"))
+          (interpret-markup layout props
+                            (make-natural-markup))))))
+
 (define-markup-command (doublesharp layout props)
   ()
   #:category music





reply via email to

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