On 2019-04-02 11:15 pm, Gianmaria Lari wrote:
The following "test" function adds parallel thirds to the notes of a
melody:
\version "2.21.0"
scale = {c d e f g a b}
test =
#(define-music-function (music) (ly:music?)
#{
\partCombine $music \modalTranspose c e \scale $music
#})
\test {\voiceOne a b c'}
I don't have lilypond programming experience and I would like to know:
- if there are hidden mistakes
- if it is better to write the function in a different way
- how I could avoid to write \voiceOne in \test {\voiceOne a b c'}
- how I can encapsulate scale, inside the "test" function
In keeping with my predilection for over-engineering, here is my take on
your function:
%%%%
\version "2.19.82"
autoParallel =
#(define-music-function (root scale target music)
(ly:pitch? number-pair-list? ly:pitch? ly:music?)
(let* ((rscale #{ \transpose c $root { $@(map
(lambda (x) (ly:make-pitch 0 (car x) (cdr x))) scale) } #})
(transposed #{ \modalTranspose $root $target $rscale $music
#}))
(if (ly:pitch<? root target)
#{ \partcombine $transposed $music #}
#{ \partcombine $music $transposed #})))
pentatonic = #`((0 . 0) (1 . 0) (2 . 0) (4 . 0) (5 . 0))
{
\autoParallel c \major e \fixed c' { e8 f g d e d c4 }
\autoParallel e \minor g, \fixed c'' { c8 d e fis g4 e4 }
\autoParallel bes \pentatonic f' \fixed c' { f4 g16 bes c8 d4 f16 g
bes,8 }
}
%%%%
This is a little more verbose in usage, but it lets you easily specify
which scale you want using the built-in scale definitions (e.g.
\mixolydian, \phrygian, etc.) or by creating your own as demonstrated.
It also detects whether the harmony will be above or below and will
\partcombine appropriately.
NOTE: I only use 2.19 currently, so I still have to write \partcombine
instead of \partCombine.
-- Aaron Hill
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user