Old 11-19-2016, 03:23 PM   #1
AkeW
Human being with feelings
 
Join Date: Dec 2008
Posts: 39
Default Set (not toggle) record arm via midi

Trying to control Reaper from my Korg Nanokontrol. Muting a track works fine and synchs with the led on the nanokontrol by mapping to 'set mute on track...' action.

But there is no corresponding action for 'set record arm', only toggle..? Then the button led and record state can diverge.

SWS has a 'set record arm', but that only enables, never disables record arming.

Any workarounds?
AkeW is offline   Reply With Quote
Old 11-20-2016, 12:02 AM   #2
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,784
Default

A workaround (if really necessary) could be, to do a small batch/script that first enables and then toggles.

-Michael
mschnell is offline   Reply With Quote
Old 11-20-2016, 12:18 AM   #3
AkeW
Human being with feelings
 
Join Date: Dec 2008
Posts: 39
Default

Not sure I follow... Won't that always disable record arm?

The point is to get the led button matching the state in Reaper. And the nanokontrol sends 7f when the led is lit, and 00 when it is turned off.
AkeW is offline   Reply With Quote
Old 11-20-2016, 12:20 AM   #4
AkeW
Human being with feelings
 
Join Date: Dec 2008
Posts: 39
Default

Seems that you can make custom actions with 'if' statements. This will probably work (but is a bit cumbersome).
AkeW is offline   Reply With Quote
Old 11-20-2016, 04:10 AM   #5
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,942
Default

You want to record-arm selected tracks or have individual actions for record-arming their "own" tracks, AkeW?

This works:

Code:
-- PL9-switch record arm state on track01.lua

track_num =1    -- 01 to 99
rec_onoff = 1    -- 1 for arm, 0 for unarm
rec_toggle_comm_id = 8*track_num +17    -- calculate CommandID num for track
toggle_state = reaper.GetToggleCommandStateEx(0, rec_toggle_comm_id)    -- get toggle state for track
if toggle_state ~= rec_onoff then reaper.Main_OnCommandEx(rec_toggle_comm_id, 0, 0) end    -- if toggle_state isn't desired rec_onoff state, toggle
-- reaper.Main_OnCommandEx(integer command, integer flag, ReaProject proj)

Just set the "track_num" variable to the track you want to arm and save the script as "PL9-switch record arm state on tracknn.lua"

The above script is for track 1. You can have an action for individul tracks from 1 to 99 with this.

If you want to make the action unarm, then set rec_onoff = 0 and save accordingly with a clear unarm filename inc track number.

I've just tested tracks 1 to 5 with the above and it works well -you could assign the scripts to your controller MIDI numbers and I think you'd be sorted. Shout back if there's anything you need clarifying...




>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 11-20-2016, 05:01 PM   #6
MikComposer
Human being with feelings
 
MikComposer's Avatar
 
Join Date: May 2012
Location: Brighton
Posts: 1,989
Default

What you can do, is too:

Edit main toolbar, add action to toggle record arm to selected track, and then use midi input for it. With toggle you can turn it on and off.
__________________
My Royalty Free Music library

Last edited by MikComposer; 11-20-2016 at 06:52 PM.
MikComposer is offline   Reply With Quote
Old 11-21-2016, 01:40 AM   #7
AkeW
Human being with feelings
 
Join Date: Dec 2008
Posts: 39
Default

planetnine - Thanks, this could work together with the if-actions. What I want is actions to arm/unarm specific tracks.

But is it possible to read a midi cc value in the script so it can set rec_onoff based on if the midi value is 0 or 127?
Like the "set mute for track x (midi only)" standard action in Reaper.

MikComposer: A toggle action won't work since the led on my controller can get out of synch with the actual state if i toggle by mouse click first, and then via the controller.
AkeW is offline   Reply With Quote
Old 11-21-2016, 02:05 AM   #8
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,942
Default

AkeW, this is a script action to arm specific tracks.

You make a copy of this for each track and just config each one with the user-settings I posted above. You can arm specific tracks with specific MIDI events then -I presumed this was for use with a controller.

If you want a single script to run and lurk, scanning for specific MIDI events and arming/unarming them, it can be done. I thought you'd probably only need 8 or 16 of these for your controller



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 11-21-2016, 01:35 PM   #9
AkeW
Human being with feelings
 
Join Date: Dec 2008
Posts: 39
Default

planetnine - Modified your script to read rec_onoff from midi value. It works great Thanks!

Code:
track_num = 1    -- 01 to 99

is_new,name,sec,cmd,rel,res,val = reaper.get_action_context()
if val > 62 then 
  rec_onoff = 1
else
  rec_onoff = 0
end

rec_toggle_comm_id = 8*track_num +17    -- calculate CommandID num for track
toggle_state = reaper.GetToggleCommandStateEx(0, rec_toggle_comm_id)    -- get toggle state for track
if toggle_state ~= rec_onoff then reaper.Main_OnCommandEx(rec_toggle_comm_id, 0, 0) end    -- if toggle_state isn't desired rec_onoff state, toggle
AkeW is offline   Reply With Quote
Old 11-21-2016, 01:40 PM   #10
AkeW
Human being with feelings
 
Join Date: Dec 2008
Posts: 39
Default

And I only had the energy to make versions for the first 9 tracks ;D
AkeW is offline   Reply With Quote
Old 08-09-2017, 03:01 AM   #11
manneokoko
Human being with feelings
 
Join Date: Aug 2017
Posts: 47
Default

Hello,
I need to do the exact same thing as thread author. I am a bit new to reaper so if somebody can help me step by step how to use the code as posted by AkeW would be very helpful.

I have copied the code from AkeW above and made a new reascript from the action list window in reaper. Then I tried to bind it to a regular midi CC. All fine so far, but then nothing happens when I send the cc from my controller.
Help please
manneokoko is offline   Reply With Quote
Old 05-19-2018, 07:36 AM   #12
Alain78
Human being with feelings
 
Join Date: Mar 2018
Posts: 19
Default Problem with Main_OnCommandEx

Hello,
I try to do the same... BUT this command doesn't do anything !
the only line of my LUA script :
reaper.Main_OnCommandEx(25, 0, 0)
ID #25 : Toggle record arm for track O1
The same with 22 for mute
The ID to close the project works fine.
Any idea ?
Alain
Alain78 is offline   Reply With Quote
Old 05-19-2018, 09:12 AM   #13
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,857
Default

Quote:
Originally Posted by Alain78 View Post
Hello,
I try to do the same... BUT this command doesn't do anything !
the only line of my LUA script :
reaper.Main_OnCommandEx(25, 0, 0)
ID #25 : Toggle record arm for track O1
The same with 22 for mute
The ID to close the project works fine.
Any idea ?
Alain
Continued in this thread : https://forum.cockos.com/showthread.php?t=206902
solger 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:10 PM.


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