+def check_clef(s):
+ if not s:
+ return ''
+ if re.match('-8va', s) or re.match('treble8', s):
+ # treble8 is used by abctab2ps; -8va is used by barfly,
+ # and by my patch to abc2ps. If there's ever a standard
+ # about this we'll support that.
+ s = s[4:]
+ state.base_octave = -1
+ voices_append("\\clef \"G_8\"\n")
+ elif re.match('^treble', s):
+ s = s[6:]
+ if re.match ('^-8', s):
+ s = s[2:]
+ state.base_octave = -2
+ voices_append("\\clef \"G_8\"\n")
+ else:
+ state.base_octave = 0
+ voices_append("\\clef treble\n")
+ elif re.match('^alto', s):
+ s = s[4:]
+ state.base_octave = -1
+ voices_append ("\\clef alto\n" )
+ elif re.match('^bass',s ):
+ s = s[4:]
+ state.base_octave = -2
+ voices_append ("\\clef bass\n" )
+ return s
+
+def select_voice (name, rol):
+ if not voice_idx_dict.has_key (name):
+ state_list.append(Parser_state())
+ voices.append ('')
+ slyrics.append ([])
+ voice_idx_dict[name] = len (voices) -1
+ __main__.current_voice_idx = voice_idx_dict[name]
+ __main__.state = state_list[current_voice_idx]
+ while rol != '':
+ m = re.match ('^([^ \t=]*)=(.*)$', rol) # find keywork
+ if m:
+ keyword = m.group(1)
+ rol = m.group (2)
+ a = re.match ('^("[^"]*"|[^ \t]*) *(.*)$', rol)
+ if a:
+ value = a.group (1)
+ rol = a.group ( 2)
+ if keyword == 'clef':
+ check_clef(value)
+ elif keyword == "name":
+ value = re.sub ('\\\\','\\\\\\\\', value)
+ ## < 2.2
+ ##voices_append ("\\property Staff.instrument = %s\n" % value )
+ voices_append ("\\set Staff.instrument = %s\n" % value )
+
+ __main__.part_names = 1
+ elif keyword == "sname" or keyword == "snm":
+ ##voices_append ("\\property Staff.instr = %s\n" % value )
+ voices_append ("\\set Staff.instr = %s\n" % value )
+ else:
+ break