Old 06-20-2015, 05:20 AM   #1
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,984
Default Get GUID of in-project midi reference

I found this line in project file:
Code:
<ITEM
      POSITION 0
      SNAPOFFS 0
      LENGTH 0.53843868291262
      LOOP 0
      ALLTAKES 0
      FADEIN 1 0 0 1 0 0
      FADEOUT 1 0 0 1 0 0
      MUTE 0
      SEL 0
      IGUID {2C465BF7-26DB-4141-BA8A-A89066480F28}
      IID 1
      NAME "untitled MIDI item"
      VOLPAN 1 0 1 -1
      SOFFS 0 0
      PLAYRATE 1 1 0 -1 0 0.0025
      CHANMODE 0
      GUID {EE6DADBA-7F26-47BD-8C92-19FF170BE114}
      <SOURCE MIDI
        HASDATA 1 960 QN
        POOLEDEVTS {948CAEEA-EB91-4D3B-B453-3A22E70803EB}
Can anyone help with getting this GUID?

Last edited by mpl; 06-20-2015 at 05:26 AM.
mpl is offline   Reply With Quote
Old 06-20-2015, 05:55 AM   #2
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Posts: 2,436
Default

Quote:
Originally Posted by mpl View Post
I found this line in project file:
Code:
<ITEM
      POSITION 0
      SNAPOFFS 0
      LENGTH 0.53843868291262
      LOOP 0
      ALLTAKES 0
      FADEIN 1 0 0 1 0 0
      FADEOUT 1 0 0 1 0 0
      MUTE 0
      SEL 0
      IGUID {2C465BF7-26DB-4141-BA8A-A89066480F28}
      IID 1
      NAME "untitled MIDI item"
      VOLPAN 1 0 1 -1
      SOFFS 0 0
      PLAYRATE 1 1 0 -1 0 0.0025
      CHANMODE 0
      GUID {EE6DADBA-7F26-47BD-8C92-19FF170BE114}
      <SOURCE MIDI
        HASDATA 1 960 QN
        POOLEDEVTS {948CAEEA-EB91-4D3B-B453-3A22E70803EB}
Can anyone help with getting this GUID?
Accidentally, I already exported the API for this in SWS. Expect it in the next pre-release.
Breeder is offline   Reply With Quote
Old 06-20-2015, 06:18 AM   #3
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Thanks Breeder!

This script returns a line from MIDI take chunk:
Code:
-- String functions from Haywoods DROPP Script
function starts_with(text,prefix)
  return string.sub(text, 1, string.len(prefix)) == prefix
end

function string:split(sep)
  return self:match("([^" .. sep .. "]+)[" .. sep .. "]+(.+)")
end

function string:trim()
  return self:match("^%s*(.-)%s*$")
end



function get_MIDI_take_source_line(item, take, first_chars_in_line)
  if item ~= nil and take ~= nil then
    fs = reaper.SNM_CreateFastString("")
    reaper.SNM_GetSetSourceState(item, -1, fs, false)
    fs_content = reaper.SNM_GetFastString(fs)
    --reaper.ShowConsoleMsg(fs_content)
    reaper.SNM_DeleteFastString(fs)

    for line in fs_content:gmatch("[^\r\n]+") do
      if starts_with(line, first_chars_in_line) then
        --reaper.ShowConsoleMsg(line .."\n")
        return line
      end
    end
  end
end


-- Test: Get "POOLEDEVTS ..." -line from MIDI take chunk. 
item = reaper.GetSelectedMediaItem(0,0)
if item ~= nil then
  take = reaper.GetActiveTake(item)
  if take ~= nil then
    reaper.GetSelectedMediaItem(0,0)
    ret_line = get_MIDI_take_source_line(item, take, "POOLEDEVTS")
  end
end

if item~=nil and take~=nil then
  if ret_line then
    reaper.ShowConsoleMsg(ret_line .."\n")
  else
    reaper.ShowConsoleMsg("Couldn't find the line\n")
  end
end
(NOTE: There's no error checking, source type checking etc.)


Last edited by spk77; 06-20-2015 at 06:54 AM. Reason: Removed unnecessary lines
spk77 is offline   Reply With Quote
Old 06-20-2015, 06:49 AM   #4
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,984
Default

Thank you, guys, you are awesome!
mpl 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 07:02 AM.


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