[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: pygame.MIDI input (Was: [pygame] Python3 version packaged?)



Thank You very much!
Much appreciated. 
May you be well.


On Fri, Mar 21, 2014 at 10:38 PM, Christopher Arndt <chris@xxxxxxxxxxxxx> wrote:
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



--
Diliup Gabadamudalige


http://www.diliupg.com
http://soft.diliupg.com/

**********************************************************************************************
This e-mail is confidential. It may also be legally privileged. If you are not the intended recipient or have received it in error, please delete it and all copies from your system and notify the sender immediately by return e-mail. Any unauthorized reading, reproducing, printing or further dissemination of this e-mail or its contents is strictly prohibited and may be unlawful. Internet communications cannot be guaranteed to be timely, secure, error or virus-free. The sender does not accept liability for any errors or omissions.
**********************************************************************************************