lilypond-user
[Top][All Lists]
Advanced

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

How to create a music function properly?


From: Marc Hohl
Subject: How to create a music function properly?
Date: Mon, 27 Sep 2010 21:02:51 +0200
User-agent: Thunderbird 2.0.0.24 (X11/20100317)

Hello list,

after having written mails way too early to this list recently
while overlooking the obvious, I think I stumbled upon a *real*
problem now :-/

Please have a look at the attached file. This is not the real world problem,
but I boiled it down to a nearly minimal example.

Only version 3 is giving the desired output in standard notation,
but ignoring the \override.


What am I doing wrong here?

Thanks in advance!

Marc

\version "2.13.32"

% thanks to Neil for this function
#(define (make-harmonic mus)
  (let ((elts (ly:music-property mus 'elements))
        (elt (ly:music-property mus 'element)))
       (cond
        ((pair? elts)
         (map make-harmonic elts))
        ((ly:music? elt)
         (make-harmonic elt))
        ((music-is-of-type? mus 'note-event)
         (set! (ly:music-property mus 'articulations)
               (append
                 (ly:music-property mus 'articulations)
                 (list (make-music 'HarmonicEvent))))))
       mus))


harmonicTestOne = #(define-music-function (parser location music) (ly:music?)
  (let* ((test 2)
         (result (/ test 2)))

  #{
    \override TabNoteHead #'transparent = ##t
  #}
  (make-harmonic music)
  (display "\nDummy output to check the let-block: ")(display result)
  #{
    \revert TabNoteHead #'transparent
  #}))

harmonicTestTwo = #(define-music-function (parser location music) (ly:music?)
  (let* ((test 4)
         (result (/ test 2)))
  #{
    \override TabNoteHead #'transparent = ##t

  #(begin
     (display "\nDummy output to check the let-block: ")
     (display result)
     (make-harmonic $music))
    \revert TabNoteHead #'transparent
  #}))

harmonicTestThree = #(define-music-function (parser location music) (ly:music?)
  (let* ((test 6)
         (result (/ test 2)))

  #{
    \override TabNoteHead #'transparent = ##t
  #}
  (begin
     (display "\nDummy output to check the let-block: ")
     (display result)
     (make-harmonic music))))

%{
harmonicTestFour = #(define-music-function (parser location music) (ly:music?)
  #{
  #(let* ((test 8)
          (result (/ test 2)))

    \override TabNoteHead #'transparent = ##t
  #(begin
     (display "\nDummy output to check the let-block: ")
     (display result)
     (make-harmonic music)))
  #})
%}

test = {
 c2^"Test 0" < c g >2
 \harmonicTestOne { c4^"Test 1" < c g >4 }
 \harmonicTestTwo { c4^"Test 2" < c g >4 }
 \harmonicTestThree { c4^"Test 3" < c g >4 }
 %\harmonicTestFour { c4^"Test 4" < c g >4 }
}

\score {
  <<
    \new Staff {
      \new Voice {
        \clef "treble_8"
        \test
      }
    }
    \new TabStaff {
      \new TabVoice {
        \test
      }
    }
  >>
}


reply via email to

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