Quick Sign In:  

Forum: General Discussion

Topic: repeat and holding doesn't work together
Goal: A short press of the button switches the volume between 0 and 100%. A long press of the button should increase the volume in 5% increments until the correct volume is reached
"repeat 1000ms & volume +5%" worked perfectly. But unfortunately the combination with "holding" doesn't work:
"holding 200 ms? repeat 1000ms & volume +5%: nothing" does not work.
Also Combinations with "down?" and "while_pressed" did not work.
Do you have a solution for this Task?
 

Posted Fri 02 Aug 24 @ 3:55 pm
your script is almost perfect.. needs a tweak for it to execute:

holding 200ms ? repeat 1000ms & volume +5% : nothing

and now for the logic,
will work but script will not stop when released.. since the repeat already has an implicit hold.. ie does the repeat during a hold.. and repeat is only called by the script when holding is true.


holding cannot be used with down (or doubleclick)
and appears also cannot be used with repeat (since it has an implicit hold)


And believe the way to get 2 functions from button.. with, repeat, would be to create a shift action, for the second action.
maybe something like:

shift ? level 0% ? level 100% : level 0% : repeat 1000ms & volume +5%

 

Posted Fri 02 Aug 24 @ 7:15 pm
AdionPRO InfinityCTOMember since 2006
repeat_start might work, although I'm not sure you can properly stop it since you can't query up.

Although combining two scripts it could work.
(down ? nothing : repeat_stop...) & (holding ? repeat_start... : else)
 

Posted Fri 02 Aug 24 @ 8:18 pm
Love that .. so clever.. @Adion
use of the (...)'s allows for the up state be seen (queried)

That works !

awesome stuff !

Love VDJ !



so one possible solution.. with 10x smoother movement (at same speed) maybe something like:

(up ? repeat_stop 'adjvol1' : nothing) & (holding ? repeat_start_instant 'adjvol1' 100ms 201 & volume +0.5% : level 0% ? level 100% : level 0%) 



 

Posted Sat 03 Aug 24 @ 9:13 am
Oh, that's a great solution, it works perfekt. Thank you a lot IIDEEJAYII and ADION for your help. I now want to switch the volume off and on and adjust the volume with a single foot switch. This means that if the volume is 100%, volume -0.5% should be used, if the volume is 0%, volume +0.5% should be used. In the middle area I want to toggle between increment and decrement using a Boolean variable. So you can change the direction. I'm not that good at programming, maybe you can expand the example to that effect!?
It's great what you can do in vdj with a single button: On, Off and adjustment.
Thanks for your support.
 

Posted Sat 03 Aug 24 @ 11:20 am
Is that what you wish ?

What do you wish to happen if the volume is not 0% or 100% .
for example, if the volume is at 98% ?

or in those cases would you set it to 0% or 100% with the momentary press?





If wishing to learn more of the amazing things one can do with, VDJ scripting, check out the following awesome thread with examples and explanations (created and curated, by the always clever Locodog):

https://www.virtualdj.com/forums/223743/General_Discussion/Script_School.html?page=1

 

Posted Sat 03 Aug 24 @ 1:50 pm
Here is one possibility.

Where
1) the momentary press will always turn OFF the volume..
(unless it is already OFF, in which case will turn it ON fully)

2) repeated holds will continue the previous direction of volume moment, until it reaches either limit, then stop.
for example: if one is decreasing the volume and you decide a min later you need to continue to decrease the volume a bit more.. one can again hold the foot pedal, to continue lowering the volume.
And of course the quick press turns it off.

(up ? repeat_stop 'adjvol1' : nothing) & (holding ?  (level 0% ? set_var 'volup' 1 : level 100% ? set_var 'volup' 0 : nothing) & var 'volup' 1 ? repeat_start_instant 'adjvol1' 100ms 201 & volume +0.5% : var 'volup' 0 ?  repeat_start_instant 'adjvol1' 100ms 201 & volume -0.5% : nothing : level 0% ? level 100% : level 0%) 


 

Posted Sat 03 Aug 24 @ 2:35 pm
In fact, I want to use my footswitch to turn my headphones on and off with a short press (deck right pfl toggle) and to increase or lower the current (preset) volume (headphone_volume) with a longer press. The first long press goes up, the second longer press down, etc. I.e. If I want it to be quieter, I press > 500ms to change the direction and then it goes down (Var '$Direction' toggle ???), i.e. the direction is changed every time. Then it goes in the wrong direction for a moment, but I hear that and press again to go in the right direction. For me, for example, the current volume is at 30%, overall it is too loud. Then I press, it gets a little louder for a moment but then I can press again and reduce it to 20%. Press twice to change direction. If you want, you can also initialize '$Direchtion' in ONSONGLOAD so that it always goes up the first time.
Many thanks for your helpful support.
 

Posted Sat 03 Aug 24 @ 2:47 pm
Ok final change :)

where

1) quick press, turns OFF the Volume, unless it is OFF, then turns it ON fully.

2) holding (long press) moves volume down from 100% or up from 0%, AND second long press toggles the direction of the volume moment.

(up ? repeat_stop 'adjvol1' : nothing) & (holding ?  toggle 'volup' & var 'volup' 1 ? repeat_start_instant 'adjvol1' 100ms 201 & volume +0.5% : var 'volup' 0 ?  repeat_start_instant 'adjvol1' 100ms 201 & volume -0.5% : nothing : level 0% & set_var 'volup' 0 ? level 100% : level 0% & set_var 'volup' 1) 


I think you get the idea now.. and can tweak it as you like..

if you need it for the headphone volume .. then the level.. for the level faders, will need to be changed to headphone_volume

and maybe if not wishing to adjust different deck volumes independently.. and only the single headphone volume.. then the variable could be changed from "volup' to '$volup' so its value is not per deck.





charly180925 wrote :
If you want, you can also initialize '$Direchtion' in ONSONGLOAD so that it always goes up the first time.

one can do that if that is useful by adding, in this case (setting volup to true)
set_var 'volup' 1 & ...... 

to the Keyboard ONSONGLOAD


 

Posted Sat 03 Aug 24 @ 3:14 pm
Thank you, this works great for me. I can now adjust the volume and switch the headphone on and off:

(up ? repeat_stop 'adjvol1' : nothing) & (holding ? toggle 'volup' & var 'volup' 1 ? repeat_start_instant 'adjvol1' 100ms 201 & volume +0.5% : var 'volup' 0 ? repeat_start_instant 'adjvol1' 100ms 201 & volume -0.5% : nothing : pfl toggle)

In your last version 0% and 100% switches only one time. Can you look about this?
 

Posted Sat 03 Aug 24 @ 6:46 pm
woot !
Happy you have the switch working as you like !


was pasting error that was not tested fully..

Correction to last script, fix for ON/OFF, mode:
(this time tested, smiles)

(up ? toggle 'volup' & repeat_stop 'adjvol1' : nothing) & (holding ? var 'volup' 1 ? repeat_start_instant 'adjvol1' 100ms 201 & volume +0.5% : var 'volup' 0 ? repeat_start_instant 'adjvol1' 100ms 201 & volume -0.5% : nothing : level 0% ? level 100% & set_var 'volup' 0 : level 0% & set_var 'volup' 1) 




Note: also moved the location of the direction toggle to the first query (changes direction with Mouse-up).



 

Posted Sat 03 Aug 24 @ 7:40 pm
Oh my God, why does everything always have to be so complicated!
With a custom bottom it works perfectly. If you want to map it to a key on the computer keyboard, louder and quieter no longer works because of the autorepeat function of the computer keyboard.

Solution: Disable autorepeat in Windows:
Control Panel --> Ease of Access --> Ease of Access Center --> Make it easier to use the keyboard --> Repeat and velocity keys: deactivate
in german:
Systemsteuerung --> Erleichterte Bedienung --> Center für erleichterte Bedienung --> Bedienung der Tastatur erleichtern --> Wiederhol- und Anschlagsgeschwindigkeitstasten: deaktivieren

But I have yet another problem!
I have enlarged the steps for changing the volume again and switch the headphones on and off:
(up ? toggle 'volup' & repeat_stop 'adjvol1' : nothing) & (holding ? var 'volup' 1 ? repeat_start_instant 'adjvol1' 1000ms 201 & volume +5% : var 'volup' 0 ? repeat_start_instant 'adjvol1' 1000ms 201 & volume -5% : nothing : pfl toggle)

I use a footswitch that generates keypresses via USB. Now there is the following problem:
If I have made it louder or quieter and when the button goes up, then "pfl toggle" is also triggered, i.e. a short button press is also triggered.
I couldn't manage to use a variable '$hold' to prevent the automatic incorrect short key press every time after a long key press.

I don't know where I have to write set_var '$hold' 1 with a long key press so that with "Var '$hold' 0 ? pfl toggle" toggle is not executed automatically after a long key press.
Maybe there is another reason for this misconduct?
A great function but the implementation has its pitfalls.
 

Posted Mon 05 Aug 24 @ 1:17 pm
appears that a keyboard does NOT make a great midi device.

A midi device would send an ON signal when pressed, and OFF signal when not. (for a non-latching button)

where it appears that keyboard sends many repeated up and down signals when held, (even when repeats are disabled)

test with just the script pfl for a keyboard key, vs a custom button or button on a midi controller.

do not know the solution to this "non-midi" behavior of the keyboard.



@Locodog @Devs is there way to send different keyboard macros from VDJ script
(which could be a possible workaround)
for example:
holding ? press key H : press key J
and then have keyboard mapped with required scripts.





PS
in your script you have pfl toggle
just use pfl
as the toggle is ignored, so in this case, the script still works
 

Posted Mon 05 Aug 24 @ 3:21 pm
locoDogPRO InfinityModeratorMember since 2013
No problem with filter keys on here, I can use up ? : logic with keyboard only
 

Posted Mon 05 Aug 24 @ 4:29 pm
Thank you for the info and your help. I tested my USB footswitch with "pfl".
In "continuous trigger" mode, the headphones turn on and off when the button is pressed.
Unfortunately, the volume control doesn't work in "single trigger" mode, only pfl switches on and off here. In the "continuous trigger" mode everything works, with the exception that when the key is released, pfl switches again and I can't correct this despite numerous attempts.
I can't do this with the $hold variable. I tried "isrepeat ?" instead of "up" but I head no success.
 

Posted Mon 05 Aug 24 @ 8:31 pm