lilypond-user
[Top][All Lists]
Advanced

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

Re: Problem with hemiola notation


From: Thomas Morley
Subject: Re: Problem with hemiola notation
Date: Mon, 16 Sep 2013 00:32:25 +0200

2013/9/15 Thomas Morley <address@hidden>:
> 2013/9/15 Alan McConnell <address@hidden>:
>> First of all, my thanks to both David K and Robert S for
>> their quick responses!
>>
>> On Sun, Sep 15, 2013 at 05:25:33PM +0200, David Kastrup wrote:
>>> Alan McConnell <address@hidden> writes:
>>>
>>
>>> > (start)--------------------------
>>> > \version "2.16.0"
>>> >
>>> > global =  {
>>> >   \key d \minor
>>> >   \time 3/4
>>> > }
>>> >
>>> > %  Here is a "hemiola"
>>> >
>>> > |ees4 d c | c4. d8 bes4. | a8 a4. g8 | g2 r4 |
>>> >                        ^
>>> >                 ------------------------(finish)
>>                     I wish the word "snippet" were available to
>>                     denote the above.  But Snippet is now a
>>                     well-established term in the copious Lilypond
>>                     documentation.  So I had to say "extract".
>>
>>
>>> >
>>> > The '^' marks the dot on the dotted Bb that I wish
>>> > to move into the next bar.  The part compiles just
>>> > fine;
>>>
>>> No, it doesn't.
>>           <G>  Not the above excerpt, for sure.  But the
>>           part from which this is taken compiles fine;
>>           I've printed out the resulting .pdf and friends
>>           here in Silver Spring and in Los Angeles have
>>           played them.
>>
>>
>>
>>> > Of course I could tie over the bes4 into a bes8 in
>>> > the next measure, but I thought it would be nice to
>>> > transcribe just as the Bach Gesellschaft has it.
>>>
>>> You'll be surprised at how few of the readers here have the Dover scores
>>> available,
>>         <G> No I wouldn't.  I'll bet almost all Lilypond users
>>         have heard of Bach, but why should readers without
>>         special needs or interest have Bach Dover scores?  But I
>>         would expect tho folks who do have such scores to easily
>>         recognize my problem from the "extract" that I gave, and
>>         reproduce above.  It is a notation that I've seen often
>>         elsewhere, but at the moment I can cite only the Bach
>>         Gesellschaft editions.
>>
>>
>>> so it might be useful to actually include a scan of what you
>>> are asking for: it should not require more than about three notes, so
>>> neither mailing list bandwidth nor copyright should be problematic here.
>>           I am Attaching a .jpg of a small chunk of a download that
>>           I got from IMSLP, that illustrates the Bach Gesellschaft
>>           practice.  I am fairly sure that the  Mailman SW will
>>           strip this Attachment, but I hope it will go through to
>>           Messrs K and S.   If anyone else here is interested,
>>           lemme know; and I'll be glad to send this small .jpg.
>>
>> Again thanks, and I hope for illumination from any/all available
>> experts.
>>
>> Alan
>>
>> --
>> Alan McConnell :  http://globaltap.com/~alan/
>>    Know thyself.  If you need help, call the C.I.A.
>>    Whenever anyone says, "theoretically", they really mean, "not really".
>>
>> _______________________________________________
>> lilypond-user mailing list
>> address@hidden
>> https://lists.gnu.org/mailman/listinfo/lilypond-user
>>
>
> Hi Alan,
>
> I've got the image, thanks.
> Now it's clear what you deserve.
>
> Maybe you find my code below helpful.
> Though let me write some remarks before.
>
> I know no way to let LilyPond checking bars without complain for code like:
> \relative c' { \time 3/4 c4. d8 bes4. | a8 a4. g8 | }
> Even if you use the "Completion_heads_engraver".
>
> If you want barchecks you have to write:
> \relative c' { \time 3/4 c4. d8 bes4~ | bes8 a8 a4. g8 | }
>
> My code now tweaks the Tie and the right bound of it. Making the Tie
> transparent, replacing the right NoteHead by a dot, making its Flag
> and Stem transparent, too.
>
> Drawbacks/limitations:
> You have to insert \noBeam before the next Note.
> I didn't manage to code 'no-ledgers for the tied Note from inside the
> Tie-override for unknown reasons. You'll have to insert the relevant
> override in case the tied NoteHead has Ledgers.
>
> So far it works for all tested versions (2.12.3 up to 2.17.26)
>
> \version "2.16.2"
>
> tiedToDot =
> \once \override Tie #'before-line-breaking =
>   #(lambda (grob)
>     (let* ((right-bound (ly:spanner-bound grob RIGHT))
>            (dot
>               (ly:font-get-glyph (ly:grob-default-font right-bound) 
> "dots.dot"))
>            (dot-X-length
>               (interval-length (ly:stencil-extent dot X)))
>            (staff-pos (ly:grob-property right-bound 'staff-position))
>            (stem (ly:grob-object right-bound 'stem))
>            (right-note-stencil (ly:grob-property right-bound 'stencil))
>            (right-note-head-X-length
>               (interval-length (ly:stencil-extent right-note-stencil X)))
>            (flag (ly:grob-object stem 'flag))
>            (dir (if (even? staff-pos)
>                     -2
>                     0))
>            (x-offset
>              (/ (- right-note-head-X-length dot-X-length) 2))
>            (new-note-stencil
>               (ly:stencil-translate-axis
>                  (ly:stencil-aligned-to dot Y dir)
>                  x-offset
>                  X)))
>
>     (ly:grob-set-property! grob 'transparent #t)
>     (if (not (null? stem)) (ly:grob-set-property! stem 'stencil 
> point-stencil))
>     (if (not (null? flag)) (ly:grob-set-property! flag 'stencil 
> point-stencil))
>     ;; No idea why it doesn't work:
>     (ly:grob-set-property! right-bound 'no-ledgers #t)
>     (ly:grob-set-property! right-bound 'stencil new-note-stencil)))
>
>
> \relative c''
> <<
>    { \tiedToDot d4~ d8\noBeam d }
>    \\
>    { d,4 d8 d }
>>>
>
> mus =
> \relative c'' {
>     \key d\minor
>     \time 3/4
>     ees4 d c |
>     c4. d8 \tiedToDot bes4~ |
> %    \once \override NoteHead #'no-ledgers = ##t
>     bes8 \noBeam a8 a4. g8 |
>     g2 r4 |
> }
>
> \new Staff { \mus \transpose c c' \mus }
>
>
>
> HTH,
>   Harm

Hi again,

I now come up with a (hopefully) improved version.
It is a function which takes a dotted(!) note as argument replacing it
with the main note and a dot (instead of a tied note)

\version "2.16.2"
% Does not work with 2.14.2 !

foo =
#(define-music-function (parser location music) (ly:music?)
  "
   Replaces a dotted note with a single main note and (a tied) single additional
   note.
   The Tie will be transparent.
   The second note will appear as dot, without Stem, Flag, Beam, Articulations.
   Barchecks should not be used.
   Limitation: does not work for chords.
  "
 (let* ((duration (ly:music-property music 'duration))
        (dot-count (if (ly:duration? duration)
                       (ly:duration-dot-count duration)
                       0)))
  ;; Apply it only if the note is a single-dotted note
  (if (= dot-count 1)
      (let* ((m-1 (ly:music-deep-copy music))
             (m-2 (ly:music-deep-copy music))
             (dur-log (ly:duration-log duration))
             (first-dur (ly:make-duration dur-log))
             (second-dur (ly:make-duration (+ dur-log 1))))

       ;; Defines a procedure to replace the given NoteHead with a dot.
       (define (note-head->dot note-head)
          (let* ((stencil (ly:grob-property note-head 'stencil))
                 (note-head-X-length
                    (interval-length (ly:stencil-extent stencil X)))
                 (dot (ly:font-get-glyph (ly:grob-default-font note-head)
                                         "dots.dot"))
                 (dot-X-length (interval-length (ly:stencil-extent dot X)))
                 (staff-pos (ly:grob-property note-head 'staff-position))
                 (stem (ly:grob-object note-head 'stem))
                 (flag (ly:grob-object stem 'flag))
                 (accidental-grob (ly:grob-object note-head 'accidental-grob))
                 ;; Get values for translating the dot-stencil to avoid putting
                 ;; it on a staff-line.
                 ;; Because ledger-lines will be removed, we return 0, if the
                 ;; NoteHead is above or below the staff.
                 (dir (if (and (even? staff-pos)
                               (not (> staff-pos 5))
                               (not (< staff-pos -5)))
                          -2
                          0))
                 ;; Calculate a value to center the dot with NoteHeads from
                 ;; other voices
                 (x-offset (/ (- note-head-X-length dot-X-length) 2))
                 (new-note-stencil
                    (ly:stencil-translate-axis
                       (ly:stencil-aligned-to dot Y dir)
                       x-offset
                       X)))
             ;;  No Stem, Flag or Accidental!
             (if (not (null? stem))
                 (ly:grob-set-property! stem 'stencil point-stencil))
             (if (not (null? flag))
                 (ly:grob-set-property! flag 'stencil point-stencil))
             (if (not (null? accidental-grob))
                 (ly:grob-set-property! accidental-grob 'stencil point-stencil))
             ;; Replace the NoteHead with a centered dot
             (ly:grob-set-property! note-head 'stencil new-note-stencil)))

       ;; Build the notes to insert, replacing the dotted one.
       (ly:music-set-property! m-1 'duration first-dur)
       (ly:music-set-property! m-2 'duration second-dur)
       ;; In order not to disturb midi we insert a Tie here, making it
       ;; tranparent later.
       (let ((articulations (ly:music-property m-1 'articulations)))
          (ly:music-set-property! m-1 'articulations
                                      (append (list (make-music 'TieEvent))
                                              articulations)))
       ;; No Beam!
       ;; Also, we don't want other elements in 'articulations of the second
       ;; note, let it replaces them.
       (ly:music-set-property! m-2 'articulations
                                   (list (make-music 'BeamForbidEvent)))
       #{
              \override Tie #'transparent = ##t
              $m-1
              \once \override NoteHead #'no-ledgers = ##t
              \once \override NoteHead #'before-line-breaking = #note-head->dot
              $m-2
       #})
       music)))

%%%%%%%%%%%%%%%%%%%%%%%%%%
% EXAMPLES
%%%%%%%%%%%%%%%%%%%%%%%%%%

#(set-global-staff-size 16)

\paper {
    indent = 0
    line-width = 60
}

\relative c''
<<
   { \foo d4.--^"xy"-1\4 d8 }
   \\
   { d,4 d8 d }
>>

mus =
\relative c''' {
    c4. d8 \foo bes4. % | % No barcheck!
    a8 a2 |
}

\new Staff {
    \time 3/4
    \mus \break
    \transpose c  bes, \mus \break
    \transpose c  a, \mus \break
    \transpose c  g, \mus \break
    \transpose c  f, \mus \break
    \transpose c  e, \mus \break
    \transpose c  d, \mus \break
    \transpose c  c, \mus \break
    \transpose c  bes,, \mus \break
    \transpose c  a,, \mus \break
    \transpose c  g,, \mus \break
    \transpose c  f,, \mus \break
    \transpose c  e,, \mus \break
    \transpose c  d,, \mus \break
    \transpose c  c,, \mus \break
}


Limitations:
-needs 2.16.2 or higher
-doesn't work for chords containing more than one note.


HTH,
  Harm



reply via email to

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