[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lyx-users
Subject:    Re: Lilypond integration
From:       Helge Hafting <helge.hafting () hist ! no>
Date:       2009-03-23 13:16:21
Message-ID: 49C78BA5.2080304 () hist ! no
[Download RAW message or body]

Johannes Asal wrote:
> I know that you can include Lilypond material by External Material. 
> That's ok when you have few notation examples in your text and I 
> appreciate that someone took the time to implement it. But I'm trying to 
> write a book about jazz harmonics and therefore I need many musical 
> examples that have to be changed often in the writing process. The main 
> problems I have with the External Material approach are the following:
> 
> 1. It interrupts the creative process, because you need to prepare the 
> lilypond snippets in another editor and import them afterwards

I understand, as I have the same problem with figures. It is possible to 
ease the pain some, though. The external inset has a "edit" button, so 
you can click that in order to edit your music snippet. Newer versions 
of lyx doesn't have the button, instead you right-click the lilypond 
object and select "edit externally" from the menu. So you can "get to 
it" from LyX, but it will obviously still be an external application. 
You may have to define an editor for .ly files in the preferences.

> 2. You don't have a preview and therefore it is a bit difficult to see 
> whether you have written something already or not

Tools->preferences->Graphics, then turn "Instant Preview" ON.
You should now get previews of all external insets, including lilypond 
music.  This is perhaps turned off by default, for performance reasons.

> 3. If you have to change one of the snippets, you have to find the 
> corresponding file
>
Not really. right-click and select "edit externally" (Or, for older 
versions of lyx: click, then use the edit button in the dialog.)

> I don't know if it's possible, but the ideal solution (for me) would be 
> some kind of lilypond environment (somewhat like the math environment), 
> where you can type in your lilypond code directly. After leaving this 
> environment, the graphic is rendered and put into place in the LyX 
> document. If you need to change it, you just click on the graphic and 
> the code environment pops up again.
> 
> This is of course not a simple modification to do, and I guess it 
> wouldn't be that fun either, but I'm sure it would be a valueable 
> addition to LyX's feature list because as far as I know there is no 
> solution today that combines text with music typesetting in a convenient 
> and straightforward way. I would even volunteer for implementing parts 
> of it if needed.

Support for lilypond-book would be interesting. And sure - if you 
volunteer to do some work then you will get it faster.

This process can be divided into several steps, you won't have to do it 
all at once.

1. Work on the support for lilypond-book.
    This will have LyX create latex output as usual,
    then, add code to run lilypond-book on the produced file
    Finally, let LyX run latex/pdflatex on the file produced, as usual.
    So this step is mostly about inserting an invocation
    of "lilypond-book" into the existing workflow.

    At this point, use a new document settings to decide whether
    lyx should do this lilypond-book step or not. Many lyx documents
    have no lilypond content, and many lyx users don't have lilypond.

    Use the latex inset for lilypond code in the beginning.
    To enter music, type stuff like
     \begin{lilypond} { c d e } \end{lilypond}
    There will be no preview so far.

2. With lilypond-book working, start on the lilypond environment.
    first figure out if it ought to be a inset, a layout module, or
    whatever. I guess an inset will be the way.

    Then add the rule about how LyX produces latex code when processing
    a lilypond inset. This is easy - just output \begin{lilypond}
    followed by the inset contents, followed by \end{lilypond}

    At this point, you have working lilypond-book!

3. Some fine-tuning. Remove the document setting that specifies if this
    is a lilypond document. Instead, add logic so that LyX will run
    lilypond-book whenever the document contains a lilypond inset.
    You can perhaps make use of similiar logic that add latex packages
    on an as-needed basis.

4. The preview. Arrange so Lyx runs the inset content through
    lilypond, and display the resulting .png if this succeeds.
    I am not sure how to do this part, but look at how it is done
    for math and graphichs insets.


Helge Hafting
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic