Re: Getting pitch out of a pair

2015-01-17 Thread Thomas Morley
2015-01-17 11:15 GMT+01:00 and...@andis59.se :
> On 2015-01-17 00:02, and...@andis59.se wrote:
>>
>> I store two pitches in a pair variable
>> x = #'(b . cis')
>>
> " I woke up this morning"
>
> I have figured out that I don't want to store the pitches in a pair but in a
> list.

Did you notice that my last proposal returns a list? ;)
Though, list or pair, the problem where/how it is done, LilyPond or
scheme, will be the same.

-Harm

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Getting pitch out of a pair

2015-01-17 Thread and...@andis59.se

On 2015-01-17 00:02, and...@andis59.se wrote:

I store two pitches in a pair variable
x = #'(b . cis')


" I woke up this morning"

I have figured out that I don't want to store the pitches in a pair but 
in a list.


Thanks to all that have answered how to use pair in a music-function. 
I'm sure I will get to use it sometime!


// Anders

--
English isn't my first language.
So any error or strangeness is due to the translation.
Please correct my English so that I may become better.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Getting pitch out of a pair

2015-01-16 Thread Thomas Morley
2015-01-17 1:20 GMT+01:00 Thomas Morley :
> 2015-01-17 0:21 GMT+01:00 and...@andis59.se :
>> On 2015-01-17 00:16, Jay Anderson wrote:
>>>
>>> On Fri, Jan 16, 2015 at 4:02 PM, and...@andis59.se 
>>> 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?
>>
>> // Anders
>
>
> How about:
>
> #(display (event-chord-pitches #{ < b cis' > #}))
>
> Cheers,
>   Harm

#(display (event-chord-pitches #{  b cis'  #}))
works as well

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Getting pitch out of a pair

2015-01-16 Thread Thomas Morley
2015-01-17 0:21 GMT+01:00 and...@andis59.se :
> On 2015-01-17 00:16, Jay Anderson wrote:
>>
>> On Fri, Jan 16, 2015 at 4:02 PM, and...@andis59.se 
>> 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?
>
> // Anders


How about:

#(display (event-chord-pitches #{ < b cis' > #}))

Cheers,
  Harm

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Getting pitch out of a pair

2015-01-16 Thread Urs Liska


Am 17.01.2015 um 00:21 schrieb and...@andis59.se:

On 2015-01-17 00:16, Jay Anderson wrote:
On Fri, Jan 16, 2015 at 4:02 PM, and...@andis59.se 
 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




___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Getting pitch out of a pair

2015-01-16 Thread and...@andis59.se

On 2015-01-17 00:16, Jay Anderson wrote:

On Fri, Jan 16, 2015 at 4:02 PM, and...@andis59.se  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?


// Anders

--
English isn't my first language.
So any error or strangeness is due to the translation.
Please correct my English so that I may become better.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Getting pitch out of a pair

2015-01-16 Thread Jay Anderson
On Fri, Jan 16, 2015 at 4:02 PM, and...@andis59.se  wrote:
> I store two pitches in a pair variable
> x = #'(b . cis')
>
> But then I want to retrieve each one as a  pitch in a music-function
> foo = #(define-music-function (parser location bar) (ly:music?)
> (define from (car x))
> (define to (cdr x))
> #{
> \transpose $from $to $bar
> #}
>
> but when I use this
> \foo a
>
> I get Expecting pitch, found (quote b)
>
> So what am I doing wrong and how can I do it right?
>
> // Anders
> PS! The foo function is just a snippet the real function does a bit more...

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

Notes:
- It needs to be lilypond and not scheme which interprets the pitches.
The #{ #} do that inside a scheme expression.
- It won't work within a quoted list (e.g. #'(#{ b #} . #{ cis' #})
won't get you pitches.)

-Jay

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Getting pitch out of a pair

2015-01-16 Thread and...@andis59.se

I store two pitches in a pair variable
x = #'(b . cis')

But then I want to retrieve each one as a  pitch in a music-function
foo = #(define-music-function (parser location bar) (ly:music?)
(define from (car x))
(define to (cdr x))
#{
\transpose $from $to $bar
#}

but when I use this
\foo a

I get Expecting pitch, found (quote b)

So what am I doing wrong and how can I do it right?

// Anders
PS! The foo function is just a snippet the real function does a bit more...
--
English isn't my first language.
So any error or strangeness is due to the translation.
Please correct my English so that I may become better.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user