/src/echonest/support/midi/example_print_events.py

http://echo-nest-remix.googlecode.com/ · Python · 28 lines · 11 code · 10 blank · 7 comment · 0 complexity · caed742ebafd9302e44a9c5156a636dc MD5 · raw file

  1. from MidiToText import MidiToText
  2. """
  3. This is an example that uses the MidiToText eventhandler. When an
  4. event is triggered on it, it prints the event to the console.
  5. """
  6. midi = MidiToText()
  7. # non optional midi framework
  8. midi.header()
  9. midi.start_of_track()
  10. # musical events
  11. midi.update_time(0)
  12. midi.note_on(channel=0, note=0x40)
  13. midi.update_time(192)
  14. midi.note_off(channel=0, note=0x40)
  15. # non optional midi framework
  16. midi.update_time(0)
  17. midi.end_of_track() # not optional!
  18. midi.eof()