ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* t-filter for LilyPond enhancements
@ 2013-01-20 12:15 Henning Hraban Ramm
  2013-01-20 16:57 ` Aditya Mahajan
  0 siblings, 1 reply; 5+ messages in thread
From: Henning Hraban Ramm @ 2013-01-20 12:15 UTC (permalink / raw)
  To: mailing ConTeXt users list for

Hi Aditya et.al.,

I'm using t-filter with LilyPond for my songbooklets like this:

-----

\def\readPDFfile#1{\externalfigure[#1]}

\usemodule[filter]
\defineexternalfilter[lilypond]
	[continue=yes,
	readcommand=\readPDFfile,
	directory=lilytemp/,
	output={\externalfilterbasefile.pdf},
	filtercommand={lilypond -dbackend=eps -dinclude-eps-fonts -dno-gs-load-fonts -o"lilytemp/\externalfilterbasefile" "\externalfilterinputfile"}]

-----

Now, I'd like my lilypond sections/buffers to have different names than just numbers; I'd prefer some unique IDs or even manually set names to be able to re-order them without the need of re-compiling.
I.e. if I change the order of songs in my songbook, all LilyPond snippets must get recalculated, even if they didn’t change.

Sorry if that’s mentioned in t-filter’s docs - I didn’t see it.

There are some more enhancements that I’d like to implement, e.g. checking the resulting files if there are several pages or using single notelines to let ConTeXt do the page breaking (like lilypond-book does with LaTeX). I guess that would be as simple as replacing my \readPDFfile with some Lua code - can you give me a hint how to do that?

Greetlings, Hraban
---
http://www.fiee.net/texnique/
http://wiki.contextgarden.net
https://www.cacert.org (I'm an assurer)

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: t-filter for LilyPond enhancements
  2013-01-20 12:15 t-filter for LilyPond enhancements Henning Hraban Ramm
@ 2013-01-20 16:57 ` Aditya Mahajan
  2013-01-20 20:02   ` Henning Hraban Ramm
  0 siblings, 1 reply; 5+ messages in thread
From: Aditya Mahajan @ 2013-01-20 16:57 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1472 bytes --]

On Sun, 20 Jan 2013, Henning Hraban Ramm wrote:

> I'm using t-filter with LilyPond for my songbooklets like this:
>
> -----
>
> \def\readPDFfile#1{\externalfigure[#1]}
>
> \usemodule[filter]
> \defineexternalfilter[lilypond]
> 	[continue=yes,
> 	readcommand=\readPDFfile,
> 	directory=lilytemp/,
> 	output={\externalfilterbasefile.pdf},
> 	filtercommand={lilypond -dbackend=eps -dinclude-eps-fonts -dno-gs-load-fonts -o"lilytemp/\externalfilterbasefile" "\externalfilterinputfile"}]
>
> -----
>
> Now, I'd like my lilypond sections/buffers to have different names than just numbers; I'd prefer some unique IDs or even manually set names to be able to re-order them without the need of re-compiling.
> I.e. if I change the order of songs in my songbook, all LilyPond snippets must get recalculated, even if they didn’t change.

Does

\startlilypond[name=one]
....
\stoplilypond

what you are looking for? (see the docs for how this behaves behind the 
scenes)


> There are some more enhancements that I’d like to implement, e.g. 
> checking the resulting files if there are several pages or using single 
> notelines to let ConTeXt do the page breaking (like lilypond-book does 
> with LaTeX). I guess that would be as simple as replacing my 
> \readPDFfile with some Lua code - can you give me a hint how to do that?

See grph-inc.*. I'll post an example later on how to handle single page 
and multipage pdfs differently.

Aditya

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: t-filter for LilyPond enhancements
  2013-01-20 16:57 ` Aditya Mahajan
@ 2013-01-20 20:02   ` Henning Hraban Ramm
  2013-01-20 20:19     ` Aditya Mahajan
  0 siblings, 1 reply; 5+ messages in thread
From: Henning Hraban Ramm @ 2013-01-20 20:02 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Am 2013-01-20 um 17:57 schrieb Aditya Mahajan:

>> Now, I'd like my lilypond sections/buffers to have different names than just numbers; I'd prefer some unique IDs or even manually set names to be able to re-order them without the need of re-compiling.
>> I.e. if I change the order of songs in my songbook, all LilyPond snippets must get recalculated, even if they didn’t change.
> 
> Does
> 
> \startlilypond[name=one]
> ....
> \stoplilypond
> 
> what you are looking for? (see the docs for how this behaves behind the scenes)

Oh, so simple? Great, that’s exactly what I meant. Since I would normally set [name=\currentcomponent], can I make that default?

>> There are some more enhancements that I’d like to implement, e.g. checking the resulting files if there are several pages or using single notelines to let ConTeXt do the page breaking (like lilypond-book does with LaTeX). I guess that would be as simple as replacing my \readPDFfile with some Lua code - can you give me a hint how to do that?
> 
> See grph-inc.*. I'll post an example later on how to handle single page and multipage pdfs differently.

Thanks, handling of multipage PDFs might help, but I’d try a different approach: LilyPond can generate EPS/PDF for single note systems and writes the number of them into a simple text file. I’d parse that with Lua and place all those small PDFs. I just need a clue how I must define t-filter’s "readcommand" as a Lua function.

Greetlings, Hraban
---
http://www.fiee.net/texnique/
http://wiki.contextgarden.net
https://www.cacert.org (I'm an assurer)

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: t-filter for LilyPond enhancements
  2013-01-20 20:02   ` Henning Hraban Ramm
@ 2013-01-20 20:19     ` Aditya Mahajan
  2013-01-20 20:35       ` Henning Hraban Ramm
  0 siblings, 1 reply; 5+ messages in thread
From: Aditya Mahajan @ 2013-01-20 20:19 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2210 bytes --]

On Sun, 20 Jan 2013, Henning Hraban Ramm wrote:

> Am 2013-01-20 um 17:57 schrieb Aditya Mahajan:
>
>>> Now, I'd like my lilypond sections/buffers to have different names than just numbers; I'd prefer some unique IDs or even manually set names to be able to re-order them without the need of re-compiling.
>>> I.e. if I change the order of songs in my songbook, all LilyPond snippets must get recalculated, even if they didn’t change.
>>
>> Does
>>
>> \startlilypond[name=one]
>> ....
>> \stoplilypond
>>
>> what you are looking for? (see the docs for how this behaves behind the scenes)
>
> Oh, so simple? Great, that’s exactly what I meant. Since I would normally set [name=\currentcomponent], can I make that default?

Unfortunately no. The name key is reset at every `\startexternalfilter`; 
otherwise it will be difficult to mix `name=....` with normal usage.

>>> There are some more enhancements that I’d like to implement, e.g. checking the resulting files if there are several pages or using single notelines to let ConTeXt do the page breaking (like lilypond-book does with LaTeX). I guess that would be as simple as replacing my \readPDFfile with some Lua code - can you give me a hint how to do that?
>>
>> See grph-inc.*. I'll post an example later on how to handle single page and multipage pdfs differently.
>
> Thanks, handling of multipage PDFs might help, but I’d try a different 
> approach: LilyPond can generate EPS/PDF for single note systems and 
> writes the number of them into a simple text file. I’d parse that with 
> Lua and place all those small PDFs. I just need a clue how I must define 
> t-filter’s "readcommand" as a Lua function.

Something like this:

\def\ParseLilypondFile#1%
    % #1 is the name of the output file
    {\ctxlua{thirddata.parselilypondfile("#1")}

\startluacode
   thirddata = thirddata or {}
   function thirddata.parselilypondfile(name)
     --- parse "name" file as you wish and
     --- generate approapriate context(...) commands
     --- to write back to ConTeXt
   end
\stopluacode

\defineexternalfilter[lilypond]
    [
      .....
      readcommand=\ParseLilypondFile,
      ....
    ]

Aditya

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: t-filter for LilyPond enhancements
  2013-01-20 20:19     ` Aditya Mahajan
@ 2013-01-20 20:35       ` Henning Hraban Ramm
  0 siblings, 0 replies; 5+ messages in thread
From: Henning Hraban Ramm @ 2013-01-20 20:35 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Am 2013-01-20 um 21:19 schrieb Aditya Mahajan:
> Unfortunately no. The name key is reset at every `\startexternalfilter`; otherwise it will be difficult to mix `name=....` with normal usage.

What do you think about using UIDs (or maybe some hash value of the buffer) instead of serial numbers? It might help with other uses of t-filter to be able to re-order the filter sections without re-compiling.

>> Thanks, handling of multipage PDFs might help, but I’d try a different approach: LilyPond can generate EPS/PDF for single note systems and writes the number of them into a simple text file. I’d parse that with Lua and place all those small PDFs. I just need a clue how I must define t-filter’s "readcommand" as a Lua function.
> 
> Something like this:
> 
> \def\ParseLilypondFile#1%
>   % #1 is the name of the output file
>   {\ctxlua{thirddata.parselilypondfile("#1")}
> 
> \startluacode
>  thirddata = thirddata or {}
>  function thirddata.parselilypondfile(name)
>    --- parse "name" file as you wish and
>    --- generate approapriate context(...) commands
>    --- to write back to ConTeXt
>  end
> \stopluacode
> 
> \defineexternalfilter[lilypond]
>   [
>     .....
>     readcommand=\ParseLilypondFile,
>     ....
>   ]

Thank you very much! It’s been a while since I wrote my last Lua code for ConTeXt...
I’ll just update the LilyPond wiki page (and then delete everything about the old LilyPond module).

Greetlings, Hraban
---
http://www.fiee.net/texnique/
http://wiki.contextgarden.net
https://www.cacert.org (I'm an assurer)

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-01-20 20:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-20 12:15 t-filter for LilyPond enhancements Henning Hraban Ramm
2013-01-20 16:57 ` Aditya Mahajan
2013-01-20 20:02   ` Henning Hraban Ramm
2013-01-20 20:19     ` Aditya Mahajan
2013-01-20 20:35       ` Henning Hraban Ramm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).