Thanks a lot.
You help advance a lot, but still i have problems to resolve.
(First question is : is it better to answer before or after what we have written before ?)
I try to use optional arguments, but may be it would not be possible from within LilyPond code call this function. I give that example :
upper = {
\time 6/8
...
<g' b'>4 <g' b'>8 <b' d''>8. <a' c''>16 <g' b'>8 |
<f' a'>8. <g' b'>16 <f' a'>8 <d' f'>4 r8 |
% \MTKey JM d'4 Hello ##t e'4 #'(9 . 8)
\MTKeyExp JM d'4 Hello ##t e'4 2 3 %ok
\MTKeyExp JM d'4 Hello ##t %wrong because following c' d' e'
c' d' e'
}
Now i give definition of MTKeyExp :
MTKeyExp = #(define-music-function
(parser location name mainNote textBelowMain cyclic . rest)
(string? ly:music? string? boolean? ly:music? number? number?)
(let-optional rest ((note1 d'4) (num1 2) (den1 1))
#{
\key c \major
\cadenzaOn
...
\setAlterationNote #num1 #den1 #note1
...
\setRightBracket s4
\cadenzaOff
...
#}
))
My idea was to use a conditional call giving note1 a default value of null :
setAlterationNote =
#(define-music-function
(parser location num den note)
(number? number? ly:music?)
(let
;;((stencil (ly:stencil-add (ly:stencil-add altV (getAltPlaceNumStencil 1 2)) (getAltPlaceNumStencil 2 -3))))
((stencil (ly:stencil-add altV
(do ((primes '(2 3 5 7 11 13 17 19 23) (cdr primes))
(place 0 place)
(st altV (ly:stencil-add st (getAltPlaceNumStencil place (- (ntimesdivide num (car primes)) (ntimesdivide den (car primes)))))))
((null? primes) st)
(set! place (+ place 1))
)
)))
(if (null? note) '()
#{
\once \override Stem.stencil = $stencil
...
\grace
c4
#note
#})))
But you see at beginning that i can not give optional arguments. LilyPond interpret following 3 musical elements as optional parameters of MTKeyExp.
If i use a list as a argument, there will be a mixt of musical expressions and numbers, but would not be possible to use commas ',' because that can be part of a musical _expression_ like "d,4".
Have you some idea to resolve this ? Thanks a lot for any help. However i am a good C++ programmer, i am newcommer at Scheme, but a big fan of LilyPond, and i will try to use my microtonal expressions through LilyPond. I also already plane how to change that midi file in order to listen correct tunings. But this step which i ask you is like a stone for my.
Daniel Tomas