Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 05-16-2020, 03:48 AM   #41
Ideosound
Human being with feelings
 
Ideosound's Avatar
 
Join Date: Oct 2017
Location: U.K
Posts: 542
Default

I tried this on the latest dev version using metal (I know currently you have to disable optimized drawing on mac) and still doesn't work. Is that because the script would need updating to reflect two of the changes made to metal? Or does it require the 3d fix too?

* SRCCOPY_USEALPHACHAN not doing alpha blending,
* StretchBlt not stretching to Metal surface, and

(still waiting on the third):
* BitBlt not blitting from Metal surface.

Thanks
Ideosound is offline   Reply With Quote
Old 05-16-2020, 06:01 AM   #42
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by Pink Wool View Post
Very nice script! Thanks! Super useful!
How would one go about making a custom action so that this would be on when choosing the ripple editing modes? I made a custom action with cycle ripple editing and this but now the cycle is messed up...

I know I could run it on startup or make a new toolbar icon for it but I would really like to learn to do custom actions like these (if it's possible)

The script monitors the ripple editing modes and does its thing if ripple is enabled. If not, it does nothing else than checking every 1/3 of a second if the ripple mode changed.
It is better to keep it on.


Making a Cycle Action is impossible due to the restraints of the Cycle Actions (no nested IFs or ELSE IFs).


You can do it with this script:
Code:
-- Get ripple state
local ripple
if reaper.GetToggleCommandState( 41991 ) == 1 then ripple = 2 -- ripple editing all tracks
elseif reaper.GetToggleCommandState( 41990 ) == 1 then ripple = 1 -- ripple editing per-track
else ripple = 0
end

-- Get script command ID
local cmd = reaper.NamedCommandLookup('_RS7507a4bbefb6bb43a22048a145a624d40ce55e1b') -- amagalma_Distinguish visually the ripple editing modes

-- Get its state
local cmd_state = reaper.GetToggleCommandState( cmd ) == 1 and true or false

-- Cycle ripple state
if ripple == 0 then
  reaper.Main_OnCommand(40310, 0) -- Set ripple editing per-track
  -- Turn on if not running
  if not cmd_state then
    reaper.Main_OnCommand(cmd, 0)
  end
elseif ripple == 1 then
  reaper.Main_OnCommand(40311, 0) -- Set ripple editing all tracks
  -- Turn on if not running
  if not cmd_state then
    reaper.Main_OnCommand(cmd, 0)
  end
elseif ripple == 2 then
  reaper.Main_OnCommand(40309, 0) -- Set ripple editing off
  -- Turn off if running
  if cmd_state then
    reaper.Main_OnCommand(cmd, 0)
  end
end

-- Create no Undo
reaper.defer(function() end)
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-16-2020, 06:03 AM   #43
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by Ideosound View Post
I tried this on the latest dev version using metal (I know currently you have to disable optimized drawing on mac) and still doesn't work. Is that because the script would need updating to reflect two of the changes made to metal? Or does it require the 3d fix too?

* SRCCOPY_USEALPHACHAN not doing alpha blending,
* StretchBlt not stretching to Metal surface, and

(still waiting on the third):
* BitBlt not blitting from Metal surface.

Thanks

I have no idea.. I am waiting for the things to settle down first... Do other scripts like Area 51 and my Guide Line work?
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-16-2020, 07:29 AM   #44
Pink Wool
Human being with feelings
 
Pink Wool's Avatar
 
Join Date: Apr 2020
Posts: 1,501
Default

Quote:
Originally Posted by amagalma View Post
The script monitors the ripple editing modes and does its thing if ripple is enabled. If not, it does nothing else than checking every 1/3 of a second if the ripple mode changed.
It is better to keep it on.


Making a Cycle Action is impossible due to the restraints of the Cycle Actions (no nested IFs or ELSE IFs).


You can do it with this script:
Thank you!

So now I made a custom action icon (using the default ripple editing icon) but it doesn't "toggle" and just flashes as I change the mode. I know this isn't really a question about the script but more about the toggle but do you know the way, old wise one? :-D
Pink Wool is offline   Reply With Quote
Old 05-16-2020, 08:15 AM   #45
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by Pink Wool View Post
Thank you!

So now I made a custom action icon (using the default ripple editing icon) but it doesn't "toggle" and just flashes as I change the mode. I know this isn't really a question about the script but more about the toggle but do you know the way, old wise one? :-D

Can't be done. All Reaper buttons have 2 states: on and off. Only the native Ripple button has 3 states (off/per-track/all-tracks). The only way to see which mode is on is by looking at the native ripple button.
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-16-2020, 11:27 AM   #46
Pink Wool
Human being with feelings
 
Pink Wool's Avatar
 
Join Date: Apr 2020
Posts: 1,501
Default

Quote:
Originally Posted by amagalma View Post
Can't be done. All Reaper buttons have 2 states: on and off. Only the native Ripple button has 3 states (off/per-track/all-tracks). The only way to see which mode is on is by looking at the native ripple button.
Ok! So I'll have two buttons then! Thanks for all the help!
Pink Wool is offline   Reply With Quote
Old 05-16-2020, 01:17 PM   #47
Jae.Thomas
Human being with feelings
 
Join Date: Jun 2006
Posts: 22,567
Default

Quote:
Originally Posted by amagalma View Post
step by step:
big pic
im sorry dude I was in an altered state will do again
Jae.Thomas is offline   Reply With Quote
Old 05-16-2020, 01:32 PM   #48
Sumalc
Human being with feelings
 
Join Date: Oct 2009
Location: France
Posts: 743
Default

Thank you Amagalma it works now on my mac with V1.21 after activate state ON
would it be possible to make the colour darker?
Thank you in advance
Sumalc is online now   Reply With Quote
Old 05-16-2020, 01:49 PM   #49
Jae.Thomas
Human being with feelings
 
Join Date: Jun 2006
Posts: 22,567
Default

https://youtu.be/_rrkeXL0NRo
Jae.Thomas is offline   Reply With Quote
Old 05-17-2020, 06:09 AM   #50
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by Jason Brian Merrill View Post
Thank you! That is super weird! In order to solve this, we will have to work step by step together. Checking one thing at a time until we find the culprit. Ok, let's check the first suspect. Could you test the following script and post me the results?
Code:
-- TEST 
local function Msg(...)
  if debug then
    local arg = { ... }
    for i = 1, #arg do
      if arg[i] then arg[i] = tostring(arg[i]) else arg[i] = "nil" end
    end
    reaper.ShowConsoleMsg(table.concat(arg) .. "\n")
  end
end
local MainHwnd = reaper.GetMainHwnd()
local trackview = reaper.JS_Window_FindChildByID(MainHwnd, 0x3E8)
local _, width_trackview, height_trackview = reaper.JS_Window_GetClientSize( trackview )
width_trackview = width_trackview + 17
reaper.ClearConsole()
Msg("Trackview: ", trackview, "\nWidth: ", width_trackview, "\nHeight: ", height_trackview, "\n")
local track_cnt = reaper.CountTracks( 0 )
local vis_tr = {}
for i = 0, track_cnt-1 do
  local track = reaper.GetTrack( 0, i )
  local id = reaper.GetMediaTrackInfo_Value( track, "IP_TRACKNUMBER" )
  local y_pos = reaper.GetMediaTrackInfo_Value( track, "I_TCPY" )
  if reaper.IsTrackVisible( track, false ) and y_pos < height_trackview then
    vis_tr[#vis_tr+1] = string.format("%i", id)
  end
end
Msg("Visible tracks: ", table.concat(vis_tr, ", "), "\n")
Test script.lua
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-17-2020, 06:12 AM   #51
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by Sumalc View Post
Thank you Amagalma it works now on my mac with V1.21 after activate state ON
would it be possible to make the colour darker?
Thank you in advance
You can set the color inside the script. Choose "Edit...". Inside you will find this:
Code:
-- SET COLOR HERE -- (0-255)
local red, green, blue, alpha = 0, 255, 0, 13
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-17-2020, 08:22 AM   #52
Sumalc
Human being with feelings
 
Join Date: Oct 2009
Location: France
Posts: 743
Default

Cool thank you very much.
Sumalc is online now   Reply With Quote
Old 05-18-2020, 01:55 PM   #53
Jae.Thomas
Human being with feelings
 
Join Date: Jun 2006
Posts: 22,567
Default

Quote:
Originally Posted by amagalma View Post
Thank you! That is super weird! In order to solve this, we will have to work step by step together. Checking one thing at a time until we find the culprit. Ok, let's check the first suspect. Could you test the following script and post me the results?
Code:
-- TEST 
local function Msg(...)
  if debug then
    local arg = { ... }
    for i = 1, #arg do
      if arg[i] then arg[i] = tostring(arg[i]) else arg[i] = "nil" end
    end
    reaper.ShowConsoleMsg(table.concat(arg) .. "\n")
  end
end
local MainHwnd = reaper.GetMainHwnd()
local trackview = reaper.JS_Window_FindChildByID(MainHwnd, 0x3E8)
local _, width_trackview, height_trackview = reaper.JS_Window_GetClientSize( trackview )
width_trackview = width_trackview + 17
reaper.ClearConsole()
Msg("Trackview: ", trackview, "\nWidth: ", width_trackview, "\nHeight: ", height_trackview, "\n")
local track_cnt = reaper.CountTracks( 0 )
local vis_tr = {}
for i = 0, track_cnt-1 do
  local track = reaper.GetTrack( 0, i )
  local id = reaper.GetMediaTrackInfo_Value( track, "IP_TRACKNUMBER" )
  local y_pos = reaper.GetMediaTrackInfo_Value( track, "I_TCPY" )
  if reaper.IsTrackVisible( track, false ) and y_pos < height_trackview then
    vis_tr[#vis_tr+1] = string.format("%i", id)
  end
end
Msg("Visible tracks: ", table.concat(vis_tr, ", "), "\n")
Test script.lua
Code:
Trackview: userdata: 00000000000C066A
Width: 1352
Height: 498

Visible tracks: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
Jae.Thomas is offline   Reply With Quote
Old 05-18-2020, 04:18 PM   #54
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Thanks! Try this please:
Code:
-- TEST
local reaper, floor = reaper, math.floor
local function Msg( ... )
  local arg = table.pack( ... )
  for i = 1, arg.n do
    if arg[i] then arg[i] = tostring(arg[i]) else arg[i] = "nil" end
  end
  reaper.ShowConsoleMsg(table.concat(arg))
end
------------------------------------------------------
local MainHwnd = reaper.GetMainHwnd()
local tracks = {}
local p_trackitems_cnt = {}

local trackview = reaper.JS_Window_FindChildByID(MainHwnd, 0x3E8)
local _, width_trackview, height_trackview = reaper.JS_Window_GetClientSize( trackview )
width_trackview = width_trackview + 17

local start = reaper.time_precise()
local checksizetime = start
local p_item, p_item_cnt = 0, -1
local huge = math.huge
local first_pos
local st, en, arr_duration, track_cnt

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

function main()
  local now = reaper.time_precise()

  st, en = reaper.GetSet_ArrangeView2( 0, false, 0, 0 )
  arr_duration = en - st
  track_cnt = reaper.CountTracks( 0 )
  
  -- Check every now and then if arrange size changed and update values
  if now - checksizetime >= 1 then
    _, width_trackview, height_trackview = reaper.JS_Window_GetClientSize( trackview )
    width_trackview = width_trackview + 17
    checksizetime = now
  end

  for i = 0, track_cnt-1 do
    local track = reaper.GetTrack( 0, i )
    local id = reaper.GetMediaTrackInfo_Value( track, "IP_TRACKNUMBER" )
    local y_pos = reaper.GetMediaTrackInfo_Value( track, "I_TCPY" )
                                                                   
    if reaper.IsTrackVisible( track, false ) and y_pos < height_trackview then
      local item_cnt = reaper.CountTrackMediaItems( track )
      if p_trackitems_cnt[id] ~= item_cnt then
        tracks[id] = nil
        p_trackitems_cnt[id] = item_cnt
      end
      if item_cnt > 0 then
        local paint = false
        local x_pos
        for j = 0, item_cnt-1 do
          local item = reaper.GetTrackMediaItem( track, j )
          if reaper.IsMediaItemSelected( item ) then
            x_pos = floor( ( ( reaper.GetMediaItemInfo_Value( item, "D_POSITION" ) - st ) / arr_duration ) * width_trackview )
            x_pos = x_pos > 0 and ( x_pos < width_trackview and x_pos or width_trackview ) or 0
            paint = true
            local ID = tostring(id)
            Msg("item selected on track ", ID:match("%d+"), "\n")
            break
          end
        end
        local track_h = reaper.GetMediaTrackInfo_Value( track, "I_WNDH" )
        --[[
        if paint then
          if ( not tracks[id] ) then
            Msg( string.format("track %i : x = %i, y = %i", id, x_pos, y_pos) .. "\n")

            tracks[id] = x_pos
          elseif x_pos ~= tracks[id] then
            Msg( string.format("track %i new positin: x = %i, y = %i", id, x_pos, y_pos) .. "\n")
            tracks[id] = x_pos
          end
        else
          if tracks[id] then
            Msg( string.format("erase track %i", id) .. "\n" )
            tracks[id] = nil
          end
        end
      --]]
      end
    else    
      break
    end
  end  
  
  if now - start <= 20 then
    reaper.defer(main)
  end
 
end

function Exit()
  Msg("\n\n== script ran for 20secs and ended ==\n\n")
  return reaper.defer(function() end)
end

reaper.atexit(Exit)
main()
script
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-18-2020, 07:34 PM   #55
Jae.Thomas
Human being with feelings
 
Join Date: Jun 2006
Posts: 22,567
Default

== script ran for 20secs and ended ==
Jae.Thomas is offline   Reply With Quote
Old 05-19-2020, 02:13 AM   #56
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by Jason Brian Merrill View Post
== script ran for 20secs and ended ==
Sorry, I forgot to tell you to select any item on a visible track and see if you get any message while the script is running. Could you try it again?
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-19-2020, 09:35 AM   #57
Jae.Thomas
Human being with feelings
 
Join Date: Jun 2006
Posts: 22,567
Default

Quote:
Originally Posted by amagalma View Post
Sorry, I forgot to tell you to select any item on a visible track and see if you get any message while the script is running. Could you try it again?
nothing...
Jae.Thomas is offline   Reply With Quote
Old 05-19-2020, 10:29 AM   #58
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by Jason Brian Merrill View Post
nothing...

Try this version with a small project (2-3 tracks with 2-3 items on each track) and have one item selected:

Code:
-- TEST
local reaper, floor = reaper, math.floor
local function Msg( ... )
  local arg = table.pack( ... )
  for i = 1, arg.n do
    if arg[i] then arg[i] = tostring(arg[i]) else arg[i] = "nil" end
  end
  reaper.ShowConsoleMsg(table.concat(arg))
end
------------------------------------------------------
local MainHwnd = reaper.GetMainHwnd()
local tracks = {}
local p_trackitems_cnt = {}

local trackview = reaper.JS_Window_FindChildByID(MainHwnd, 0x3E8)
local _, width_trackview, height_trackview = reaper.JS_Window_GetClientSize( trackview )
width_trackview = width_trackview + 17

local start = reaper.time_precise()
local checksizetime = start
local p_item, p_item_cnt = 0, -1
local huge = math.huge
local first_pos
local st, en, arr_duration, track_cnt

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

function main()
  local now = reaper.time_precise()

  st, en = reaper.GetSet_ArrangeView2( 0, false, 0, 0 )
  arr_duration = en - st
  track_cnt = reaper.CountTracks( 0 )
  
  -- Check every now and then if arrange size changed and update values
  if now - checksizetime >= 1 then
    _, width_trackview, height_trackview = reaper.JS_Window_GetClientSize( trackview )
    width_trackview = width_trackview + 17
    checksizetime = now
  end

  for i = 0, track_cnt-1 do
    local track = reaper.GetTrack( 0, i )
    local id = reaper.GetMediaTrackInfo_Value( track, "IP_TRACKNUMBER" )
    local ID = tostring(id)
    ID = ID:match("%d+")
    local y_pos = reaper.GetMediaTrackInfo_Value( track, "I_TCPY" )
                                                                   
    if reaper.IsTrackVisible( track, false ) and y_pos < height_trackview then
      Msg("Track ",ID," visible with ")
      local item_cnt = reaper.CountTrackMediaItems( track )
      Msg(item_cnt, " items.\n")
      if p_trackitems_cnt[id] ~= item_cnt then
        tracks[id] = nil
        Msg(" -- Item count changed. -- ")
        p_trackitems_cnt[id] = item_cnt
      end
      if item_cnt > 0 then
        local item_selected = false
        local paint = false
        local x_pos
        for j = 0, item_cnt-1 do
          local item = reaper.GetTrackMediaItem( track, j )
          if reaper.IsMediaItemSelected( item ) then
            x_pos = floor( ( ( reaper.GetMediaItemInfo_Value( item, "D_POSITION" ) - st ) / arr_duration ) * width_trackview )
            x_pos = x_pos > 0 and ( x_pos < width_trackview and x_pos or width_trackview ) or 0
            paint = true
            
            Msg("item selected\n")
            break
          end
        end
        local track_h = reaper.GetMediaTrackInfo_Value( track, "I_WNDH" )
        --[[
        if paint then
          if ( not tracks[id] ) then
            Msg( string.format("track %i : x = %i, y = %i", id, x_pos, y_pos) .. "\n")

            tracks[id] = x_pos
          elseif x_pos ~= tracks[id] then
            Msg( string.format("track %i new positin: x = %i, y = %i", id, x_pos, y_pos) .. "\n")
            tracks[id] = x_pos
          end
        else
          if tracks[id] then
            Msg( string.format("erase track %i", id) .. "\n" )
            tracks[id] = nil
          end
        end
      --]]
      end
    else    
      break
    end
  end  
  
  if now - start <= 20 then
    reaper.defer(main)
  end
 
end

function Exit()
  Msg("\n\n== script ran for 20secs and ended ==\n\n")
  return reaper.defer(function() end)
end

reaper.atexit(Exit)
main()
script


Do you see anything like this?:
Code:
Track 2 visible with 2 items.
Track 3 visible with 1 items.
Track 1 visible with 2 items.
item selected
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-20-2020, 08:40 AM   #59
Jae.Thomas
Human being with feelings
 
Join Date: Jun 2006
Posts: 22,567
Default

Quote:
Originally Posted by amagalma View Post
Try this version with a small project (2-3 tracks with 2-3 items on each track) and have one item selected:

Code:
-- TEST
local reaper, floor = reaper, math.floor
local function Msg( ... )
  local arg = table.pack( ... )
  for i = 1, arg.n do
    if arg[i] then arg[i] = tostring(arg[i]) else arg[i] = "nil" end
  end
  reaper.ShowConsoleMsg(table.concat(arg))
end
------------------------------------------------------
local MainHwnd = reaper.GetMainHwnd()
local tracks = {}
local p_trackitems_cnt = {}

local trackview = reaper.JS_Window_FindChildByID(MainHwnd, 0x3E8)
local _, width_trackview, height_trackview = reaper.JS_Window_GetClientSize( trackview )
width_trackview = width_trackview + 17

local start = reaper.time_precise()
local checksizetime = start
local p_item, p_item_cnt = 0, -1
local huge = math.huge
local first_pos
local st, en, arr_duration, track_cnt

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

function main()
  local now = reaper.time_precise()

  st, en = reaper.GetSet_ArrangeView2( 0, false, 0, 0 )
  arr_duration = en - st
  track_cnt = reaper.CountTracks( 0 )
  
  -- Check every now and then if arrange size changed and update values
  if now - checksizetime >= 1 then
    _, width_trackview, height_trackview = reaper.JS_Window_GetClientSize( trackview )
    width_trackview = width_trackview + 17
    checksizetime = now
  end

  for i = 0, track_cnt-1 do
    local track = reaper.GetTrack( 0, i )
    local id = reaper.GetMediaTrackInfo_Value( track, "IP_TRACKNUMBER" )
    local ID = tostring(id)
    ID = ID:match("%d+")
    local y_pos = reaper.GetMediaTrackInfo_Value( track, "I_TCPY" )
                                                                   
    if reaper.IsTrackVisible( track, false ) and y_pos < height_trackview then
      Msg("Track ",ID," visible with ")
      local item_cnt = reaper.CountTrackMediaItems( track )
      Msg(item_cnt, " items.\n")
      if p_trackitems_cnt[id] ~= item_cnt then
        tracks[id] = nil
        Msg(" -- Item count changed. -- ")
        p_trackitems_cnt[id] = item_cnt
      end
      if item_cnt > 0 then
        local item_selected = false
        local paint = false
        local x_pos
        for j = 0, item_cnt-1 do
          local item = reaper.GetTrackMediaItem( track, j )
          if reaper.IsMediaItemSelected( item ) then
            x_pos = floor( ( ( reaper.GetMediaItemInfo_Value( item, "D_POSITION" ) - st ) / arr_duration ) * width_trackview )
            x_pos = x_pos > 0 and ( x_pos < width_trackview and x_pos or width_trackview ) or 0
            paint = true
            
            Msg("item selected\n")
            break
          end
        end
        local track_h = reaper.GetMediaTrackInfo_Value( track, "I_WNDH" )
        --[[
        if paint then
          if ( not tracks[id] ) then
            Msg( string.format("track %i : x = %i, y = %i", id, x_pos, y_pos) .. "\n")

            tracks[id] = x_pos
          elseif x_pos ~= tracks[id] then
            Msg( string.format("track %i new positin: x = %i, y = %i", id, x_pos, y_pos) .. "\n")
            tracks[id] = x_pos
          end
        else
          if tracks[id] then
            Msg( string.format("erase track %i", id) .. "\n" )
            tracks[id] = nil
          end
        end
      --]]
      end
    else    
      break
    end
  end  
  
  if now - start <= 20 then
    reaper.defer(main)
  end
 
end

function Exit()
  Msg("\n\n== script ran for 20secs and ended ==\n\n")
  return reaper.defer(function() end)
end

reaper.atexit(Exit)
main()
script


Do you see anything like this?:
Code:
Track 2 visible with 2 items.
Track 3 visible with 1 items.
Track 1 visible with 2 items.
item selected
nothing. I'm going to try it on a portable version. After a bit it say:



== script ran for 20secs and ended ==
Jae.Thomas is offline   Reply With Quote
Old 05-20-2020, 08:51 AM   #60
Jae.Thomas
Human being with feelings
 
Join Date: Jun 2006
Posts: 22,567
Default

same for portable
Jae.Thomas is offline   Reply With Quote
Old 05-20-2020, 08:52 AM   #61
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by Jason Brian Merrill View Post
nothing. I'm going to try it on a portable version. After a bit it say:

== script ran for 20secs and ended ==

Super super strange! It seems like all the API functions do not work!? Try it please on a portable installation and tell me if it works there. Thanks!
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-20-2020, 08:53 AM   #62
Jae.Thomas
Human being with feelings
 
Join Date: Jun 2006
Posts: 22,567
Default

Quote:
Originally Posted by amagalma View Post
Super super strange! It seems like all the API functions do not work!? Try it please on a portable installation and tell me if it works there. Thanks!
just did as you're posting. No go. I wonder if I'm doing something wrong.

I'm not stupid I swear
Jae.Thomas is offline   Reply With Quote
Old 05-20-2020, 12:43 PM   #63
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by Jason Brian Merrill View Post
just did as you're posting. No go. I wonder if I'm doing something wrong.

I'm not stupid I swear

Don't worry! Let's try a final test:
Code:
-- TEST
local reaper, floor = reaper, math.floor
local function Msg( ... )
  local arg = table.pack( ... )
  for i = 1, arg.n do
    if arg[i] then arg[i] = tostring(arg[i]) else arg[i] = "nil" end
  end
  reaper.ShowConsoleMsg(table.concat(arg))
end

------------------------------------------------------
MainHwnd = reaper.GetMainHwnd()
tracks = {}
p_trackitems_cnt = {}
local _
trackview = reaper.JS_Window_FindChildByID(MainHwnd, 0x3E8)
_, width_trackview, height_trackview = reaper.JS_Window_GetClientSize( trackview )
width_trackview = width_trackview + 17

local start = reaper.time_precise()
local checksizetime = start
p_item, p_item_cnt = 0, -1
local huge = math.huge

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

function main()
  local now = reaper.time_precise()

  st, en = reaper.GetSet_ArrangeView2( 0, false, 0, 0 )
  arr_duration = en - st
  track_cnt = reaper.CountTracks( 0 )
  
  -- Check every now and then if arrange size changed and update values
  if now - checksizetime >= 1 then
    _, width_trackview, height_trackview = reaper.JS_Window_GetClientSize( trackview )
    width_trackview = width_trackview + 17
    checksizetime = now
  end

  for i = 0, track_cnt-1 do
    track = reaper.GetTrack( 0, i )
    local id = reaper.GetMediaTrackInfo_Value( track, "IP_TRACKNUMBER" )
    ID = tostring(id)
    ID = ID:match("%d+")
    y_pos = reaper.GetMediaTrackInfo_Value( track, "I_TCPY" )
                                                                   
    if reaper.IsTrackVisible( track, false ) and y_pos < height_trackview then
      --Msg("Track ",ID," visible with ")
      item_cnt = reaper.CountTrackMediaItems( track )
      --Msg(item_cnt, " items.\n")
      if p_trackitems_cnt[id] ~= item_cnt then
        tracks[id] = nil
        --Msg(" -- Item count changed. -- ")
        p_trackitems_cnt[id] = item_cnt
      end
      if item_cnt > 0 then
        item_selected = false
        local paint = false
        for j = 0, item_cnt-1 do
          item = reaper.GetTrackMediaItem( track, j )
          if reaper.IsMediaItemSelected( item ) then
            item_selected = true
            x_pos = floor( ( ( reaper.GetMediaItemInfo_Value( item, "D_POSITION" ) - st ) / arr_duration ) * width_trackview )
            x_pos = x_pos > 0 and ( x_pos < width_trackview and x_pos or width_trackview ) or 0
            paint = true
            
            --Msg("item selected\n")
            break
          end
        end
        local track_h = reaper.GetMediaTrackInfo_Value( track, "I_WNDH" )
        --[[
        if paint then
          if ( not tracks[id] ) then
            Msg( string.format("track %i : x = %i, y = %i", id, x_pos, y_pos) .. "\n")

            tracks[id] = x_pos
          elseif x_pos ~= tracks[id] then
            Msg( string.format("track %i new positin: x = %i, y = %i", id, x_pos, y_pos) .. "\n")
            tracks[id] = x_pos
          end
        else
          if tracks[id] then
            Msg( string.format("erase track %i", id) .. "\n" )
            tracks[id] = nil
          end
        end
      --]]
      end
    else    
      break
    end
  end  
  
  if now - start <= 40 then
    reaper.defer(main)
  end
 
end

function Exit()
  Msg("\n\n== script ran for 40secs and ended ==\n\n")
  return reaper.defer(function() end)
end

reaper.atexit(Exit)
main()
script

Follow my instructions in the gif to make me a licecap:
Big image

EDIT> IMPORTANT: Add a dot after "reaper" so it is:
Code:
NOT gfx NOT reaper.
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)

Last edited by amagalma; 05-20-2020 at 12:56 PM.
amagalma is offline   Reply With Quote
Old 05-21-2020, 09:47 AM   #64
Pink Wool
Human being with feelings
 
Pink Wool's Avatar
 
Join Date: Apr 2020
Posts: 1,501
Default

Ummm...is this "normal"? If there's a folder, then any tracks under that won't show color (tracks not in the folder)?

Last edited by Pink Wool; 05-21-2020 at 10:01 AM.
Pink Wool is offline   Reply With Quote
Old 05-21-2020, 09:49 AM   #65
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by Pink Wool View Post
Ummm...is this "normal"? If there's a folder, then any tracks under that won't show color (tracks not in the folder)?

A licecap please?
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-21-2020, 09:59 AM   #66
Pink Wool
Human being with feelings
 
Pink Wool's Avatar
 
Join Date: Apr 2020
Posts: 1,501
Default

Quote:
Originally Posted by amagalma View Post
A licecap please?
Also had this happen...

https://stash.reaper.fm/39231/Ripple%20color%201.gif
Pink Wool is offline   Reply With Quote
Old 05-21-2020, 01:01 PM   #67
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by Pink Wool View Post

Thanks! Fixed in v1.30
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-22-2020, 08:18 AM   #68
Jae.Thomas
Human being with feelings
 
Join Date: Jun 2006
Posts: 22,567
Default

https://youtu.be/jpmwAzxkx-A


Quote:
Originally Posted by amagalma View Post
Don't worry! Let's try a final test:
Code:
-- TEST
local reaper, floor = reaper, math.floor
local function Msg( ... )
  local arg = table.pack( ... )
  for i = 1, arg.n do
    if arg[i] then arg[i] = tostring(arg[i]) else arg[i] = "nil" end
  end
  reaper.ShowConsoleMsg(table.concat(arg))
end

------------------------------------------------------
MainHwnd = reaper.GetMainHwnd()
tracks = {}
p_trackitems_cnt = {}
local _
trackview = reaper.JS_Window_FindChildByID(MainHwnd, 0x3E8)
_, width_trackview, height_trackview = reaper.JS_Window_GetClientSize( trackview )
width_trackview = width_trackview + 17

local start = reaper.time_precise()
local checksizetime = start
p_item, p_item_cnt = 0, -1
local huge = math.huge

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

function main()
  local now = reaper.time_precise()

  st, en = reaper.GetSet_ArrangeView2( 0, false, 0, 0 )
  arr_duration = en - st
  track_cnt = reaper.CountTracks( 0 )
  
  -- Check every now and then if arrange size changed and update values
  if now - checksizetime >= 1 then
    _, width_trackview, height_trackview = reaper.JS_Window_GetClientSize( trackview )
    width_trackview = width_trackview + 17
    checksizetime = now
  end

  for i = 0, track_cnt-1 do
    track = reaper.GetTrack( 0, i )
    local id = reaper.GetMediaTrackInfo_Value( track, "IP_TRACKNUMBER" )
    ID = tostring(id)
    ID = ID:match("%d+")
    y_pos = reaper.GetMediaTrackInfo_Value( track, "I_TCPY" )
                                                                   
    if reaper.IsTrackVisible( track, false ) and y_pos < height_trackview then
      --Msg("Track ",ID," visible with ")
      item_cnt = reaper.CountTrackMediaItems( track )
      --Msg(item_cnt, " items.\n")
      if p_trackitems_cnt[id] ~= item_cnt then
        tracks[id] = nil
        --Msg(" -- Item count changed. -- ")
        p_trackitems_cnt[id] = item_cnt
      end
      if item_cnt > 0 then
        item_selected = false
        local paint = false
        for j = 0, item_cnt-1 do
          item = reaper.GetTrackMediaItem( track, j )
          if reaper.IsMediaItemSelected( item ) then
            item_selected = true
            x_pos = floor( ( ( reaper.GetMediaItemInfo_Value( item, "D_POSITION" ) - st ) / arr_duration ) * width_trackview )
            x_pos = x_pos > 0 and ( x_pos < width_trackview and x_pos or width_trackview ) or 0
            paint = true
            
            --Msg("item selected\n")
            break
          end
        end
        local track_h = reaper.GetMediaTrackInfo_Value( track, "I_WNDH" )
        --[[
        if paint then
          if ( not tracks[id] ) then
            Msg( string.format("track %i : x = %i, y = %i", id, x_pos, y_pos) .. "\n")

            tracks[id] = x_pos
          elseif x_pos ~= tracks[id] then
            Msg( string.format("track %i new positin: x = %i, y = %i", id, x_pos, y_pos) .. "\n")
            tracks[id] = x_pos
          end
        else
          if tracks[id] then
            Msg( string.format("erase track %i", id) .. "\n" )
            tracks[id] = nil
          end
        end
      --]]
      end
    else    
      break
    end
  end  
  
  if now - start <= 40 then
    reaper.defer(main)
  end
 
end

function Exit()
  Msg("\n\n== script ran for 40secs and ended ==\n\n")
  return reaper.defer(function() end)
end

reaper.atexit(Exit)
main()
script

Follow my instructions in the gif to make me a licecap:
Big image

EDIT> IMPORTANT: Add a dot after "reaper" so it is:
Code:
NOT gfx NOT reaper.
Jae.Thomas is offline   Reply With Quote
Old 05-22-2020, 08:41 AM   #69
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by Jason Brian Merrill View Post

Thanks mate! Got it now! Fix is coming
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-22-2020, 02:12 PM   #70
Jae.Thomas
Human being with feelings
 
Join Date: Jun 2006
Posts: 22,567
Default

Quote:
Originally Posted by amagalma View Post
Thanks mate! Got it now! Fix is coming
thank you for your work!
Jae.Thomas is offline   Reply With Quote
Old 05-25-2020, 02:09 AM   #71
Ideosound
Human being with feelings
 
Ideosound's Avatar
 
Join Date: Oct 2017
Location: U.K
Posts: 542
Default

I think there has been an improvement in how this works with metal on mac. When I tested it before it wouldn't show any change using metal at all (rather than the recommended disabled drawing option). Using the latest reaper release build and reapack builds.

Ideosound is offline   Reply With Quote
Old 05-25-2020, 06:08 AM   #72
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Nice to see it working.. But it does not appear right.. The yellow should be transparent.. Could you try a thing for me?
Go to lines 74-76 inside the script:
Code:
alpha = OSX and (alpha and (alpha < 0 and 0 or (alpha > 255 and 255 or alpha)) or 13) or
        (alpha and (alpha < 0 and 0 or (alpha > 255 and 1 or alpha/255)) or 0.051)
local color_trackview = OSX and ((blue&0xFF)|((green&0xFF)<<8)|((red&0xFF)<<16)|((alpha&0xFF)<<24)) or
And comment out this: (by adding "--")
Code:
alpha = -- OSX and (alpha and (alpha < 0 and 0 or (alpha > 255 and 255 or alpha)) or 13) or
        (alpha and (alpha < 0 and 0 or (alpha > 255 and 1 or alpha/255)) or 0.051)
local color_trackview = -- OSX and ((blue&0xFF)|((green&0xFF)<<8)|((red&0xFF)<<16)|((alpha&0xFF)<<24)) or

And tell me please if it shows correctly now. Thanks!
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-25-2020, 06:45 AM   #73
Ideosound
Human being with feelings
 
Ideosound's Avatar
 
Join Date: Oct 2017
Location: U.K
Posts: 542
Default

Quote:
Originally Posted by amagalma View Post
Nice to see it working.. But it does not appear right.. The yellow should be transparent.. Could you try a thing for me?
Go to lines 74-76 inside the script:
Code:
alpha = OSX and (alpha and (alpha < 0 and 0 or (alpha > 255 and 255 or alpha)) or 13) or
        (alpha and (alpha < 0 and 0 or (alpha > 255 and 1 or alpha/255)) or 0.051)
local color_trackview = OSX and ((blue&0xFF)|((green&0xFF)<<8)|((red&0xFF)<<16)|((alpha&0xFF)<<24)) or
And comment out this: (by adding "--")
Code:
alpha = -- OSX and (alpha and (alpha < 0 and 0 or (alpha > 255 and 255 or alpha)) or 13) or
        (alpha and (alpha < 0 and 0 or (alpha > 255 and 1 or alpha/255)) or 0.051)
local color_trackview = -- OSX and ((blue&0xFF)|((green&0xFF)<<8)|((red&0xFF)<<16)|((alpha&0xFF)<<24)) or

And tell me please if it shows correctly now. Thanks!
I get this now, sorry its a rubbish capture but its the same just not yellow.

Ideosound is offline   Reply With Quote
Old 05-25-2020, 08:14 AM   #74
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

So, it seems that the drawing is fixed but it can't do transparency
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-25-2020, 08:43 AM   #75
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Could you please try a few more values?:
Go to line 78 (which is empty and add this:
Code:
color_trackview = 0x23FFFF7F
And try these values too: 0x01FFFF7F, 0x0AFFFF7F, 0x01232311, 0x23232311, 0x7F232311

Just to be sure.. Thanks!

(with a dev build that has the Metal fix)
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-25-2020, 09:40 AM   #76
Ideosound
Human being with feelings
 
Ideosound's Avatar
 
Join Date: Oct 2017
Location: U.K
Posts: 542
Default

Quote:
Originally Posted by amagalma View Post
Could you please try a few more values?:
Go to line 78 (which is empty and add this:
Code:
color_trackview = 0x23FFFF7F
And try these values too: 0x01FFFF7F, 0x0AFFFF7F, 0x01232311, 0x23232311, 0x7F232311

Just to be sure.. Thanks!

(with a dev build that has the Metal fix)
Can't see any dev builds in the directory at the moment, maybe wait until V6.12 release is out since that should include the improvements.
Ideosound is offline   Reply With Quote
Old 05-25-2020, 11:44 AM   #77
Jae.Thomas
Human being with feelings
 
Join Date: Jun 2006
Posts: 22,567
Default

hey, this works for me now
Jae.Thomas is offline   Reply With Quote
Old 07-04-2020, 11:25 PM   #78
todoublez
Human being with feelings
 
todoublez's Avatar
 
Join Date: Aug 2019
Location: beijing
Posts: 612
Default

wow this is kinda useful and handy !
does it wrk on Mac yet ?
thank u amagalma
todoublez is offline   Reply With Quote
Old 08-07-2020, 08:04 AM   #79
djabthrash
Human being with feelings
 
Join Date: Dec 2018
Location: Paris (France)
Posts: 155
Default

Very useful script, thank you !
djabthrash is offline   Reply With Quote
Old 08-07-2020, 08:47 AM   #80
djabthrash
Human being with feelings
 
Join Date: Dec 2018
Location: Paris (France)
Posts: 155
Default

Very useful script, thank you !

Since my problem with the original "ripple" button is that you forget to turn it off when you're done, i just added another button next to it (with the "nuke" red icon), and this button triggers a custom action that i named "Custom: Cycle ripple editing mode and ripple visualization", which has the two following actions :

Options: Cycle ripple editing mode
Script: amagalma_Distinguish visually the ripple editing modes.lua

I also swapped the "Alt + P" shortcut from the original "Options: Cycle ripple editing mode" action, to this new action.

This way, if i use my regular shortcut to cycle ripple editing, i now have the obvious ripple visualization (from "Script: amagalma_Distinguish visually the ripple editing modes.lua") on the items that lets me know that i'm in ripple mode, and if i'm tempted to click on the default "ripple editing mode" button on the taskbar, i have a bright red button next to it that reminds me i should use the keystroke or this other button instead.

Of course the best way would be to have only one button with the new action, and that changes icons just like the original "ripple editing mode", but it seems nobody has found a way to do changing icons so far.




Last edited by djabthrash; 08-07-2020 at 10:07 AM. Reason: licecap
djabthrash 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 11:53 PM.


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