Re: Has anyone extended \include?

2006-12-27 Thread Rick Hansen (aka RickH)



Eduardo Vieira-3 wrote:
 
 Citando Rick Hansen (aka RickH) [EMAIL PROTECTED]:
 


 If you have done this can you share it or sell it to me?  (please dont
 suggest m4, I gave up on that monster)

 Thanks

 
 Hi, Rick! Yes, this preprocessor looks scary, as well as some advanced
 programming with Scheme. But once I got into reading about the GEMA
 preprocessor and didn't look as complicated as m4. Maybe it's worth a try.
 Another thing I found out that is *really* useful with text editing,
 manipulating: Learn Regular Expressions. You can do quite a few tricky
 search
 and replace tasks. And most of text editors for programmers support them.
 
 Eduardo
 ___
 Neste Fim de Ano, interurbano para cidades próximas ou distantes é com o 
 21.
 A Embratel tem tarifas muito baratas de presente para você ligar para quem
 você gosta e economizar. Faz um 21 e aproveite.
 
 
 
 ___
 lilypond-user mailing list
 lilypond-user@gnu.org
 http://lists.gnu.org/mailman/listinfo/lilypond-user
 
 


Thanks Eduardo,

I am liking the GEMA pre-processor, here is how I implememnted snippet
libraries of canned lilypond code that can be macroized and for
inclusion in lilypond source.



SAMPLE chord library GEMA definition (the macro parameters are root,
chordname, duration with a period delimiter):

GEMA_Chord * * *.=\\transpose c $1 \{ \\relative \{\
\
@cmpi{$2;Maj7;; c e g b;}\
@cmpi{$2;Maj7_1;; c\5 g' b e;}\
@cmpi{$2;6;; c e g a;}\
! etc, etc, etc...\
\
$3 \} \};



SAMPLE of what the lilypond source would look like prior to GEMA resolution:

GEMA_Chord c Maj7 4.
GEMA_Chord c 6 4.



SAMPLE of what GEMA resolves (output to be compiled by lilypond):

\transpose c c { \relative { c e g b4 } }
\transpose c c { \relative { c e g a4 } }



This is much easier than scheme music functions for generating lp source
code.  GEMA was pretty easy to figure out how to use by a non-programmer
(like me), in about 2 hours time I was able to make the above chord library
macro.  I only have to now change my build scripts to run GEMA ahead of
lilypond.  To keep my LP code cleaner I'm prefixing all my future macros
with GEMA_.

In my sample above the @cmpi functions act like a big CASE statement to
output the desired music based on the second parameter (chord name).  The
first parameter (the chord root) is appended to a \transpose statement.  The
last parameter (the duration) is appended behind the generated notes.  In my
chord library I only need to state each chord inversion once (with roots of
c).  I expect the library to have a thousand different inversions eventually
so this will help in future productivity in generating chords for all
purposes.

Thanks again
Rick




-- 
View this message in context: 
http://www.nabble.com/Has-anyone-extended-%5Cinclude--tf2871492.html#a8067102
Sent from the Gnu - Lilypond - User mailing list archive at Nabble.com.



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


Has anyone extended \include?

2006-12-22 Thread Rick Hansen (aka RickH)

Has anyone on this list extended the \include lilypond command to also do
simple token replacement as it is including the text?  IOW like this:

\include myFile.ly @myToken1=a; @myToken2=25; @myToken3=replace with
this

Whereby @myToken1, 2 and 3 above will be whole word searched and replaced
with the data between the = sign and semi-colon.

Or similar?

Kind of like a smart \include?

If you have done this can you share it or sell it to me?  (please dont
suggest m4, I gave up on that monster)

Thanks


-- 
View this message in context: 
http://www.nabble.com/Has-anyone-extended-%5Cinclude--tf2871492.html#a8025808
Sent from the Gnu - Lilypond - User mailing list archive at Nabble.com.



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


Re: Has anyone extended \include?

2006-12-22 Thread Eduardo Vieira
Citando Rick Hansen (aka RickH) [EMAIL PROTECTED]:



 If you have done this can you share it or sell it to me?  (please dont
 suggest m4, I gave up on that monster)

 Thanks


Hi, Rick! Yes, this preprocessor looks scary, as well as some advanced
programming with Scheme. But once I got into reading about the GEMA
preprocessor and didn't look as complicated as m4. Maybe it's worth a try.
Another thing I found out that is *really* useful with text editing,
manipulating: Learn Regular Expressions. You can do quite a few tricky search
and replace tasks. And most of text editors for programmers support them.

Eduardo
___
Neste Fim de Ano, interurbano para cidades próximas ou distantes é com o  21.
A Embratel tem tarifas muito baratas de presente para você ligar para quem
você gosta e economizar. Faz um 21 e aproveite.



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


Re: Has anyone extended \include?

2006-12-22 Thread Rick Hansen (aka RickH)



Eduardo Vieira-3 wrote:
 
 Citando Rick Hansen (aka RickH) [EMAIL PROTECTED]:
 


 If you have done this can you share it or sell it to me?  (please dont
 suggest m4, I gave up on that monster)

 Thanks

 
 Hi, Rick! Yes, this preprocessor looks scary, as well as some advanced
 programming with Scheme. But once I got into reading about the GEMA
 preprocessor and didn't look as complicated as m4. Maybe it's worth a try.
 Another thing I found out that is *really* useful with text editing,
 manipulating: Learn Regular Expressions. You can do quite a few tricky
 search
 and replace tasks. And most of text editors for programmers support them.
 
 Eduardo
 ___
 Neste Fim de Ano, interurbano para cidades próximas ou distantes é com o 
 21.
 A Embratel tem tarifas muito baratas de presente para você ligar para quem
 você gosta e economizar. Faz um 21 e aproveite.
 
 
 
 ___
 lilypond-user mailing list
 lilypond-user@gnu.org
 http://lists.gnu.org/mailman/listinfo/lilypond-user
 
 

I was not aware of GEMA, (I already tried m4 and ML1 but was uncomfortable
with them in the mix), actually ideally I'd rather lilypond had it's own
source text pre-processor, then going forward my music would have no other
software dependencies other than a lilypond installation, IOW no 3rd party
macros.

I know of regular expressions and use them in my text editor searches, etc.
but this is more along the lines of making my lilypond music code itself
more flexible, I'm happy with many different editors and am trying to avoid
creating my lilypond music code libraries in any specific editors snippet
library.  I'd prefer to keep my libraries as lp \include files, but at some
point I'm always needing some pre-processing of the source text prior to lp
compilation.  Be it token replacement (to change \key perhaps), or a Case
statement to \include a parameterized chord inversion selection from a
library of chords, etc.



-- 
View this message in context: 
http://www.nabble.com/Has-anyone-extended-%5Cinclude--tf2871492.html#a8026572
Sent from the Gnu - Lilypond - User mailing list archive at Nabble.com.



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


Re: Has anyone extended \include?

2006-12-22 Thread Nicolas Sceaux
Rick Hansen (aka RickH) [EMAIL PROTECTED] writes:

 Has anyone on this list extended the \include lilypond command to also do
 simple token replacement as it is including the text?  IOW like this:

 \include myFile.ly @myToken1=a; @myToken2=25; @myToken3=replace with
 this

 Whereby @myToken1, 2 and 3 above will be whole word searched and replaced
 with the data between the = sign and semi-colon.

 Or similar?

 Kind of like a smart \include?

 If you have done this can you share it or sell it to me?  (please dont
 suggest m4, I gave up on that monster)

I use in my scores some functions called \includeScore, \includeNotes,
\includeLyrics, etc. You can look at the sources at
http://nicolas.sceaux.free.fr/lully/ or this article:
http://nicolas.sceaux.free.fr/index.php/2006/06/29/9

The LilyPond distribution has a function that makes a conditional
include: see \includePageLayoutFile in ly/music-functions-init.ly.

But then, there is no textual replacement when parsing LilyPond file;
instead you should use variables.

%% The function definition:
myInclude =
#(define-music-function (parser location filename bindings)
(string? list?)
  ..set some variables and include the file..
  (make-Music 'SequentialMusic 'void #t))

%% Function usage:
\myInclude foo.ily #'((myPadding . 4)
(myString . hello)
(myMusicPattern . #{ c d e f #}))

%% foo.ily:
\score {
  \new Staff {
\override TextScript #'padding = \myPadding
 
  s0^\markup \italic \myString 
  \repeat unfold 4 \myMusicPattern

  }
}

nicolas


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


Re: Has anyone extended \include?

2006-12-22 Thread Rick Hansen (aka RickH)

Thanks,

Browsing the manual GEMA looks like it could work to do both substitution
and conditional outputting, I'll try it.

Rick



Eduardo Vieira-3 wrote:
 
 Citando Rick Hansen (aka RickH) [EMAIL PROTECTED]:
 


 If you have done this can you share it or sell it to me?  (please dont
 suggest m4, I gave up on that monster)

 Thanks

 
 Hi, Rick! Yes, this preprocessor looks scary, as well as some advanced
 programming with Scheme. But once I got into reading about the GEMA
 preprocessor and didn't look as complicated as m4. Maybe it's worth a try.
 Another thing I found out that is *really* useful with text editing,
 manipulating: Learn Regular Expressions. You can do quite a few tricky
 search
 and replace tasks. And most of text editors for programmers support them.
 
 Eduardo
 ___
 Neste Fim de Ano, interurbano para cidades próximas ou distantes é com o 
 21.
 A Embratel tem tarifas muito baratas de presente para você ligar para quem
 você gosta e economizar. Faz um 21 e aproveite.
 
 
 
 ___
 lilypond-user mailing list
 lilypond-user@gnu.org
 http://lists.gnu.org/mailman/listinfo/lilypond-user
 
 

-- 
View this message in context: 
http://www.nabble.com/Has-anyone-extended-%5Cinclude--tf2871492.html#a8030107
Sent from the Gnu - Lilypond - User mailing list archive at Nabble.com.



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