Hi, Nicolas,
I recognized two potential sources of trouble with your new q command.
(Excellent! Wonderful! Tremendous! idea, by the way.)
I might have a solution for one of them, but I don't trust myself at all.
Firstly, the one I have no clue about. Is it reasonable to hope for an
addition s.t. q ignores preceding rests or skips? If I want to repeat
those, I can just write r or s, but it'd be great if they don't
overwrite the previous-chord register. E.g. for the following
{ <c c,>8 q r q q q r q }
instead of
{ <c c,>8 q r <c c,> q q r <c c,> }
? AFAICS, the previous-chord is set during parsing/lexing (?), so this
once more needs coding in the C++ part, and this is well beyond my scope
right now.
Secondly, q behaves somewhat unintuitive in relative mode when repeating
chords where the octave changes for the "main" note (is there a better
name for this one?).
When I enter
\relative c { <c c,> <c' c,> q }
I expect the outcome to be (in absolute mode)
{ <c c,> <c' c> <c' c> },
but instead it's
{ <c c,> <c' c> <c'' c'> }.
I kind of seem to have a fix for this - which is a very naive "I'm
feeling lucky"-modification of your default-repeat-chord repetition
function. I attach it, and it seems to work well, but to be honest - I
have not the slightest clue why, and I don't trust it at all. I'd
probably feel better if I had (ly:make-pitch 0 ...) in line 13 (which
was my initial guess), but it might well be false trust also then.
And, of course, what's missing (if at all possible without C++ hacking)
is to find out whether the function is called inside a relative or an
absolute context, thus choosing the appropriate repetition function. I'm
not even sure if that's reasonable, since I don't know when the function
actually gets evaluated, and, alas, one can define music in absolute
context and put a \relative before it later on. See \parallelMusic,
which suffers from the same problem, as I understand.
Okay, looking forward to read your reply,
Cheers,
Alexander
#(define-public (relative-repeat-chord previous-chord duration articulations)
"Copy the previous chord, filter out events which are not notes, set the
chord duration, add articulations."
(let ((new-chord (ly:music-deep-copy previous-chord)))
(set! (ly:music-property new-chord 'elements)
(append! articulations
(let ((notes (filter (lambda (event)
(eqv? (ly:music-property event 'name) 'NoteEvent))
(ly:music-property new-chord 'elements))))
(if (not (null? notes))
(let ((pitch (ly:music-property (car notes) 'pitch)))
(set! (ly:music-property (car notes) 'pitch)
(ly:make-pitch -1 (ly:pitch-notename pitch) (ly:pitch-alteration pitch)))))
notes)))
(for-each (lambda (event)
(if (ly:duration? (ly:music-property event 'duration))
(set! (ly:music-property event 'duration) duration)))
(ly:music-property new-chord 'elements))
new-chord))
#(ly:parser-set-repetition-symbol parser 'q)
#(ly:parser-set-repetition-function parser relative-repeat-chord)
\relative c { <f'' f,,> q q q | <a, e a'> q q q }
_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel