lucidstack / ex-portmidi

Elixir bindings to the portmidi library
MIT License
35 stars 12 forks source link

Confused about event API, especially empty messages [] #16

Open patmaddox opened 3 years ago

patmaddox commented 3 years ago

I am a bit confused about the event API, and hope @lucidstack can clear it up for me. I am admittedly very new to elixir and so am not sure if it's normal or not.

First, the documentation says that a received event looks like {144, 112, 127}. I am seeing events that look like this though: [{{146, 46, 127}, 36124}].

Okay, I'm guessing that the events are now a list of events with a timestamp. Cool. But I'm seeing LOTS of empty events. Sometimes when I press and release a button on my controller, there are several hundred empty events between the on and off. Example:

[{{146, 36, 127}, 79898}]
[]
[]
...286 more times
[]
[{{130, 36, 127}, 79989}]

What's the purpose of those empty events?

Also, other times I can press the buttons on my controller hundreds of times without seeing an empty event. Why is that?

Also sometimes only the first few button presses register and it seems to get stuck. It's pretty inconsistent and I'm not sure what's going on.

I'm just a bit confused and could use some help clearing it up :)

thbar commented 3 years ago

I have seen the exact same behaviour on all counts: empty events at time, and "stuck" process then coming back to life.

I have seen a few commits in forks mentioning a "sleep", will try that out and investigate.

thbar commented 3 years ago

It is fixed by #15 for me (which I'll incorporate in my fork at https://github.com/thbar/ex-portmidi).