lilypond-user
[Top][All Lists]
Advanced

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

Re: Scheme function for alternate tagged swing stopped working


From: Thomas Morley
Subject: Re: Scheme function for alternate tagged swing stopped working
Date: Sun, 21 Dec 2014 11:29:50 +0100

2014-12-21 8:29 GMT+01:00 Christopher R. Maden <address@hidden>:
> I wrote a function \sw, against LilyPond 2.12, a while back.
>
> It takes music as an argument, and returns two copies of the music, one
> tagged 'layout and one tagged 'midi.  The 'midi tagged one has eighth
> notes changed to quarter-eighth triplets (i.e., swung).
>
> I’ve run it through convert-ly a couple of times, and now, against
> 2.16.2, it doesn’t work.  I’m not sure when it stopped working; I was
> setting reels fast enough that it was hard to hear the difference.  But
> now I’m setting some hornpipes, and the difference is very clear.
>
> The file that defines the swing function can be found at <URL:
> http://crism.maden.org/music/swing.ly >.
>
> Attached is a simple test file and its output.  The first staff should
> have the same passage twice, but swung the second time.  The second
> staff should be straight, and the third swung.  Instead, you’ll see that
> all four copies are identical, and straight.
>
> It seems that the music internals have changed but I can’t put my finger
> on how.  Any pointers would be welcome.

Hi Christopher,

it's due to the changes for 'EventChord. Until 2.15.x (don't remember
the exact version) every single note was wrapped into an 'EventChord.

Look at the output from:

\displayMusic { d8 e }

2.14.2 returns:

(make-music
  'SequentialMusic
  'elements
  (list (make-music
          'EventChord
          'elements
          (list (make-music
                  'NoteEvent
                  'duration
                  (ly:make-duration 3 0 1 1)
                  'pitch
                  (ly:make-pitch -1 1 0))))
        (make-music
          'EventChord
          'elements
          (list (make-music
                  'NoteEvent
                  'duration
                  (ly:make-duration 3 0 1 1)
                  'pitch
                  (ly:make-pitch -1 2 0))))))

2.16.2 and later returns:

(make-music
  'SequentialMusic
  'elements
  (list (make-music
          'NoteEvent
          'duration
          (ly:make-duration 3 0 1)
          'pitch
          (ly:make-pitch -1 1 0))
        (make-music
          'NoteEvent
          'duration
          (ly:make-duration 3 0 1)
          'pitch
          (ly:make-pitch -1 2 0))))

A quick fix would be to wrap the music into EventChords again.

sw = #(define-music-function (parser location notes) (ly:music?)
       (let ((swing (make-music
                     'SequentialMusic
                     'elements
                     (list
                      (make-music
                       'RelativeOctaveMusic
                       'element
                       (make-music
                        'SequentialMusic
                        'elements
                        (swing-eighths
                         (ly:music-deep-copy
                          (ly:music-property
                           (ly:music-property
                            (car (ly:music-property
                                  (event-chord-wrap! notes)  ;; !!!!!!!!
                                  'elements))
                            'element)
                           'elements))
                         '()
                         #f)))))))
        #{
          \tag #'layout { $notes }
          \tag #'midi { $swing }
        #}
      )
     )


Alternatively rewrite the functions to work with 'NoteEvent and 'EventChord.




HTH,
  Harm



reply via email to

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