Old 06-29-2020, 11:52 AM   #1
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 2,024
Default Script to set random colour to different source files?

Is there a script or Custom Action that would allow someone to select a bunch of items, and run it to set random colours for each item that has a different source file?

For example, say you had items with source files FileA.WAV FileA.MP3 FileB.WAV FileC.WAV. You chop up the items and put all the pieces onto one track. By default they will all inherit the track's colour.
This script/action would colour each item in the item selection to a different random colour.

For example: FileA.WAV red, FileA.MP3 blue, FileB.WAV green, FileC.WAV purple


Thanks in advance to anyone who has any ideas how to achieve this!

All the best!
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia GT710, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 06-29-2020, 12:39 PM   #2
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,200
Default

Cool and useful idea... I don't think there is one.
__________________
Cheers,
Andrew K
v6.03+dev0114 - January 14 2020 • Mac 10.12.+ • i7 Quad 2.9GHz • 24GB
Thonex is online now   Reply With Quote
Old 06-29-2020, 01:36 PM   #3
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 2,024
Default

No worries, thanks Andrew!
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia GT710, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 06-29-2020, 04:24 PM   #4
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,584
Default

Script: X-Raym_Color selected items randomly according to their source.lua



It uses a special algorythm where it is not pure random at each items, there is always nice hue contrast/shift between each ones.

Though, it is a premium unreleased script for now... Not sure in which pack I could put it. I made it back in 2017 and there was demand before today ^^
X-Raym is offline   Reply With Quote
Old 06-30-2020, 11:06 AM   #5
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,864
Default

Quote:
Originally Posted by daxliniere View Post
For example: FileA.WAV red, FileA.MP3 blue, FileB.WAV green, FileC.WAV purple
I've been wanting to make a script like that, this is limited to 10 hard coded colors (tweak as needed) and used in the same order (its what I prefer), if it doesn't help then just don't use it (no updates planned). Probably not as versatile as XRaym scripts but it does what I need.

Code:
-- Color selected items of same source file
-- Edgemeal - June 30, 2020
-- Donate: https://www.paypal.me/Edgemeal

-- 10 colors max (Red, Orange, Yellow, Lime, Cyan, Cadet Blue, Purple, Green, Blue, Pink).
local colors = {16777471,16810239,16842751,16842496,33554176,29392896,33489024,16809984,33488896,33521919}
local itemSource = {}

function contains(src)
  for n = 1, #itemSource do
    if itemSource[n].src == src then return true end
  end
end

function ColorItems()
  local itemCount = reaper.CountSelectedMediaItems()
  if itemCount == 0 then return end
  
  reaper.PreventUIRefresh(1)
  local takes = {}
  local colorIndex,takeIndex,sourceIndex = 0,0,0

  for i = 0, itemCount-1 do
    local item = reaper.GetSelectedMediaItem(0,i)
    if item then
      local take = reaper.GetActiveTake(item)
      if take and not reaper.TakeIsMIDI(take) then -- ignore MIDI items!
        local src_file = reaper.GetMediaSourceFileName(reaper.GetMediaItemTake_Source(take), "")
        takeIndex=takeIndex+1 takes[takeIndex] = {take = take, src = src_file}
        if not contains(src_file) then -- associate a color to source file
          colorIndex=colorIndex+1 if colorIndex > #colors then colorIndex = 1 end
          sourceIndex=sourceIndex+1 itemSource[sourceIndex] = {src = src_file, color = colors[colorIndex]}
        end
      end
    end
  end
 
  for i = 1, #takes do
    for j = 1, #itemSource do
      if takes[i].src == itemSource[j].src then
        reaper.SetMediaItemTakeInfo_Value(takes[i].take,"I_CUSTOMCOLOR",itemSource[j].color)
        break
      end
    end
  end
 reaper.UpdateArrange()
 reaper.PreventUIRefresh(-1)
end

ColorItems()
reaper.defer(function () end)
Edgemeal is offline   Reply With Quote
Old 06-30-2020, 05:03 PM   #6
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 2,024
Default

Hey guys!
Raymond and Edgemeal, thank you both for your efforts.
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia GT710, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 07-02-2020, 10:53 AM   #7
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,200
Default

Nice one Edgemeal!!

Cheers,

Andrew K
__________________
Cheers,
Andrew K
v6.03+dev0114 - January 14 2020 • Mac 10.12.+ • i7 Quad 2.9GHz • 24GB
Thonex is online now   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:29 PM.


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