- global length_specified
- m = re.match ('^([A-Za-z]): *(.*)$', ln)
-
- if m:
- g =m.group (1)
- a = m.group (2)
- if g == 'T': #title
- a = re.sub('[ \t]*$','', a) #strip trailing blanks
- if header.has_key('title'):
- if a:
- if len(header['title']):
- # the non-ascii character
- # in the string below is a
- # punctuation dash. (TeX ---)
- header['title'] = header['title'] + ' — ' + a
- else:
- header['subtitle'] = a
- else:
- header['title'] = a
- if g == 'M': # Meter
- if a == 'C':
- if not state.common_time:
- state.common_time = 1
- voices_append (" \\override Staff.TimeSignature #\'style = #'C\n")
- a = '4/4'
- if a == 'C|':
- if not state.common_time:
- state.common_time = 1
- voices_append ("\\override Staff.TimeSignature #\'style = #'C\n")
- a = '2/2'
- if not length_specified:
- set_default_len_from_time_sig (a)
- else:
- length_specified = 0
- if not a == 'none':
- voices_append ('\\time %s' % a)
- state.next_bar = ''
- if g == 'K': # KEY
- a = check_clef(a)
- if a:
- m = re.match ('^([^ \t]*) *(.*)$', a) # seperate clef info
- if m:
- # there may or may not be a space
- # between the key letter and the mode
- if key_lookup.has_key(m.group(2)[0:3]):
- key_info = m.group(1) + m.group(2)[0:3]
- clef_info = m.group(2)[4:]
- else:
- key_info = m.group(1)
- clef_info = m.group(2)
- __main__.global_key = compute_key (key_info)
- k = lily_key (key_info)
- if k:
- voices_append ('\\key %s' % k)
- check_clef(clef_info)
- else:
- __main__.global_key = compute_key (a)
- k = lily_key (a)
- if k:
- voices_append ('\\key %s \\major' % k)
- if g == 'N': # Notes
- header ['footnotes'] = header['footnotes'] + '\\\\\\\\' + a
- if g == 'O': # Origin
- header ['origin'] = a
- if g == 'X': # Reference Number
- header ['crossRefNumber'] = a
- if g == 'A': # Area
- header ['area'] = a
- if g == 'H': # History
- header_append ('history', a)
- if g == 'B': # Book
- header ['book'] = a
- if g == 'C': # Composer
- if header.has_key('composer'):
- if a:
- header['composer'] = header['composer'] + '\\\\\\\\' + a
- else:
- header['composer'] = a
- if g == 'S':
- header ['subtitle'] = a
- if g == 'L': # Default note length
- set_default_length (ln)
- if g == 'V': # Voice
- voice = re.sub (' .*$', '', a)
- rest = re.sub ('^[^ \t]* *', '', a)
- if state.next_bar:
- voices_append(state.next_bar)
- state.next_bar = ''
- select_voice (voice, rest)
- if g == 'W': # Words
- lyrics_append(a)
- if g == 'w': # vocals
- slyrics_append (a)
- if g == 'Q': #tempo
- try_parse_q (a)
- return ''
- return ln
+ global length_specified
+ m = re.match ('^([A-Za-z]): *(.*)$', ln)
+
+ if m:
+ g =m.group (1)
+ a = m.group (2)
+ if g == 'T': #title
+ a = re.sub('[ \t]*$','', a) #strip trailing blanks
+ if header.has_key('title'):
+ if a:
+ if len(header['title']):
+ # the non-ascii character
+ # in the string below is a
+ # punctuation dash. (TeX ---)
+ header['title'] = header['title'] + ' — ' + a
+ else:
+ header['subtitle'] = a
+ else:
+ header['title'] = a
+ if g == 'M': # Meter
+ if a == 'C':
+ if not state.common_time:
+ state.common_time = 1
+ voices_append (" \\override Staff.TimeSignature #'style = #'C\n")
+ a = '4/4'
+ if a == 'C|':
+ if not state.common_time:
+ state.common_time = 1
+ voices_append ("\\override Staff.TimeSignature #'style = #'C\n")
+ a = '2/2'
+ if not length_specified:
+ set_default_len_from_time_sig (a)
+ else:
+ length_specified = 0
+ if not a == 'none':
+ voices_append ('\\time %s' % a)
+ state.next_bar = ''
+ if g == 'K': # KEY
+ a = check_clef(a)
+ if a:
+ m = re.match ('^([^ \t]*) *([^ ]*)( *)(.*)$', a) # separate clef info
+ if m:
+ # there may or may not be a space
+ # between the key letter and the mode
+ # convert the mode to lower-case before comparing
+ mode = m.group(2)[0:3].lower();
+ if key_lookup.has_key(mode):
+ # use the full mode, not only the first three letters
+ key_info = m.group(1) + m.group(2).lower()
+ clef_info = a[m.start(4):]
+ else:
+ key_info = m.group(1)
+ clef_info = a[m.start(2):]
+ __main__.global_key = compute_key (key_info)
+ k = lily_key (key_info)
+ if k:
+ voices_append ('\\key %s' % k)
+ check_clef(clef_info)
+ else:
+ __main__.global_key = compute_key (a)
+ k = lily_key (a)
+ if k:
+ voices_append ('\\key %s \\major' % k)
+ if g == 'N': # Notes
+ header ['footnotes'] = header['footnotes'] + '\\\\\\\\' + a
+ if g == 'O': # Origin
+ header ['origin'] = a
+ if g == 'X': # Reference Number
+ header ['crossRefNumber'] = a
+ if g == 'A': # Area
+ header ['area'] = a
+ if g == 'H': # History
+ header_append ('history', a)
+ if g == 'B': # Book
+ header ['book'] = a
+ if g == 'C': # Composer
+ if header.has_key('composer'):
+ if a:
+ header['composer'] = header['composer'] + '\\\\\\\\' + a
+ else:
+ header['composer'] = a
+ if g == 'S':
+ header ['subtitle'] = a
+ if g == 'L': # Default note length
+ set_default_length (ln)
+ if g == 'V': # Voice
+ voice = re.sub (' .*$', '', a)
+ rest = re.sub ('^[^ \t]* *', '', a)
+ if state.next_bar:
+ voices_append(state.next_bar)
+ state.next_bar = ''
+ select_voice (voice, rest)
+ if g == 'W': # Words
+ lyrics_append(a)
+ if g == 'w': # vocals
+ slyrics_append (a)
+ if g == 'Q': #tempo
+ try_parse_q (a)
+ return ''
+ return ln