lilypond-user
[Top][All Lists]
Advanced

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

Re: Scheme music function attempt


From: Tao Cumplido
Subject: Re: Scheme music function attempt
Date: Tue, 27 Jan 2009 00:01:07 +0100

-------- Original-Nachricht --------
> Datum: Mon, 26 Jan 2009 06:09:08 -0700
> Von: "Carl D. Sorensen" <address@hidden>


> You may want to use a different name from cs.  cs is C sharp in english,
> so
> this code would run into the same problem as you had before with c if
> somebody wants to use english note names.

I see. Thanks for pointing it out.
It's not so easy to find short names for functions. :)

Well, I got now as far that the function returns from a given pitch the 
notename and the alteration as string but my main goal, to make it 
transposable, doesn't seem to work as it is.
The standard music inside of the tranpose-block is tranposed but the pitch used 
for my function isn't.

Now, is it actually possible to make the function aware that it is inside the 
TransposedMusic and if so, how would I do it?
And if not, what would you suggest to do? Create my own tranposeChords function?
This'd have the advantage for me to get more involved with scheme but my 
logical thinking wants to avoid it somehow.

Regards,

Tao

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#(define (root-name music)
   (let* ((e (car (ly:music-property music 'elements)))
          (p (ly:music-property e 'pitch)))
     (if (ly:pitch? p)
         (let ((n (ly:pitch-notename p)))
           (case n
             ((0) "C")
             ((1) "D")
             ((2) "E")
             ((3) "F")
             ((4) "G")
             ((5) "A")
             ((6) "B"))))))
             
#(define (root-alter music)
   (let* ((e (car (ly:music-property music 'elements)))
          (p (ly:music-property e 'pitch)))
     (if (ly:pitch? p)
         (let ((a (ly:pitch-alteration p)))
           (case a
             ((-1) "<")
             ((-1/2) "b")
             ((0) "")
             ((1/2) "#")
             ((1) ">"))))))
                 
ch = #(define-music-function (parser location root) (ly:music?)
        (let ((rn (root-name root))
              (ra (root-alter root)))
          #{ \mark \markup \concat { $rn $ra } #}))

\new Staff { \transpose c d { c'1 \ch ces'1 c'1 } }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-- 
Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: 
http://www.gmx.net/de/go/multimessenger




reply via email to

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