lilypond-devel
[Top][All Lists]
Advanced

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

Re: Ekiga chat


From: Carl Sorensen
Subject: Re: Ekiga chat
Date: Fri, 5 Jun 2015 22:03:34 +0000
User-agent: Microsoft-MacOutlook/14.5.0.150423

Hi David,

I'm quite certain I won't answer exactly as David K would, but my answer
is still better than no answer, so here goes.

By the way, the LilyPond development community generally frowns on top
posting, and on including entire emails.  Rather the answers to questions
should be included in-line, and the original email should be trimmed as
much as possible.  If you can write your emails with that format, you're
likely to get much better answers from the group.

Anyway, see my answers below.

On 6/5/15 2:43 PM, "David Garfinkle" <address@hidden>
wrote:

>
>I think I get what's going on and what I need to do. But I would like to
>make sure with an example.
>
>Given this input file "test1.ly"
>\version "2.18.2"
>\score{
> \relative{a4}
>}
>
>1. a file similar to dumpit.ly would find&separate the {} blocks? and for
>our simplest case we're just looking at a score block with one note

I don't think you need to find and separate the {} blocks; the LilyPond
parser will do that for you.  It does the conversion from LilyPond input
to Scheme representation.

>
>2. then for this score block we have a scheme representation that looks
>like this:
>
>(make-music
>  'SequentialMusic
>  'elements
>  (list (make-music
>    'NoteEvent
>    'pitch (ly:make-pitch -1 5 0)
>    'duration (ly:make-duration 2 0 1))))
>
>which further defines a C++ representation, that I don't need to work
>with..?

Actually, the scheme representation is never converted to a C++
representation.  The scheme representation is worked on by both C++ and
Scheme routines, and is converted into a series of StreamEvents.  But you
correctly identified that you don't need to worry about anything beyond
the scheme representation for this particular part of the project.

>
>3. And this is where I want to make really sure I know what's going on. We
>want to turn the scheme function representation, using the display-lily
>machinery, into an SXML representation which looks like this: (i think?)
>
>(list (make-music
>  (list 'SequentialMusic
>    (list 'elements
>      (list (make-music
>        'NoteEvent
>        (list 'pitch (ly:make-pitch -1 5 0)
>        (list 'duration (ly:make-duration 2 0 1)))))
>
>or equivalently,
>
>'(make-music
>  (SequentialMusic
>    (elements
>      (make-music
>      NoteEvent
>      (pitch (ly:make-pitch -1 5 0))
>      (duration (ly:make-duration 2 0 1))))))
>
>... so that each scheme function is now the first element in a series of
>nested lists
>and this will be done in a guile-1/lilypond script

Pretty much.  The essential function of the guile-1 script is to write the
output as a Scheme procedure, rather than as a string.

You will want to use write and read, rather than display and read-char.
You want to have s-expressions in the file, rather than strings.  See
section 6.17 of the Guile manual for more information.


>
>4. then a guile-2 script uses (sxml simple) module and calls sxml->xml,
>and
>with the above example, turns our music into
>
><make-music>
>  <SequentialMusic>
>    <elements>
>      <make-music>
>        NoteEvent
>        <pitch>
>          <ly:make-pitch>-150</ly:make-pitch></pitch>
>        <duration>
>          <ly:make-duration>201</ly:make-duration></duration>
>      </make-music>
>    </elements>
>  </SequentialMusic>
></make-music>

This is xml, not sxml, if I understand correctly (see section 7.22 of the
Guile manual).  sxml is a scheme representation, meaning it is made up of
lists, and hence parentheses as delimiters rather than angle brackets.

sxml for the above might properly look more like

(SequentialMusic (@ (elements (NoteEvent (@ (pitch (@ (octave -1) (step 5)
(alteration 0)))
                                            (duration (@ (durlog 2)
(dotcount 0) (scale 1)))))

And the relevant xml would be

<SequentialMusic>
  <elements>
    <NoteEvent>
      <pitch>
        <octave>-1</octave>
        <step>5</step>
        <alteration>0</alteration>
      </pitch>
      <duration>
        <durlog>2</durlog>
        <dotcount>0</dotcount>
        <scale>1</scale>
      </duration>
    </NoteEvent>
   </elements>
</SequentialMusic>
        
Now, this doesn't get to the end of the problem, because there are
automatically added Staffs, Voices, Key Signatures, and Clefs (at a
minimum).  But it's a good start, I think.

The function calls (make-music, ly:make-pitch, and ly:make-duration)
should not be part of the XML.  Instead, the arguments to the functions
should be placed in the XML.

I hope this has been helpful.  I think you definitely have enough to get
going.

Thanks,

Carl




reply via email to

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