Place the notes on the current_beat. Notes can be strings, Notes, list of strings, list of Notes or a NoteContainer. Raise a MeterFormatError if the duration is not valid. Return True if succesful, False otherwise (ie. the Bar hasn't got enough room for a n
(self, notes, duration)
| 78 | ) |
| 79 | |
| 80 | def place_notes(self, notes, duration): |
| 81 | """Place the notes on the current_beat. |
| 82 | |
| 83 | Notes can be strings, Notes, list of strings, list of Notes or a |
| 84 | NoteContainer. |
| 85 | |
| 86 | Raise a MeterFormatError if the duration is not valid. |
| 87 | |
| 88 | Return True if succesful, False otherwise (ie. the Bar hasn't got |
| 89 | enough room for a note of that duration). |
| 90 | """ |
| 91 | # note should be able to be one of strings, lists, Notes or |
| 92 | # NoteContainers |
| 93 | if hasattr(notes, "notes"): |
| 94 | pass |
| 95 | elif hasattr(notes, "name"): |
| 96 | notes = NoteContainer(notes) |
| 97 | elif isinstance(notes, six.string_types): |
| 98 | notes = NoteContainer(notes) |
| 99 | elif isinstance(notes, list): |
| 100 | notes = NoteContainer(notes) |
| 101 | if self.current_beat + 1.0 / duration <= self.length or self.length == 0.0: |
| 102 | self.bar.append([self.current_beat, duration, notes]) |
| 103 | self.current_beat += 1.0 / duration |
| 104 | return True |
| 105 | else: |
| 106 | return False |
| 107 | |
| 108 | def place_notes_at(self, notes, at): |
| 109 | """Place notes at the given index.""" |