MCPcopy Create free account
hub / github.com/bspaans/python-mingus / add_note

Method add_note

mingus/containers/note_container.py:50–76  ·  view source on GitHub ↗

Add a note to the container and sorts the notes from low to high. The note can either be a string, in which case you could also use the octave and dynamics arguments, or a Note object.

(self, note, octave=None, dynamics=None)

Source from the content-addressed store, hash-verified

48 self.notes = []
49
50 def add_note(self, note, octave=None, dynamics=None):
51 """Add a note to the container and sorts the notes from low to high.
52
53 The note can either be a string, in which case you could also use
54 the octave and dynamics arguments, or a Note object.
55 """
56 if dynamics is None:
57 dynamics = {}
58 if isinstance(note, six.string_types):
59 if octave is not None:
60 note = Note(note, octave, dynamics)
61 elif len(self.notes) == 0:
62 note = Note(note, 4, dynamics)
63 else:
64 if Note(note, self.notes[-1].octave) < self.notes[-1]:
65 note = Note(note, self.notes[-1].octave + 1, dynamics)
66 else:
67 note = Note(note, self.notes[-1].octave, dynamics)
68 if not hasattr(note, "name"):
69 raise UnexpectedObjectError(
70 "Object '%s' was not expected. "
71 "Expecting a mingus.containers.Note object." % note
72 )
73 if note not in self.notes:
74 self.notes.append(note)
75 self.notes.sort()
76 return self.notes
77
78 def add_notes(self, notes):
79 """Feed notes to self.add_note.

Callers 1

add_notesMethod · 0.95

Calls 3

NoteClass · 0.90
sortMethod · 0.80

Tested by

no test coverage detected