[PATCH]: Tracker 836 - Allow output filename and output-suffix to be specified for a \book block

2009-10-23 Thread Ian Hulin
init.ly - Add new parser variables book-output-suffix and book-filename 
initialized as #f and empty queue/stack structure.


music-functions-init.ly adds three new functions

   * \bookOutputSuffix - to set the output suffix for the \book block
   * \bookOutputName - to set output filename for the current \book block
   * \bookOuptutNameRevert - to restore the the output filename to the
 value prior to that of the last \bookOuputName call.

\bookOutputName and \bookOuptutNameRevert use the book-filename as a 
stack structure.  I have used this so we can we could eventually allow 
users to do stuff like the following (controlling the names used to open 
the midi files is *not* part of the current patch).

\book {
   \bookOutputName "My-Homeland"
   \score {
  \bookOutputName "Vysehrad"
 music-declarations ...
 \midi{
 % midi file gets written to Vysehrad.mid(i)
 }
 \layout{
 }
  \bookOutputNameRevert
   }
   \score {
   \bookOuputName "Vltava"
   ...
   \midi {
   % midi file is written to Vltava.mid(i)
   }
   }
.
.
. 

lily-library.scm has changes to the filename generating code in 
print-book-with to pick up the current values of the new parser 
variables if set before using the current output-suffix or result of a 
call to ly:parser-output-name.
The routine to get the name now uses as combination of the current 
output name and output suffix value to at as a key for the internal 
a-list of filenames being written to during a compilation.


lily-guile.hh, lily-guile.cc and parser.yy have code that I would like 
to use to re-initialize book-output-suffix and book-filename to initial 
values on encountering the end of a \book block, but  I've hit a 
dead-end currently in this  as the code I tried to use in parser.yy 
negates the effect of calling the new functions altogether.  If anyone 
with more experience of how bison works has any better ideas as to how 
do this I'd be interested in hearing them.


Thanks in advance for any feedback.

Cheers,

Ian Hulin


>From c99522fea1e518f33b24307b7b64f5780bb34add Mon Sep 17 00:00:00 2001
From: ian 
Date: Fri, 23 Oct 2009 02:06:24 +0100
Subject: [PATCH] Tracker 836:
  Add facility to change output file-name for a \book block or to set a
  suffix to prevent multiple files over-writing each other during a
  compilation.
  This change allows user to to this via functions rather than having to do so
  so by manipulating semi-documented parser variables.

---
 input/regression/backend-svg.ly |4 +-
 lily/include/lily-guile.hh  |2 +
 lily/lily-guile.cc  |   11 
 lily/parser.yy  |7 +
 ly/init.ly  |3 ++
 ly/music-functions-init.ly  |   52 +++
 scm/lily-library.scm|   52 --
 7 files changed, 99 insertions(+), 32 deletions(-)

diff --git a/input/regression/backend-svg.ly b/input/regression/backend-svg.ly
index 69116f1..b8b6ffd 100644
--- a/input/regression/backend-svg.ly
+++ b/input/regression/backend-svg.ly
@@ -1,6 +1,6 @@
 %{
 #(ly:set-option 'backend 'svg)
-#(set! output-count 1)
+#(define output-suffix "1")
 
 
 \include "typography-demo.ly"
@@ -26,7 +26,7 @@
(format #f "FONTCONFIG_FILE=~a/fonts/fonts.conf" (ly:effective-prefix))
(ly:start-environment)))
 
-#(set! output-count 0)
+#(define output-suffix #f)
 #(set-default-paper-size "a5")
 
 \book { 
diff --git a/lily/include/lily-guile.hh b/lily/include/lily-guile.hh
index 859131a..ec1b0b0 100644
--- a/lily/include/lily-guile.hh
+++ b/lily/include/lily-guile.hh
@@ -117,6 +117,8 @@ inline SCM ly_append4 (SCM x1, SCM x2, SCM x3, SCM x4)
   return scm_append (scm_listify (x1, x2, x3, x4, SCM_UNDEFINED));
 }
 
+SCM ly_scm_make_q ();
+
 /*
   display and print newline.
 */
diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc
index d81eec8..f3054b9 100644
--- a/lily/lily-guile.cc
+++ b/lily/lily-guile.cc
@@ -187,6 +187,17 @@ to_boolean (SCM s)
 }
 
 /*
+ QUEUES - for compatibility with (ice-9 q)
+ 1. ly_scm_make_q - initialize a queue
+*/
+
+SCM
+ly_scm_make_q ()
+{  
+return scm_cons ( SCM_EOL, SCM_BOOL_F);
+}
+
+/*
   DIRECTIONS
  */
 Direction
diff --git a/lily/parser.yy b/lily/parser.yy
index 813452e..12a3e6b 100644
--- a/lily/parser.yy
+++ b/lily/parser.yy
@@ -656,6 +656,13 @@ book_block:
 		$$ = $3;
 		pop_paper (PARSER);
 		PARSER->lexer_->set_identifier (ly_symbol2scm ("$current-book"), SCM_BOOL_F);
+/*		TODO
+*It would be nice to scope book-output-suffix and book-filename to the current 
+*book block, but using this cancels
+*_all_ changes made by calling the functions in the \book block.
+*PARSER->lexer_->set_identifier (ly_symbol2scm ("book-output-suffix"), SCM_BOOL_F); 
+*		 PARSER->lexer_->set_identifier (ly_symbol2scm ("book-filename"), ly_scm_make_q () ); 
+*/
 	}
 	;
 
diff --git a/ly/init.ly b/ly/init.ly
index 5418b80..bc2

Re: Alternative music font

2009-10-23 Thread Han-Wen Nienhuys
On Mon, Oct 19, 2009 at 5:36 PM, Bertalan Fodor (LilyPondTool)
 wrote:
> Wow too.
> Actually, there are things in Feta what I don't feel natural either.
> For example: the caesura sign, the G-clef and the trill indication feels
> better for me in Gonville.
> Though the G-clef is I think a clear LilyPond watermark, so I would keep
> that one :)

I am to blame for curve in the downstroke of the clef, and I am not
satisfied with it either.  We had a straight version at some point,
but I gave up on it, because I couldnt get the transition at the
bottom crook from straight to curve correct, also I liked the somewhat
swingy feel of the curved downstroke, but I agree it could be less
curvy.


-- 
Han-Wen Nienhuys - han...@xs4all.nl - http://www.xs4all.nl/~hanwen


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


Review of your modified midi2ly

2009-10-23 Thread John Mandereau
Hi Martin,

I reviewed your changed version on midi2ly with inclusion in official
sources in mind, the patch that match your work (minus trailing
whitespaces and indentation errors).  If you want your future work on
midi2ly to be considered for committing into official sources, it is
highly recommended to send patches (instead of the full file) to this
list, although you are free to send again the full script to user-list
to make user testing easier.  You can read more about submitting patches
in out Contributor's guide.

I'm sorry to set higher requirements on code quality than the original
code, but not doing so would not arrange the bad maintenance state of
this script, and would not encourage future work on it.


> diff --git a/scripts/midi2ly.py b/scripts/midi2ly.py
> index c57c788..040dec5 100644
> --- a/scripts/midi2ly.py
> +++ b/scripts/midi2ly.py
> @@ -11,7 +11,7 @@
>  '''
>  TODO:
>  * test on weird and unquantised midi input (lily-devel)
> -* update doc and manpage
> +* update doc and manpage and translations

Updating translations is just a matter of updating lilypond.pot and
sending it to the Translation Project, it doesn't require changing this
script again, so you needn't change this line.  However, you could add
something like

   * move each global variable used in the conversion process to
global_options or per-file variable

(see just below)


> @@ -497,19 +505,28 @@ def events_on_channel (channel):
>  seconds_per_1 = us_per_4 * 4 / 1e6
>  events.append ((t, Tempo (seconds_per_1)))
>  elif e[1][1] == midi.TIME_SIGNATURE:
> +global num, den

Global variables are evil when multiple files can be processed, better
define these as per-files variables or attributes of global_options.


>  (num, dur, clocks4, count32) = map (ord, e[1][2])
>  den = 2 ** dur 
> +if global_options.mytime:
> +   num = 
> int(global_options.mytime[:global_options.mytime.index('/')])
> +   den = 
> int(global_options.mytime[global_options.mytime.index('/')+1:])

Could you rewrite this using something more concise and clear like

num, den = [int (s) for s in global_options.mytime.split ('/')]

after having checked at the options parsing stage that mytime has a correct 
form?


>  events.append ((t, Time (num, den)))
>  elif e[1][1] == midi.KEY_SIGNATURE:
>  (alterations, minor) = map (ord, e[1][2])
>  sharps = 0
>  flats = 0
> +
>  if alterations < 127:
>  sharps = alterations
>  else:
>  flats = 256 - alterations
>  
> -k = Key (sharps, flats, minor)
> +if mysharps == myflats:
> +k = Key (sharps, flats, minor)
> +else:
> +k = Key (mysharps, myflats, myminor)
> +

Why do you use variable names starting with "my"?  If it means some
values can be overriden by the user, this should not appear in the
variable names but the variables should be initalized with the values
properties of global_options in case this override is forced by some
option or makes sense in all situations.


> +def mykey (sharps, flats, minor):
> +ks = [ 'g' , 'd' , 'a' , 'e' , 'b' , 'fis' , 'cis', 'gis', 'dis' ]
> +kf = [ 'd', 'g', 'c' , 'f' , 'bes' , 'es' , 'as' , 'des' , 'ges' , 'ces' 
> ] 
> +if sharps > 0:
> +mykey = ks [ sharps - 1 + 3*minor ]
> +elif flats > 0:
> +mykey = kf [ 2 + flats - 3*minor ]
> +else:
> +if minor == 1:
> +mykey = 'a'
> +else:
> +mykey = 'c'

Nice, but why don't you handle the case sharps == flats == 0 by
prepending 'a' to kf, replacing "elif flats...:" with "else:" and adding
1 to kf index?  You could even have only one list named fifth_helix and
use -flats instead of +flats.

By the way:
- this list (or these two lists) should be tuples,
- this duplicates lists at the beginning of class Key,
- full names (with underscores for compound names) would be better than
initialisms like kf, ks;
- we use no space at the inside side of brackets and parentheses, e.g.
"[sharps - 1]" and not "[ sharps -1 ]", and list and dictionary
subscripts should not be separated by space, e.g.
"ks[sharps - 1]" not "ks [sharps - 1]".

Oh, and did you notice your function duplicates the functionality of
Key.dump?  Please consider replacing Key.dump with your function, which
I find clearer.

 
>  def convert_midi (in_file, out_file):
>  global clocks_per_1, clocks_per_4, key
>  global start_quant_clocks
> -global  duration_quant_clocks
> +global duration_quant_clocks
>  global allowed_tuplet_clocks
> +global mysharps, myflats, myminor, use_mykey

Same thing as above: prefer global options, or variables specific to
each file, over global variables.



>  str = ope

Re: [frogs] [PATCH] : Supply missing documentation strings in music-function-init.ly

2009-10-23 Thread Ian Hulin

And here's the patch actually attached (sorry for the noise).

Ian

Ian Hulin wrote:


Neil Puttock wrote:

2009/10/20 Ian Hulin :
  

Please push if these changes look OK.



Hmm, this looks suspiciously like one of the patches you posted last
month, but missing some of the changes I suggested.
  
Cor, blimey, guv'nor, you've got me banged to rights (serves me right 
for trying to tidy up my git repository).

+#(use-modules (ice-9 q))

I can't see any procedures from this module in init.ly.
  

Changed from another patch I was working on, reverted for this patch.

+#(define output-count 0)% Now only used in regression tests

This isn't user serviceable any more, so you might as well clear out
all remaining references to it (and the obsolete code).
  
Removed.  The only remaining thing I could see in git which used it was 
a regression test where the whole lot of code was commented out 
(input/regression/backend-svg.ly).  Reinhold has already changed the 
regression test where it is actually used.

+(_i "Take the music in @var{part1} and @var{part2} and typeset so
that they share a staff")

staff.")

+(_i "Print a trill with @var{main-note} as the main note of the trill and

trailing space, docstring goes after predicate list

+print @var{secondary-note} as stemless note head in paretheses")

parentheses.")

+(_i "Indicate a section of music to be quoted.  @var{what} indicates the name

trailing space, docstring goes after predicate list

+of the quoted voice, as specified in a @code{\addquote} command.

trailing spaces, @code{\\addQuote}

+(_i "Set up a custom style of dash pattern for @var{dash-fraction} ratio of

trailing space

+(_i "Set up a custom style of dash pattern for @var{dash-fraction} ratio of

trailing space
  

All these are re-applied.

In all cases, the indentation needs fixing.
  

Have run the code through the Frescobaldi indent tool.

Now is it OK to push?

Cheers,
Ian





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


>From a0d99140b6199199b846db9fa07a5b568a90b16d Mon Sep 17 00:00:00 2001
From: ian 
Date: Fri, 23 Oct 2009 01:49:11 +0100
Subject: [PATCH] Add missing documentation strings to declarations in
 music-functions-init.ly.
 Redundant output-count parser variable removed

---
 ly/init.ly |2 --
 ly/music-functions-init.ly |   20 +++-
 ly/property-init.ly|7 +++
 3 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/ly/init.ly b/ly/init.ly
index 9304810..5418b80 100644
--- a/ly/init.ly
+++ b/ly/init.ly
@@ -8,11 +8,9 @@
 
 \include "declarations-init.ly"
 
-
 #(ly:set-option 'old-relative #f)
 #(define toplevel-scores (list))
 #(define toplevel-bookparts (list))
-#(define output-count 0) 
 #(define $defaultheader #f)
 #(define $current-book #f)
 #(define $current-bookpart #f)
diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly
index 718615a..a8a2ece 100644
--- a/ly/music-functions-init.ly
+++ b/ly/music-functions-init.ly
@@ -323,7 +323,7 @@ killCues =
(music-map
 (lambda (mus)
   (if (and (string? (ly:music-property mus 'quoted-music-name))
-	   (string=? (ly:music-property mus 'quoted-context-id "") "cue"))
+  (string=? (ly:music-property mus 'quoted-context-id "") "cue"))
 	  (ly:music-property mus 'element)
 	  mus)) music))
 
@@ -449,8 +449,8 @@ or @code{\"GrobName\"}")
 %% because music identifiers are not allowed at top-level.
 pageBreak =
 #(define-music-function (location parser) ()
-   (_i "Force a page break. May be used at toplevel (ie between scores or
-markups), or inside a score.")
+   (_i "Force a page break. May be used at toplevel (i.e. between scores or
+ markups), or inside a score.")
(make-music 'EventChord
 	   'page-marker #t
 	   'line-break-permission 'force
@@ -584,11 +584,14 @@ parenthesize =
 
 partcombine =
 #(define-music-function (parser location part1 part2) (ly:music? ly:music?)
-		(make-part-combine-music parser
+(_i "Take the music in @var{part1} and @var{part2} and typeset so that they share a staff.")
+(make-part-combine-music parser
 	 (list part1 part2)))
 
 pitchedTrill =
 #(define-music-function
+(_i "Print a trill with @var{main-note} as the main note of the trill and 
+print @var{secondary-note} as stemless note head in parentheses")
(parser location main-note secondary-note)
(ly:music? ly:music?)
(let*
@@ -622,6 +625,10 @@ pitchedTrill =
 
 quoteDuring =
 #(define-music-function
+(_i "Indicate a section of music to be quoted.  @var{what} indicates the name 
+of the quoted voice, as specified in a @code{\\addQuote} command.  
+...@var{main-music} is used to indicate the length of music to be quoted;
+usually contains spacers or multi-measure rests.")
   (parser location what main-music)
   (string? ly:music?)

Re: [frogs] [PATCH] : Supply missing documentation strings in music-function-init.ly

2009-10-23 Thread Ian Hulin


Neil Puttock wrote:

2009/10/20 Ian Hulin :
  

Please push if these changes look OK.



Hmm, this looks suspiciously like one of the patches you posted last
month, but missing some of the changes I suggested.
  
Cor, blimey, guv'nor, you've got me banged to rights (serves me right 
for trying to tidy up my git repository).

+#(use-modules (ice-9 q))

I can't see any procedures from this module in init.ly.
  

Changed from another patch I was working on, reverted for this patch.

+#(define output-count 0)% Now only used in regression tests

This isn't user serviceable any more, so you might as well clear out
all remaining references to it (and the obsolete code).
  
Removed.  The only remaining thing I could see in git which used it was 
a regression test where the whole lot of code was commented out 
(input/regression/backend-svg.ly).  Reinhold has already changed the 
regression test where it is actually used.

+(_i "Take the music in @var{part1} and @var{part2} and typeset so
that they share a staff")

staff.")

+(_i "Print a trill with @var{main-note} as the main note of the trill and

trailing space, docstring goes after predicate list

+print @var{secondary-note} as stemless note head in paretheses")

parentheses.")

+(_i "Indicate a section of music to be quoted.  @var{what} indicates the name

trailing space, docstring goes after predicate list

+of the quoted voice, as specified in a @code{\addquote} command.

trailing spaces, @code{\\addQuote}

+(_i "Set up a custom style of dash pattern for @var{dash-fraction} ratio of

trailing space

+(_i "Set up a custom style of dash pattern for @var{dash-fraction} ratio of

trailing space
  

All these are re-applied.

In all cases, the indentation needs fixing.
  

Have run the code through the Frescobaldi indent tool.

Now is it OK to push?

Cheers,
Ian


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