An easy to extend base class that can be used to observe a Sequencer. Each time a Sequencer starts playing a new Note, Bar, w/e, an event is fired; this SequencerObserver intercepts the event messages and calls the proper function so you only have to implement the functions for the
| 30 | |
| 31 | |
| 32 | class SequencerObserver(object): |
| 33 | |
| 34 | """An easy to extend base class that can be used to observe a Sequencer. |
| 35 | |
| 36 | Each time a Sequencer starts playing a new Note, Bar, w/e, an event is |
| 37 | fired; this SequencerObserver intercepts the event messages and calls |
| 38 | the proper function so you only have to implement the functions for the |
| 39 | events you need to see. |
| 40 | """ |
| 41 | |
| 42 | # Low Level MIDI Events |
| 43 | def play_int_note_event(self, int_note, channel, velocity): |
| 44 | pass |
| 45 | |
| 46 | def stop_int_note_event(self, int_note, channel): |
| 47 | pass |
| 48 | |
| 49 | def cc_event(self, channel, control, value): |
| 50 | pass |
| 51 | |
| 52 | def instr_event(self, channel, instr, bank): |
| 53 | pass |
| 54 | |
| 55 | def sleep(self, seconds): |
| 56 | pass |
| 57 | |
| 58 | def play_Note(self, note, channel, velocity): |
| 59 | pass |
| 60 | |
| 61 | def stop_Note(self, note, channel): |
| 62 | pass |
| 63 | |
| 64 | def play_NoteContainer(self, notes, channel): |
| 65 | pass |
| 66 | |
| 67 | def stop_NoteContainer(self, notes, channel): |
| 68 | pass |
| 69 | |
| 70 | def play_Bar(self, bar, channel, bpm): |
| 71 | pass |
| 72 | |
| 73 | def play_Bars(self, bars, channels, bpm): |
| 74 | pass |
| 75 | |
| 76 | def play_Track(self, track, channel, bpm): |
| 77 | pass |
| 78 | |
| 79 | def play_Tracks(self, tracks, channels, bpm): |
| 80 | pass |
| 81 | |
| 82 | def play_Composition(self, composition, channels, bpm): |
| 83 | pass |
| 84 | |
| 85 | def notify(self, msg_type, params): |
| 86 | if msg_type == Sequencer.MSG_PLAY_INT: |
| 87 | self.play_int_note_event( |
| 88 | params["note"], params["channel"], params["velocity"] |
| 89 | ) |