|
|
|
02-22-2019, 02:24 AM
|
#1
|
Human being with feelings
Join Date: Apr 2010
Posts: 45
|
LUA script, VCA slave setup
Hello there,
I'm setting up some LUA scripts to automate some stuff which I need to do by hand every time, and it's somewhat annoying and time consuming.
So, I've setup these scripts, which pretty much handle the stuff I want to, except that I can not get the VCA slave grouping to work.
I would like to automatically add a track as a slave to a specific group. So let's say I have the Group 1 setup, with a track as master, then I would like to link a newly created track as a slave.
I have been reading the documentation here over and over, but I can not make sense of it.
https://www.reaper.fm/sdk/reascript/...roupMembership
My code is available here: https://github.com/marcvanduivenvoor...kDecorator.lua
It's the method on line 61 to 64
Thanx a bunch.
|
|
|
02-23-2019, 06:43 PM
|
#2
|
Human being with feelings
Join Date: Jun 2012
Posts: 2,173
|
Not aware of any good real example scripts using this function.
It uses the 32 bits of a 32-bit integer as toggles or booleans, I guess you could say. It looks like you have to, at least, provide setmask with an integer that has the bit set that you want to set in setvalue, if you want to "set". If you provided an integer with other additional bits set for setmask, then provided setvalue an integer without those bits set, they would get unset (wiped out in grouping matrix). I don't know the proper geek language to use to describe that. lol. Maybe you already know some of that stuff. If not, google bitwise or bitmask. So basically you can set/unset VCA slave status for the track in question in all of the first 32 groups with one call.
Or, keep it limited to one group (bit) that you are concerned with. This seems to work, on the first track in the project. You could change grp_num to another up to 32. If you want 33-64, you have to use the GetSetTrackGroupMembershipHigh function.
Code:
trk = reaper.GetTrack(0,0)
grp_num = 1
setvalue = 1 << (grp_num-1)
setmask = setvalue
reaper.GetSetTrackGroupMembership(trk, "VOLUME_VCA_SLAVE", setmask, setvalue)
|
|
|
02-26-2019, 03:35 AM
|
#3
|
Human being with feelings
Join Date: Apr 2010
Posts: 45
|
Hmmm, thnx, but that doesn't really make it more clear
I got it running for group 1, but how would it work for groups 2 and up? Use the setmask for that?
So an integer of 2 on the setmask should access group 2? It's kind of fuzzy to me.
|
|
|
02-26-2019, 07:44 AM
|
#4
|
Human being with feelings
Join Date: Jun 2012
Posts: 2,173
|
All you should have to change in the code snippet I posted previously is grp_num value.
for example:
grp_num = 1
to, say,
grp_num = 13
it should turn on first track in project's VCA slave status for group 13 without altering any other groups already set.
setvalue = 1 << (grp_num-1)
performs a bit shift on the 32 bit int for 1, which only has a nonzero bit (1) in the one position. It slides that 1 over (grp_num-1) bits to the left, which in the case of group #1, is (1-1) bits, or no change. If you use grp_num = 2 to 32, it will actually shift the 1 bit over x places. All bits in a number would move. Zeroes pad new spaces.
Code:
--this is not real code, just using code box for illustrative purposes:
1 =
00000000 00000000 00000000 00000001
1 << 0
00000000 00000000 00000000 00000001
1 << (13-1) =
00000000 00000000 00010000 00000000
It appears that a comparison is run on those 0s and 1s between setmask and setvalue
Code:
00000000 00000000 00010000 00000000 --setmask
00000000 00000000 00010000 00000000 --setvalue
A more complicated script might get into doing multiple groups.
You could have, say,
setmask = 4294967275 (0xffffffff in hex)
and that would set group 13 and unset all other groups
Code:
11111111 11111111 11111111 11111111 --setmask
00000000 00000000 00010000 00000000 --setvalue
Last edited by FnA; 02-26-2019 at 07:52 AM.
|
|
|
02-26-2019, 08:22 AM
|
#5
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
I actually found the solution to access the groups above 32 in a script from SeXan. I'll check my computer in a few and post it.
|
|
|
02-26-2019, 10:01 AM
|
#6
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
Oh geez, I just tried to understand my code, but I can't get my head around it.
But what it basically does:
I have this folder structure in my project:
STRINGS FOLDER
-- Strings VCA
-- 1st VIOLINS FOLDER
---- 1st Violins VCA
---- 1st Violins Instrument
The VCA is always the first item below the parent folder.
When I execute the script on "1st Violins Instrument", the script will get the next parent folder (1st VIOLINS FOLDER) and go to track 1st VIOLINS FOLDER + 1 (= 1st Violins VCA). Then it will set VCA slave to that track. Next, the script will check, if there's another parent folder (which is the case = STRINGS FOLDER) and the same procedure is applied: the 1st Violins Instrument will now also be VCA slave to the Strings VCA. There are no more parent folders now, the script stops.
Code:
tracks_amount = reaper.CountSelectedTracks(0)
reaper.Undo_BeginBlock2(0)
for t=0, tracks_amount-1 do
selected_track = reaper.GetSelectedTrack(0, t)
source_track = selected_track
while reaper.GetParentTrack(source_track) ~= nil do
parent_track = reaper.GetParentTrack(source_track) -- get parent foldertrack, because we know foldertrack + 1 = VCA
source_track = parent_track -- save current parent track as new source
parent_track_number = reaper.GetMediaTrackInfo_Value(parent_track, 'IP_TRACKNUMBER')
vca_track = reaper.GetTrack(0, parent_track_number) -- track numbers start with 0, therefore parent_track_number is already the VCA
-- if value == 0, then "High" needs to be used
if reaper.GetSetTrackGroupMembership(vca_track, 'VOLUME_VCA_MASTER', 0, 0) > 0 then
number = reaper.GetSetTrackGroupMembership(vca_track, 'VOLUME_VCA_MASTER', 0, 0)
reaper.GetSetTrackGroupMembership(selected_track, 'VOLUME_VCA_SLAVE', number, number)
else
number = reaper.GetSetTrackGroupMembershipHigh(vca_track, 'VOLUME_VCA_MASTER', 0, 0)
reaper.GetSetTrackGroupMembershipHigh(selected_track, 'VOLUME_VCA_SLAVE', number, number)
end
end
end
reaper.Undo_EndBlock2(0, "Assign track to all parent VCAs", -1)
|
|
|
02-26-2019, 11:46 AM
|
#7
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,599
|
Easy way to set any group:
-1 must be since :
group 1 = 2^0 (which is 1)
group 2 = 2^1 (which is 2)
and so on....
There are two APIs one for groups < 32 and one for groups > 32 (membershiphigh)
Hope I help someone if I understood the problem,but probably I didn't
You are working with folders (new track is a child)?
If you could explain your workflow maybe I can help you
quick example
Code:
reaper.GetSetTrackGroupMembership(currentTrack, "VOLUME_VCA_SLAVE", 1, 1) -- group 1
reaper.GetSetTrackGroupMembership(currentTrack, "VOLUME_VCA_SLAVE", 2, 2) -- group 2
reaper.GetSetTrackGroupMembership(currentTrack, "VOLUME_VCA_SLAVE", 3, 3) -- group 3
etc
in my vca script this is how I set masters and slaves
Code:
-- SET TRACK AS VCA MASTER
local VCA_M = group(tr,"VOLUME_VCA_MASTER", free_group,free_group)
if mute_solo == 1 then
local VCA_M_MUTE = group(tr,"MUTE_MASTER", free_group,free_group)
local VCA_M_SOLO = group(tr,"SOLO_MASTER", free_group,free_group)
end
-- SET VCA SLAVES
for i = 1, #tracks do
local tr = tracks[i]
local VCA_S = group(tr,"VOLUME_VCA_SLAVE", free_group,free_group)
if mute_solo == 1 then
local VCA_S_MUTE = group(tr,"MUTE_SLAVE", free_group,free_group)
local VCA_S_SOLO = group(tr,"SOLO_SLAVE", free_group,free_group)
end
end
end
free group is calculated in other function where I scan which group is unassigned, but anyway it spits out 1,2,3,4,64,45 whatever
Also I shortcoded the API so I do not need to write high low or anything, when group is > 32 then it automatically sets proper api
Code:
if i > 32 then
group = reaper.GetSetTrackGroupMembershipHigh -- SET API FOR GROUPS > 32
free_group = 2^((i-32)-1)
else
group = reaper.GetSetTrackGroupMembership -- SET API FOR GROUPS < 32
free_group = 2^(i-1)
end
In your case that would be
Code:
local api
function set_api(group)
if group > 32 then
api = reaper.GetSetTrackGroupMembershipHigh
else
api = reaper.GetSetTrackGroupMembership
end
end
function trackDecorator.addToVcaGroup(currentTrack, group)
set_api(group)
api(currentTrack, "VOLUME_VCA_SLAVE", group, group)
end
Last edited by Sexan; 02-26-2019 at 12:16 PM.
|
|
|
02-27-2019, 07:06 AM
|
#8
|
Human being with feelings
Join Date: Apr 2010
Posts: 45
|
Ahaaaaa .. got it working. Thanks all.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 04:46 AM.
|