At 07:15 on 03 Apr 2019, 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
Funnily enough, I wrote something to do this last week, adapted from http://lsr.di.unimi.it/LSR/Item?id=445 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \version "2.19.82" %% adapted from http://lsr.di.unimi.it/LSR/Item?id=445 #(define (third-up m) (let* ((new-note (ly:music-deep-copy m)) (new-pitch (ly:pitch-transpose (ly:music-property m 'pitch) (ly:make-pitch 0 2 0)))) (set! (ly:music-property new-note 'pitch) new-pitch) new-note)) #(define (addthird-chord elements) (cond ((null? elements) elements) ((eq? (ly:music-property (car elements) 'name) 'NoteEvent) (cons (car elements) (cons (third-up (car elements)) (addthird-chord (cdr elements))))) (else (cons (car elements) (addthird-chord (cdr elements)))))) #(define (addthird music) (if (eq? (ly:music-property music 'name) 'EventChord) (ly:music-set-property! music 'elements (addthird-chord (ly:music-property music 'elements)))) music) makeThirds = #(define-music-function (mus) (ly:music?) (music-map (lambda (x) (addthird x)) (event-chord-wrap! mus))) \makeThirds { \clef bass dis8( e dis)~ dis8.( cis16 b8 ais gis dis) cis( dis <dis gis>) c d e fis gis aes bes c' \clef treble bes des' ees' f' g' a' b' c'' d'' e'' fis'' <f c'> } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- Mark Knoop _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user