locodog
Fighting the war on drugs,
not telling which war or what drugs I'm on XD
My soundcloud likes
Built my own HID controller, I thought it would save money XD
My Releases
Once you figure out that everything you see or do in vdj is because of scripts, you're thinking like a 21st century DJ.
If you want a custom plugin writing or help mapping drop me a pm.
 How to; Perform A Action Automatically When A Track Is Loaded

Mon 26 Sep 16 @ 2:07 pm

How to; Perform A Action Automatically When A Track Is Loaded


This is a question that crops up from time to time so here is a tutorial.
In this tutorial we want the hotcues padpage to be shown whenever a new track is loaded.
We'll be using a repeating script to check a variable called load_pulse (this automatically changes from normally true to briefly false when a track is loaded) when load_pulse is false we call the pad page 'hotcues'

repeat_start_instant 'rsiPulseCheck' 190ms & load_pulse ? nothing : pad_page 'hotcues'

I tell vdj that I want a repeating script

repeat_start_instant

I give the repeating script a name

'rsiPulseCheck'

I tell vdj how often I want to repeat the script (more on why 190ms later)

190ms

Now the actual script I want to repeat

load_pulse ? nothing : pad_page 'hotcues'

load_pulse is a script that most of the time when queried gives the answer true/yes but when a track is loaded will turn to false/no for 200ms and then returns to true (This is why I used 190ms)

While load_pulse is true I want nothing to happen, when it turns to false I want the pad pages to switch to 'hotcues'

Where do I write this script?
Well if you always want this action to happen the best place would be on your ONINIT mapping
If you want this to be switchable then you need to change the script a little and put it on a custom button or a keyboard key or a HW button,
Here is the modified script

toggle '$pulseCheck' & var '$pulseCheck' ? repeat_start_instant 'rsiPulseCheck' 190ms & load_pulse ? nothing : pad_page 'hotcues' : repeat_stop 'rsiPulseCheck'

Here is the explanation
When I press a button I want to change a variable from false to true, or from true to false (I called the variable 'pulseCheck' and made it a global variable by putting a $ on the start. (most variables start as false when you turn vdj on)

toggle '$pulseCheck'

I then query the variable

var '$pulseCheck' ?

If the variable is true then this is the action that is performed (which we have already covered)

repeat_start_instant 'rsiPulseCheck' 190ms & load_pulse ? nothing : pad_page 'hotcues'

If the variable is false (when you press your button for a second time togging the variable from true to false) we don't want rsiPulseChecker running any more so this is the action sent

repeat_stop 'rsiPulseCheck'

We tell vdj we want to stop a repeating script

repeat_stop

and we tell vdj the name of the repeating script we want to stop

'rsiPulseCheck'

Some Pioneer HW works a little differently (pads work from a variable called padmode) so here's the script for them

toggle '$pulseCheck' & var '$pulseCheck' ? repeat_start_instant 'rsiPulseCheck' 190ms & load_pulse ? nothing : set 'padmode' 0 : repeat_stop 'rsiPulseCheck'


For further discussion or help please post here
http://www.virtualdj.com/forums/212799/General_Discussion/How_to__Perform_A_Action_Automatically_When_A_Track_Is_Loaded__Tutorial.html