Old 10-05-2019, 11:45 PM   #1
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,640
Default Lua Get Markers from Midi File

I need to open a midi file with Lua and get the maker names and location to create a region csv
the color will be representative of the song section (marker name)


Code:
#,Name,Start,End,Length,Color
R1,Intro,1.1.00,3.1.00,2.0.00,FF80C0
R2,Verse,3.1.00,4.1.00,1.0.00,1127AE
R3,Chorus,4.1.00,5.1.00,1.0.00,3776EB
R4,Bridge,5.1.00,8.1.00,3.0.00,3776EB
....
Not sure if this will get the 0x06 Markers or there's something else ??

https://github.com/FMS-Cat/Lua_midiP...idi-parser.lua

I added a bit in lyrics.lua to select what text event but that's with the midi tracks loaded into Reaper
https://forums.cockos.com/showthread...645&page=5#186

Quote:
Originally Posted by ELP View Post
Meta Event Status-byte = 0xFF ; two String Characters F|F
Meta Event ID 0x0F would be REAPER Notation ;two String Characters 0|F

= four String Characters
...
META ID´s
(0xID)

0x01 = Text
0x02 = Copyright
0x03 = Sequence/Track Name
0x04 = Instrument
0x05 = Lyric
0x06 = Marker
0x07 = Cue
0x08 = Program
0x09 = Device
....
0x0F = REAPER Notation
..
.
and so on.

at the End you need this 4 String Characters F|F|I|D with midisend_str(offset,string)
or 0xFF|0xID with midisend_buf(offset,buf, len)

0xFF Meta Message statusbyte //within REAPER and MIDI Files; over MIDI Pipe this would be MIDI RESET)
0xID Meta ID

otherwise you get/send of course a corrupt Meta Message!
(The result would be the Meta text Data within REAPERs auto SysEx Body 0xF0....0xF7)
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 10-06-2019, 03:07 AM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,866
Default

I strongly advise you to mod my Import and Export regions script to CSV. There is known bugs with the default reaper format, and you will have all the code logic.



For the marker part, there is an api function to get MIDI Text Event (just make a search for this keywords in api doc) Again, there are scripts out there you can take a look to :P
X-Raym is offline   Reply With Quote
Old 10-06-2019, 04:27 AM   #3
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,640
Default

There's reaper.MIDI_GetTextSysexEvt but you need a selected item,
I just want to open the midi with Lua without importing the midi into Reaper first.
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 10-06-2019, 05:52 AM   #4
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,866
Default

You dont need to have it selected, you just need to have it avaible take source somewhere. But yes you do need to import it in reaper. Thouhj maybe it can be imported and then deleted ? Surely less efficient than parsing the file directy indeed.


I leave others answer then cause Im.not familiar with MIDI file parsing.
X-Raym is offline   Reply With Quote
Old 10-06-2019, 10:09 AM   #5
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,640
Default

Yes I might be able to do that, will have a think about it.
Now what about "Open As" if the midi file has the extension .seq
can I open as .mid rather than using the shell command to copy and rename.
__________________
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 02:05 AM.


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