lilypond-user
[Top][All Lists]
Advanced

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

Re: Emacs integration


From: David Kastrup
Subject: Re: Emacs integration
Date: Sat, 31 Aug 2013 20:26:28 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Thomas Morley <address@hidden> writes:

> \version "2.17.25"
>
> scalesAndTriads =
> #(define-music-function (parser location m music)(ly:music? ly:music?)
>   (let* ((elts (ly:music-property m 'elements))
>          (pitches (map (lambda (x) (ly:music-property x 'pitch)) elts))
>          (pitch-octaves (map (lambda (x) (ly:pitch-octave x)) pitches))

           (pitch-octaves (map ly:pitch-octave pitches))

>          (pitch-notename (map (lambda (x) (ly:pitch-notename x)) pitches))

           (pitch-notename (map ly:pitch-notename pitches))

>          (pitch-alteration (map (lambda (x) (ly:pitch-alteration x)) 
> pitches)))

           guess...

>   #{
>     $(make-simultaneous-music
>         (map
>            (lambda (octave note alter)
>               #{
>                  \new Staff
>                    \transpose c $(ly:make-pitch octave note alter)
>                    \relative $music
>               #})
>            pitch-octaves pitch-notename pitch-alteration))
>   #}))

What's the point of picking the pitches apart into octave/note/alter and
then assembling them into a pitch again without change?  Why not map
over the pitches directly in the first place?

> }
>
> \scalesAndTriads { c f bes ees aes des ges g d a e b fis } \scale
>
>
>
> Franky, it took me more than two minutes, although I recycled some old
> code for tranposing sequential music, but less than 30 min.
>
> _And_ I now have two functions to reuse again and again: One for
> sequential and another for simultaneous music.

Why use two?  Just do (music-clone m 'origin location 'elements (map ...

And then you use either
\scalesAndTriads { c f bes ees aes des ges g d a e b fis }
or
\scalesAndTriads << c f bes ees aes des ges g d a e b fis >>

I'd not use \relative $music here: that looks like asking for trouble.
If people want \relative music, they should spell it out.

-- 
David Kastrup




reply via email to

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