lilypond-user
[Top][All Lists]
Advanced

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

Re: Getting pitch out of a pair


From: Urs Liska
Subject: Re: Getting pitch out of a pair
Date: Sat, 17 Jan 2015 00:36:54 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.4.0


Am 17.01.2015 um 00:21 schrieb address@hidden:
On 2015-01-17 00:16, Jay Anderson wrote:
On Fri, Jan 16, 2015 at 4:02 PM, address@hidden <address@hidden> wrote:
I store two pitches in a pair variable
x = #'(b . cis')


pitches = #(cons #{ b #} #{ cis' #})
#(display (ly:pitch? (car pitches)))  => #t


Ok that works but looks really bad....
I liked the clean way the #'(b . cis') looks.

Is there some other way of storing two pitches and accessing each one in a music-function?

You can encapsulate the ugliness in one more function:

#(define x #f)

setTransposition =
#(define-void-function (parser location a b)
   (ly:pitch? ly:pitch?)
   (set! x (cons #{ #a #} #{ #b #})))

foo =
#(define-music-function (parser location bar) (ly:music?)
   (define from (car x))
   (define to (cdr x))
   #{
     \transpose $from $to $bar
   #})

{
  \setTransposition a b
  \foo a
}


HTH
Urs

// Anders





reply via email to

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