Hi Eelke, 

Rtmidi has it's own internal event loop. You shouldn't have to worry about 
the pyglet event loop - just use `port.set_callback` to update the methods 
on your classes.

1. Why are you trying to pass `self` into the callback? I'm not sure what 
you are trying to do.
2. Do you mean PC Keyboard key, or musical keyboard key? 


On Saturday, April 21, 2018 at 4:57:24 PM UTC+9, Eelke Johnson wrote:
>
> Hi,
> It's been a while since I didn't posted anything but I'm back!
> I've got some problem with the python rt-midi package. I didn't find any 
> useful and complete documentation. I built the sphinx documentation but 
> except the installation, I didn't found something useful and I'm stuck!
>
> What I want to do basically is this:
> key_map = { 0:  "c",
>             1:  "c#",
>             2:  "d#",
>             3:  "d#",
>             4:  "e",
>             5:  "f",
>             6:  "f#",
>             7:  "g",
>             8:  "g#",
>             9:  "a",
>             10: "a#",
>             11: "b"
>                     }
>
> # Midi configuration
>
> midi_in = rtmidi.MidiIn()
> available_ports = midi_in.get_ports()
> port = midi_in.open_port(1)
>
> def hit_a_key(message, data):
>     m = message[0][1]%12
>     self.ring.notes[key_map[m]].played()
>
> def release_a_key(message, data):
>     m = message[0][1]%12
>     self.ring.notes[key_map[m]].idle()
>
> port.set_callback(hit_a_key, data=self)
> port.set_callback(release_a_key, data=self)
>
> The two problems I faced are:
>
>    1. I cannot pass the self object who contain my ring into the midi 
>    function
>    2. I didn't found how to implement an event hit/release. The callback 
>    is called each time you press/release a key and I don't want that^^
>    
> Furthermore, I'm not sure if this is properly nested with the 
> pyglet.app.run() loop
>
> My code is on github https://github.com/way2key/Midi_Visualizer HERE 
> <https://github.com/way2key/Midi_Visualizer>
>
> I'm close to the end of this small program! 
>
> Merci Eelke
>

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pyglet-users+unsubscr...@googlegroups.com.
To post to this group, send email to pyglet-users@googlegroups.com.
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to