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

Reply
 
Thread Tools Display Modes
Old 08-15-2018, 09:18 AM   #1
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,721
Default New Scripts: 4 presets for vertical waveform Peak Display views

Hi guys,

Really this is all cfillion's code example from this thread, but I decided to make 4 scripts -- 1 for each preset. I find it tedious to mouse around on the Peak Display Setting window while editing... so I made 4 presets with varying degrees of vertical waveform zoom. This is the actual control that is being changed behind the scene... and it doesn't need to even be open:



Here I have a toolbar to change the settings to demonstrate... as well as binding them to key commands (7, 8, 9, and 0 in this case). Of course you can change the values of the gainfactor variables to suit your preferences.

Should this be in ReaPack?



The code is crazy simple... except I would have never found the correct function or variable name without cfillion's help.

Set Peaks Display 1 (0dB)
Code:
function Set_Peak_Display_to_0 ()

  local gainFactor = 1 -- 0dB You can substitue your own value here (prefereably between 0-64)
  dB = reaper.SNM_SetDoubleConfigVar('projpeaksgain', gainFactor)
  reaper.UpdateArrange()
  
end

Set_Peak_Display_to_0 ()
Set Peaks Display 2 (9dB)
Code:
function Set_Peak_Display_to_9dB ()

  local gainFactor = 2.83 -- 9dB You can substitue your own value here (prefereably between 0-64)
  dB = reaper.SNM_SetDoubleConfigVar('projpeaksgain', gainFactor)
  reaper.UpdateArrange()
  
end

Set_Peak_Display_to_9dB ()

Set Peaks Display 3 (22dB)
Code:
function Set_Peak_Display_to_22dB ()

  local gainFactor = 12.6 -- 22dB You can substitue your own value here (prefereably between 0-64)
  dB = reaper.SNM_SetDoubleConfigVar('projpeaksgain', gainFactor)
  reaper.UpdateArrange()
  
end

Set_Peak_Display_to_22dB ()

Set Peaks Display 4 (36dB)
Code:
function Set_Peak_Display_to_36dB ()

  local gainFactor = 63.4 -- 36dB You can substitue your own value here (prefereably between 0-64)
  dB = reaper.SNM_SetDoubleConfigVar('projpeaksgain', gainFactor)
  reaper.UpdateArrange()
  
end

Set_Peak_Display_to_36dB ()
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
Thonex is offline   Reply With Quote
Old 03-06-2020, 04:47 PM   #2
shady
Human being with feelings
 
Join Date: Jun 2017
Posts: 110
Default

Thanks
__________________
twitch.tv/suprshady trying to stream REAPER stuff.. more than twice a year
shady is offline   Reply With Quote
Old 03-09-2020, 04:57 AM   #3
anomar
Human being with feelings
 
anomar's Avatar
 
Join Date: Jan 2019
Location: Brazil
Posts: 115
Default

Thanks !
anomar is online now   Reply With Quote
Old 03-09-2020, 10:13 AM   #4
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,721
Default

You're welcome!
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
Thonex is offline   Reply With Quote
Old 04-29-2020, 01:31 AM   #5
80icio
Human being with feelings
 
Join Date: Mar 2016
Location: Italy
Posts: 332
Default

My actual first Lua scripts,
I'm no genius, but quarantine took me here.

I started from the script i've found on this thread
thank you Thonex!
The Script might be useful for those people like me that comes from PT.
These two scripts can add or subtract db's to the Peak display scale.
I set em up with 3db steps, but you can change it however you want.

Code:
function Add_Peak_Display ()

  Gain = 3 -- db You can put your own value here (Not more than 36db)
  GetGain = reaper.SNM_GetDoubleConfigVar('projpeaksgain', 0) --Get displayed gain
  Gain_Db_log = math.exp( Gain * 0.115129254 ) -- Translate Gain var to Log Scale thanx Xraym blog
  Max_Db_Display = math.exp( (36 - Gain) * 0.115129254 )
    if(GetGain > Max_Db_Display) -- new gain can't be more then 36db
    then
    NEWgain = 63.095732972255 -- Log scale number for 36db
    else
    NEWgain = GetGain * Gain_Db_log --Add gain
    end
  dB =  reaper.SNM_SetDoubleConfigVar('projpeaksgain', NEWgain)
  reaper.UpdateArrange()
--reaper.ShowConsoleMsg(NEWgain.."\n") -- Use it to check log scale

end

Add_Peak_Display ()
Code:
function Subtract_Peak_Display ()

  Gain = 3 -- db You can put your own value here (Not more than 36db)
  GetGain = reaper.SNM_GetDoubleConfigVar('projpeaksgain', 0) --Get displayed gain
  Gain_Db_log = math.exp( Gain * 0.115129254 ) -- Translate Gain var to Log Scale thanx Xraym blog
    if(GetGain < Gain_Db_log) -- new gain can't be less then 0db
    then
    NEWgain = 1 --0db log
    else
    NEWgain = GetGain / Gain_Db_log -- subtract desired gain
    end
  dB =  reaper.SNM_SetDoubleConfigVar('projpeaksgain', NEWgain)
  reaper.UpdateArrange()
--reaper.ShowConsoleMsg(NEWgain.."\n") -- Use it to check log scale

end

Subtract_Peak_Display ()
They are pretty simple scripts but i feel like i just hacked a bank account LOL


the reset function you see on the gif is exactly the one that Thonex posted in this thread
80icio 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 07:42 AM.


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