| 1 | -- Generate the Clover Recorder session template. |
| 2 | -- |
| 3 | -- Creates a fresh project with a single record-armed MIDI track listening to |
| 4 | -- "All MIDI Inputs / All Channels" (so any keyboard works), then saves it to |
| 5 | -- the template path. The recorder copies this per session. Open it in REAPER |
| 6 | -- afterwards to add your instrument / tweak settings and re-save — it's yours. |
| 7 | -- |
| 8 | -- Run via: REAPER -nonewinst generate_recorder_template.lua |
| 9 | |
| 10 | local template_path = "/Volumes/Documents/Recorder Template.rpp" |
| 11 | |
| 12 | -- Work in a fresh project tab so we never disturb whatever is already open. |
| 13 | reaper.Main_OnCommand(40859, 0) -- New project tab |
| 14 | |
| 15 | reaper.InsertTrackAtIndex(0, false) |
| 16 | local track = reaper.GetTrack(0, 0) |
| 17 | reaper.GetSetMediaTrackInfo_String(track, "P_NAME", "Improv MIDI", true) |
| 18 | reaper.SetMediaTrackInfo_Value(track, "I_RECARM", 1) |
| 19 | -- MIDI record input: 4096 + (device<<5) + channel; device 62 = all MIDI inputs, |
| 20 | -- channel 0 = omni (all channels). See REAPER API docs for I_RECINPUT. |
| 21 | reaper.SetMediaTrackInfo_Value(track, "I_RECINPUT", 4096 + (62 << 5)) |
| 22 | reaper.SetMediaTrackInfo_Value(track, "I_RECMON", 1) -- input monitoring on |
| 23 | |
| 24 | reaper.Main_SaveProjectEx(0, template_path, 0) |
| 25 | |
| 26 | local readback = reaper.GetMediaTrackInfo_Value(track, "I_RECINPUT") |
| 27 | local log = io.open("/tmp/reaper-template.log", "w") |
| 28 | if log then |
| 29 | log:write(string.format("saved=%s I_RECINPUT=%d\n", template_path, readback)) |
| 30 | log:close() |
| 31 | end |
| 32 | |
| 33 | -- Close the template tab; leave REAPER as it was. |
| 34 | reaper.Main_OnCommand(40860, 0) -- Close current project tab |