openstenoproject/plover

Assertion error when using a standard Midi keyboard

Closed this issue · 6 comments

Describe the bug

When a standard Midi controller is used as a steno device, instead of a standard steno keyboard (Ireland, Melani, Michela etc.), it can happen to hit accidentally a key which doesn"t belong to the layout in use. In this case Plover doesn't recognize it, and produces the following error message: "Plover error: Qt GUI error. AssertionError: 'B2' (or whichever key not in the layout) not in OrderedDict...."

To Reproduce

  1. install the midi plugin
  2. define in Plover a layout to use
  3. connect any midi controller
  4. just hit a music key which doesn't belong to the defined layout
  5. see error in the error Window at the bottom right

Expected behavior
Plover shouldn't come up with this alert window (quite useless) or, at least, there should be a way to disabile this warning when a midi keyboard is used

Screenshots

185444086-4115fa9f-58a1-4f51-95cf-8f938b99b3c1

185444080-6d2d36ea-e3df-4b1a-8ed8-fd1c56299f68

Operating system

  • Windows 10
  • Plover Version: pre release dev 11

[delete part below]

[end delete part]

Actually I think you're using the plugin https://github.com/benoit-pierre/plover_michela/blob/master/plover_michela/machine.py instead... which indeed does not list these keys.

Can't you simply fix the problem by selecting "MIDI keyboard" instead of "Michela keyboard" as the machine?

@Sillabix: which machine type are you using? MIDI Keyboard, Michela Keyboard (MIDI, 2 octaves), or Michela Keyboard (MIDI, 3+ octaves)? The issue might be that the later 2 declare a reduced layout.

the error happens with both Midi Michela 2 and 3 octaves. With the midi plugin there is a slighty different error message, but this only comes out if a musical key is not defined at all in the config menu. If the key is defined and mapped with a midi value or as "no-op" the error doesn't come out
midi error

OK, so this is a Michela plugin issue, I've reopened openstenoproject/plover_michela#8.

[delete part below]

[end delete part]

Actually I think you're using the plugin https://github.com/benoit-pierre/plover_michela/blob/master/plover_michela/machine.py instead... which indeed does not list these keys.

Can't you simply fix the problem by selecting "MIDI keyboard" instead of "Michela keyboard" as the machine?

The problem happens also with the midi plugin, as described in the reply to Benoit, but it can be avoided in this case defining the unused key in the layout as "no-op". Here is the traceback with the midi plugin

Traceback (most recent call last):
File "C:\Users\Compadmin_Asus\AppData\Local\plover\plover\plugins\win\Python39\site-packages\plover_midi\machine.py", line 83, in _on_message
steno_keys = self.keymap.keys_to_actions(stroke)
File "build/windist/data\Lib\site-packages\plover\machine\keymap.py", line 95, in keys_to_actions
KeyError: 'D2'
2022-08-19 20:24:36,104 [Dummy-7] DEBUG: message: [144, 50, 61]
2022-08-19 20:24:36,104 [Dummy-7] DEBUG: D2 pressed
2022-08-19 20:24:36,264 [Dummy-7] DEBUG: message: [128, 50, 64]
2022-08-19 20:24:36,264 [Dummy-7] DEBUG: D2 released
2022-08-19 20:24:36,264 [Dummy-7] ERROR: Qt GUI error
Traceback (most recent call last):
File "C:\Users\Compadmin_Asus\AppData\Local\plover\plover\plugins\win\Python39\site-packages\plover_midi\machine.py", line 83, in _on_message
steno_keys = self.keymap.keys_to_actions(stroke)
File "build/windist/data\Lib\site-packages\plover\machine\keymap.py", line 95, in keys_to_actions
KeyError: 'D2'
Exception ignored in: 'rtmidi._rtmidi._cb_func'
Traceback (most recent call last):
File "C:\Users\Compadmin_Asus\AppData\Local\plover\plover\plugins\win\Python39\site-packages\plover_midi\machine.py", line 83, in _on_message
steno_keys = self.keymap.keys_to_actions(stroke)
File "build/windist/data\Lib\site-packages\plover\machine\keymap.py", line 95, in keys_to_actions
KeyError: 'D2'

If the code is warning about the keymap being invalid, than all bets are off. A valid keymap would indeed assign all those unused keys to no-op.