UPD 08.04.23: the script is no longer supported, since REAPER has this feature natively.
================================================== =============
Concept: dump all incoming MIDI events into project MIDI data
without actully recording it.
Before 2021 it was implemented using custom JSFX tracker.
After 2021 REAPER 6.39+ has native way to do this.
Instructions: 1) play something on your MIDI device connected to REAPER, 2) run script. Result: incoming MIDI is inside selected track new take at edit cursor.
Here is bunch of scripts from ReaPack:
Free version:
mpl_Dump Retrospective Record log (old version). No dependencies and mostly built around Justin`s code.
Paid version:
- mpl_Dump Retrospective Record log.lua kinda general script, uses optimized settings, including breaks to not get previous added data and obey looped recordings as multiple takes
- mpl_Dump Retrospective Record log (notes only).lua
- mpl_Dump Retrospective Record log (only data at playing).lua - event put into their played positions
- mpl_Dump Retrospective Record log (only data at stop).lua - start from edit cursor to a event list length
- mpl_Dump Retrospective Record log (everything recorded from last REAPER start).lua - collect everything without any filters
- mpl_Dump Retrospective Record log (everything from last 5 minutes).lua - ignore break, dump everything based on time limit
- mpl_Dump Retrospective Record log (everything from last 10 minutes).lua
- mpl_Dump Retrospective Record log (everything from last 30 minutes).lua
- mpl_Dump Retrospective Record log (everything from last hour, obey stored data break).lua
These scripts use VariousFunctions package 2.62+ from my repository (which is paid).
They have different (better) way of handling/sorting data, also they are easier to extend so any suggestions welcome.
old post:

Eugen made previously a JSFX writing MIDI data during playing project, and the script dumping this data as new item.
gmem API allows to share memory across JSFX and Reascript, so what I did is easier to think through and code.
Here are parts of making this real:- RetrospectiveRecord_tracker.jsfx is a JSFX sitting at some fixed track FX Chain to receive MIDI data for further translating it into ReaScript.
- mpl_Prepare selected track for RetrospectiveRecord tracker.lua
Eugen`s script search for track where tracker is inserted and add/hide it automatically if not found. I personally don`t like such things, so I made this action going manual. The script add RetrospectiveRecord tracker, disable parent send, enable monitoring, record arm, set input to all channels all MIDI devices, disable record). You can hide this track, add to default project template and forget.
- mpl_Dump RetrospectiveRecord tracker log to selected track.lua 1) dump raw MIDI log into new item/take on selected track at edit cursor. Since tracker write system timestamps (not related to playing state), script just put whole buffer data as is, not syncronized to project, if you played while playing project; 2) reset buffer data.
Buffer is limited to 3.500.000 messages (it wraps if buffer filled).
Requirements:Require REAPER 5.97+.
ReaPack 1.2+
Download: ReaPack.com (MPL`s repository is embedded into default ReaPack configuration)
Install: - run ActionList > ReaPack: Browse packages...
- navigate and install Various_functions.lua, RetrospectiveRecord_tracker.jsfx, mpl_Prepare selected track for RetrospectiveRecord tracker.lua, mpl_Dump RetrospectiveRecord tracker log to selected track.lua packages