Old 06-03-2019, 08:47 AM   #1
Travesty
Human being with feelings
 
Travesty's Avatar
 
Join Date: Nov 2014
Posts: 461
Default reaper.CF_EnumMediaSourceCues usage

Hi,

does anyone have any info on how to use reaper.CF_EnumMediaSourceCues?

I'm trying to get the position of the first cue, and compare it to the item position.

Is this something I can do with this? I can't work it out from the API info page

integer retval, number time, number endTime, boolean isRegion, string name = reaper.CF_EnumMediaSourceCues(PCM_source src, integer index)

Enumerate the source's media cues. Returns the next index or 0 when finished.

Cheers
Travesty is offline   Reply With Quote
Old 06-03-2019, 02:07 PM   #2
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,850
Default

This seems to work here getting the position (relative to source start) of first cue (if any) in first selected item's active take:

Code:
function msg(m)
  return reaper.ShowConsoleMsg(tostring(m) .. "\n")
end

item = reaper.GetSelectedMediaItem(0, 0)
if item ~= nil then
  take =  reaper.GetActiveTake(item)
  if take ~= nil then
    src = reaper.GetMediaItemTake_Source(take)
    if src ~= nil then
      retval, time, endTime, isRegion, name = reaper.CF_EnumMediaSourceCues(src, 0)
      if retval == 1 then
        msg("time of first cue: " .. time)
      else
        msg("no cues in take?")
      end
    end
  end
end
nofish is offline   Reply With Quote
Old 06-03-2019, 04:16 PM   #3
Travesty
Human being with feelings
 
Travesty's Avatar
 
Join Date: Nov 2014
Posts: 461
Default

Thanks, I think I see what I did wrong now 😊
Travesty is offline   Reply With Quote
Old 06-04-2019, 05:09 AM   #4
Travesty
Human being with feelings
 
Travesty's Avatar
 
Join Date: Nov 2014
Posts: 461
Default

Got it working, thanks, I wasn't telling the command which to look at, it was set to -1. I wasn't quite sure what it was expecting.

Here's the result

Code:
function ValidateCues() -- Determine if 1st cue is at the beginning of the item

-- get item
  
  item = reaper.GetSelectedMediaItem(0, 0)
  
-- get item length

  if item ~= nil then
    itemlen = reaper.GetMediaItemInfo_Value( item, "D_LENGTH" )
    
-- get take

    take =  reaper.GetActiveTake(item)
    
-- get source file

    if take ~= nil then
      src =  reaper.GetMediaItemTake_Source( take )
      
--enum cues

      retval, time, endTime, isRegion, name = reaper.CF_EnumMediaSourceCues( src, 0)
      if retval == 1 then
      
-- compare itempos to 1st cue

        cuepos = itemlen + time
        
        if cuepos == itemlen then
          cuevalid = false
        else 
          cuevalid = true
        end
      end
    end 
 
  else msg("No items selected")
  
  end


  -- return result
  return cuevalid
end
Travesty 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 10:26 AM.


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