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

Reply
 
Thread Tools Display Modes
Old 12-05-2021, 10:03 AM   #1
Gaett
Human being with feelings
 
Join Date: Jun 2021
Posts: 27
Default Script to get value of a fader track and apply it on item volume take (on track)

Hi Reapers,
I please need your help in reaper scripting (.lua).
I would like to apply/copy the fader's dB value (of a selected track) on the item volume (active item?) which is on that track. And then, reset the fader at 0 (unity).
If possible, if many tracks are selected, apply that action on each item on respective tracks and reset all faders at 0.
I have a good starting point, thanks to TeddyTheToad. https://forum.cockos.com/showthread.php?t=181565 but here this is something a bit different.

May I have your help please ? Here is a piece of the code that works with obe selected track and one (any) selected take only :

n = 0 -- loop var init
fx = "volume" -- fx name to target. change if you want it to taget a different fx
while(reaper.GetSelectedTrack(0,n) ~= nil) do --loop runs untill no more selected tracks
selTrack = reaper.GetSelectedTrack(0,n) -- gets the number of a track
volume = reaper.GetMediaTrackInfo_Value(selTrack,"D_VOL") -- gets fader level
item = reaper.GetSelectedMediaItem(0,0)
take = reaper.GetActiveTake(item)
reaper.SetMediaItemTakeInfo_Value(take,"D_VOL",vol ume)

--
--
reaper.SetMediaTrackInfo_Value(selTrack, "D_VOL", 1.00) --resets fader val to 0db
n = n+1 -- move to next selected track
end

Thanks in advance,
Gaetan
Attached Images
File Type: png pics ex.PNG (61.0 KB, 55 views)

Last edited by Gaett; 12-05-2021 at 11:36 AM.
Gaett is offline   Reply With Quote
Old 12-05-2021, 12:36 PM   #2
ErBird
Human being with feelings
 
Join Date: Jan 2017
Location: Los Angeles
Posts: 1,161
Default

Quote:
Originally Posted by Gaett View Post
I would like to apply/copy the fader's dB value (of a selected track) on the item volume (active item?) which is on that track.
The question mark is throwing me off. You do want the volume transfer to apply only to active/selected items or to every item on the track? Please clarify.
ErBird is offline   Reply With Quote
Old 12-05-2021, 01:36 PM   #3
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 7,432
Default

Quote:
Originally Posted by Gaett View Post

Code:
n = 0 -- loop var init
fx = "volume" -- fx name to target. change if you want it to taget a different fx
while(reaper.GetSelectedTrack(0,n) ~= nil) do --loop runs untill no more selected tracks
  selTrack = reaper.GetSelectedTrack(0,n) -- gets the number of a track
  volume = reaper.GetMediaTrackInfo_Value(selTrack,"D_VOL") -- gets fader level
  item = reaper.GetSelectedMediaItem(0,0)
  take = reaper.GetActiveTake(item)
  reaper.SetMediaItemTakeInfo_Value(take,"D_VOL",volume)

--
--
  reaper.SetMediaTrackInfo_Value(selTrack, "D_VOL", 1.00) --resets fader val to 0db
  n = n+1 -- move to next selected track
end
Are you saying that only a single item is handled? Here:
Code:
item = reaper.GetSelectedMediaItem(0,0)
it seems you select the same media item again and again, and then assign and re-assign the track fader value of the successive selected tracks. Note that selecting a track (on the TCP) does not necessarily select that track's media items.

I think you need to loop through the selected media items and for each select its parent track:
Code:
MediaTrack track = reaper.GetMediaItemTake_Track(MediaItem_Take take)
to get the track fader value to assign to the active take volume.
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
Fabian is offline   Reply With Quote
Old 12-05-2021, 01:42 PM   #4
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,900
Default

I have this script already :


X-Raym_Offset selected items volume by their track fader value.lua


just plug Reset track volume action after it.
X-Raym is offline   Reply With Quote
Old 12-05-2021, 02:02 PM   #5
Gaett
Human being with feelings
 
Join Date: Jun 2021
Posts: 27
Default

Quote:
Originally Posted by ErBird View Post
The question mark is throwing me off. You do want the volume transfer to apply only to active/selected items or to every item on the track? Please clarify.
To clarify,I have a take on each track. I want to transfer the volume fader's value on each respected item (item volume/gain knob).
ex :
Track 1 : fader -20dB / Item on that track : 0dB (item volume knob)
Track 2 : fader -12dB / Item on that track : 0dB (item volume knob)
...
Track n

to become :
Track 1 : fader 0dB / Item on that track : -20dB (item volume knob)
Track 2 : fader 0dB / Item on that track : -12dB (item volume knob)
Gaett is offline   Reply With Quote
Old 12-05-2021, 02:08 PM   #6
Gaett
Human being with feelings
 
Join Date: Jun 2021
Posts: 27
Default

Quote:
Originally Posted by X-Raym View Post
I have this script already :


X-Raym_Offset selected items volume by their track fader value.lua


just plug Reset track volume action after it.
Thanks ! Nice !!!
Gaett 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 06:31 AM.


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