Old 08-16-2018, 02:56 PM   #1
Sonorityscape
Human being with feelings
 
Sonorityscape's Avatar
 
Join Date: Aug 2016
Posts: 91
Default Looking for help with a small script (Lua)

I'm trying get the count of media items (which I believe are the same as takes), however when I run this script I get a bad argument # 1 saying that the 'TakeFX_GetCount' function is expecting a "MediaItem_Take'. I thought my variable covered that and I swear it was working before. I'm wondering if I'm missing something here? I've made sure that I have the items selected before I run the script. See below.

-------------------------------------------------

count_sel_items = reaper.CountSelectedMediaItems(0)

for i = 0, count_sel_items - 1 do

(indent)media_item = reaper.GetSelectedMediaItem(0, i)
(indent)reaper.TakeFX_GetCount(media_item)

end
Sonorityscape is offline   Reply With Quote
Old 08-16-2018, 03:01 PM   #2
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

A media item (MediaItem*) contains one or more takes (MediaItem_Take*).

Code:
for ii=0, reaper.CountSelectedMediaItems(0)-1 do
  local item = reaper.GetSelectedMediaItem(0, ii)

  -- go through all takes
  for ti=0, reaper.CountTakes(item)-1 do
    local take = reaper.GetMediaItemTake(item, ti)
    reaper.TakeFX_GetCount(take)
  end

  -- or just the current take
  local take = reaper.GetActiveTake(item)
  reaper.TakeFX_GetCount(take)
end

Last edited by cfillion; 08-16-2018 at 03:08 PM.
cfillion is offline   Reply With Quote
Old 08-16-2018, 03:33 PM   #3
Sonorityscape
Human being with feelings
 
Sonorityscape's Avatar
 
Join Date: Aug 2016
Posts: 91
Default

Quote:
Originally Posted by cfillion View Post
A media item (MediaItem*) contains one or more takes (MediaItem_Take*).

Code:
for ii=0, reaper.CountSelectedMediaItems(0)-1 do
  local item = reaper.GetSelectedMediaItem(0, ii)

  -- go through all takes
  for ti=0, reaper.CountTakes(item)-1 do
    local take = reaper.GetMediaItemTake(item, ti)
    reaper.TakeFX_GetCount(take)
  end

  -- or just the current take
  local take = reaper.GetActiveTake(item)
  reaper.TakeFX_GetCount(take)
end
Thank you!
Sonorityscape 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 01:19 AM.


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