快速登录:  

Forum: General Discussion

话题: Script/Param/Variable Maths
adamPRO SubscriberMember since 2022
I've set a custom button to do 3/4 loop for bpm transition like mentioned here (https://www.youtube.com/watch?v=UUyqNDDdNn0), allowing a simple transition from, say 126 to 168bpm.
[3/4 Loop Button]
loop 0.75
Super simple.

Now I want VDJ to do the math for me. It would set the bpm of the other deck to 4/3 (divide by 0.75) of the currently playing deck.
[3/4 Loop Up Button] e.g. changing from 126bpm to 168bpm
loop 0.75 && action_deck 1 ? deck 2 pitch (master_bpm/0.75) : deck 1 pitch (master_bpm/0.75)

Seems like I need to set a master_bpm (variable? parameter?), though, as the above bases it off of deck 2's BPM, not deck 1's bpm.
Spent a few hours trying to work out how to do that and I'm pretty stumped. My references are (http://www.virtualdj.com/forums/223743/General_Discussion/Script_School.html?page=2.35 - I know it's old but it's the most in depth I've been able to find) and from here (https://virtualdj.com/wiki/VDJScript) and just not having any luck with var_list after testing it.

Lines 2 & 3 below have different syntax but I've tried both, no luck.
loop 0.75 &
set $master_bpm' get_bpm &&
set 'bpm_up' "(master bpm/0.75)" && set 'bpm_down' "(master_bpm*0.75) &&
action_deck 1 ? param_multiply bpm_up deck 2 pitch : param_multiply bpm_up deck 1 pitch

Effectively, all I need to do is:
-Turn on 3/4 Loop
-Set BPM on opposite deck to 4/3 of the currently playing track
Any ideas?
 

发表时间 Tue 21 Mar 23 @ 10:42 am
AdionPRO InfinityCTOMember since 2006
pitch also accepts beats as parameter to set the pitch so that it matches the given bpm.
pitch 128bt

I think combined with the regular param_multiply and param_cast beats that should allow to do what you want
 

发表时间 Tue 21 Mar 23 @ 12:44 pm
adamPRO SubscriberMember since 2022
Thanks, I've spent another hour on it and still can't work it out. I'm really trying to learn myself but the instructions on how to multiply etc aren't very clear.

I just need to set the BPM on the opposite deck to 4/3 of the currently playing track
 

发表时间 Sun 16 Apr 23 @ 6:03 am
locoDogPRO InfinityModeratorMember since 2013
/3 *4 example
action_deck 1 ? set $thing `param_multiply 4 'param_multiply 0.333333 get_bpm'` & get_var $thing & param_cast 'beats' & deck 2 pitch


or mathematically simplified
action_deck 1 ? set $thing `param_multiply 1.333333 get_bpm` & get_var $thing & param_cast 'beats' & deck 2 pitch


or with no variable to hold the value
action_deck 1 ? param_multiply 1.333333 get_bpm & param_cast 'beats' & deck 2 pitch
 

发表时间 Sun 16 Apr 23 @ 7:04 am
adamPRO SubscriberMember since 2022
This is fantastic! Thank you so much Locodog. A couple of concepts in this that I was having trouble with but now I can also see a lot of how it works/is put together. Will definitely help me make more complex commands.

Hugely appreciative of your help Locodog and already working on expanding this functionality (will hopefully post for others once I have it sorted to my liking).
 

发表时间 Sun 23 Apr 23 @ 12:03 pm
adamPRO SubscriberMember since 2022
I painstakingly put all the info into ChatGPT 4. I had a suspicion the docs were incomplete/unclear and I was correct.

If you want to do it yourself, at the current point in time you will need to use the "Access Link" plugin. ChatGPT's inbuilt Browser function will not read the huge list of verbs.

Access Link, however, will not read forum posts, only the first post in each thread, so for individual topics you will have to manually copy/paste the text from the whole thread. ChatGPT does fine interpreting this via copy/paste.

You must also tell ChatGPT to NOT use VirtualDJ 8. Explain to it that VirtualDJ 2023 came out just recently - after ChatGPT's Sept 2021 knowledge cutoff, and that it's completely different to VirtualDJ 8.

Important Note on the Wiki
I'd like to remark that the Wiki is incomplete, and created a lot of headaches. For example, creating the script related below wasn't possible because of the order of operations (remember BOMDAS/BIMDAS from school? Haha).

You will therefore ALSO need to search, and copy/paste relevant posts from within the "Script School" posts in the VDJ Thread.

ChatGPT was very happy after this - after about 90 minutes of back and forth as you'll see below:

Brackets can be used in VDJScript to group operations and control the order of execution. This is a powerful feature that can greatly simplify complex scripts and make them easier to read and understand.

For example, in the context of a script that sets a 3/4 beat loop, calculates the new BPM for the other deck, starts playing the other deck at full volume, and sets the level of the active deck to 75%, you could use brackets to ensure that the level of Deck 2 is set to 75% when you activate the script on it. Here's how you might modify your script:



loop 0.75 && ( action_deck 1 ? param_multiply 1.333333 get_bpm & param_cast 'beats' & deck 2 pitch & deck 2 play & deck 2 volume 1 & deck 1 level 0.75 : param_multiply 1.333333 get_bpm & param_cast 'beats' & deck 1 pitch & deck 1 play & deck 1 volume 1 & deck 2 level 0.75 )


This script checks if Deck 1 is the active deck and if so, performs the actions on Deck 2 and adjusts the level on Deck 1. Otherwise, it performs the actions on Deck 1 and adjusts the level on Deck 2. The use of brackets ensures that the level adjustment is correctly applied to the active deck.

I hope this update is helpful and encourages more exploration and discussion on using AI tools like ChatGPT to understand and write VDJScript.

Yours sincerely Adam and ChatGPT 4(lol)
 

发表时间 Sat 20 May 23 @ 11:23 am