Entra:     


Forum: General Discussion

Topic: Script School - Page: 54.85
Hi everyone,

I'm hoping someone can help me with a VDJScript syntax problem that I'm stuck on.

My goal is to create a script that shifts all cue points on a deck backwards by exactly 8 beats.

I have successfully written the first part of the script, which calculates the correct negative millisecond value based on the track's BPM and stores it in a variable named $msShift.

The debug logs confirm that the calculation is working perfectly. For a 120 BPM track, it correctly calculates the shift as -4000ms.

Here is the code that I used:

deck right get_bpm & param_bigger 0 ?
( debug 'BPM(right)' &
deck right get_bpm & param_cast & debug &
deck right get_bpm & param_1_x & param_multiply 60000 & set_var '$msBeat' &
debug 'ms/beat' & get_var '$msBeat' & param_cast & debug &
get_var '$msBeat' & param_multiply 8 & param_multiply -1 & set_var '$msShift' &
debug 'shift(ms) = -8 beats' & get_var '$msShift' & param_cast & debug &
deck right shift_all_cues '`get_var '$msShift' & param_cast 'ms'`' ) :
debug 'No BPM on right deck – shift aborted'


This is the part that fails to execute:
deck right shift_all_cues '`get_var '$msShift' & param_cast 'ms'`'

And here is the successful debug output:
Val: -4000.00
Text: shift(ms) = -8 beats
Val: 500.00
Text: ms/beat
Val: 120.00
Text: BPM(right)

The Problem:
I cannot figure out the correct syntax to make the shift_all_cues command use the value stored in my $msShift variable. The cue points do not move.
I know that a hardcoded command like deck right shift_all_cues -4000ms works, so the issue is definitely with passing the variable.

Here are the syntaxes I have already tried without success:

1. String interpolation with `param_cast` inside backticks:
shift_all_cues `get_var '$msShift' & param_cast 'ms'`

2. String interpolation with the unit appended outside the backticks:
shift_all_cues `get_var '$msShift'`ms

3. Command chaining without `param_cast`:
get_var '$msShift' & deck right shift_all_cues

4. Command chaining with `param_cast`:
get_var '$msShift' & param_cast 'ms' & deck right shift_all_cues

5. Using the `set` verb:
deck right set 'shift_all_cues' `get_var '$msShift'`ms

6. String interpolation wrapped in single quotes:
shift_all_cues '`get_var '$msShift' & param_cast 'ms'`'

Am I doing something completely wrong, or is the shift_all_cues command simply not capable of receiving a value stored in a variable?
 

needs to be cast to the verb as ms and needs to be relative too, so almost 4
get_var $msShift & param_cast ms & param_cast relative & deck right shift_all_cues

you won't ever get a 'no bpm reading' as it will default to 120
you can skip all the maths and variable setting if it's a known constant,

constant, cast as beats, cast as time, cast as relative time to verb

deck right constant -8 & param_cast beats & param_cast ms & param_cast relative & shift_all_cues.

 

@LOCODOG

Solved. I had to add “deck all “ to both MOTOR_JOG and MOTOR_TIMESTAMP.
 

In the end, I found that I just needed to set deck all to PLAY_PAUSE, CUE, MOTOR_JOG, MOTOR_TIMESTAMP, PITCH, and SHIFT.
 

Neat Script to switch back and forth from normal songs view to linked tracks view

browser_window 'songs' ? show_splitpanel 'folders' off & show_splitpanel 'sideview' on & deck 1 has_linked_tracks & wait 33 ms & sideview_sort 'bpm' & browser_window sideview & browser_scroll 'top' & browser_scroll +1 : show_splitpanel 'sideview' off & browser_window 'songs'