def add_note(self, note, octave=None, dynamics={}):
        if type(note) == str:
            if octave is not None:
                note = Note(note, octave, dynamics)
            elif len(self.notes) == 0:
                note = Note(note, 4, dynamics)
            else:
                if Note(note, self.notes[-1].octave) < self.notes[-1]:
                    note = Note(note, self.notes[-1].octave + 1, dynamics)
                else:
                    note = Note(note, self.notes[-1].octave, dynamics)
        if not hasattr(note, 'name'):
            raise UnexpectedObjectError("Object '%s' was not expected. "
                    "Expecting a mingus.containers.Note object." % note)
        if note not in self.notes:
            self.notes.append(note)
            self.notes.sort()
        return self.notes