Old 10-11-2019, 04:04 PM   #1
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,227
Default set pre-roll on/set pre-roll off

searched actions and reapack and, while i do find an action to toggle the pre-roll, i don't find an action(s) to set a specific state, such as on or off. anyone know if this exists?

i ask because i was just testing the avid media composer key command emulation scripts and find that they are a little funny if pre-roll is on. thought i'd try making a custom action that would set the pre-roll to off when starting the avid keys script but then couldn't find an action to set the pre-roll to 'off'.

thanks,
babag
babag is offline   Reply With Quote
Old 10-11-2019, 06:10 PM   #2
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Metronome Settings
REAPER.ini

1 Pre-roll before playback
2 Pre-roll before recording
preroll=11

1 Pre-roll before playback

preroll=9


2 Pre-roll before recording
preroll=10

something like this:
Code:
inipath = reaper.get_ini_file() 

retval, prerol_state = reaper.BR_Win32_GetPrivateProfileString("reaper", "preroll", "", inipath)
use reaper.BR_Win32_WritePrivateProfileString( "reaper", "preroll", value, inipath) to set it
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak

Last edited by MusoBob; 10-11-2019 at 06:16 PM.
MusoBob is offline   Reply With Quote
Old 10-11-2019, 06:22 PM   #3
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

This can also be done by checking the state of the action and running it if necessary:

Code:
function setActionEnabled(action, state)
  if reaper.GetToggleCommandState(action) == 1 ~= state then
    reaper.Main_OnCommand(action, 0)
  end
end

-- Set "Pre-roll: Toggle pre-roll on play" to ON
setActionEnabled(41818, true)

-- Set "Pre-roll: Toggle pre-roll on record" to OFF
setActionEnabled(41819, false)
Quote:
Originally Posted by MusoBob View Post
Metronome Settings
REAPER.ini
The .ini file may or may not be read/written immediately. Many REAPER settings that don't have a dedicated API can be set directly using the configvar API:

Code:
oldValue = reaper.SNM_GetIntConfigVar('preroll', 0)
reaper.SNM_SetIntConfigVar('preroll', newValue)
The preroll configvar is a bitfield. Its known values have been documented here by mespotine: https://mespotin.uber.space/Mespotin...s.html#preroll.

Last edited by cfillion; 10-11-2019 at 06:35 PM.
cfillion is offline   Reply With Quote
Old 10-11-2019, 09:10 PM   #4
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,227
Default

wow. thanks for all of the suggestions. i think i follow the edgemeal approach a little better but am trying to grasp the cfillion.

not having much idea about how to do these things, here are the things i did with the cfillion approach for review. they do seem to do what i want, to toggle the playback pre-roll in the appropriate circumstance.

toggle_pre-roll_if_disabled
Code:
function setActionEnabled(action, state)
  if reaper.GetToggleCommandState(41818) == 0 ~= state then
    reaper.Main_OnCommand(41818, 0)
  end
end

-- Set "Pre-roll: Toggle pre-roll on play" to ON
setActionEnabled(41818, true)

-- Set "Pre-roll: Toggle pre-roll on record" to OFF
setActionEnabled(41819, false)
toggle_pre-roll_if_enabled
Code:
function setActionEnabled(action, state)
  if reaper.GetToggleCommandState(41818) == 1 ~= state then
    reaper.Main_OnCommand(41818, 0)
  end
end

-- Set "Pre-roll: Toggle pre-roll on play" to ON
setActionEnabled(41818, true)

-- Set "Pre-roll: Toggle pre-roll on record" to OFF
setActionEnabled(41819, false)
actually, as i look at it, it looks like all i did was to set one script to a state of 1 and the other to 0 and insert the id's.

thanks again,
babag

Last edited by babag; 10-11-2019 at 09:27 PM.
babag is offline   Reply With Quote
Old 10-11-2019, 09:44 PM   #5
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Quote:
Originally Posted by cfillion View Post
The .ini file may or may not be read/written immediately. Many REAPER settings that don't have a dedicated API can be set directly using the configvar API:

Code:
oldValue = reaper.SNM_GetIntConfigVar('preroll', 0)
reaper.SNM_SetIntConfigVar('preroll', newValue)
The preroll configvar is a bitfield. Its known values have been documented here by mespotine: https://mespotin.uber.space/Mespotin...s.html#preroll.
I'm gonna have to hang that up on the wall.
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 10-11-2019, 10:23 PM   #6
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by babag View Post
not having much idea about how to do these things, here are the things i did with the cfillion approach for review. they do seem to do what i want, to toggle the playback pre-roll in the appropriate circumstance.
The contents of the setActionEnabled function should be left as I originally posted. The other lines are usage examples:

toggle_pre-roll_if_disabled.lua would do setActionEnabled(41818, true) and toggle_pre-roll_if_enabled.lua would do setActionEnabled(41818, false). The first parameter is the action ID and the second parameter is whether that action should be enabled (true) or disabled (false) by the function.

Last edited by cfillion; 10-11-2019 at 10:46 PM.
cfillion is offline   Reply With Quote
Old 10-12-2019, 09:56 AM   #7
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,227
Default

ok. i might be getting this a little better. changed per cfillion advice and added comments for myself.

since i'm using these for the play pre-roll, in all cases, the record lines are commented.

toggle_pre-roll_if_disabled:
Code:
function setActionEnabled(action, state)
  if reaper.GetToggleCommandState(action) == 1 ~= state then
    reaper.Main_OnCommand(action, 0)
  end
end

-- Set "Pre-roll: Toggle pre-roll on play"
-- uncomment 'true'  line to turn ON  pre-roll if it's currently OFF
-- uncomment 'false' line to turn OFF pre-roll if it's currently ON
setActionEnabled(41818, true)
--setActionEnabled(41818, false)

-- Set "Pre-roll: Toggle pre-roll on record" to OFF
-- uncomment 'true'  line to turn ON  pre-roll if it's currently OFF
-- uncomment 'false' line to turn OFF pre-roll if it's currently ON
--setActionEnabled(41819, true)
--setActionEnabled(41819, false)
toggle_pre-roll_if_enabled:
Code:
function setActionEnabled(action, state)
  if reaper.GetToggleCommandState(action) == 1 ~= state then
    reaper.Main_OnCommand(action, 0)
  end
end

-- Set "Pre-roll: Toggle pre-roll on play"
-- uncomment 'true'  line to turn ON  pre-roll if it's currently OFF
-- uncomment 'false' line to turn OFF pre-roll if it's currently ON
--setActionEnabled(41818, true)
setActionEnabled(41818, false)

-- Set "Pre-roll: Toggle pre-roll on record" to OFF
-- uncomment 'true'  line to turn ON  pre-roll if it's currently OFF
-- uncomment 'false' line to turn OFF pre-roll if it's currently ON
--setActionEnabled(41819, true)
--setActionEnabled(41819, false)
do i have things right now? do my comments seem right?

thanks again,
babag

Last edited by babag; 10-12-2019 at 10:01 AM.
babag 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 08:22 AM.


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