Old 11-13-2012, 01:38 PM   #1
gofer
-blänk-
 
gofer's Avatar
 
Join Date: Jun 2008
Posts: 11,359
Default Track and item color ReaScript bundle on the stash

Quite a while ago I did this pile of ReaScripts that deal with custom colors on tracks and items. I always wanted to upload them, but never got around to it.
I finally packed a bunch of them for you to enjoy. The coding is - to put it lightly - clumsy at best (even for my humble standards ), but they do the job as intended.


There are no scripts dealing with take color in this pack, because down the road I changed the approach to it, to avoid the action flood. More on that at the end of this post.

Most of them are scripts to increase or decrease either hue, brightness or saturation of the selected track or item colors, so you can dial in existing colors by making it brighter/darker or cycle it around the color wheel or change saturation without going into the color picker dialog. You can also have a bunch of differently colored tracks or items and, say, desaturate them a tad all in one go.

Track as well as item color scripts include:
  • brightness increase and decrease
  • saturation increase and decrease
  • hue increase and decrease (rather: cycle forward/backwards through the color wheel) plus versions with a wider step size (coarse)
  • copy color of first selected track (item) to clipboard
  • paste color from clipboard to all selected tracks (items)
The copy/paste scripts share a common clipboard, so you can copy a track color and paste it on items and vice versa

For track colors there are a few additional scripts to give a bunch of selected tracks individual colors:
  • "Track color brightness darker decrease multitrack.py" looks at the color of the first selected track and gives all other selected tracks a relative color, getting a tad darker on each subsequent track. There is a coarser version (wider steps) of that one also. Useful (and looking fancy) on folders.
  • "Track color hue rainbow" does a similar thing but with the hue aspect.
  • "Track color hue shuffle" is the same as the above with wider step size

Most of the track color scripts (except copy to clipboard) will init the color to a medium red-ish color if no custom track color is set.

Item color scripts will first look whether they find a custom item color, if not then look for a custom track color. If neither is found they also init to a medium red-ish (IIRC, that is...).

All of the increase/decrease scripts cycle when a certain extreme value is reached. Eg, if you go darker, at a certain value it will start over from "pretty bright". The resulting jump can look a bit weird in case of brightness and saturation, but I figured it's the best I could do when the extremes are reached.





Here is a teaser screencap I did back then, showing some of them in action. Quoting myself from the thread back then:
Quote:
Originally Posted by gofer View Post
At the start I select all folder parents and use the "hue shuffler" script to give each a "random" color (SWS autocolor does the neat live coloring of child tracks). Then I use the "get darker" script to sweeten the children tracks up (this would work as well without SWS pre-coloring, it only depends on the first selected track). Afterwards I just toy around changing various color aspects on track 5.



Boy, how I want to make them ready for prime time
This capture was made before Cockos provided a much nicer API to track colors. The scripts run a lot faster than that now

grab and enjoy: https://stash.reaper.fm/v/14535/gofer...%20scripts.zip






As said, the code is really noobish but as they work fine I probably just leave them as that. But still, if someone has a more direct conversion from Reaper's color numbers to HSV values and back, I'd like to know. The stuff I found back then sort of travels from Rome to Paris via Capetown and Sidney .

Also, I have a lot of these functions as scripts that work on either track, item or take color, depending on a state which can be set via another set of actions. I use them on a color toolbar, but setting it up is a bit more involved and due to Reaper's toolbar not playing nice with 3-way-toggling it's also not totally perfect if you really want to have access to all 3 target types from the toolbar. If there is some interest I could probably find some spare time to pack them as well (and come up with a description about ways to make it work - which is the part I hate about it ).
gofer is offline   Reply With Quote
Old 11-20-2012, 08:10 AM   #2
sws
Code Monkey
 
sws's Avatar
 
Join Date: Sep 2007
Location: Madison, WI
Posts: 857
Default

In response to MBN from the SWS thread:
Quote:
Originally Posted by musicbynumbers View Post
Hi Gofer, Finally got round to trying these with python 2.7 and no matter what colour the items are they always turn black regardless of the parameter I choose to increase or decrease. any ideas? need python 3?

Thanks!
gofer, any time you set the custom color you need to OR with 0x1000000 or 16777216 to set the color properly. So replace
RPR_SetTrackColor(TRACK, New_Color)
with
RPR_SetTrackColor(TRACK, New_Color | 16777216)

sws is offline   Reply With Quote
Old 11-20-2012, 10:43 AM   #3
musicbynumbers
Human being with feelings
 
musicbynumbers's Avatar
 
Join Date: Jun 2009
Location: South, UK
Posts: 14,214
Default

Quote:
Originally Posted by sws View Post
In response to MBN from the SWS thread:

gofer, any time you set the custom color you need to OR with 0x1000000 or 16777216 to set the color properly. So replace
RPR_SetTrackColor(TRACK, New_Color)
with
RPR_SetTrackColor(TRACK, New_Color | 16777216)

Thanks tim and gofer for looking at this. It's a great idea to have these scripts as they will help with quick visual cues : )

Got to learn this stuff myself soon!
musicbynumbers is offline   Reply With Quote
Old 11-20-2012, 12:31 PM   #4
gofer
-blänk-
 
gofer's Avatar
 
Join Date: Jun 2008
Posts: 11,359
Default

Quote:
Originally Posted by sws View Post
In response to MBN from the SWS thread:

gofer, any time you set the custom color you need to OR with 0x1000000 or 16777216 to set the color properly. So replace
RPR_SetTrackColor(TRACK, New_Color)
with
RPR_SetTrackColor(TRACK, New_Color | 16777216)

Thanks, I will look into it.

as of now I don't understand a lick of it what's the reason? Shouldn't we ask Cockos to mention that OR-thing in the ReaScript help doc, then?


And, more important, is this also necessary for item colors set via
SetMediaItemInfo_Value(MediaItem* item, "I_CUSTOMCOLOR", double newvalue)

That is what I use for the item color scripts, which MBN has the problem with?
New_Color in all of the item related scripts is always >= 16777216 (unless the functions I fished from the web are calculating wrong and give a negative integer as return - which they never did for me), if that changes something.

Actually I was wondering, why I had to set that bit (add the 16777216) for item colors, but not for track colors.
Should that be a clue in my investigation about the why of the OR, and the when and when not?


Is it pure luck that they worked all this time? I used them as is for about a year and pretty often, so I really thought they'd be proper and fit for all conditions, just not elegant. They seem to run for a few others as well.



MBN, I tested that change for both item and track color change scripts, here it doesn't make a difference - both still work absolutely the same .
So I guess I'll just change them all now. I'll post here when they are updated on the stash and hope that will solve it for you.

(Still wondering whether it could also (or additionally) be a Python version thing. I think I remember a situation where I had to change some syntax because v3.x was expecting a line in a slightly different manner than 2.7. But for the life of me, I don't remember what that was.)

Last edited by gofer; 11-20-2012 at 12:41 PM.
gofer is offline   Reply With Quote
Old 11-20-2012, 12:39 PM   #5
sws
Code Monkey
 
sws's Avatar
 
Join Date: Sep 2007
Location: Madison, WI
Posts: 857
Default

As far as I know, it's required always. In reaper_plugin_functions.h (the API header) it says:
Quote:
// I_CUSTOMCOLOR : int * : custom color, windows standard color order (i.e. RGB(r,g,b)|0x100000). if you do not |0x100000, then it will not be used (though will store the color anyway)
It never hurts to add it, so I would in all cases.

Is it possible that you're using either AutoColor or always using templates that already have a color set? That way you never are in the position MBN is in of having "default" colored tracks. I haven't studied your scripts but it's possible that's the issue.

EDIT LATE BREAKING THOUGHT - It's possibly an operating system difference, too... One of you using OSX?
sws is offline   Reply With Quote
Old 11-20-2012, 01:08 PM   #6
musicbynumbers
Human being with feelings
 
musicbynumbers's Avatar
 
Join Date: Jun 2009
Location: South, UK
Posts: 14,214
Default

Thanks gofer and Tim (again)

I'm on pc with python 2.7 so I could try 3 and also your potential fix.
musicbynumbers is offline   Reply With Quote
Old 11-20-2012, 01:20 PM   #7
gofer
-blänk-
 
gofer's Avatar
 
Join Date: Jun 2008
Posts: 11,359
Default

Though I do use auto color (you deserve a medal for that thing, Tim ), I of course tested the scripts with default, aka no custom color. Maybe it's one of these things that have a safety leash in ReaScript but not in C?




Off to the drawing board, ctrl+v here I come!
Boy, I'll have to do that for all take and region/marker color scripts as well... phew... Could be worse
gofer is offline   Reply With Quote
Old 11-20-2012, 01:57 PM   #8
gofer
-blänk-
 
gofer's Avatar
 
Join Date: Jun 2008
Posts: 11,359
Default

Files are updated on the stash now

Hope this does the trick.
gofer is offline   Reply With Quote
Old 11-22-2012, 01:22 PM   #9
EvilDragon
Human being with feelings
 
EvilDragon's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 24,790
Default

This is very cool, gofer! Bravo!
EvilDragon is offline   Reply With Quote
Old 12-08-2019, 09:27 AM   #10
daeavelwyn
Human being with feelings
 
daeavelwyn's Avatar
 
Join Date: Dec 2014
Posts: 597
Default

This is a very old post, I know But I would know if there are chances to get this port to lua ?
daeavelwyn is offline   Reply With Quote
Old 02-12-2023, 03:30 PM   #11
EpicSounds
Human being with feelings
 
EpicSounds's Avatar
 
Join Date: Jul 2009
Posts: 7,570
Default

Old thread but there's no mention of the newer .EEL versions of these scripts here.

https://stash.reaper.fm/v/26916/Trac...%20scripts.zip

probably worth getting these into ReaPack too
__________________
REAPER Video Tutorials, Tips & Tricks and more at The REAPER Blog
EpicSounds 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:45 AM.


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