+class FretBoardNote (Music):
+ def __init__ (self):
+ Music.__init__ (self)
+ self.pitch = None
+ self.string = None
+ self.fingering = None
+ def ly_expression (self):
+ str = self.pitch.ly_expression()
+ if self.fingering:
+ str += "-%s" % self.fingering
+ if self.string:
+ str += "\%s" % self.string
+ return str
+
+class FretBoardEvent (NestedMusic):
+ def __init__ (self):
+ NestedMusic.__init__ (self)
+ self.duration = None
+ def print_ly (self, printer):
+ fretboard_notes = [n for n in self.elements if isinstance (n, FretBoardNote)]
+ if fretboard_notes:
+ notes = []
+ for n in fretboard_notes:
+ notes.append (n.ly_expression ())
+ contents = string.join (notes)
+ printer ('<%s>%s' % (contents,self.duration))
+
+class FunctionWrapperEvent (Event):
+ def __init__ (self, function_name=None):
+ Event.__init__ (self)
+ self.function_name = function_name
+ def pre_note_ly (self, is_chord_element):
+ if self.function_name:
+ return "\\%s" % self.function_name
+ else:
+ return ''
+ def pre_chord_ly (self):
+ return ''
+ def ly_expression (self):
+ if self.function_name:
+ return "\\%s" % self.function_name
+ else:
+ return ''
+
+class ParenthesizeEvent (FunctionWrapperEvent):
+ def __init__ (self):
+ FunctionWrapperEvent.__init__ (self, "parenthesize")
+
+class StemEvent (Event):
+ """"
+ A class to take care of stem values (up, down, double, none)
+ """
+ def __init__ (self):
+ Event.__init__ (self)
+ self.value = None
+ def pre_chord_ly (self):
+ if self.value:
+ return "\\%s" % self.value
+ else:
+ return ''
+ def pre_note_ly (self, is_chord_element):
+ return ''
+ def ly_expression (self):
+ return self.pre_chord_ly ()
+
+class NotestyleEvent (Event): #class changed by DaLa: additional attribute color
+ def __init__ (self):
+ Event.__init__ (self)
+ self.style = None
+ self.filled = None
+ self.color = None
+ def pre_chord_ly (self):
+ return_string = ''
+ if self.style:
+ return_string += " \\once \\override NoteHead #'style = #%s" % self.style
+ if self.color:
+ return_string += " \\once \\override NoteHead #'color = #(rgb-color %s %s %s)" % (self.color[0], self.color[1], self.color[2])
+ return return_string
+ def pre_note_ly (self, is_chord_element):
+ if self.style and is_chord_element:
+ return "\\tweak #'style #%s" % self.style
+ else:
+ return ''
+ def ly_expression (self):
+ return self.pre_chord_ly ()
+
+class StemstyleEvent (Event): #class added by DaLa
+ def __init__ (self):
+ Event.__init__ (self)
+ self.color = None
+ def pre_chord_ly (self):
+ if self.color:
+ return "\\once \\override Stem #'color = #(rgb-color %s %s %s)" % (self.color[0], self.color[1], self.color[2])
+ else:
+ return ''
+ def pre_note_ly (self, is_chord_element):
+ return ''
+ def ly_expression (self):
+ return self.pre_chord_ly ()
+
+