Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Color Themes and Icon Sets

Reply
 
Thread Tools Display Modes
Old 02-09-2018, 04:24 AM   #1
pyerbass
Human being with feelings
 
Join Date: Jan 2009
Posts: 322
Default macro expert needed: scalar variable "nothing"

Hi

I have a question about scalar variables:

is there a variable like "if nothing special then..."
Why would you need that?

I am working on a system of macros to create a lot of layouts with a very few lines


as an example
If I want a mcp.io at h500 but when rec is armed, I want it at h600

- my macros are:

macro io_thing value
set mcp.io + [0 0 20 20] [0 value]
endmacro

macro io_thing_if condition value
set mcp.io condition + [0 0 20 20] [0 value]
endmacro

- And then in the layout I just write:

io_thing 500
io_thing_if ?recarm 600



If there was a variable like "if nothing special" I could do this with only one macro:

macro io_thing_if condition value
set mcp.io condition + [0 0 20 20] [0 value]
endmacro

and then in the layout:

macro io_thing_if "nothing" 500
macro io_thing_if ?recarm 600



... or maybe there is a beter way to do that.

many Thanks in advance for your input
Cheers
Pyer
pyerbass is offline   Reply With Quote
Old 02-09-2018, 11:42 PM   #2
cubic13
Human being with feelings
 
cubic13's Avatar
 
Join Date: Dec 2013
Location: Near Serre-Ponçon lake, french Alps
Posts: 855
Default

Hi, pyerbass

I'm not an "expert" by any mean but I have already used few of them, so... In your example, I would set also the control to be modified as a parameter and do the recarm test in the macro itself. So we would have :

Code:
macro y_recshift element x_pos y_pos w_pos h_pos value
set element + [x_pos y_pos w_pos h_pos] ?recarm [0 value] [0 0]
endmacro
And its call would be :

Code:
y_recshift mcp.io 0 500 20 20 100
But maybe I'm wrong, as I never had to use a test on a condition such as the ?recarm one in a macro, until now...
__________________
DAW: Ryzen 3700X|Asus X-470Pro|32Gb|2 SSD512(M2)+1024|W10Pro(64)|RME Fireface UCX+ADA8200
Soft: Reaper|Cubase 10|Emulator X3 & several other VSTis (2 bridged)...
Gear: VMK-188+|MPD32|ME30P|Korg 05R/W|Roland D110|Yamaha TX802|Pre-MIDI stuff...

Last edited by cubic13; 02-10-2018 at 12:02 AM.
cubic13 is offline   Reply With Quote
Old 02-10-2018, 05:20 AM   #3
pyerbass
Human being with feelings
 
Join Date: Jan 2009
Posts: 322
Default

Hi Cubic,

Thanks for your answer!

Sorry I wasn't very clear on my goals.

I would like to structure my rxconfig as follows:

- a big list of position values
- a big list of position variations
- a big list of macros to create groups of elements
- then all my layers using only macros, with no values at all

the goal is to be able to modify all layer at once, just by making changes in the value list


as an example: picture a mcp with group containing a mute and solo button on top of each other.
I want to have all layers with the same size, say 80 900:
- layer 1: mute solo group on top
- layer 2: mute solo group 100 px lower
- layer 3: mute solo group on top but when recarm: 100px lower
- layer 4: mute solo group on top but when recarm: 100px lower and when it's main folder: 200px lower


Then what I whrite is

; --- VALUES

def bg_size [80 900]
def solo_pos + [50 0 23 23]
def mute_pos + [50 40 23 23]


; --- VARIATIONS

def var_l 100
def var_xl 200


; ---MACROS

macro create_mcp
clear mcp.*
set mcp.size bg_size
end marco

macro group_ms val
set mcp.solo solo_pos [0 val]
set mcp.mute mute_pos [0 val]
end macro

macro group_ms_if cond val
set mcp.solo cond solo_pos [0 val]
set mcp.mute cond mute_pos [0 val]
end macro

; --- MCP LAYERS

Layout "1"
create_mcp
group_ms
endlayout

Layout "2"
create_mcp var_l
group_ms
endlayout

Layout "3"
create_mcp
group_ms
group_ms_if ?recarm var_l
endlayout

Layout "4"
create_mcp
group_ms
group_ms_if ?recarm var_l
group_ms_if folderstate>0 var_xl
endlayout



This way I have no values in my layouts, and I can change them all in a row by working on my value and variable list


The problem is that I still need 2 macros: one for static layout, one for interations "if" condition

If there was something like a "if nothing", then I would do everything with ne macro
pyerbass is offline   Reply With Quote
Old 02-10-2018, 07:33 AM   #4
pyerbass
Human being with feelings
 
Join Date: Jan 2009
Posts: 322
Default

I think I found my answer! the "nothing" variable would be "?1"

then I can do with a single macro
(in the example) I can do everything only the ms_group_if macro

for static layout

ms_group_if ?1

for interactive layout

ms_group_if ?1 0
ms_group_if ?recarm 100
pyerbass is offline   Reply With Quote
Old 02-10-2018, 09:05 AM   #5
cubic13
Human being with feelings
 
cubic13's Avatar
 
Join Date: Dec 2013
Location: Near Serre-Ponçon lake, french Alps
Posts: 855
Default

Quote:
Originally Posted by pyerbass View Post
I think I found my answer! the "nothing" variable would be "?1"

then I can do with a single macro
(in the example) I can do everything only the ms_group_if macro

for static layout

ms_group_if ?1

for interactive layout

ms_group_if ?1 0
ms_group_if ?recarm 100
Could be ; I never used such a statement. So, alternatively, the first thing I would avoid is to use any clear instruction for a layout, because it means that you will have to redefine each and every mcp control for the involved one. The second thing is that I would also get rid of the set mcp.size instruction, as it's seem that the same mcp size is shared by all the layouts that you intend to define. This said, and strictly following the way you have defined your layouts, I would set a unique macro which would be the following :

Code:
;flag_rf==0 : "normal" track
;flag_rf==1 : record armed track
;flag_rf==2 : folder track

macro y_shift m_x m_ym m_ys m_w m_h flag_rf
set mm_ym flag_rf==2 folderstate>0 + m_ym 200 m_ym flag_rf==1 ?recarm + m_ym 100 m_ym m_ym
set mm_ys flag_rf==2 folderstate>0 + m_ys 200 m_ys flag_rf==1 ?recarm + m_ys 100 m_ys m_ys
set mcp.mute [m_x mm_ym m_w m_h]
set mcp.solo [m_x mm_ys m_w m_h]
endmacro
And its call would be :

Code:
Layout "1"
y_shift 50 40 0 23 23 0
EndLayout
Code:
Layout "2"
y_shift 50 140 100 23 23 0
EndLayout
Code:
Layout "3"
y_shift 50 40 0 23 23 1
EndLayout
Code:
Layout "4"
y_shift 50 40 0 23 23 2
EndLayout
Not sure that it's what you were expecting. Just let me know...
__________________
DAW: Ryzen 3700X|Asus X-470Pro|32Gb|2 SSD512(M2)+1024|W10Pro(64)|RME Fireface UCX+ADA8200
Soft: Reaper|Cubase 10|Emulator X3 & several other VSTis (2 bridged)...
Gear: VMK-188+|MPD32|ME30P|Korg 05R/W|Roland D110|Yamaha TX802|Pre-MIDI stuff...

Last edited by cubic13; 02-10-2018 at 09:13 AM.
cubic13 is offline   Reply With Quote
Old 02-27-2018, 11:14 AM   #6
pyerbass
Human being with feelings
 
Join Date: Jan 2009
Posts: 322
Default

Hi Cubic,

Thanks for your answer, it took me that long to understand what you wrote! I'm definetly not a dev, just a graphic designer trying to code the best I can

I finally figured out how your macro works, (and how "set custom_line" does work duh!)

It doesn't really work for me as I want the same layout to react differently if a track is both recarmed and folder. I also need to have all my values in the same place so I can change every layers at once. I also need to work with groups of features

But your marco opened me a lot of possibilities and at the end, here is what I came up with:


A value list of default position ready to be added with something else:
Code:
 
def mcp_fxbyp + [8 293 21 21] 
def mcp_fx + [44 297 32 13]
a cool macro to make my fx module
Code:
macro mcp_mod_ins is0 dead0 recmov deadrecmov busmov deadbusmov
	
	set isrec + [is0] [recmov]
	set deadrec + [dead0] [deadrecmov]
	
	set isbus + [is0] [busmov]
	set deadbus + [dead0] [deadbusmov]

	set live 	?recarm isrec{x} folderstate>0 isbus{x} is0
	set dead 	?recarm deadrec{x} folderstate>0 deadbus{x} [dead0]

	set mcp.fxbyp 	h<dead{x} [0] mcp_fxbyp [0 live]
	set mcp.fx 		h<dead{x} [0] mcp_fx [0 live]
	endmacro
- is0: px you want to add to the default position

- dead0: the minimum tcp size where you want the module to disapear

- recmov: px you want to add to the new position when the track is ARMED

- deadrecmov: px you want to add to the the minimum mcp size where you want the module to -
disapear when the track is ARMED

- recmov: px you want to add to the new position when the track is FOLDER

- deadrecmov: px you want to add to the the minimum mcp size where you want the module to disapear when the track is FOLDER


Then I can write
Code:
mcp_mod_ins 100 694 61 51 -30 -20
- the module will be 100px lower than default value.
- it will disapear when mcp is shorter than 694
WHEN RECARMED
- the module will be 161px lower than defaulft value.
- it will disapear when mcp is shorter than 745

WHEN FOLDER
- the module will be 70px lower than defaulft value.
- it will disapear when mcp is shorter than 674



Or I can whrite
Code:
mcp_mod_ins 100 694
- the module will be 100px lower than defaulft value.
- it will disapear when mcp is shorter than 694

nothing will change when recarmed or folder
pyerbass is offline   Reply With Quote
Old 03-04-2018, 04:55 PM   #7
hopi
Human being with feelings
 
hopi's Avatar
 
Join Date: Oct 2008
Location: Right Hear
Posts: 15,618
Default

wow... you guys are SMART... I get the concept which is a kewl idea but it makes my brain hurt just to read your code...
__________________
...should be fixed for the next build... http://tinyurl.com/cr7o7yl
https://soundcloud.com/hopikiva
hopi is offline   Reply With Quote
Old 03-05-2018, 02:05 AM   #8
cubic13
Human being with feelings
 
cubic13's Avatar
 
Join Date: Dec 2013
Location: Near Serre-Ponçon lake, french Alps
Posts: 855
Default

@hopi

Sometimes it makes my brain hurt also...


@pyerbass

Sorry for the late answer...
So, is the macro in your last post working for you ? I have tested it with my Nitrogen theme and both the mcp.fx and mcp.fxbyp controls vanish, no matter the parameters used. Just in case, I have an alternate solution that seems to work with this theme : I have used just little shift values to see what was going on without too much visual problems. It's the following :

1) In the header of rtconfig.txt, I have, first, the initial coordinates of both controls :

Code:
def mcp_fx [26 22 33 18]
def mcp_fxbyp [59 22 14 18]
Then the following macro :

Code:
macro mcp_fxmod init_sh bus_sh bus_0 rec_sh rec_0
def init_posfx + + mcp_fx [0 init_sh 0 0]
def init_posfxbyp + + mcp_fxbyp [0 init_sh 0 0]
set mcp.fx folderstate>0 h<bus_0{x} [0] init_posfx [0 bus_sh] ?recarm h<rec_0{x} [0] init_posfx [0 rec_sh] init_posfx [0 0]
set mcp.fxbyp folderstate>0 h<bus_0{x} [0] init_posfxbyp [0 bus_sh] ?recarm h<rec_0{x} [0] init_posfxbyp [0 rec_sh] init_posfxbyp [0 0]
endmacro
- init_sh : initial shift of both controls (your is0)
- bus_sh : vertical shift of controls when the track is a bus (~ folder)
- bus_0 : vertical size under which the controls will disappear when the track is a bus (~ folder)
- rec_sh : vertical shift of controls when the track is record armed
- rec_0 : vertical size under which the controls will disappear when the track is record armed


2) The macro is called with something like this :
Code:
mcp_fxmod 5 3 300 6 350
...or something like this if you always want the controls to be reachable :
Code:
mcp_fxmod 5 3 0 6 0
...or something like this if you never want them reachable :
Code:
mcp_fxmod 5 3 2000 6 2000
...or, at last, something like this if no shift should happen :
Code:
mcp_fxmod 0 0 300 0 350

I guess it's more or less what you were looking for, but it has a limitation : the macro is build so as the folder state takes precedence over the recarm status, which means that a folder will always have the vertical shift defined for it, no matter how the latter is positioned.

HTWH...
__________________
DAW: Ryzen 3700X|Asus X-470Pro|32Gb|2 SSD512(M2)+1024|W10Pro(64)|RME Fireface UCX+ADA8200
Soft: Reaper|Cubase 10|Emulator X3 & several other VSTis (2 bridged)...
Gear: VMK-188+|MPD32|ME30P|Korg 05R/W|Roland D110|Yamaha TX802|Pre-MIDI stuff...

Last edited by cubic13; 03-05-2018 at 10:45 AM. Reason: typos and english grammar corrections... ;)
cubic13 is offline   Reply With Quote
Old 03-06-2018, 05:46 AM   #9
pyerbass
Human being with feelings
 
Join Date: Jan 2009
Posts: 322
Default

Hi Cubic

Thanks for your answer! the "+ +" trick of course! that will save me some lines! thanks
I think your macro misses something like "init_0", to define when the element should disapear when its on its normal state...

I made my macro evolving because in some case I will need to have modules appearing only in when the track is recarmed, but not in any other cases so I added a third condition.

I will come back here with the macro but I think I will try to mix it with what you wrote before
pyerbass is offline   Reply With Quote
Old 03-08-2018, 03:46 PM   #10
pyerbass
Human being with feelings
 
Join Date: Jan 2009
Posts: 322
Default

ok here we go

here is a practical example in my theme API beta v5.12

first, sorry about the esoteric custom variables names, but I spent a lot of time on this and I try to make it fun...


So, I have 4 modules, from top to bottom:

- rec module: with recarm and fx in
- rec extended module: with monitor options, recomde and input select
- rooting module: with send/recieve
- fx module: with fx and fx bp

When the track is normal, I want to have all the module displayed exepted the rec extended, witch i don't need in normal state

When the track is armed, I want the rec extended module to appear below the rec module, so the rooting and fx modules have to move down

When the track is a folder, I want every recording related modules to disapear, so the rooting and fx has to move up

When the track is both folder and recarm (whitch won't happen anyway) I want the priority to rec

I also want to have all values in the same place, so in the future, if I need to change the size of a button, I do it only once.

so first the values:
Code:
; REC

def mcp_recarm [8 209 21 21]
def mcp_fxin [44 220 32 13]

; REC EX

def mcp_recmode [8 237 21 21]
def mcp_recinput [4 261 73 20]  
def mcp_recmon [8 284 21 21]  

; ROOT
	
def mcp_io [8 258 21 21] 
	
; INS

def mcp_fxbyp [8 293 21 21] 
def mcp_fx [44 297 32 13]
Then the variables: some defined values to use to have thing going up or down
Code:
	def var_norec -21
	def var_recx 61

Then I can write marcos to call each module.
To have them react properly I will need 9 inputs for each marco:

IS: when the track is normal
- is_born: type 1 if I want the module to exist in this normal state, 0 if not
- is_life: px to add to the defaut y position in this normal state
- is_dead: minimum tcp size before the module die in this normal state

REC: when the track is recarmed
- rec_born: type 1 if I want the module to exist in this rec state, 0 if not
- rec_life: px to add to the IS y position in this rec state
- rec_dead: px to add to the IS minimum tcp size before the module die in this rec state

BUS: when the track is a folder,
- rec_born: type 1 if I want the module to exist in this bus state, 0 if not
- rec_life: px to add to the IS y position in this bus state
- rec_dead: px to add to the IS minimum tcp size before the module die in this bus state

So here is the first module marco:

Code:
macro mcp_mod_rec is_born is_life is_dead rec_born rec_life rec_dead bus_born bus_life bus_dead
	set tobe_rec + [is_life] [rec_life]
	set nottobe_rec + [is_dead] [rec_dead]

	set tobe_bus + [is_life] [bus_life]
	set nottobe_bus + [is_dead] [bus_dead]

	set life 		?recarm tobe_rec{x} folderstate>0 tobe_bus{x} is_life
	set dead 		?recarm nottobe_rec{x} folderstate>0 nottobe_bus{x} [is_dead]

	set existence 0
	set existence rec_born==1 recarm=1 1 
	set existence is_born==1 recarm=0 folderstate=0 1 
	set existence bus_born==1 recarm=0 folderstate!=0 1 	

	set mcp.recarm 		existence{x}==0 [0] h<dead{x} [0] + mcp_recarm [0 life]
	set mcp.fxin 		existence{x}==0 [0] h<dead{x} [0] + mcp_fxin [0 life]
	endmacro
(yeah about the 4 lines existence variable, I can't figure how to write it in one line, Each time I give it a try, I have some bugs)


But wait, does it mean I will have to write that for all the modules?! that's way too much for a lazy man like me!

Let's forget that, and make a sub macro that will make the modules born, live and die...

Code:
macro mcp_mod_destiny is_born is_life is_dead rec_born rec_life rec_dead bus_born bus_life bus_dead
	set tobe_rec + [is_life] [rec_life]
	set nottobe_rec + [is_dead] [rec_dead]

	set tobe_bus + [is_life] [bus_life]
	set nottobe_bus + [is_dead] [bus_dead]

	set life 		?recarm tobe_rec{x} folderstate>0 tobe_bus{x} is_life
	set dead 		?recarm nottobe_rec{x} folderstate>0 nottobe_bus{x} [is_dead]

	set existence 0
	set existence rec_born==1 recarm=1 1 
	set existence is_born==1 recarm=0 folderstate=0 1 
	set existence bus_born==1 recarm=0 folderstate!=0 1 	
	endmacro
And now, we can make our modules

Code:
macro mcp_mod_rec is_born is_life is_dead rec_born rec_life rec_dead bus_born bus_life bus_dead
	mcp_mod_destiny is_born is_life is_dead rec_born rec_life rec_dead bus_born bus_life bus_dead
	set mcp.recarm 		existence{x}==0 [0] h<dead{x} [0] + mcp_recarm [0 life]
	set mcp.fxin 		existence{x}==0 [0] h<dead{x} [0] + mcp_fxin [0 life]
	endmacro

macro mcp_mod_recex is_born is_life is_dead rec_born rec_life rec_dead bus_born bus_life bus_dead
	mcp_mod_destiny is_born is_life is_dead rec_born rec_life rec_dead bus_born bus_life bus_dead
	set mcp.recmode 	existence{x}==0 [0] h<dead{x} [0] + mcp_recmode [0 life]
	set mcp.recinput 	existence{x}==0 [0] h<dead{x} [0] + mcp_recinput [0 life]
	set mcp.recmon 		existence{x}==0 [0] h<dead{x} [0] + mcp_recmon [0 life]
	endmacro


macro mcp_mod_rout is_born is_life is_dead rec_born rec_life rec_dead bus_born bus_life bus_dead
	mcp_mod_destiny is_born is_life is_dead rec_born rec_life rec_dead bus_born bus_life bus_dead
	set mcp.io 	existence{x}==0 [0] h<dead{x} [0] + mcp_io [0 life]
	endmacro



macro mcp_mod_ins is_born is_life is_dead rec_born rec_life rec_dead bus_born bus_life bus_dead
	mcp_mod_destiny is_born is_life is_dead rec_born rec_life rec_dead bus_born bus_life bus_dead
	set mcp.fxbyp 	existence{x}==0 [0] h<dead{x} [0] + mcp_fxbyp [0 life]
	set mcp.fx 		existence{x}==0 [0] h<dead{x} [0] + mcp_fx [0 life]
	endmacro
Now, If I track to react as said above, i have to write on my layout:
Code:
mcp_mod_rec 1 0 625 1 0 0 0 0 0 
mcp_mod_recex 0 0 0 1 0 690 0 0 0
mcp_mod_rout 1 0 664 1 var_recx var_recx 1 var_norec var_norec
mcp_mod_ins 1 0 694 1 var_recx var_recx 1 var_norec var_norec

So it's a lot of work at first but now I can create as many layouts as I want, and also, it opens the posibility for the user to create its own layout by combining block and reactions as he wants, without any knowledge of walter.

But maybe there is some more efficient ways to get that result...
pyerbass is offline   Reply With Quote
Old 03-09-2018, 01:25 AM   #11
cubic13
Human being with feelings
 
cubic13's Avatar
 
Join Date: Dec 2013
Location: Near Serre-Ponçon lake, french Alps
Posts: 855
Default

Hi, pyerbass

Well, I tested all this on your API bete 5.12 theme. What I did is simply create in it a new 'TEST' layout and put in it the four lines that call the macros.

Basically, it seems to more or less work. But, as I'm not used to your theme, I'm not absolutely sure about it. If I understood well, and with the call that you wrote, all the involved controls should appear, a way or on another (depending on the recarm and folderstate status), excepting the mcp.recmon, mcp.recmode and mcp.recinput ones and it's the case. There are several coordinates and controls dimensions issues, though, that prevents me from testing all this in a more in depth way.

Beside this, I indeed have a problem with the four lines involving the existence variable : how is it supposed to be positioned and the conditions involved ? AFAIK, tests such as recarm=0 or folderstate=0 are not valid, from which I'm wondering if the existence variable isn't wrongly positioned in some cases. Another thing, but maybe I'm wrong : I would have put is_life between brackets, as is_dead, both of them being coordinates.

Overall, and if I had the time, I would try to get rid of the three _born variables as well as the existence one. I'm nearly sure that all this could be more easily done with only the _life and _dead ones. But that's just me...

Sadly, I don't have the time, presently, to try something of my own. Let us know how things evolve, though, and keep on the good work...
__________________
DAW: Ryzen 3700X|Asus X-470Pro|32Gb|2 SSD512(M2)+1024|W10Pro(64)|RME Fireface UCX+ADA8200
Soft: Reaper|Cubase 10|Emulator X3 & several other VSTis (2 bridged)...
Gear: VMK-188+|MPD32|ME30P|Korg 05R/W|Roland D110|Yamaha TX802|Pre-MIDI stuff...
cubic13 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 07:37 AM.


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