Old 11-07-2016, 10:52 AM   #1
Stroudy
Human being with feelings
 
Stroudy's Avatar
 
Join Date: Jul 2014
Location: London
Posts: 739
Default Can scripts change preferences? Tint Color



Can any of these preferences be changed via a script? Specifically "Tint media item *** to : 'Take Color'"
Stroudy is offline   Reply With Quote
Old 11-07-2016, 05:42 PM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,902
Default

You should be able to do that yes,
You just have to know how this parameter is called from the REAPER.ini file in REAPER resources folder.
Make a copy of the REAPER.ini,
save new settings,
and use a software compare two files. The line modified will show you how the key parameter is named.

Then you will be able to use reaper.SNM_SetIntConfigVar(string varname, integer newvalue)
or
reaper.SNM_GetDoubleConfigVar(string varname, number errvalue)

according to context.

Need some testing, but it should work.
X-Raym is offline   Reply With Quote
Old 11-08-2016, 03:41 AM   #3
Stroudy
Human being with feelings
 
Stroudy's Avatar
 
Join Date: Jul 2014
Location: London
Posts: 739
Default

Interesting. I'll give this a go. Not exactly a scripter, but I'll give it a shot
Stroudy is offline   Reply With Quote
Old 11-08-2016, 03:54 AM   #4
Stroudy
Human being with feelings
 
Stroudy's Avatar
 
Join Date: Jul 2014
Location: London
Posts: 739
Default

"tinttcp=" is the line in reper.ini that pertains to Item and Waveform tinting.

Variations on Take Color


tinttcp=1726


tinttcp=1982


tinttcp=1854


tinttcp=1598
Stroudy is offline   Reply With Quote
Old 11-08-2016, 04:16 AM   #5
Stroudy
Human being with feelings
 
Stroudy's Avatar
 
Join Date: Jul 2014
Location: London
Posts: 739
Default

Ignore the previous post. Here's how tint preferences affect the Reaper.ini configuration number...



Settings are now going from 0, not 2. Don't know why but everything else remains true

LOWEST NUMBER IS NOT 2. A value of 2 is set by 'Tint track panel backgrounds'

Last edited by Stroudy; 11-08-2016 at 02:45 PM. Reason: Wrong image
Stroudy is offline   Reply With Quote
Old 11-08-2016, 04:54 AM   #6
Stroudy
Human being with feelings
 
Stroudy's Avatar
 
Join Date: Jul 2014
Location: London
Posts: 739
Default

Learning as I go here. "Item Background Take color" would set the 9th digit in a 12bit binary number to 1 or 0. As it adds 256.

i.e. 1024 - 512 - 256 - 128 - 64 - 32 - 16 - 8 - 4 - 2 - 1

256 is 9th from the right.

My maths aren't good enough to do this in Hex, but binary seems straight forward. I would convert the "tinttcp" value to Binary, check the 9th digit and change to eith a 1 or 0. Then convert it back to decimal and apply the value to Reaper.ini
Stroudy is offline   Reply With Quote
Old 11-08-2016, 05:09 AM   #7
xpander
Human being with feelings
 
xpander's Avatar
 
Join Date: Jun 2007
Location: Terra incognita
Posts: 7,670
Default

There's also this little calculator help
http://forum.cockos.com/showpost.php...9&postcount=47
First page with what ELP found out.
xpander is offline   Reply With Quote
Old 11-08-2016, 05:16 AM   #8
Stroudy
Human being with feelings
 
Stroudy's Avatar
 
Join Date: Jul 2014
Location: London
Posts: 739
Default

What format is that in? .ods I can't do anything with that. Mac based
Stroudy is offline   Reply With Quote
Old 11-08-2016, 06:12 AM   #9
Stroudy
Human being with feelings
 
Stroudy's Avatar
 
Join Date: Jul 2014
Location: London
Posts: 739
Default

I can't get reaper.SNM_SetDoubleConfigVar( varname, newvalue ) to write any value

Code:
  reaper.SNM_SetIntConfigVar("tinttcp", "1940")
What am I doing wrong?
Stroudy is offline   Reply With Quote
Old 11-08-2016, 06:35 AM   #10
xpander
Human being with feelings
 
xpander's Avatar
 
Join Date: Jun 2007
Location: Terra incognita
Posts: 7,670
Default

Quote:
Originally Posted by Stroudy View Post
What format is that in? .ods I can't do anything with that. Mac based
OpenDocument Spreadsheet (ODS). Open Office or Libre Office, I prefer the latter myself.
https://www.libreoffice.org
xpander is offline   Reply With Quote
Old 11-08-2016, 08:57 AM   #11
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,902
Default

@Stroudy
Seems more complicated than expected ^^

Have you tried quit and restart REAPER after the set function ? it is possible than the file get modified only at REAPER closing.

Other possibility: the value you set is wrong (you can check what the set function return to see that).
X-Raym is offline   Reply With Quote
Old 11-08-2016, 09:43 AM   #12
Stroudy
Human being with feelings
 
Stroudy's Avatar
 
Join Date: Jul 2014
Location: London
Posts: 739
Default

Thanks X-Raym

Code:
CurSetting = reaper.SNM_GetIntConfigVar( "tinttcp", -666 )
num=CurSetting
bits=12

function toBits(num, bits)
    -- returns a table of bits
    local t={} -- will contain the bits
    for b=bits,1,-1 do
        rest=math.fmod(num,2)
        t[b]=rest
        num=(num-rest)/2
    end
    if num==0 then return t else return {'Not enough bits to represent this number'}end
end

bits=toBits(num, bits)

NinthBit = tonumber(table.concat(bits):sub(9,10))

reaper.ShowConsoleMsg(table.concat(bits).."\n"..NinthBit.."\n")

if NinthBit == 1 then
    reaper.ShowConsoleMsg("Yes it's on")
elseif NinthBit == 0 then
    reaper.ShowConsoleMsg("it's off")
  
    NewSetting = CurSetting+256
    reaper.ShowConsoleMsg(NewSetting)
  
    reaper.SNM_SetDoubleConfigVar( "tinttcp", 1940 ) -- 1940 would normally be the variable "NewSetting"
  
 
end
Does it need the equivolent of the "apply" button?

Quiting/Reaper Reaper doesn't help. Values are still not written.

Using the pref window, values when setting manually only change in the .ini when apply is pressed.
Stroudy is offline   Reply With Quote
Old 11-08-2016, 02:43 PM   #13
Stroudy
Human being with feelings
 
Stroudy's Avatar
 
Join Date: Jul 2014
Location: London
Posts: 739
Default



Checked adds 2 to tinttcp in Reaper.ini
Stroudy is offline   Reply With Quote
Old 08-28-2023, 11:41 PM   #14
GrizzlyAK
Human being with feelings
 
Join Date: Nov 2015
Location: Alaska
Posts: 260
Default

Very old thread, I know, but curious if you ever got this working and if so, would be willing to share the script?
GrizzlyAK is offline   Reply With Quote
Old 08-31-2023, 04:01 AM   #15
Stroudy
Human being with feelings
 
Stroudy's Avatar
 
Join Date: Jul 2014
Location: London
Posts: 739
Default

Quote:
Originally Posted by GrizzlyAK View Post
Very old thread, I know, but curious if you ever got this working and if so, would be willing to share the script?
Yes! I do use this a fair amount. I hope you find it useful. It could be modified to change other, similar visual aspects, I'm sue.

Code:
CurSetting = reaper.SNM_GetIntConfigVar( "tinttcp", -666 )
retval, stringOut = reaper.BR_Win32_GetPrivateProfileString("REAPER", "tinttcp", "sdfsdf",  reaper.get_ini_file())


--reaper.ShowConsoleMsg(stringOut)
 
num=CurSetting
bits=12 --The number of bit we need to make this setingwork

-- When the "tinttcp" number from the reaper.ini is converted to binary, the 
-- 256 value digit will correspond to  "Tint media item background to Take Color".
-- First, let's convert to bits...  
function toBits(num, bits)
    -- returns a table of bits
    local t={} -- will contain the bits
    for b=bits,1,-1 do
        rest=math.fmod(num,2)
        t[b]=rest
        num=(num-rest)/2
    end
    if num==0 then return t else return {'Not enough bits to represent this number'}end
end
bits=toBits(num, bits)

NinthBit = tonumber(table.concat(bits):sub(9,10)) --This is the bit will value of 256

--reaper.ShowConsoleMsg(table.concat(bits).."\n"..NinthBit.."\n")

if NinthBit == 1 then
    --reaper.ShowConsoleMsg("Tack Color BG is ON")
    NewSetting = CurSetting-256
    reaper.SNM_SetIntConfigVar( "tinttcp", NewSetting )--1940 is a placeholder value to be replaced with NewSetting
    
elseif NinthBit == 0 then
  --reaper.ShowConsoleMsg("Tack Color BG is OFF")
  
  NewSetting = CurSetting+256 --Get ready to turn it on. +256 will mean 9th bit will be "ON"
  --reaper.ShowConsoleMsg(NewSetting)
  
  reaper.SNM_SetIntConfigVar("tinttcp", NewSetting )--1940 is a placeholder value to be replaced with NewSetting

end

  reaper.TrackList_AdjustWindows(true)
  reaper.UpdateArrange()
Stroudy is offline   Reply With Quote
Old 09-01-2023, 04:38 PM   #16
GrizzlyAK
Human being with feelings
 
Join Date: Nov 2015
Location: Alaska
Posts: 260
Default

This is AWESOME! Thanks! Love the Reaper community.

Cheers
GrizzlyAK 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:43 AM.


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