Re: Reverse Lilypond Book...

2012-06-21 Thread m...@apollinemike.com
On 21 juin 2012, at 01:50, Sami wrote:

 
 Hi all!
 
 This has probably been asked before, but I haven't found it anywhere, so I
 ask it myself. Excuse any repetition, and please direct me there if it
 exists and you can find it easily.
 
 With lilypond-book and co, what I understood is that one writes a LaTeX
 document with lilypond snippets. Essentially, it is a text document, and has
 some musical examples. LaTeX is the boss.
 
 What if we want to do the exact opposite? Like, a music book with snippets
 of TeX or LaTex-formatted text. An ideal situation would be for prefaces,
 contents, etc. to be in LaTex, or TeX or whatever, and then the music in
 lilypond, and all of this inside the lilypond file.
 
 I suppose that each LaTeX snippet would be a small LaTeX document with its
 own preamble etc, and most page-formatting variables dictated by lilypond,
 which would do the analogous of what lilypond-book does, but in reverse.
 Such a case would be great if one wants to write a music book, but using the
 Tex text functionality for any big chunks of text, like cover pages,
 prefaces, contents, etc.
 
 Is any of this possible?

Nicolas Sceaux is the master of this sort of thing.

http://nicolas.sceaux.free.fr/

He's very generous about sharing his code, so I'm sure you can contact him for 
ideas.

Cheers,
MS


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


Re: Reverse Lilypond Book...

2012-06-21 Thread Jan-Peter Voigt

Hi Sami,

for the purpose of a text at the beginning of a music-book, I created a 
markup-list command.
This command expects some installed commands: pdflatex and/or xelatex, 
pdftops and pdfinfo.
I use ubuntu so this is installed via aptitude and callable on the 
console. I don't know anything about how this could work on windows ...


These are the function, that I created for my own purposes, so I cannot 
give any warranty, that they do work as expected!
And take care/ATTENTION: This function creates files on your harddisk, 
processes them with the above mentioned commands *and then removes these 
working files!*


So this is a proof of concept and the answer to your question: yes it is 
possible
But you (or whoever) might have to tweak this stuff to work as *you* 
expect ;-)


HTH
cheers, Jan-Peter

On 21.06.2012 01:50, Sami wrote:

Hi all!

This has probably been asked before, but I haven't found it anywhere, so I
ask it myself. Excuse any repetition, and please direct me there if it
exists and you can find it easily.

With lilypond-book and co, what I understood is that one writes a LaTeX
document with lilypond snippets. Essentially, it is a text document, and has
some musical examples. LaTeX is the boss.

What if we want to do the exact opposite? Like, a music book with snippets
of TeX or LaTex-formatted text. An ideal situation would be for prefaces,
contents, etc. to be in LaTex, or TeX or whatever, and then the music in
lilypond, and all of this inside the lilypond file.

I suppose that each LaTeX snippet would be a small LaTeX document with its
own preamble etc, and most page-formatting variables dictated by lilypond,
which would do the analogous of what lilypond-book does, but in reverse.
Such a case would be great if one wants to write a music book, but using the
Tex text functionality for any big chunks of text, like cover pages,
prefaces, contents, etc.

Is any of this possible?



\version 2.15.37

#(use-modules
  (lily)
  (ice-9 popen)
  (ice-9 rdelim)
  (ice-9 regex)
  (scm framework-eps))

% string-join with arbitrary objects
#(define-public (glue-list lst glue)
  create string from list containing arbitrary objects
  (string-join (map (lambda (s)(format ~A s)) lst) glue 'infix))

% taken from markup-macros.scm
#(define (markup-function? x)
(and (markup-command-signature x)
 (not (object-property x 'markup-list-command

% extract available page-height from layout and properties
#(define-public (content-height layout props)
  (let ((mm (ly:output-def-lookup layout 'mm))
(height (ly:output-def-lookup layout 'paper-height))
(perc (chain-assoc-get 'percent props 100))
(tm (ly:output-def-lookup layout 'top-margin))
(bm (ly:output-def-lookup layout 'bottom-margin))
(hom (ly:output-def-lookup layout 'oddHeaderMarkup))
(hem (ly:output-def-lookup layout 'evenHeaderMarkup))
(bom (ly:output-def-lookup layout 'oddFooterMarkup))
(bem (ly:output-def-lookup layout 'evenFooterMarkup)))
   (define (mupheight mup)(if (markup? mup) (let ((y-ext (ly:stencil-extent (interpret-markup layout props mup) Y)))
(- (cdr y-ext)(car y-ext))) 0))
   (/ (* (- height (+ tm bm (max (mupheight hom)(mupheight hem))
 (max (mupheight hom)(mupheight hem (/ perc 100)) mm)
))

% create TeX-string from markup
#(define-public (markup-tex mup . mprops)
  (let ((conc (if ( (length mprops) 0) (car mprops) #f))
(layout (if ( (length mprops) 1) (cadr mprops) #f))
(props (if ( (length mprops) 2) (caddr mprops) '()))
(mup? (lambda (m)(or (string? m)(list? m)(markup? m
(result ))
   (cond ((string? mup) (set! result mup))
 ((null? mup) (set! result ))

 ((and (pair? mup) (equal? (car mup) concat-markup))
  (set! result (markup-tex (cdr mup) #t layout props)))

 ((and (pair? mup) (equal? (car mup) fromproperty-markup))
  (set! result (markup-tex (chain-assoc-get (cadr mup) props ???) conc layout props)))

 ((and (pair? mup) (equal? (car mup) override-markup))
  (set! result (markup-tex (cdr (cdr mup)) conc layout (cons (list (car (cdr mup))) props
 ((and (pair? mup) (equal? (car mup) page-ref-markup))
  (set! result (let* ((table (if layout (ly:output-def-lookup layout 'label-page-table) '()))
  (pg (assoc-get (car (cdr mup)) table)))
 (if pg (format ~A pg) (caddr (cdr mup ))

 ((and (pair? mup)(markup-function? (car mup)))
  (let ((proc (get-markup-producer (car mup
   (if (procedure? proc)
 (set! result (markup-tex (proc layout props (cdr mup
 (for-each (lambda (m)(set! result (string-append result (if (or conc (string=? result ))   ) (markup-tex m conc layout props
  

Re: Reverse Lilypond Book...

2012-06-21 Thread David Kastrup
Sami sami.ami...@gmail.com writes:

 This has probably been asked before, but I haven't found it anywhere, so I
 ask it myself. Excuse any repetition, and please direct me there if it
 exists and you can find it easily.

 With lilypond-book and co, what I understood is that one writes a LaTeX
 document with lilypond snippets. Essentially, it is a text document, and has
 some musical examples. LaTeX is the boss.

 What if we want to do the exact opposite? Like, a music book with snippets
 of TeX or LaTex-formatted text. An ideal situation would be for prefaces,
 contents, etc. to be in LaTex, or TeX or whatever, and then the music in
 lilypond, and all of this inside the lilypond file.

 I suppose that each LaTeX snippet would be a small LaTeX document with its
 own preamble etc, and most page-formatting variables dictated by lilypond,
 which would do the analogous of what lilypond-book does, but in reverse.
 Such a case would be great if one wants to write a music book, but using the
 Tex text functionality for any big chunks of text, like cover pages,
 prefaces, contents, etc.

 Is any of this possible?

Probably the easiest way to achieve embedded TeX is to use a version of
LilyPond in the vicinity of 2.0.

Instead of mulling over the problem whether to run LilyPond first, or
TeX first, it would make more sense to run them synchronously in order
to get to coordinated page break decisions.

-- 
David Kastrup


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


Re: Reverse Lilypond Book...

2012-06-21 Thread Sami

Thank you to everyone that took the time to answer!
-- 
View this message in context: 
http://old.nabble.com/Reverse-Lilypond-Book...-tp34046085p34048185.html
Sent from the Gnu - Lilypond - User mailing list archive at Nabble.com.


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


Re: Reverse Lilypond Book...

2012-06-21 Thread Sami



Jan-Peter Voigt wrote:
 
 Hi Sami,
 
 for the purpose of a text at the beginning of a music-book, I created a 
 markup-list command.
 This command expects some installed commands: pdflatex and/or xelatex, 
 pdftops and pdfinfo.
 I use ubuntu so this is installed via aptitude and callable on the 
 console. I don't know anything about how this could work on windows ...
 
 These are the function, that I created for my own purposes, so I cannot 
 give any warranty, that they do work as expected!
 And take care/ATTENTION: This function creates files on your harddisk, 
 processes them with the above mentioned commands *and then removes these 
 working files!*
 
 So this is a proof of concept and the answer to your question: yes it is 
 possible
 But you (or whoever) might have to tweak this stuff to work as *you* 
 expect ;-)
 
 HTH
 cheers, Jan-Peter
 
 


Wow! Thanks a million! And now I have to understand how this works! See you
in a couple hundred thousand years! :-)
-- 
View this message in context: 
http://old.nabble.com/Reverse-Lilypond-Book...-tp34046085p34048364.html
Sent from the Gnu - Lilypond - User mailing list archive at Nabble.com.


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


Reverse Lilypond Book...

2012-06-20 Thread Sami

Hi all!

This has probably been asked before, but I haven't found it anywhere, so I
ask it myself. Excuse any repetition, and please direct me there if it
exists and you can find it easily.

With lilypond-book and co, what I understood is that one writes a LaTeX
document with lilypond snippets. Essentially, it is a text document, and has
some musical examples. LaTeX is the boss.

What if we want to do the exact opposite? Like, a music book with snippets
of TeX or LaTex-formatted text. An ideal situation would be for prefaces,
contents, etc. to be in LaTex, or TeX or whatever, and then the music in
lilypond, and all of this inside the lilypond file.

I suppose that each LaTeX snippet would be a small LaTeX document with its
own preamble etc, and most page-formatting variables dictated by lilypond,
which would do the analogous of what lilypond-book does, but in reverse.
Such a case would be great if one wants to write a music book, but using the
Tex text functionality for any big chunks of text, like cover pages,
prefaces, contents, etc.

Is any of this possible?
-- 
View this message in context: 
http://old.nabble.com/Reverse-Lilypond-Book...-tp34046085p34046085.html
Sent from the Gnu - Lilypond - User mailing list archive at Nabble.com.


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


Re: Reverse Lilypond Book...

2012-06-20 Thread Marc Hohl

Am 21.06.2012 01:50, schrieb Sami:

Hi all!

This has probably been asked before, but I haven't found it anywhere, so I
ask it myself. Excuse any repetition, and please direct me there if it
exists and you can find it easily.

With lilypond-book and co, what I understood is that one writes a LaTeX
document with lilypond snippets. Essentially, it is a text document, and has
some musical examples. LaTeX is the boss.

What if we want to do the exact opposite? Like, a music book with snippets
of TeX or LaTex-formatted text. An ideal situation would be for prefaces,
contents, etc. to be in LaTex, or TeX or whatever, and then the music in
lilypond, and all of this inside the lilypond file.

I suppose that each LaTeX snippet would be a small LaTeX document with its
own preamble etc, and most page-formatting variables dictated by lilypond,
which would do the analogous of what lilypond-book does, but in reverse.
Such a case would be great if one wants to write a music book, but using the
Tex text functionality for any big chunks of text, like cover pages,
prefaces, contents, etc.

Is any of this possible?

I remember that the following post

http://lists.gnu.org/archive/html/lilypond-user/2011-09/msg4.html

showed an example of calling xelatex within lilypond, perhaps this
could serva as a starting point.

HTH,

Marc

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