FILENAME = 'filename'
FILTER = 'filter'
FRAGMENT = 'fragment'
-LANG = 'lang' ## TODO: This is handled nowhere!
LAYOUT = 'layout'
LILYQUOTE = 'lilyquote'
LINE_WIDTH = 'line-width'
NOFRAGMENT = 'nofragment'
NOGETTEXT = 'nogettext'
NOINDENT = 'noindent'
-NOQUOTE = 'noquote'
INDENT = 'indent'
NORAGGED_RIGHT = 'noragged-right'
NOTES = 'body'
# NOTIME and NOGETTEXT have no opposite so they aren't part of this
# dictionary.
-# NOQUOTE is used internally only.
no_options = {
NOFRAGMENT: FRAGMENT,
NOINDENT: INDENT,
PRINTFILENAME,
DOCTITLE,
TEXIDOC,
- LANG,
VERBATIM,
FILENAME,
ALT,
-FRAGMENT_LY = r'''
-%(notes_string)s
-{
-
-
-%% ****************************************************************
-%% ly snippet contents follows:
-%% ****************************************************************
-%(code)s
-
-
-%% ****************************************************************
-%% end ly snippet
-%% ****************************************************************
-}
-'''
-
def classic_lilypond_book_compatibility (key, value):
if key == 'singleline' and value == None:
return (RAGGED_RIGHT, None)
return (None, None)
+# TODO: Remove the 1mm additional padding in the line-width, once lilypond
+# creates tighter cropped images!
PREAMBLE_LY = '''%%%% Generated by %(program_name)s
%%%% Options: [%(option_string)s]
\\include "lilypond-book-preamble.ly"
\paper {
%(paper_string)s
- force-assignment = #""
- line-width = #(- line-width (* mm %(padding_mm)f))
+ %% offset the left padding, also add 1mm as lilypond creates cropped
+ %% images with a little space on the right
+ line-width = #(- line-width (* mm %(padding_mm)f) (* mm 1))
}
\layout {
%% ****************************************************************
'''
+FRAGMENT_LY = r'''
+%(notes_string)s
+{
+%% ****************************************************************
+%% ly snippet contents follows:
+%% ****************************************************************
+%(code)s
+%% ****************************************************************
+%% end ly snippet
+%% ****************************************************************
+}
+'''
+
if has_relative and not self.option_dict.has_key (FRAGMENT):
self.option_dict[FRAGMENT] = None
- if not has_line_width:
- if type == 'lilypond' or FRAGMENT in self.option_dict:
- self.option_dict[RAGGED_RIGHT] = None
-
- if type == 'lilypond':
- if LINE_WIDTH in self.option_dict:
- del self.option_dict[LINE_WIDTH]
- else:
- if RAGGED_RIGHT in self.option_dict:
- if LINE_WIDTH in self.option_dict:
- del self.option_dict[LINE_WIDTH]
-
- if QUOTE in self.option_dict or type == 'lilypond':
- if LINE_WIDTH in self.option_dict:
- del self.option_dict[LINE_WIDTH]
-
if not INDENT in self.option_dict:
self.option_dict[INDENT] = '0\\mm'
return self.option_list
def compose_ly (self, code):
- if FRAGMENT in self.option_dict:
- body = FRAGMENT_LY
- else:
- body = FULL_LY
# Defaults.
relative = 1
d = globals().copy()
d.update (locals())
d.update (self.global_options.information)
+ if FRAGMENT in self.option_dict:
+ body = FRAGMENT_LY
+ else:
+ body = FULL_LY
return (PREAMBLE_LY + body) % d
def get_checksum (self):
# UGH - junk self.global_options
skip_lily = self.global_options.skip_lilypond_run
- for required in [base + '.ly']:
+ for required in [base + '.ly',
+ base + '.txt']:
require_file (required)
if not skip_lily:
require_file (base + '-systems.count')
def convert_from_musicxml (self):
name = self.filename
- option_list = []
+ xml2ly_option_list = []
for (key, value) in self.option_dict.items ():
cmd_key = self.musicxml_options_dict.get (key, None)
if cmd_key == None:
continue
if value == None:
- option_list.append (cmd_key)
+ xml2ly_option_list.append (cmd_key)
else:
- option_list.append (cmd_key + '=' + value)
- if ('.mxl' in name) and ('--compressed' not in option_list):
- option_list.append ('--compressed')
+ xml2ly_option_list.append (cmd_key + '=' + value)
+ if ('.mxl' in name) and ('--compressed' not in xml2ly_option_list):
+ xml2ly_option_list.append ('--compressed')
self.compressed = True
- opts = " ".join (option_list)
+ opts = " ".join (xml2ly_option_list)
progress (_ ("Converting MusicXML file `%s'...\n") % self.filename)
ly_code = self.filter_pipe (self.contents, 'musicxml2ly %s --out=- - ' % opts)
out = file (filename, 'w')
out.write (self.full_ly ())
out.close ()
+ file (path + '.txt', 'w').write ('image of music')
+
class LilyPondVersionString (Snippet):