+def set_create_midi(option):
+ """
+ Implement the midi command line option '-m' and '--midi'.
+ If True, add midi-block to .ly file (see L{musicexp.Score.print_ly}).
+
+ @param option: Indicates whether the midi-block has to be added or not.
+ @type option: boolean
+ """
+ global midi_option
+ midi_option = option
+
+def get_create_midi ():
+ """
+ Return, if exists the state of the midi-option.
+
+ @return: The state of the midi-option.
+ @rtype: boolean
+ """
+ try:
+ return midi_option
+ except:
+ return False
+
+# implement the command line option '--transpose'
+def set_transpose(option):
+ global transpose_option
+ transpose_option = option
+
+def get_transpose(optType):
+ try:
+ if(optType == "string"):
+ return '\\transpose c %s' % transpose_option
+ elif(optType == "integer"):
+ p = generic_tone_to_pitch(transpose_option)
+ return p.semitones()
+ except:
+ if(optType == "string"):
+ return ""
+ elif(optType == "integer"):
+ return 0
+
+# implement the command line option '--tab-clef'
+def set_tab_clef(option):
+ global tab_clef_option
+ tab_clef_option = option
+
+def get_tab_clef():
+ try:
+ return ("tab", tab_clef_option)[tab_clef_option == "tab" or tab_clef_option == "moderntab"]
+ except:
+ return "tab"
+
+# definitions of the command line option '--string-numbers'
+def set_string_numbers(option):
+ global string_numbers_option
+ string_numbers_option = option
+
+def get_string_numbers():
+ try:
+ return ("t", string_numbers_option)[string_numbers_option == "t" or string_numbers_option == "f"]
+ except:
+ return "t"
+
+def generic_tone_to_pitch (tone):
+ accidentals_dict = {
+ "" : 0,
+ "es" : -1,
+ "s" : -1,
+ "eses" : -2,
+ "ses" : -2,
+ "is" : 1,
+ "isis" : 2
+ }
+ p = Pitch ()
+ tone_ = tone.strip().lower()
+ p.octave = tone_.count("'") - tone_.count(",")
+ tone_ = tone_.replace(",","").replace("'","")
+ p.step = ((ord (tone_[0]) - ord ('a') + 5) % 7)
+ p.alteration = accidentals_dict.get(tone_[1:], 0)
+ return p