lilypond-user
[Top][All Lists]
Advanced

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

Re: Autochange snippet broken?


From: David Kastrup
Subject: Re: Autochange snippet broken?
Date: Sat, 02 Jun 2012 06:28:21 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux)

David Kastrup <address@hidden> writes:

> Valentin Villenave <address@hidden> writes:
>
>> Hi everybody,
>> (lots of awesome talks on -user these days!)
>>
>> I'm wondering what has gone wrong with this:
>> http://lsr.dsi.unimi.it/LSR/Item?id=724
>> a.k.a. "Autochange with a different pitch" (for the search engine's sake).
>> It used to work with 2.15.30 or so, but with 2.15.39 it doesn't work
>> anymore. (My guess would be: something about the EventChord wrapper
>> recently removed.)
>
> Shouldn't be that: this works by playing the stream events, and those
> remain the same.  It is more likely that the AutoChange broke as a
> whole.  I'll take a look.

Much more banal, and actually you were right.  The internals are working
fine, it is just the user interface that broke down.  Change

autochangeWithPitch =
#(define-music-function (parser location ref music) (ly:music? ly:music?)
      (let* ((note (car (ly:music-property ref 'elements)))
             (ref-pitch (ly:music-property note 'pitch)))
  (make-autochange-music parser music
    (if (ly:pitch? ref-pitch) ref-pitch #f))))

to

autochangeWithPitch =
#(define-music-function (parser location ref music) ((ly:pitch?) ly:music?)
  (make-autochange-music parser music ref))

Or straight to

autochange = ...

since the pitch argument in the changed function is optional (this would
not work if the music to autochange looks like c'4 or so, namely is just
a single note-event, but so what).

I actually would write the whole snippet as

autochange =
#(define-music-function (parser location ref music) ((ly:pitch?) ly:music?)
  (let ((mus (make-autochange-music parser
              (if ref #{ \transpose $ref c' $music #} music))))
   (set! (ly:music-property mus 'element) music)
   mus))

\context PianoStaff <<
 \context Staff = "up" {
   \autochange a \new Voice << \relative c' {
       g4 c e d c r4 a g } >>
 }
 \context Staff = "down" {
   \clef bass
   s1*2
 }
>>

There is no point in meddling with internals for a task like this.  If
this was supposed to replace the built-in definition, one would probably
change the internals for a variable split point.  But a user-level
snippet?  Using \transpose here is certainly good enough.

-- 
David Kastrup




reply via email to

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