I insert a midi file and need to read the markers and write them as regions to the csv standard that Reaper will import.
Code:
retval, notecnt, ccevtcnt, textsyxevtcnt = reaper.MIDI_CountEvts( take )
markers from 6:MIDI text event type
Code:
retval, selected, muted, ppqpos, type, msg = reaper.MIDI_GetTextSysexEvt( take, textsyxevtidx, selected, muted, ppqpos, type, msg )
covert the ppqpos to time_pos
Code:
time_pos = reaper.MIDI_GetProjTimeFromPPQPos( take, ppqpos )
convert time_pos to measure/beat
Code:
retval, measures, cml, fullbeats, cdenom = reaper.TimeMap2_timeToBeats( proj, tpos )
I modified Script: X-Raym_Export regions as file.lua that works fine
to write to csv file in Reaper format, so it just needs to get this info from the midi markers.
The color will be set depending on the marker name (verse, chorus etc..)
Code:
line = "R" .. iMarkrgnindexnumberOut .. "," .. name .. "," .. iPosOut .. "," .. iRgnendOut .. "," .. duration .. "," .. color
export(f, line)
csv output
Code:
#,Name,Start,End,Length,Color
R1,Name,1.1.00,2.4.00,1.3.00,FF80C0
R2,Name,3.1.00,4.1.00,1.0.00,1127AE
R3,Name,4.1.00,5.1.00,1.0.00,3776EB
When I EnumProjectMarkers I get all the info in one loop but with MIDI_GetTextSysexEvt I only get the time_pos (iPosOut)
Code:
iRetval, bIsrgnOut, iPosOut, iRgnendOut, name, iMarkrgnindexnumberOut, iColorOur = reaper.EnumProjectMarkers3(0,i)