b1e27f9f344aec6da656767638c25fefb797311f
[minwii.git] / src / mxmMidi / example_print_events.py
1 from MidiToText import MidiToText
2
3 """
4 This is an example that uses the MidiToText eventhandler. When an
5 event is triggered on it, it prints the event to the console.
6 """
7
8 midi = MidiToText()
9
10 # non optional midi framework
11 midi.header()
12 midi.start_of_track()
13
14
15 # musical events
16
17 midi.update_time(0)
18 midi.note_on(channel=0, note=0x40)
19
20 midi.update_time(192)
21 midi.note_off(channel=0, note=0x40)
22
23
24 # non optional midi framework
25 midi.update_time(0)
26 midi.end_of_track() # not optional!
27
28 midi.eof()