Here's the abstraction: learn_midi.pd
To use, hit the toggle and then press a note, move a knob, or press a pgm button.
The basic premise is to associate a unique number to each type of midi input (note, ctl, or pgm), and packing them into a list. "Learning" a MIDI note, ctl, or pgm number means storing this list in the cold inlet of [list-compare] from [list-abs]. If any MIDI data coming in the hot inlet of [list-compare] matches the stored data in its cold inlet, a [spigot] opens up and the data is allowed to pass through its outlets.
EDIT: The outlets are meant to mirror those of [notein]. Outlets are as follows from left to right: (note, ctl, prgm number), (velocity, ctl value, pgm value), channel no.