As promised, here is the source code of my proof-of-concept "Midi Processor" Reaper extension plugin.
Note to non-dev Reaper users: I didn't include the .dll because the plugin isn't useful as such, it's just dev stuff really.
Related topics:
http://forum.cockos.com/showthread.php?t=48514
http://forum.cockos.com/showthread.php?t=45430
http://forum.cockos.com/showthread.php?t=19881 (around page 4)
* What it does:
Registers 3 new "MIDI Item Processor: test" actions that will affect selected Midi items: note transpose, note on/off positions, CC LFO, CC delete.
* Start
I started with Rome's source code.
Mod 1: use MIDI_eventlist_Create()/MIDI_eventlist_Destroy()
Mod 2: alter current PCM_Source in "overwrite" mode instead of creating a new item. Simpler + fix Rome's "Midi Editor open" crash
Mod 3: Undo_OnStateChangeEx(UNDO_STATE_ALL) instead of UNDO_STATE_ITEMS (undo was broken after Mod 2)
Mod 4: added an object state parser. The plugin won't work with external .mid files AND in-project files with the "ignore project tempo information" option checked (frameOffset ignored on new events). See MidiItemProcessor::getMidiItemType() and MidiItemProcessor:: processSelectedMidiTakes()
* How to start
Use a proper Reaper plugin/actions registration code. The "reaperMidiItemProcMain.cpp" file is a quick & dirty. Suggestion: SWS open source project!
See reaperMidiItemGenerators.cpp/.h and reaperMidiItemFilters.cpp/.h: there's a "MidiFilterBase" base class for MIDI event filters and another "MidiGeneratorBase" for MIDI events generators (LFO, etc).
See how "MidiItemProcessor* midiProc" objects are used in "reaperMidiItemProcMain.cpp".
* Object state parsing functions
MidiItemProcessor::getMidiItemType() : see earlier
MidiItemProcessor::getSelectedMidiNotes() : not used at this time, but working. Restriction: after process you may want to put them back into Midi Editor selection (replace a few "E" with "e"), I haven't programmed this.
If you read schwa's comments on working with object state data, I wouldn't go any further and rather wait for proper API functions regarding note selection.
* API requests
- Get current Midi Editor item
- Get current Midi notes selection
- Register Midi Editor actions
Many thanks to Rome, Jeffos, Mike and Schwa!