On 21.03.2014 17:44, diliup gabadamudalige wrote: > I am writing a music software and I need to calculate MIDI note on and > note off from [...] MIDI input? Can I use the pygame.midi.time() counter to > do that?
You could, but I would just use the pygame.event queue to handle all events in the same fashion. Just make sure you poll MIDI input often enough (by calling poll/read on your MIDI Input instance) and pass the received MIDI events to the pygame.event queue via pygame.midi.midis2events and pygame.event.post. Of course, MIDI input handling is much easier with a callback API, because you don't need to poll regularly. Here's a short example of handling MIDI input with python-rtmidi's callback mechanism: http://trac.chrisarndt.de/code/browser/projects/python-rtmidi/trunk/tests/test_midiin_callback.py > (difference between key on and key off time). This has nothing to do with MIDI. Just use the pygame.event mechanism to record the key events and when they occur (use time.time() or pygame.time.get_ticks()) and then calculate the difference. Chris