lilypond-user
[Top][All Lists]
Advanced

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

Re: \makeOctaves broken?


From: Jan-Peter Voigt
Subject: Re: \makeOctaves broken?
Date: Thu, 19 Apr 2012 12:32:27 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:11.0) Gecko/20120327 Thunderbird/11.0.1

Hello Urs,

the articulations are were copied to the EventChord - so I added copying the articulations from NoteEvent to EventChord. That means, they should not stay in the NoteEvents when getting wrapped into the EventChord:

--snip--
\version "2.15.36"

#(define (with-octave-up m octave)
        (let* ((duration (ly:music-property m 'duration))
               (old-pitch (ly:music-property m 'pitch))
               (new-pitch (ly:make-pitch
                   (- octave 1)
                   (ly:pitch-notename old-pitch)
                   (ly:pitch-alteration old-pitch))))
              ; create NoteEvents using duration and pitch only
(list (make-music 'NoteEvent 'duration duration 'pitch old-pitch) (make-music 'NoteEvent 'duration duration 'pitch new-pitch))))

#(define (octavize music t)
        (map-some-music
          (lambda (m)
                  (cond ((music-is-of-type? m 'event-chord)
                         (set!
                           (ly:music-property m 'elements)
                           (append-map!
                             (lambda (n)
                                     (if (music-is-of-type? n 'note-event)
                                         (with-octave-up n t)
                                         (list n)))
                             (ly:music-property m 'elements)))
                         m)
                        ((music-is-of-type? m 'note-event)
(make-event-chord (append (with-octave-up m t) (ly:music-property m 'articulations))))
                        (else #f)))
          music))

makeOctaves = #(define-music-function (parser location arg mus)
  (integer? ly:music?)
  (octavize mus arg))

\new Staff {
  \relative c'
  {
    \time 3/8
    \key gis \minor
    \makeOctaves #1  { dis8(\f e-. dis')~ dis8.( cis16 b8 }
    \makeOctaves #-1 { ais' gis dis) cis( dis <dis gis'>--)\p }
  }
}
--snip--

This is the version for use in relative sections. If you have an absolute sequence, it has to be changed to David Kastrups version.

HTH
Cheers, Jan-Peter


On 19.04.2012 11:51, Urs Liska wrote:
Hi Jay,

Thanks for the link. I'l look into it, but am practically sure that I won't be able to fix anything. As mentioned I don't have any experience with Scheme.

Best
Urs

BTW: The current piece not only has plenty of octaves (one voice is virtually octaves-only), but each octave has a -. articulation on it :-(

Am 19.04.2012 04:23, schrieb Jay Anderson:
On Wed, Apr 18, 2012 at 4:44 PM, Urs Liska<address@hidden>  wrote:
I was quite happy to find the function \makeOctaves in the LSR.

But now it seems to be broken - there is no error message, but the function
doesn't do anything (2.15.36).
As I don't know _anything_ about Scheme I can't do more than ask if anybody
has an idea what has changed with LilyPond so that this function is now
broken?
David Kastrup did a quick fix a few months
back:http://lists.gnu.org/archive/html/lilypond-user/2012-03/msg00114.html

I just tried it and it had a few problems:
- it didn't work within a relative section. It only worked within
relative sections before.
- Slurs and dynamics attached to single notes are lost during the
conversion to chords.

Below fixes the relative problem, but I haven't spent enough time on
it to figure out the second problem. That will take a little bit more
time to understand the internal structure changes which I don't have
at the moment. Perhaps you can take a look and make it work.

-----Jay

\version "2.15.35"

#(define (with-octave-up m octave)
   (let* ((old-pitch (ly:music-property m 'pitch))
          (new-note (ly:music-deep-copy m))
          (new-pitch (ly:make-pitch
                       (- octave 1)
                       (ly:pitch-notename old-pitch)
                       (ly:pitch-alteration old-pitch))))
     (set! (ly:music-property new-note 'pitch) new-pitch)
     (list m new-note)))

#(define (octavize music t)
   (map-some-music
     (lambda (m)
       (cond ((music-is-of-type? m 'event-chord)
              (set!
                (ly:music-property m 'elements)
                (append-map!
                  (lambda (n)
                    (if (music-is-of-type? n 'note-event)
                      (with-octave-up n t)
                      (list n)))
                  (ly:music-property m 'elements)))
              m)
             ((music-is-of-type? m 'note-event)
              (make-event-chord (with-octave-up m t)))
             (else #f)))
     music))

makeOctaves = #(define-music-function (parser location arg mus)
(integer? ly:music?)
  (octavize mus arg))

\relative c'
{
   \time 3/8
   \key gis \minor
   \makeOctaves #1  { dis8(\f e dis')~ dis8.( cis16 b8 }
   \makeOctaves #-1 { ais' gis dis) cis( dis<dis gis'>)\p }
}

_______________________________________________
lilypond-user mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user


_______________________________________________
lilypond-user mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user





reply via email to

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