Old 10-09-2019, 03:50 AM   #1
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default Midi Text Events to Region CSV [SOLVED]

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)
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak

Last edited by MusoBob; 10-12-2019 at 04:58 PM.
MusoBob is offline   Reply With Quote
Old 10-12-2019, 04:57 PM   #2
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

I had to put another loop inside
Code:
for i = 0, textsyxevtcnt do
         retval, selected, muted, ppqpos, text_type, part_name1 = reaper.MIDI_GetTextSysexEvt( take, i, false, false, 0, 6, "" )
to get the next relative marker and set that as the region_end,
then get the item length to set as the region_end for the last marker.
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:06 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.