lilypond-user
[Top][All Lists]
Advanced

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

Re: Adding parallel thirds to the notes of a melody


From: Aaron Hill
Subject: Re: Adding parallel thirds to the notes of a melody
Date: Wed, 03 Apr 2019 02:12:41 -0700
User-agent: Roundcube Webmail/1.3.8

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

Attachment: auto-parallel.cropped.png
Description: PNG image


reply via email to

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