|
|
|
06-29-2018, 05:18 AM
|
#1
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 811
|
API for Automatic record-arm when selected
Hi!
I am beginner reascripter searching for API for GET/SET tracks
"Automatic record-arm when selected"-function but cant find it.
Is there none??
|
|
|
06-29-2018, 06:08 AM
|
#2
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
It exists in the API for extensions, but isn't exposed for scripts to use.
However, you can work with the track chunk directly:
Code:
local function Msg(str)
reaper.ShowConsoleMsg(tostring(str) .. "\n")
end
-- Accepts a multiline string and splits each line into a separate table value
-- Returns the table
local function split_by_line(str)
local t = {}
for line in string.gmatch(str, "[^\r\n]+") do
t[#t+1] = line
end
return t
end
-- Accepts an indexed table and a string
-- Returns the first index whose value contains the string
local function find_in_table(t, str)
for i = 1, #t do
if string.match(t[i], str) then return i end
end
return nil
end
local function Main()
-- Get a MediaTrack somehow
local track = reaper.GetSelectedTrack(0, 0)
if not track then return end
-- Get the chunk
local ret, chunk = reaper.GetTrackStateChunk(track, "", false)
if not ret then return end
--[[ The chunk is a string that looks like this:
<TRACK {BF616BDB-CEAD-4D9C-9310-C650B8A0666A}
NAME ""
PEAKCOL 16576
BEAT -1
AUTOMODE 0
VOLPAN 1 0 -1 -1 1
MUTESOLO 0 0 0
IPHASE 0
ISBUS 0 0
BUSCOMP 0 0
SHOWINMIX 1 0.6667 0.5 1 0.5 0 0 0
FREEMODE 0
SEL 0
REC 0 3 0 0 0 0 0
AUTO_RECARM 1
VU 2
TRACKHEIGHT 0 0 0
INQ 0 0 0 0.5 100 0 0 100
NCHAN 2
FX 1
TRACKID {BF616BDB-CEAD-4D9C-9310-C650B8A0666A}
PERF 0
MIDIOUT -1
MAINSEND 1 0
>
]]--
-- Convert it to a table to make our lives easier
chunk = split_by_line(chunk)
local idx = find_in_table(chunk, "AUTO_RECARM")
-- Boolean of the Auto Rec-Arm state
local state = ( idx and chunk[idx] == "AUTO_RECARM 1" )
-- Things you can do with it now:
-- Force it to be on
--[[
if idx then
chunk[idx] = "AUTO_RECARM 1"
else
table.insert(chunk, #chunk, "AUTO_RECARM 1")
end
]]--
-- Force it to be off (just remove the entry)
--if idx then table.remove(chunk, idx) end
-- Toggle it
state = not state
if state then
if idx then
chunk[idx] = "AUTO_RECARM 1"
else
table.insert(chunk, #chunk, "AUTO_RECARM 1")
end
else
if idx then table.remove(chunk, idx) end
end
-- We have to use table.insert to avoid overwriting the chunk's final >, or writing
-- something after it
-- Write the new chunk
-- Change the 'true' to 'false' if you're doing this multiple times and only want
-- a single undo point for the whole process
chunk = table.concat(chunk, "\n")
reaper.SetTrackStateChunk( track, chunk, true)
local ret, new = reaper.GetTrackStateChunk(track, "", false)
-- Reaper sometimes doesn't realize it needs to update things when we fiddle with stuff
reaper.UpdateTimeline()
end
Main()
|
|
|
06-29-2018, 06:46 AM
|
#3
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 811
|
Uhuuuu!
Oh I need to be more clear in my head and read this thru a couple of times!
I think I understand it but need to test it - I'll be back.
Thanks Lokasenna!
|
|
|
06-29-2018, 09:21 AM
|
#4
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
Quote:
Originally Posted by Lokasenna
It exists in the API for extensions, but isn't exposed for scripts to use.
|
Which function is this ?
(I may have a look exporting it to ReaScript via SWS)
|
|
|
06-30-2018, 02:51 AM
|
#6
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by Lokasenna
|
That appears to be a callback Reaper makes into a control surface plugin, not a call an extension code itself can make.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
06-06-2019, 07:03 PM
|
#7
|
Human being with feelings
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,618
|
Thread necro. Just wanted to chime in to say I'm looking for this too. It seems to be missing from the API.
|
|
|
06-07-2019, 06:48 AM
|
#8
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
You could do chunking, "AUTO_RECARM 1" is added to track state chunk if track is set to automatic record arm.
But proper API is always preferred of course.
edit:
Missed that Lokasenna already mentioned it.
|
|
|
06-07-2019, 06:52 AM
|
#9
|
Human being with feelings
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,618
|
The problem there is I need to get and set this value over a large project (~100 tracks) and when you're doing a full get/set track state chunk on that many tracks it's sslllooowwwww.
|
|
|
06-07-2019, 07:36 AM
|
#10
|
Human being with feelings
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
|
Quote:
Originally Posted by tack
The problem there is I need to get and set this value over a large project (~100 tracks) and when you're doing a full get/set track state chunk on that many tracks it's sslllooowwwww.
|
Open RPP in any text editor and replace all strings at once.
|
|
|
06-07-2019, 07:45 AM
|
#11
|
Human being with feelings
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,618
|
Quote:
Originally Posted by mpl
Open RPP in any text editor and replace all strings at once.
|
I can have my often-used action first popup a message with instructions, and then spawn notepad to have the user search/and replace manually. Genius!
|
|
|
06-08-2019, 06:43 AM
|
#13
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Quote:
Originally Posted by mespotine
|
Worth noting that these functions wrap the state chunk stuff, so while they're easier to use it would still have performance issues on large projects.
|
|
|
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 02:02 PM.
|