Quick Sign In:  

Forum: General Discussion

Topic: Controlling two dials with one button
Hi!

I have a problem with the scripting engine. Maybe someone can help me.

My goal:
I would like to assign a button to the right deck that does the following: as soon as it is pressed, the eq_high knob of the right deck is increased by 0.05 and at the same time the eq_high knob of the left deck is decreased by 0.05. Of course, this only makes sense if you have previously set the eq_high knob of the right deck to 0 and the eq_high knob of the left deck is set to normal (0.5). And then the whole thing should also work in mirror image for a button on the left side.

My code that works so far is:
------------------------------------------------------------
( leftdeck ?
( ( deck left eq_high<=0.5 ?
deck left eq_high +0.05 : nothing ) &
deck right eq_high -0.05 ) )
&
( rightdeck ?
( ( deck right eq_high<=0.5 ?
deck right eq_high +0.05 : nothing ) &
deck left eq_high -0.05 ) )
------------------------------------------------------------


My problem:
In addition, pressing the Shift key should cause the knobs to move in the other direction so that you can make quick corrections without having to use the button on the other deck. Basically, the left button and Shift+right button should have the same function (as should the right button and Shift+left button)


The code I have so far (thanks, ADION, for the hint with the OR disjunction ( https://virtualdj.com/forums/258818/General_Discussion/OR-disjunction_in_a_query.html )):
------------------------------------------------------------
( ( leftdeck ? true : ( rightdeck && shift ) ) ?
( ( deck left eq_high<=0.5 ?
deck left eq_high +0.05 : nothing ) &
deck right eq_high -0.05 ) )
------------------------------------------------------------

Now the left button and shift+right button works.

But as soon as you add the code for the right button again, the shift button no longer works:
------------------------------------------------------------
( ( leftdeck ? true : ( rightdeck && shift ) ) ?
( ( deck left eq_high<=0.5 ?
deck left eq_high +0.05 : nothing ) &
deck right eq_high -0.05 ) )
&
( ( rightdeck ? true : ( leftdeck && shift ) ) ?
( ( deck right eq_high<=0.5 ?
deck right eq_high +0.05 : nothing ) &
deck left eq_high -0.05 ) )
------------------------------------------------------------

Does anyone have a solution? I just can't get any further!
Many Thanks.......
 

Posted Mon 27 May 24 @ 11:18 am
AdionPRO InfinityCTOMember since 2006
Why do you separate left deck and right deck?
You can remove the check for leftdeck and remove 'deck left' in front of the scripts to simply execute the action based on the side of the button automatically
 

Posted Mon 27 May 24 @ 11:34 am
locoDogPRO InfinityModeratorMember since 2013
just to add; this being true
leftdeck && shift
also means this is true
leftdeck ?
same for the right, you're asking it to undo what it just did.

Until you're deeper into it better to just write longer more logic tree scripts

shift ?
leftdeck ?
shift leftdeck branch :
shift rightdeck branch :
leftdeck ?
leftdeck branch :
rightdeck branch :
 

Posted Mon 27 May 24 @ 11:47 am
Many thanks for the information. Now I need some time to implement these tips.
I am always grateful for any further hints...
 

Posted Mon 27 May 24 @ 12:46 pm
LOCODOG wrote:
"Until you're deeper into it better to just write longer more logic tree scripts"

You're absolutely right. But I'm not a big fan of redundancy. In your suggestion, two branches are identical - but with a very clear structure.
Let's see, maybe I can do it without redundancy (hints are still welcome :-).
 

Posted Mon 27 May 24 @ 1:11 pm
Now I am happy!!!
The redundant version works (thank you LOCODOG). It is much code, but it is OK. Hey - it works!

But if one of you script experts should ever get bored :-), it would be nice to get one or two more suggestions for the version without redundancy :-)

Many, many thanks so far...
 

Posted Mon 27 May 24 @ 2:26 pm
locoDogPRO InfinityModeratorMember since 2013
This is the minimum I came up with, I'll leave it to you to figure out how it does what it does.

set $side `leftdeck` & (shift ? toggle $side :) & set_deck `param_multiply -1 "param_add 'get_var $side' -2"` & eq_high -0.05 & set_deck `param_add 'get_var $side' 1` & param_bigger eq_high 0.451 !? eq_high 0.5 : eq_high +0.05
 

Posted Mon 27 May 24 @ 3:00 pm
Wow, I'm really impressed. Two lines instead of 20 lines.
Thank you very much! That's more than I could have expected!
Let's see if I can figure out how it works. I think this takes time...:-)
Thanks for all.
 

Posted Mon 27 May 24 @ 3:26 pm
locoDogPRO InfinityModeratorMember since 2013
A few chars more but cuts it down to one query and no brackets

set $side `param_add shift leftdeck & param_mod 2` & set_deck `param_multiply -1 "param_add 'get_var $side' -2"` & eq_high -0.05 & set_deck `param_add 'get_var $side' 1` & param_bigger eq_high 0.451 !? eq_high 0.5 : eq_high +0.05
 

Posted Mon 27 May 24 @ 3:31 pm
But I think, the last one has an unwanted sideeffect:
The button is colored after the first press.
 

Posted Mon 27 May 24 @ 3:53 pm
Now that it's working for me, I would like to improve my scripting skills.
I'm wondering why my script above with the OR disjunctions didn't work with both parts, but only one part alone:
------------------------------------------------------------
( ( leftdeck ? true : ( rightdeck && shift ) ) ?
.....
( ( rightdeck ? true : ( leftdeck && shift ) ) ?
.....
------------------------------------------------------------

The reason might be the following:
The expressions are wrong. However, there seems to be no way to express it correctly, since there is no negation and therefore no expression for “NOT(shift)”. The correct expressions should be something like that:
------------------------------------------------------------
( ( ( leftdeck && NOT(shift) ) ? true : ( rightdeck && shift ) ) ?
.....
( ( ( rightdeck && NOT(shift) ) ? true : ( leftdeck && shift ) ) ?
.....
------------------------------------------------------------

Do I see that correctly?
 

Posted Tue 28 May 24 @ 10:24 am
locoDogPRO InfinityModeratorMember since 2013
( not shift && deck 1 play ) ? deck 2 play : 


this is valid
 

Posted Tue 28 May 24 @ 10:29 am
Perfect! This was the missing hint!
My version from above now works (but maybe a bit too many brackets for your taste :-))
Many thanks again!

Now I'm spoiled for choice: should I use my version with 10 lines of code or your version with 2 lines of code? :-)
 

Posted Tue 28 May 24 @ 11:11 am