The learn process comes after *recognised* NRPNs and vectors, but before all other controllers.

To learn, hold CTRL while right-clicking on any GUI control then operate a physical control.

Along with parameters, a text string is provided with precise details of this complete action.

Control capabilities:

Incoming CC and channel tracked (in that order).

Multiple actions on the same CC/channel pair.

Range limiting, compression or threshold setting.

Blocking of all later actions on the same CC / channel pair.

Muting of this action.

Status bits:
0   block
1   limit (otherwise compress)
2   mute

3   mark as an NRPN
4   mark as 7 bit NRPN

When sending internal control messages to the GUI (instead of passing on MIDI actions) the part number will be 216 (0xd8) - a value that is never used in the rest of the system.

This is used for updating the list and filling in/altering line entries. The gui never does these directly, but requests them using the same part number.

Name strings are passed across using the simple message system. These are not editable in the GUI.

These transfers are done outside the RT threads.

Normally the data will be sent as a complete instruction for one line.


data structure:
value       line number (used as an integer)
type        status - this is unique to MIDI learn
control     normal use
part        216
kit         CC
engine      channel
insert      min_in
parameter   max_in
misMsg      text message number

For NRPNs, CC has bit 16 set. This is so that even one with a current value less than 127 won't be mistaken for a normal CC when being matched.

Currently there is a limit of 200 independent learned lines due to the use of miscMsg to update the GUI when loading complete learned lists. In the future, the GUI may be restricted to 'viewing groups' of 128 lines. This would allow a much greater number.


Control numbers:
These redraw a line in place.
0   block switch
1   limit switch
2   mute switch
5   set min_in
6   set max-in
7   returned message to GUI
9   set NRPN - overwrites a normal CC and makes it unchangeable

These move a line, so a complete redraw is inititalsed.
 8  delete line
16  write line
17  set CC
18  set channel

20  send list size
21  send ID of learn type message
22  open MIDI-learn editing window

24 incoming activity

96  clear all

The gui always does a redraw (except 20 & 21), but 0 to 7, 24 and 96 don't do a list re-order first.


0xf1 load list
0xf2 load numbered item from recent history
0xf5 save list


*** UPDATE ***

Max MIDI-learn lines has been increased to 400.

This has been achieved by inserting a 10mS sleep every 32 lines while updating the GUI. This ensures the message buffer doesn't get overloaded. There was no other reason for the earlier limit. This still comes in at less that 1S for a full list load.

Time to scan is very difficult to measure. Finding a bunch of  5 controls at the end of a list of 20 usually returned less than 3uS, and very occasionally one at around 8uS. The search is fairly straightforward so presumably ones right at the end of a full list would be worst case around 160uS
