lilypond-user
[Top][All Lists]
Advanced

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

Re: scheme function help


From: Stjepan Horvat
Subject: Re: scheme function help
Date: Mon, 6 May 2013 09:57:33 +0200

Ok..thanks Madoka..
It wasn't to me clear where i have to use the display-scheme-music function => in lilypond scheme-sandbox..and that it had to be music..ok..that is now clear..

but your function does not work for me:
i get this
(make-music
  'SequentialMusic
  'elements
  (list (make-music (quote Music) (quote error-found) #t)
        (make-music (quote Music) (quote error-found) #t)
        (make-music (quote Music) (quote error-found) #t)
        (make-music
          'NoteEvent.....


On Sun, May 5, 2013 at 9:35 PM, Madoka Machitani <address@hidden> wrote:
Hi,

Let me first point out that you have to remember object type matters. 
ly:music-property expects music object, not pitch object or anything else, so you have to 
give a music object to it, like this:

(display-scheme-music
 (car (ly:music-property #{ \mark "A" c'4 #}
                         'elements)))

which gives
(make-music (quote MarkEvent) (quote label) "A")


Now, is it correct to assume you are trying to achieve something like this?
\insMark "a" musical-sequence

If so, the function would be:

insMark = 
#(define-music-function (parser location mark mus)
   (markup? ly:music?)
   (set! (ly:music-property mus 'elements)
         (cons (make-music 'MarkEvent 'label mark)
               (ly:music-property mus 'elements)))
   mus)

This is a crude example and won't work with single note events like c'4

example:
\displayMusic \insMark "A" { c'4 }
=>
(make-music
  'SequentialMusic
  'elements
  (list (make-music (quote MarkEvent) (quote label) "A")
        (make-music
          'NoteEvent
          'duration
          (ly:make-duration 2 0 1)
          'pitch
          (ly:make-pitch 0 0 0))))


BTW, have you read the extending manuagl?
http://lilypond.org/doc/v2.16/Documentation/extending/



On Sun, May 5, 2013 at 9:30 PM, Stjepan Horvat <address@hidden> wrote:
I'm trying to figure out how and learn to create a function based on a \displayMusic function.
for example:
\displayMusic { \mark "A" c'4 }
gives me
(make-music
  'SequentialMusic
  'elements
  (list (make-music (quote MarkEvent) (quote label) "A")
        (make-music
          'NoteEvent
          'duration
          (ly:make-duration 2 0 1)
          'pitch
          (ly:make-pitch 0 0 0))))

so what i have gotten so far is that there is new (make-music (quote MarkEvent) (quote label) "A") or (make-music 'MarkEvent 'label "A") in front of c'
and i don't know how to put this line into it. I understand that i have to use cons on 'elements to put the line in front of c.
Is there a way to figure out what "elements" do i have to use in my function to work.
I'm going through http://lilypond.org/doc/v2.12/Documentation/user/lilypond/Music-properties#Music-properties to get an idea of how to get into it but #(display-scheme-music (first (ly:music-property someNote 'elements))) doesn't work. I get an error saying:
Wrong type argument in position 1 (expecting Music): #<Pitch c' > with someNote = c'.
Help would be appreciated.

--
Nesmotren govori kao da mačem probada, a jezik je mudrih iscjeljenje. Izreke 12:18

_______________________________________________
lilypond-user mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user



_______________________________________________
lilypond-user mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user




--
Nesmotren govori kao da mačem probada, a jezik je mudrih iscjeljenje. Izreke 12:18

reply via email to

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